gdal icon indicating copy to clipboard operation
gdal copied to clipboard

CreateGeometryFromEsriJson Doesn't Support Arcs and Curves

Open achapkowski opened this issue 1 year ago • 6 comments

What is the bug?

gdal doesn't export the EsriJSON to the proper curve geometries. See: https://gdal.org/development/rfc/rfc49_curve_geometries.html

When using the CreateGeometryFromEsriJson method and passing in the path and curve objects, the result is always None.

Steps to reproduce the issue

g_polygon:dict = {
  "hasM":true,
  "curveRings": [
    [
      [11, 11, 1],
      [10, 10, 2],
      [10, 11, 3],
      [11, 11, 4],
      {
        "b": [
          [15, 15, 2],
          [10, 17],
          [18, 20]
        ]
      },
      [11, 11, 4]
    ],
    [
      [15, 15, 1],
      {
        "c": [
          [20, 16, 3],
          [20, 14]
        ]
      },
      [15, 15, 3]
    ]
  ],
  "rings":[
    [
      [11, 11, 1],
      [10, 10, 2],
      [10, 11, 3],
      [11, 11, 4]
    ],
    [
      [15, 15, 1],
      [11, 11, 2],
      [12, 15.5],
      [15.4, 17.3],
      [15, 15, 3]
    ],
    [
      [20, 16 ,1],
      [20, 14],
      [17.6, 12.5],
      [15, 15, 2],
      [20, 16, 3]
    ]
  ]
}
g_curve_path:dict = {
  "curvePaths": [
    [
      [6,3],
      [5,3],
      {
        "b": [
          [3, 2],
          [6, 1],
          [2, 4]
        ]
      },
      [1, 2],
      {
        "a": [
          [0, 2],
          [0, 3],
        ]
      }
    ]
  ]
}

for geom in [g_curve_path, g_polygon]:
    ogr_geom = ogr.CreateGeometryFromEsriJson(json.dumps(geom))
    assert ogr_geom # always None

Versions and provenance

Version: '3.7.0e' OS: Windows 10 Enterprise

Additional context

No response

achapkowski avatar Mar 07 '24 15:03 achapkowski

Maybe worth adding a note that non-linear geometries are not supported to the ESRIJSON driver documentation https://gdal.org/drivers/vector/esrijson.html. @achapkowski, could you have a try and create a pull request?

jratike80 avatar Mar 07 '24 16:03 jratike80

@jratike80 ok, that can be done, but I think with the support of OGC curved geometries, it makes sense to support them.

achapkowski avatar Mar 07 '24 16:03 achapkowski

@rouault here is the link to all the supported Esri JSON geometry formats: https://developers.arcgis.com/rest/services-reference/enterprise/geometry-objects.htm .

achapkowski avatar Mar 07 '24 16:03 achapkowski

I was just thinking that because GeoJSON and the OGC JSON-FG formats do not support curved geometries it may take some time to get the support into ESRIJSON driver. There is a proposal about adding the support into JSON-FG, though https://github.com/opengeospatial/ogc-feat-geo-json/blob/main/proposals/circular-geometry-objects.adoc.

Can ESRI servers output GML or GeoPackages?

jratike80 avatar Mar 07 '24 18:03 jratike80

@jratike80 not directly. Some hosted services can export them to geopackages if registered with ArcGIS Enterprise. GML I do not believe so.

achapkowski avatar Mar 08 '24 11:03 achapkowski

We're certainly open to contributions from willing contributors to add support for that. Some inspiration could certainly be taken from ogr/ogrpgeogeometry.cpp which deals with geometries from (the old) Personal Geodatabase format that has probably a very similar/identical geometry model and which handles already circular curves and Bezier curves (approximated as linestrings)

rouault avatar Mar 08 '24 23:03 rouault