Skip to content
This repository was archived by the owner on Mar 27, 2020. It is now read-only.
This repository was archived by the owner on Mar 27, 2020. It is now read-only.

superposed nodes when importing Polygons/MultiPolygons and closed LineStrings, and area=yes/no OSM tags #12

@verdy-p

Description

@verdy-p

GeoJSON does not detail nodes in the "coordinates" array embedded in geometries for Polygons (single area possibly with holes)/MultiPolygons(simple array of Polygons), or LineStrings (possibly closed)/MultiLineStrings(simple array of LineStrings).

The import tool currently creates a single new OSM node for each coordinate pair, including for the first and last [x,y] pair of every ring member of a Polygon (which are implicitly closed), or of any polygon member of a MultiPolygon, when they are the same (this is not a requirement for rings of Polygons/MultiPolygons as they are necessarily closed to represent surfaces, and if the last coordinates pair in a ring is not the same as the first one, the rings MUST still be closed as it it was there by as if the missing last pair was present).

Because coordinates pairs are compeltely untagged in GeoJSON geometries (except when they are in a feature whose geometry is only a single node), it makes no sense to not merge the duplicate nodes coming from the same geometry object (or the same "coordinates": properties of any imported "Feature" type).

Please merge these nodes, and make sure that ring members in Polygon (first ring for the outer border, 2nd and following rings for the optional inner borders) and MultiPolygons are effectively closed:

This closure is implicit in GeoJSON, where a triangular polygon like this one is still valid and closed:

{"type":"Polygon","coordinates":[
  [[x0,y0], [x1,y1], [x2,y2]]
]}

and equivalent to:

{"type":"Polygon","coordinates":[
  [[x0,y0], [x1,y1], [x2,y2], [x0,y0]]
]}

which should still be imported as 3 OSM nodes (not 4) and a OSM closed way connecting the 3 nodes.

As well this tetragonal area with an inner triangular hole (sharing a common node between outer and inner rings):

[x3,y3]                       [x2,y2]
       +---------------------+
        \                   /
         \[x4,y4]  [x5,y5] /
          \   +---+       /
           \  |  /       /
            \ | /       /
             \|/       /
              +-------+
       [x0,y0]         [x1,y1]

represented in GeoJSON with this geometry:

{"type":"Polygon","coordinates":[
  [[x0,y0], [x1,y1], [x2,y2], [x3,y3]],
  [[x4,y4], [x5,y5], [x0,y0]]
]}

or equivalently as:

{"type":"Polygon","coordinates":[
  [[x0,y0], [x1,y1], [x2,y2], [x3,y3], [x0,y0]],
  [[x4,y4], [x5,y5], [x0,y0], [x4,y4]]
]}

which should be imported as 6 OSM nodes (not 9 because [x0,y0] occurs 3 times, and [x4,y4] occurs 2 times), two OSM ways (one for each ring), and a OSM relation with "type=multipolygon" whose members will be the two rings, the first one with "outer" role, the second with "inner" role.

In contrast, the following "similar" tetragonal and triangular areas:

[x3,y3]                       [x2,y2]
       +---------------------+
        \                   /
         \                 /
          \               /
           \             /
            \           /
             \         /
              +-------+
       [x0,y0]|\       [x1,y1]
              | \
              |  \
              +---+
          [x4,y4]  [x5,y5]

represented in GeoJSON as:

{"type":"MultiPolygon","coordinates":[
  [
    [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]
  ],[
    [[x5,y5], [x0,y0], [x4,y4]]
  ]
]}

or equivalently as:

{"type":"MultiPolygon","coordinates":[
  [
    [[x0,y0], [x1,y1], [x2,y2], [x3,y3], [x0,y0]]
  ],[
    [[x5,y5], [x0,y0], [x4,y4], [x5,y5]]
  ]
]}

will be imported as two closed ways, but no OSM "multipolygon" relation, unless they are part of a "Feature" with properties (in which case both closed ways will be members with "outer" role), and there will also be 6 OSM nodes only (not 9): the generated nodes should also be merged as they are part of the same geometry object (and necessarily have the same tags in the generated OSM feature, but OSM nodes themselves for this geometry will have no tags at all).

Notes: in strict GeoJSON, the outer rings should be traced anticlockwise and the inner rings should be clockwise. As well rings should not intersect except on isolated nodes with supplied coordinate pairs; outer rings should not overlap any non-zero surface; inner rings should be fully contained in the outer ring which is the first member of the polygon, and inner rings should not overlap themselves any non-zero surface. It is still valid (but not recommanded in GeoJSON) for a Multipolygon to have shared borders (but it is permitted if they are part of separate geometries in distinct Features with possibly separate GeoJSON properties, i.e. separate OSM tags). Such strict validation constraints do not need to be enforced when importing GeoJSON, but the JOSM validator may detect these. These constraints should be checked when exporting/saving from JOSM to a new GeoJSON, because GeoJSON applications may depend on these constraints for correct handling or rendering.


Also for Polygon/MultiPolygon, the imported OSM feature should also have tag "area=yes" as polygons in GeoJSON are necessarily representing surfaces, not just their border. This is different from GeoJSON "LineString/MultiLinestring", where the implicit OSM tag should be "area=no".

This would allow saving/exporting from JOSM to GeoJSON with the correct GeoJSON type: currently the imported Polygons/MultiPolygons will be saved incorrectly as "Linestring" or "MultiLineStrings" (the export does not figure out correctly that OSM closed ways or relations represent only borders or the surface, the surface interpretation should be assumed for OSM relations with "type=multipolygon" or "type=boundary", or for OSM closed ways with "landuse=" or "natural=" or "building=" or "water=", unless they have "area=no", or for any closed way with "area=yes").

When exporting to a geojson, the OSM tag "area=yes/no" should be discarded from the properties of the exported feature, it will just be used to select if a [Multi]LineString or [Multi]Polygon will be generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Hacktoberfesthttps://hacktoberfest.digitalocean.com

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions