0
"geometry": {
    "coordinates": [{
        "coordinates": [{
            "type": "LineString",
            "coordinates": [{
                "x": 63.176,
                "y": 34.354
            },
            ...
            {
                "x": 63.176,
                "y": 34.354
            }]
        }],
        "type": "Polygon"
    }, {
        "coordinates": [{
            "type": "LineString",
            "coordinates": [{
                "x": 69.169,
                "y": 32.875
            },
            ...
            {
                "x": 69.169,
                "y": 32.875
            }]
        }],
        "type": "Polygon"
    }],
    "type": "MultiPolygon"
}}

Background:

With the goal of displaying GeoJSONs(indexed in Elasticsearch as geo_shape) in a LeafLet-based map in my frontend.

  • I retrieve them from a REST API featuring SpringData.
  • The repository maps Elasticsearch-data to a generic org.springframework.data.elasticsearch.core.geo.GeoJson interface, as my indexed data can contain Polygons or Multipolygons.
  • Original shapes are indexed from a .shp file using ogr2ogr.
Vince
  • 20,017
  • 15
  • 45
  • 64
nonNumericalFloat
  • 223
  • 1
  • 2
  • 10
  • You can display any valid GeoJSON with Leaflet. To check if GeoJSON is valid, you can use any of validating sites, for example https://geojsonlint.com/ – TomazicM Jan 16 '22 at 13:39
  • Yeah but, why do I have x, y coordinates in my objects? LeafLet cannot really work with this as far as I know. – nonNumericalFloat Jan 16 '22 at 13:58
  • 1
    As I wrote, Leaflet can work with any valid GeoJSON data. So your problem is how to get valid GeoJSON from your GeoJSON source. – TomazicM Jan 16 '22 at 14:06
  • 2
    I read https://datatracker.ietf.org/doc/html/rfc7946#section-6 A GeoJSON object has a member with the name "type". The value of the member MUST be one of the GeoJSON types. so that there can be only one type and thus your geometry with two types is not valid. But you can use a GeometryCollection https://gis.stackexchange.com/questions/193590/can-a-geojson-multigeometry-contain-a-multipoint-among-other-geometries. – user30184 Jan 16 '22 at 14:43

0 Answers0