Opened 10 years ago

Closed 10 years ago

#24207 closed Cleanup/optimization (fixed)

ogrinspect multi_geom doesn't account for 25D types

Reported by: Michael Diener Owned by: Michael Diener
Component: GIS Version: dev
Severity: Normal Keywords: gis, multi_geom
Cc: mdiener21@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Michael Diener)

I would recommend changing the /contrib/gis/util/ogrinspect.py default to use "Multi" geometry because this will eliminate ERROR when trying to import a data set that could contain both linestring and multilinestring for example.

The reason is that gdal cannot always guess the correct geometry type for example in a Shapefile.

link to my GIT Branch https://github.com/mdiener21/django/blob/master/django/contrib/gis/utils/ogrinspect.py

# TODO: Autodetection of multigeometry types (see #7218).

Attachments (2)

ogrinspect.py (9.4 KB ) - added by Michael Diener 10 years ago.
new ogrinspect.py code
gas_lines.zip (9.4 KB ) - added by Michael Diener 10 years ago.
Shapefile Example with both Linestrings and Multilinestrings

Download all attachments as: .zip

Change History (15)

by Michael Diener, 10 years ago

Attachment: ogrinspect.py added

new ogrinspect.py code

comment:1 by Michael Diener, 10 years ago

Description: modified (diff)

forgot the link to my GIT branch https://github.com/mdiener21/django/blob/master/django/contrib/gis/utils/ogrinspect.py

Pull Request was already sent off :)

comment:2 by Michael Diener, 10 years ago

Cc: mdiener21@… added
Owner: changed from nobody to Michael Diener
Status: newassigned

comment:3 by Tim Graham, 10 years ago

Easy pickings: unset
Has patch: set

comment:4 by Tim Graham, 10 years ago

Summary: contrib gis change ogrinspect multi_geom default to TrueChange ogrinspect multi_geom default to True

comment:5 by Claude Paroz, 10 years ago

Resolution: wontfix
Status: assignedclosed

I'm not convinced to force multi geometries by default. If you obtain errors when importing data from a shapefile because of a missing multi field, you can always improve your model and force the multi geometries in a later time. And if you don't want to risk the potential errors, there is the multi_geom parameter you can set yourself.

Feel free to add more arguments if you think I missed the point.

comment:6 by Michael Diener, 10 years ago

Hi the problem is this code if multi_geom and gtype.num in (1, 2, 3): LINE 213 gtype.num in (1,2,3) does NOT always return TRUE for multi_geom because GDAL does not always guess correct. Therefore if I set multi_geom to True it still fails because GDAL guesses wrong. Another solution is to simply remove the GDAL check ? any thoughts

in reply to:  5 comment:7 by Michael Diener, 10 years ago

Replying to claudep:

I'm not convinced to force multi geometries by default. If you obtain errors when importing data from a shapefile because of a missing multi field, you can always improve your model and force the multi geometries in a later time. And if you don't want to risk the potential errors, there is the multi_geom parameter you can set yourself.

Feel free to add more arguments if you think I missed the point.

Please check out my comment :) cheers

comment:8 by Claude Paroz, 10 years ago

Do you have an example of such a "deficient" layer? It would be nice to make a test case for this issue.

by Michael Diener, 10 years ago

Attachment: gas_lines.zip added

Shapefile Example with both Linestrings and Multilinestrings

comment:9 by Michael Diener, 10 years ago

Yes I do, the Shapefile origin is AutoCAD and this is where things get messy when converting to Shapefile then trying to import into PostGIS. I have attached the problem Shapefile of multilinestrings which is a false positive "linestring" according to GDAL and QGIS (which uses GDAL). The Shapefile is of course valid with no geometry errors or invalid geometries all is good. The problem is the Shapefile can store linestrings and multi-geom and still be valid. When trying to import such a Shapefile PostGIS will NOT allow you to have both you must choose and in this case you must always choose the multi-geom "MULTILINESTRING" geom type otherwise boom error on import.

comment:10 by Claude Paroz, 10 years ago

Patch needs improvement: set
Resolution: wontfix
Status: closednew
Summary: Change ogrinspect multi_geom default to Trueogrinspect multi_geom doesn't account for 25D types
Triage Stage: UnreviewedAccepted

Thanks, that's very useful. This demonstrates that the inspect code hasn't been updated after commit [c169f8cb174c9a885] to take 25D OGR types into account.

comment:11 by Claude Paroz, 10 years ago

Patch needs improvement: unset

comment:12 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin
Version: 1.8alpha1master

comment:13 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: newclosed

In d1df1fd2:

Fixed #24207 -- Added 25D-type geometry field support to ogrinspect

Thanks Michael Diener for the report and sample data, and Tim Graham
for the review.

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