eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.58k stars 1.44k forks source link

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

Open RobertHilbrich opened 4 months ago

RobertHilbrich commented 4 months ago

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

behrisch commented 4 months ago

see also #15294 and #15296

behrisch commented 3 months ago

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