Search code examples
jacksongeojsongml

Convert GeoJSON object to GML geometry


I have the following issue with transforming GeoJSON object into GML geometry object.

First, on backend in request I retrieve GeoJSON object. Then I use jackson library to transform it into java object. This java object is FeatureCollection from geojson-jackson library. So I have java object representing GeoJSON on backend and now I need to transform it into GML object and extract geometry from it.

From this:

{
  "featureCollection : {
    "type": "FeatureCollection",
    "features": [{
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [ [[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]] ]
      },
    }]
  }
}

I need to get this:

<gml:Rectangle srsName="urn:x-ogc:def:crs:EPSG:6.6:25833">
  <gml:exterior>
    <gml:LinearRing>
      <gml:coordinates>100.0,0.0 101.0,0.0 101.0,1.0 100.0,1.0 100.0,0.0</gml:coordinates>
    </gml:LinearRing>
  </gml:exterior>
</gml:Rectangle> 

The question, is there any existing library which allows transform from GeoJSON into GML object?


Solution

  • No, there is definetly not. You have to find another way to do that.

    I suggest you to do that either manually or read it as file and save to variables.