Opened 17 years ago

Closed 17 years ago

#5779 closed (fixed)

If the layer.srs does not have a srid it should return None

Reported by: tlp Owned by: jbronn
Component: GIS Version: gis
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If a srs of a layer does not have a srid it should return None instead of throwing a Type Error.

I am using this dataset: http://www.eng.hctx.net/gis/Shapefiles/ZIP CODE.zip

>>> from django.contrib.gis.gdal import DataSource
>>> ds = DataSource("/home/osc/data/zipcode/zipcodep.shp")
>>> layer = ds[0]

In [40]: layer.srs.srid
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/geo/geo/<ipython console> in <module>()

/home/geo/local/lib/python2.5/site-packages/django/contrib/gis/gdal/srs.py in srid(self)
    206         """
    207         try:
--> 208             return int(self.attr_value('AUTHORITY', 1))
    209         except ValueError:
    210             return None

<type 'exceptions.TypeError'>: int() argument must be a string or a number, not 'NoneType'

Change History (2)

comment:1 by jbronn, 17 years ago

Owner: changed from nobody to jbronn
Status: newassigned
Triage Stage: UnreviewedAccepted
Version: SVNgis

comment:2 by jbronn, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [6574]) gis: Fixed #5779, thanks tlp; added type checking to SpatialReference.getitem.

Note: See TracTickets for help on using tickets.
Back to Top