Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support GDAL >= 3 #91

Open
araichev opened this issue Feb 11, 2020 · 4 comments
Open

Feature request: support GDAL >= 3 #91

araichev opened this issue Feb 11, 2020 · 4 comments

Comments

@araichev
Copy link

Currently multigtfs is not compatible with GDAL >= 3.
Can we make it compatible, and is that sensible?
My company is willing to fund this feature request.

As far as i can tell, the only incompatibility is that GDAL >= 3 requires WGS84 coordinates to be specified in latitude-longitude order by default; they can be specified in longitude-latitude order as is done in multigtfs, but doing so now requires a special flag; see the GDAL docs.

Creating longitude-latitude geometries with multigtfs and GDAL >= 3 appears to work at first ---no errors are thrown--- but those geometries are actually malformed and certain methods fail on them, e.g. the transform() method raises a GDALException.
Here's an example on Linux Mint 19.3 with Python 3.7.6, GDAL 3.0.2, and Django 2.2.10.

Python 3.7.6 (default, Dec 19 2019, 23:50:13) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from django.contrib.gis.gdal import OGRGeometry                                   

In [2]: point = OGRGeometry("POINT(174.74 -36.840556)", srs=4326)  # WGS84 lon-lat            

In [3]: point.transform(2193, clone=True)   #Transform to NZTM                                                  
---------------------------------------------------------------------------
GDALException                             Traceback (most recent call last)
<ipython-input-4-898671070db8> in <module>
----> 1 point.transform(2193, clone=True)

~/.virtualenvs/gtfs_explorer/lib/python3.7/site-packages/django/contrib/gis/gdal/geometries.py in transform(self, coord_trans, clone)
    409         elif isinstance(coord_trans, (int, str)):
    410             sr = SpatialReference(coord_trans)
--> 411             capi.geom_transform_to(self.ptr, sr.ptr)
    412         else:
    413             raise TypeError('Transform only accepts CoordTransform, '

~/.virtualenvs/gtfs_explorer/lib/python3.7/site-packages/django/contrib/gis/gdal/prototypes/errcheck.py in check_errcode(result, func, cargs, cpl)
    116     Check the error code returned (c_int).
    117     """
--> 118     check_err(result, cpl=cpl)
    119 
    120 

~/.virtualenvs/gtfs_explorer/lib/python3.7/site-packages/django/contrib/gis/gdal/error.py in check_err(code, cpl)
     57     elif code in err_dict:
     58         e, msg = err_dict[code]
---> 59         raise e(msg)
     60     else:
     61         raise GDALException('Unknown error code: "%s"' % code)

GDALException: OGR failure.

In [4]: point = OGRGeometry("POINT(-36.840556 174.74)", srs=4326)  #WGS84 lat-lon                         

In [5]: point.transform(2193, clone=True).coords  #Transform to NZTM and display coordinates                                          
Out[5]: (5921452.26055115, 1755039.2190557136)
@araichev
Copy link
Author

I guess the compatibility could be accomplished by adding a boolean option (that defaults to False) to the multigtfs import command, e.g. use_lat_lon_order, to import geographic coordinates in lat-lon order.

@araichev
Copy link
Author

@jwhitlock any word on this?
I forgot about this feature request and now need it again.

@jwhitlock
Copy link
Member

@araichev, I haven't looked closely at the GDAL change, but it sounds good to me (latitude / longitude is how I think of coordinates anyway), and your ideas for handling this transition sound good. I haven't had time to work on multigtfs for a while, and I don't see that changing this year.

@jspetrak
Copy link
Contributor

@araichev If you have chance to provide PR for this issue, feel free to do so. The project will add few new maintainers to run it further. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants