Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Mapping Language

rkrucker edited this page Mar 18, 2014 · 3 revisions

##ogrtransform library

OGR has many options to transform data when convertion from one format into an other. The ogrtransform library uses a configuration in JSON format to transform data.

This JSON-format can have several sections.

###Metadata dst_dsco Here, the data-set creation option is given. dst_lco Sets the layer-creation option. For instance the name of the Schema to be generated, if any, can be given.

###Layers layers In the layer-section OGR is told how to handle individual layers, as there can be a field for every layer. The field name will be the name of the layer after the transformation. This can be manipulated to one's choosing.

Within the following bracket-pair, all fields of the layer itself are listed. Each field of the layer again comes with the new name that will be set as its identifier, followed by information about itself. This includes:

src           The original name before the transformation
type          The type of the field, e.g. "String" or "Real". These types again can be 
              changed, for instance casting integers given as Strings to Integers, but off course here
              also lies a possibility of mismatches.

Next, the geom-type of the layer and its original name are listed, identified by

geometry_type
src_layer

Afterwards, the geometry-type-fields are listed in a similar way as the normal fields. One can again set the name after the transformation, and information like "src"-name and type of the geometry are given. This sub-section completes the layers-section. Every field and subfield can be omitted, resulting in it not being included in the transformation.

###Source-format

src_format    Specifies the input-format

###Enumerations enums Starts the enum-section. Each enumeration gets a sub-section src_name Specifies the name in the source-file values For each enum, all its values are listed here. Holds information such as the text, the
actual enum and its id. Each enumeration-name can be changed, along with all its values.

###Output-format dst_format Sets the format of the output-file

###Example

{
  "//": "OGR transformation configuration", 
  "dst_dsco": {}, 
  "dst_lco": {
    "SCHEMA": "public"
  }, 
  "layers": {
    "roadsexdm2ben_roads_streetnameposition": {
      "fields": {
        "tid": {
          "src": "TID", 
          "type": "String"
        }, 
        "street": {
          "src": "Street", 
          "type": "String"
        }, 
        "namori": {
          "src": "NamOri", 
          "type": "Real"
        }
      }, 
      "geometry_type": "Point", 
      "src_layer": "RoadsExdm2ben.Roads.StreetNamePosition", 
      "geom_fields": {
        "nampos": {
          "src": "NamPos", 
          "type": "Point"
        }
      }
    }, 
    "roadsexdm2ben_roads_streetaxis": {
      "fields": {
        "tid": {
          "src": "TID", 
          "type": "String"
        }, 
        "street": {
          "src": "Street", 
          "type": "String"
        }
      }, 
      "geometry_type": "MultiLineString", 
      "src_layer": "RoadsExdm2ben.Roads.StreetAxis", 
      "geom_fields": {
        "geometry": {
          "src": "Geometry", 
          "type": "MultiLineString"
        }
      }
    }
  }, 
  "src_format": "Interlis 2", 
  "enums": {
    "enum0_type": {
      "src_name": "RoadsExdm2ben.Roads.RoadSign.Type", 
      "values": [
        {
          "enumtxt": "prohibition", 
          "enum": "prohibition", 
          "id": 0
        }, 
        {
          "enumtxt": "indication", 
          "enum": "indication", 
          "id": 1
        }, 
        {
          "enumtxt": "danger", 
          "enum": "danger", 
          "id": 2
        }, 
        {
          "enumtxt": "velocity", 
          "enum": "velocity", 
          "id": 3
        }
      ]
    }
  }, 
  "dst_format": "PostgreSQL"
}
Clone this wiki locally