Django

Code

Ticket #5779 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: tlp Assigned to: jbronn
Milestone: Component: GIS
Version: gis Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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'

Attachments

Change History

10/19/07 11:11:35 changed by jbronn

  • status changed from new to assigned.
  • needs_better_patch changed.
  • needs_tests changed.
  • version changed from SVN to gis.
  • owner changed from nobody to jbronn.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.

10/20/07 23:27:23 changed by jbronn

  • status changed from assigned to closed.
  • resolution set to fixed.

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


Add/Change #5779 (If the layer.srs does not have a srid it should return None)




Change Properties
Action