Skip to content

Feature request: support GDAL >= 3 #91

@araichev

Description

@araichev

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions