#9244: LayerMapping.save fails for large polygon record
--------------------------+-------------------------------------------------
Reporter: tylere | Owner: nobody
Status: new | Milestone:
Component: GIS | Version: 1.0
Keywords: LayerMapping | Stage: Unreviewed
Has_patch: 0 |
--------------------------+-------------------------------------------------
When trying to load a shapefile using LayerMapping, the save method fails
when it encounters a large record. I will attach a shapefile that causes
this problem to the page.
Here is the error that is returned...
{{{
[EMAIL PROTECTED]:~/django_projects/django_nasa_fire_dss$ python
manage.py shell
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.1 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: import load_data
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
[EMAIL PROTECTED]:~/django_projects/django_nasa_fire_dss$
}}}
Here is the script for loading the data (load_data.py)
{{{
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from psycopg2 import IntegrityError
from django.contrib.gis.utils import mapping, LayerMapping,
add_postgis_srs
from fccs.models import FccsPoints,FccsPolygons
fccs_polys = 'data/fccs/fccs_poly_orig_wgs84_problem.shp'
mapping2 = {'gridcode' : 'GRIDCODE',
'area_km2' : 'AREA_KM2',
'geometry' : 'POLYGON',
}
layer2 = LayerMapping(FccsPolygons,fccs_polys,mapping2,
transaction_mode='autocommit')
layer2.save(verbose=True, progress=True)
}}}
Here is the model file (fccs/models.py)
{{{
from django.contrib.gis.db import models
class FccsPolygons(models.Model):
gridcode = models.IntegerField(help_text="FCCS code of the plygon
region",)
area_km2 = models.IntegerField(help_text="Area of the polygon in SQ
kilometers",)
# GeoDjango specific Polygon Field and GeoManager
geometry = models.MultiPolygonField(srid=4326)
# GeoManager, a subclass that adds a rich set of geospatial queryset
methods
objects = models.GeoManager()
class Meta:
verbose_name_plural = "FCCS Polygons"
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9244>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---