Commits

springmeyer  committed e57a5a1

avoid nonetype error fixing #11 - thanks gilles

  • Participants
  • Parent commits 7ffecf9

Comments (0)

Files changed (1)

File shapes/views/export.py

 
         # Set up the native spatial reference of the geometry field using the srid
         if hasattr(geo_field,'srid'):
-            srs = SpatialReference(geo_field.srid)
+            native_srs = SpatialReference(geo_field.srid)
         else:
-            srs = SpatialReference(geo_field._srid)
+            native_srs = SpatialReference(geo_field._srid)
         
-        # Set the 'out_srs' if we are going to transform on the fly 
         if self.proj_transform:
-            out_srs = SpatialReference(self.proj_transform)
+            output_srs = SpatialReference(self.proj_transform)
+            ct = CoordTransform(native_srs, output_srs)
         else:
-            out_srs = None
+            output_srs = native_srs
         
-        if out_srs:
-            ct = CoordTransform(srs, out_srs)
-        
-        # Creating the layer
-        layer = ogr.OGR_DS_CreateLayer(ds,os.path.basename(tmp.name), out_srs._ptr or srs._ptr, ogr_type, None)
+        # create the layer
+        layer = ogr.OGR_DS_CreateLayer(ds, os.path.basename(tmp.name), output_srs._ptr, ogr_type, None)
         
         # Create the fields
         # Todo: control field order as param
             # if requested we transform the input geometry
             # to match the shapefiles projection 'to-be'            
             if geom:
-                ogr_geom = OGRGeometry(geom.wkt,srs)
-                if out_srs:
+                ogr_geom = OGRGeometry(geom.wkt,output_srs)
+                if self.proj_transform:
                     ogr_geom.transform(ct)
                 # create the geometry
                 check_err(ogr.OGR_F_SetGeometry(feat, ogr_geom._ptr))