Changes between Version 1 and Version 2 of rfc60_improved_roundtripping_in_ogr


Ignore:
Timestamp:
Oct 31, 2015, 3:53:25 PM (9 years ago)
Author:
Even Rouault
Comment:

Update with changes after implementation

Legend:

Unmodified
Added
Removed
Modified
  • rfc60_improved_roundtripping_in_ogr

    v1 v2  
    1717Some 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.
    1818
    19 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.
     19Various extensions exist above the core GeoJSON specification: at the FeatureCollection, Feature or Geometry levels.
     20
     21See https://github.com/mapbox/carmen/blob/master/carmen-geojson.md,
     22
     23{{{
     24{
     25    "type": "FeatureCollection",
     26    "query": ["austin"],
     27    "features": [
     28        {
     29            "type": "Feature",
     30            "id": "place.4201",
     31            "text": "Austin",
     32            "place_name": "Austin, Texas, United States",
     33            "bbox": [-97.9383829999999, 30.098659, -97.5614889999999, 30.516863],
     34            "center": [-97.7559964, 30.3071816],
     35            "geometry": {
     36                "type": "Point",
     37                "coordinates": [-97.7559964, 30.3071816]
     38            },
     39            "properties": {
     40                "title": "Austin",
     41                "type": "city",
     42                "score": 600000790107194.8
     43            },
     44            "context": [
     45                {
     46                    "id": "province.293",
     47                    "text": "Texas"
     48                },
     49                {
     50                    "id": "country.51",
     51                    "text": "United States"
     52                }
     53            ]
     54        },
     55        ...
     56    ]
     57}
     58}}}
     59
     60https://github.com/geocoders/geocodejson-spec/blob/master/draft/README.md:
     61
     62{{{
     63{
     64
     65  // REQUIRED. GeocodeJSON result is a FeatureCollection.
     66  "type": "FeatureCollection",
     67
     68  // REQUIRED. Namespace.
     69  "geocoding": {
     70
     71    // REQUIRED. A semver.org compliant version number. Describes the version of
     72    // the GeocodeJSON spec that is implemented by this instance.
     73    "version": "0.1.0",
     74
     75    // OPTIONAL. Default: null. The licence of the data. In case of multiple sources,
     76    // and then multiple licences, can be an object with one key by source.
     77    "licence": "ODbL",
     78
     79    // OPTIONAL. Default: null. The attribution of the data. In case of multiple sources,
     80    // and then multiple attributions, can be an object with one key by source.
     81    "attribution": "OpenStreetMap Contributors",
     82
     83    // OPTIONAL. Default: null. The query that has been issued to trigger the
     84    // search.
     85    "query": "24 allée de Bercy 75012 Paris",
     86
     87  },
     88
     89  // REQUIRED. As per GeoJSON spec.
     90  "features": [
     91    // OPTIONAL. An array of feature objects. See below.
     92  ]
     93}
     94}}}
     95
     96or https://github.com/geojson/draft-geojson/issues/80#issuecomment-138037554 for a few examples.
     97
     98{{{
     99{ "type" : "GeometryCollection",
     100  "geometries" : [
     101    { "type" : "LineString",
     102      "extensions" : [ "time", "atemp", "hr", "cad" ],
     103      "coordinates" : [
     104        [
     105          -122.45671039447188,
     106          37.786870915442705,
     107          0.4000000059604645,
     108          "2014-11-06T19:16:06.000Z",
     109          31.0,
     110          99,
     111          0
     112        ],
     113}}}
    20114
    21115== Changes ==
     
    23117=== OGRFeature ===
    24118
    25 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 [https://en.wikipedia.org/wiki/Media_type media type]
    26 
    27 Thus, in the GeoJSON case, nativeData would contain  the full serialization of a GeoJSON Feature. nativeMediaType would be set to "application/vnd.geo+json"
     119Two new members will be added to the OGRFeature class, m_pszNativeData (string) and m_pszNativeMediaType (string). m_pszNativeData will contain the representation (or part of the representation) of the original feature, and m_pszNativeMediaType the [https://en.wikipedia.org/wiki/Media_type media type]
     120
     121The following methods will be added to OGRFeature class:
     122
     123{{{
     124public:
     125    const char *GetNativeData() const;
     126    const char *GetNativeMediaType() const;
     127    void        SetNativeData( const char* pszNativeData );
     128    void        SetNativeMediaType( const char* pszNativeMediaType );
     129}}}
     130
     131Thus, in the GeoJSON case, nativeData would contain  the full serialization of a GeoJSON Feature. m_pszNativeMediaType would be set to "application/vnd.geo+json"
    28132The 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.
    29133
     134The OGRFeature::Clone() and ::SetFrom() methods will propagate nativeData and nativeMediaType.
     135
    30136=== OGRLayer ===
    31137
    32138A 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).
     139
     140=== Driver open options and layer creation options ===
     141
     142Drivers that support nativeData on read should expose a NATIVE_DATA boolean open option, and disable it by default so as not to impact performance. ogr2ogr will by default turn this option on.
     143
     144Drivers that support nativeData on write at the layer level should expose a NATIVE_DATA string and NATIVE_MEDIA_TYPE string layer creation options, so that ogr2ogr can fill them with the content of the NATIVE_DATA metadata domain of the source layer(s).
    33145
    34146== C API ==
     
    45157== SWIG bindings (Python / Java / C# / Perl) changes ==
    46158
    47 The new functions will mapped to SWIG.
     159The new functions will mapped to SWIG as GetNativeData(), SetNativeData(), GetNativeMediaType() and SetNativeMediaType()
    48160
    49161== Drivers ==
    50162
    51 The GeoJSON driver will be modified to implement this RFC.
     163The GeoJSON driver will be modified to implement this RFC, in read and write, and thus
     164wil* :
     165  * declare a NATIVE_DATA open option to enable storing layer and feature native data.
     166  * and NATIVE_DATA & NATIVE_MEDIA_TYPE layer creation options so as to be able to write native data at FeatureCollection levels
     167  * use OGRFeature nativeData on write.
     168
     169The effect of this is that ogr2ogr will be able to preserve the members marked between {{{***}}} in the below snippet:
     170
     171{{{
     172{
     173  "type": "FeatureCollection",
     174  ***"extra_fc_member": "foo",***
     175  "features":
     176  [
     177    {
     178      "type": "Feature",
     179      ***"extra_feat_member": "bar",***
     180      "geometry": {
     181        "type": "Point",
     182        ***extra_geom_member": "baz",***
     183        "coordinates": [ 2, 49, 3, ***100, 101*** ]
     184      },
     185      "properties": {
     186        "a_property": "foo",
     187      }
     188    }
     189  ]
     190}
     191}}}
     192
    52193
    53194Other drivers like ElasticSearch and MongoDB drivers, that use a _json OGR field
     
    59200will be added to avoid doing so, when this is not desirable.
    60201
     202By default, ogr2ogr will open datasources with the NATIVE_DATA=YES open option so that drivers that
     203can store nativeData do so. And if the output datasource supports the NATIVE_DATA and NATIVE_MEDIA_TYPE
     204layer creation options, it will feel them with the content of the source layer NATIVE_DATA metadata domain.
     205
    61206== Documentation ==
    62207
     
    79224The implementation will be done by Even Rouault (Spatialys) and be sponsored by Mapbox.
    80225
     226The proposed implementation lies in the "rfc60_native_data" branch of the ​https://github.com/rouault/gdal2/tree/rfc60_native_data, in pull request https://github.com/OSGeo/gdal/pull/75
     227
    81228== Voting history
    82229