sumo icon indicating copy to clipboard operation
sumo copied to clipboard

Output of net2geojson.py does not (always) validate properly

Open RobertHilbrich opened this issue 1 year ago • 2 comments

Creating a geojson output of a net with net2geojson.py sometimes fails to produce a geojson, that validates for example with http://geojsonlint.com/. See example files below.

Errors of the GeoJSON validator seem to fall into several categories:

1. Validator error: "a LinearRing of coordinates needs to have four or more positions"

{
      "geometry": {
        "coordinates": [
          [
            [13.43944, 52.522418],
            [13.439407, 52.522439],
            [13.43944, 52.522418]
          ]
        ],
        "type": "Polygon"
      },
      "properties": { "element": "junction", "id": "10139448462" },

Probable cause: junctions at the boundary of the scenario only come with three coords. Should these junctions be shapes at all? Should they be LineStrings instead? We should not leave them out, but are they shapes?

2. Validator error: "the first and last positions in a LinearRing of coordinates must be the same"

{
      "geometry": {
        "coordinates": [
          [
            [13.440316, 52.52309],
            [13.440356, 52.523038],
            [13.440347, 52.523033],
            [13.440344, 52.523031],
            [13.440343, 52.523027],
            [13.440343, 52.523024],
            [13.440344, 52.523019],
            [13.440258, 52.522994],
            [13.440241, 52.523024],
            [13.440233, 52.523034],
            [13.440214, 52.523055],
            [13.440201, 52.523071],
            [13.440286, 52.523096],
            [13.440293, 52.52309],
            [13.440298, 52.523088],
            [13.440303, 52.523088],
            [13.440309, 52.523088]
          ]
        ],
        "type": "Polygon"
      },
      "properties": { "element": "junction", "id": "9987935682" },

Probable cause: sumolib or net2geojson do not add the first coord as the last to close the polygon. Could be fixed in net2geojson.

3. Validation error: "Polygons and MultiPolygons should follow the right-hand rule"

{
      "geometry": {
        "coordinates": [
          [
            [13.440411, 52.523086],
            [13.440431, 52.52306],
            [13.440411, 52.523086]
          ]
        ],
        "type": "Polygon"
      },
      "properties": { "element": "junction", "id": "9987935683" },

Will be probably be fixed automatically, if we address errors of category 1.

Example files

RobertHilbrich avatar Jul 29 '24 13:07 RobertHilbrich

see also #15294 and #15296

behrisch avatar Jul 29 '24 14:07 behrisch

Concerning the counter clockwise ordering, the current approach would be to change this in netconvert as well

behrisch avatar Aug 27 '24 12:08 behrisch