Découvrez notre formation Comptabilité Odoo !

Context


Graphical representation of spatial data is an important step in all geographical information systems (GIS) with a mapping component. Numerous systems of style have been developed to graphically represent geographical data in the various GIS solutions existing on the market. Among the most used today are the QGIS Style File (QML), QGIS Layer Definition File (QLR), Styled Layer Descriptor (SLD), MapServer Mapfile (MAP), Google Keyhole Markup Language (KML), Esri ArcGIS Layer File (LYRX) or Esri ArcGIS Style File (STYLX). Many of these formats use an XML syntax or other custom markup languages, using tags similar in their functioning as HTML. When transferring from one solution to another or when using different solutions simultaneously, the use of a parser (syntactic analyzer) is useful for replicating styles from one solution to another in order to minimize manual work..

GeoStyler (https://github.com/geostyler/geostyler) aims to be an exchange format to facilitate the transition from one style to another by offering a generic representation serving as a common denominator to the various styles. To process the different formats, GeoStyler uses libraries (called “parser”) handling each specific style format. These parsers are developed as needed on an ad hoc basis (see  https://github.com/geostyler for a list of all the parsers currently available).

GeoStyler | © Camptocamp

Objective

The objective of the Mapfile parser is to translate the styling of geographic data as defined in MapServer (https://mapserver.org) into a GeoStyler object that can be subsequently converted into several other formats (QGIS, SLD, OpenLayers, Mapbox, CartoCSS,...).

Concretely, it is a question of analyzing the structure of a representation file to convert it into another structure. Here is an example with a simple style representation of a green point in MapServer, GeoStyler and QGIS:

Mapfile (.map)GeoStyler (.ts)QGIS (.qml)

LAYER

  NAME "point_simple_point"

  TYPE POINT

  DATA "../shapes/points.shp"

  CLASS

    STYLE

    SYMBOL "circle"

    COLOR 0 255 0

    SIZE 15

  END

  END

END

const pointStyle: Style = {

  name: 'point_simple_point',

  rules: [{

    name: 'MyRule',

    symbolizers: [{

      kind: 'Mark',

      wellKnownName: 'Circle',

      color: '#00FF00',

      radius: 7.5

    }]

  }]

}

<qgis>

  <renderer-v2 type="RuleRenderer">

    <rules key="renderer_rules">

    <rule key="renderer_rule_0" symbol= "0" label="QGIS Simple Symbol"/>

    </rules>

    <symbols>

      <symbol type="marker" name="0">

        <layer class="SimpleMarker">

          <prop k="color" v="0,255,0,255"/>

          <prop v="diameter" k="scale_method"/>

          <prop v="15" k="size"/>

          <prop k="name" v="circle"/>

        </layer>

      </symbol>

    </symbols>

  </renderer-v2>

</qgis>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LAYER
NAME "point_simple_point"
TYPE POINT
DATA "../shapes/points.shp"
CLASS
STYLE
SYMBOL "circle"
COLOR 0 255 0
SIZE 15
END
END
END

GeoStyler (.ts)

const pointStyle: Style = {
name: 'point_simple_point',
rules: [{
name: 'MyRule',
symbolizers: [{
kind: 'Mark',
wellKnownName: 'Circle',
color: '#00FF00',
radius: 7.5
}]
}]
}

QGIS (.qml)

<qgis>
<renderer-v2 type="RuleRenderer">
<rules key="renderer_rules">
<rule key="renderer_rule_0" symbol= "0" label="QGIS Simple Symbol"/>
</rules>
<symbols>
<symbol type="marker" name="0">
 <layer class="SimpleMarker">
<prop k="color" v="0,255,0,255"/>
<prop v="diameter" k="scale_method"/>
 <prop v="15" k="size"/>
<prop k="name" v="circle"/>
</layer>
</symbol>
</symbols>
</renderer-v2>
</qgis>

Carrière

Vous souhaitez travailler dans un environnement inspirant et rejoindre nos équipes motivées et multiculturelles ?