The reason is that gdal cannot always guess the correct geometry type for
example in a Shapefile.
# TODO: Autodetection of multigeometry types (see #7218).
--
Ticket URL: <https://code.djangoproject.com/ticket/24207>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> 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.
>
> # TODO: Autodetection of multigeometry types (see #7218).
New description:
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).
--
Comment:
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 :)
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:1>
* owner: nobody => mdiener21
* cc: mdiener21@… (added)
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:2>
* has_patch: 0 => 1
* easy: 1 => 0
Comment:
[https://github.com/django/django/pull/3979 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:3>
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:4>
* status: assigned => closed
* resolution: => wontfix
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:5>
Comment (by mdiener21):
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
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:6>
Comment (by mdiener21):
Replying to [comment:5 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
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:7>
Comment (by claudep):
Do you have an example of such a "deficient" layer? It would be nice to
make a test case for this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:8>
* Attachment "gas_lines.zip" added.
Shapefile Example with both Linestrings and Multilinestrings
Comment (by mdiener21):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:9>
* status: closed => new
* needs_better_patch: 0 => 1
* resolution: wontfix =>
* stage: Unreviewed => Accepted
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:10>
* needs_better_patch: 1 => 0
Comment:
New PR: https://github.com/django/django/pull/4617
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:11>
* version: 1.8alpha1 => master
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:12>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"d1df1fd2bb274574fd895f6984892b3aba372f48" d1df1fd2]:
{{{
#!CommitTicketReference repository=""
revision="d1df1fd2bb274574fd895f6984892b3aba372f48"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24207#comment:13>