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 )
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)
Change History (15)
by , 10 years ago
Attachment: | ogrinspect.py added |
---|
comment:1 by , 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 , 10 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 10 years ago
Summary: | contrib gis change ogrinspect multi_geom default to True → Change ogrinspect multi_geom default to True |
---|
follow-up: 7 comment:5 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
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 , 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
comment:7 by , 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 , 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 , 10 years ago
Attachment: | gas_lines.zip added |
---|
Shapefile Example with both Linestrings and Multilinestrings
comment:9 by , 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 , 10 years ago
Patch needs improvement: | set |
---|---|
Resolution: | wontfix |
Status: | closed → new |
Summary: | Change ogrinspect multi_geom default to True → ogrinspect multi_geom doesn't account for 25D types |
Triage Stage: | Unreviewed → Accepted |
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 , 10 years ago
Patch needs improvement: | unset |
---|
comment:12 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
Version: | 1.8alpha1 → master |
new ogrinspect.py code