wiki:rfc60_improved_roundtripping_in_ogr

Version 1 (modified by Even Rouault, 9 years ago) ( diff )

--

RFC 60 : Improved round-tripping in OGR

Author: Even Rouault

Contact: even.rouault at spatialys.com

Status: Development

Implementation version: 2.1

Summary

This RFC defines how to improve better round-tripping in conversion of vector formats, in particular for GeoJSON extensions.

Rationale

Some formats have concepts that are not well modeled by the OGR abstraction, but that are desirable to be preserved in transformation scenarios involving reprojection, spatial/attribute filtering, clipping, etc... where the target format is the source format.

Various extensions exist above the core GeoJSON specification: at the FeatureCollection, Feature or Geometry levels. See https://github.com/mapbox/carmen/blob/master/carmen-geojson.md, https://github.com/geocoders/geocodejson-spec/blob/master/draft/README.md or https://github.com/geojson/draft-geojson/issues/80#issuecomment-138037554 for a few examples.

Changes

OGRFeature

Two new members will be added to the OGRFeature class, nativeData (string) and nativeMediaType (string). nativeData will contain the representation (or part of the representation) of the original feature, and nativeMediaType the media type

Thus, in the GeoJSON case, nativeData would contain the full serialization of a GeoJSON Feature. nativeMediaType would be set to "application/vnd.geo+json" The writer side of the GeoJSON driver would start from the nativeData if present (and if nativeMediaType = "application/vnd.geo+json", replace its properties member with the content of the OGR fields and patch its geometry to include additional JSON objects.

OGRLayer

A dedicated metadata domain "NATIVE_DATA" in which there would be a "NATIVE_DATA" and "NATIVE_MEDIA_TYPE" items would be used. In the GeoJSON case, this would contain JSON members at the FeatureCollection level (excluding the features array of course).

C API

The following functions will be added:

const char CPL_DLL *OGR_F_GetNativeData(OGRFeatureH);
void OGR_F_SetNativeData(OGRFeatureH, const char*);
const char CPL_DLL *OGR_F_GetNativeMediaType(OGRFeatureH);
void OGR_F_SetNativeMediaType(OGRFeatureH, const char*);

SWIG bindings (Python / Java / C# / Perl) changes

The new functions will mapped to SWIG.

Drivers

The GeoJSON driver will be modified to implement this RFC.

Other drivers like ElasticSearch and MongoDB drivers, that use a _json OGR field for round-tripping could potentially be upgraded to benefit from the mechanism of this RFC.

Utilities

ogr2ogr will be modified to automatically copy nativeData at layer and feature level. A -noNativeData flag will be added to avoid doing so, when this is not desirable.

Documentation

All new methods/functions are documented.

Test Suite

The GeoJSON and ogr2ogr related tests will be extended

Compatibility Issues

Nothing severe expected. Potentially existing scripts might need to add -noNativeData to get previous behaviour.

Related ticket

https://trac.osgeo.org/gdal/ticket/5310

Implementation

The implementation will be done by Even Rouault (Spatialys) and be sponsored by Mapbox.

Voting history

TBD

Note: See TracWiki for help on using the wiki.