Ticket #1888 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

ExportToJson GeometryCollection handling

Reported by: crschmidt Owned by: hobu
Priority: normal Milestone: 1.5.0
Component: PythonBindings Version: unspecified
Severity: normal Keywords:
Cc: warmadam

Description (last modified by hobu) (diff)

   if self.GetGeometryType() == ogr.wkbGeometryCollection or \
       self.GetGeometryType() == ogr.wkbGeometryCollection25D:
        geometries = []    
        geom_count = geometry.GetGeometryCount()
        for g in range(geom_count):
            geom = self.GetGeometryRef(g)
            geometries.append(geom.ExportToJson())
        output = {'type': types[self.GetGeometryType()],
                  'geometries': geometries}
    else:
        output = {'type': types[geometry.GetGeometryType()],
                  'coordinates': get_coordinates(geometry)}

Attachments

better_exporttojson.patch Download (2.4 KB) - added by crschmidt 6 years ago.
fixes copy paste errors

Change History

Changed 6 years ago by crschmidt

Needs a \ after the or.

Changed 6 years ago by hobu

  • status changed from new to closed
  • resolution set to fixed

Added in r12333

Changed 6 years ago by hobu

  • description modified (diff)
  • milestone set to 1.5.0

Changed 6 years ago by crschmidt

fixes copy paste errors

Changed 6 years ago by crschmidt

  • status changed from closed to reopened
  • resolution fixed deleted

The code I pasted was cargo culted from an external ogrhelpers module -- not written internally. This patch is against the actual ogr code, and is tested to after a 'python setup.py install' from trunk plus this patch.

Changed 6 years ago by hobu

  • status changed from reopened to closed
  • resolution set to fixed

I think we're done with this after r12335.

Note: See TracTickets for help on using tickets.