Changes between Initial Version and Version 1 of rfc50_ogr_field_subtype


Ignore:
Timestamp:
Nov 19, 2014, 2:08:10 PM (10 years ago)
Author:
Even Rouault
Comment:

Initial version of RFC 50

Legend:

Unmodified
Added
Removed
Modified
  • rfc50_ogr_field_subtype

    v1 v1  
     1= RFC 50: OGR field subtypes =
     2
     3Author: Even Rouault[[BR]]
     4Contact: even dot rouault at spatialys dot com[[BR]]
     5Status: In development
     6
     7== Summary ==
     8
     9This RFC aims at adding the capability of specifying sub-types to OGR fields,
     10like boolean, 16 bit integers or 32 bit floating point values.
     11The sub-type of a field definition is an additional
     12attribute that specifies a hint or a restriction to the main type. The subtype
     13can be used by applications and drivers that know how to handle it, and
     14can generally be safely ignored by applications and drivers that do not.
     15
     16== Core changes ==
     17
     18=== Field subtypes ===
     19
     20The OGRFieldSubType enumeration is added :
     21
     22{{{
     23/**
     24 * List of field subtypes. A subtype represents a hint, a restriction of the
     25 * main type, that is not strictly necessary to consult.
     26 * This list is likely to be extended in the
     27 * future ... avoid coding applications based on the assumption that all
     28 * field types can be known.
     29 * Most subtypes only make sense for a restricted set of main types.
     30 * @since GDAL 2.0
     31 */
     32typedef enum
     33{
     34    /** No subtype. This is the default value */        OFSTNone = 0,
     35    /** Boolean integer. Only valid for OFTInteger and OFTIntegerList.*/
     36                                                        OFSTBoolean = 1,
     37    /** Signed 16-bit integer. Only valid for OFTInteger and OFTIntegerList. */
     38                                                        OFSTInt16 = 2,
     39    /** Single precision (32 bit) floatint point. Only valid for OFTReal and OFTRealList. */
     40                                                        OFSTFloat32 = 3,
     41                                                        OFSTMaxSubType = 3
     42} OGRFieldSubType;
     43}}}
     44
     45
     46=== New attributes and methods ===
     47
     48  * In OGRFieldDefn class :
     49{{{
     50    OGRFieldSubType     eSubType;
     51
     52    OGRFieldSubType     GetSubType() { return eSubType; }
     53    void                SetSubType( OGRFieldSubType eSubTypeIn );
     54    static const char  *GetFieldSubTypeName( OGRFieldSubType );
     55}}}
     56
     57OGRFeature::SetField() will check that the passed value is in the accepted
     58range for boolean and int16 subtypes. If not, it will emit a warning and
     59correct/clamp the value to fit the subtype.
     60
     61=== C API changes ===
     62
     63Only additions :
     64{{{
     65OGRFieldSubType CPL_DLL OGR_Fld_GetSubType( OGRFieldDefnH );
     66void   CPL_DLL OGR_Fld_SetSubType( OGRFieldDefnH, OGRFieldSubType );
     67const char CPL_DLL *OGR_GetFieldSubTypeName( OGRFieldSubType );
     68int CPL_DLL OGR_AreTypeSubTypeCompatible( OGRFieldType eType,
     69                                          OGRFieldSubType eSubType );
     70}}}
     71
     72== Changes in OGR SQL ==
     73
     74  * Subtypes are preserved when a field name (or *) is specified in the list
     75    of fields of a SELECT
     76  * CAST(xxx AS BOOLEAN) and CAST(xxx AS SMALLINT) are now supported.
     77  * The field list of a SELECT can now accept boolean expressions, such as
     78    "SELECT x IS NULL, x >= 5 FROM foo"
     79  * The WHERE clause of a SELECT can now accept boolean fields, such as
     80    "SELECT * FROM foo WHERE a_boolean_field"
     81
     82== Changes in drivers ==
     83
     84  * GeoJSON: can read/write OFSTBoolean
     85  * GML: can read/write OFSTBoolean, OFSTInt16 and OFSTFloat32
     86  * CSV: can read/write OFSTBoolean (explicitely with CSVT or with autodetection), OFSTInt16 and OFSTFloat32 (explicitely with CSVT)
     87  * PG: can read/write OFSTBoolean, OFSTInt16 and OFSTFloat32
     88  * PGDump: can write OFSTBoolean, OFSTInt16 and OFSTFloat32
     89  * GeoPackage: can read/write OFSTBoolean, OFSTInt16 and OFSTFloat32
     90  * SQLite: can read/write OFSTBoolean and OFSTInt16
     91  * SQLite dialect: can read/write OFSTBoolean, OFSTInt16 and OFSTFloat32
     92  * FileGDB: can read/write OFSTInt16 and OFSTFloat32
     93  * OpenFileGDB: can read OFSTInt16 and OFSTFloat32
     94  * VRT: 'subtype' property added to be able to handle any subtype.
     95
     96== Changes in utilities ==
     97
     98  * ogrinfo: the output of ogrinfo is slightly modified in presence of a subtype.
     99    A field with a non-default subtype will be described as "field_type(field_subtype)".
     100    For example
     101{{{
     102Had to open data source read-only.
     103INFO: Open of `out.gml'
     104      using driver `GML' successful.
     105
     106Layer name: test
     107Geometry: None
     108Feature Count: 2
     109Layer SRS WKT:
     110(unknown)
     111short: Integer(Int16) (0.0)
     112b: Integer(Boolean) (0.0)
     113OGRFeature(test):0
     114  short (Integer(Int16)) = -32768
     115  b (Integer(Boolean)) = 1
     116}}}
     117
     118== Changes in SWIG bindings ==
     119
     120Addition of :
     121  * ogr.OFSTNone, ogr.OFSTBoolean, ogr.OFSTInt16 and ogr.OFSTFloat32
     122  * ogr.GetFieldSubTypeName()
     123  * FieldDefn.GetSubType()
     124  * FieldDefn.SetSubType()
     125
     126== Compatibility ==
     127
     128This should have no impact on read-only operations done by applications.
     129Update operations could be impacted if an out-of-range value for the subtype
     130is written (but such a behaviour probably already caused issues, either ignored or
     131notified by the backend)
     132
     133== Documentation ==
     134
     135All new methods are documented. Driver documentationis updated when necessary.
     136
     137== Testing ==
     138
     139The various aspects of this RFC are tested:
     140  * core changes
     141  * OGR SQL changes
     142  * driver changes
     143
     144== Implementation ==
     145
     146Implementation will be done by Even Rouault ([http://spatialys.com Spatialys]),
     147and sponsored by [https://cartodb.com CartoDB].
     148
     149The proposed implementation lies in the "ogr_field_subtype" branch of the
     150https://github.com/rouault/gdal2/tree/ogr_field_subtype repository.
     151
     152The list of changes : https://github.com/rouault/gdal2/compare/ogr_field_subtype
     153
     154== Voting history ==
     155
     156TBD