Code

Opened 7 years ago

Closed 7 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: UI/UX:

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 (0)

Change History (2)

comment:1 Changed 7 years ago by jbronn

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from SVN to gis

comment:2 Changed 7 years ago by jbronn

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.