Skip to content

Convert OSM geometry to Simple Features geometry & streamline layers #7

@mrmaxguns

Description

@mrmaxguns

Geometry

OSM has only nodes, ways, and relations. Polygons are thus second-class citizens, and polygons with inner holes have to be represented as a multipolygon relation.

It makes more sense to style based on the physical geometry represented by the OSM data, rather than directly using OSM's data model.

Thus, an additional processing step is proposed, in which OSM data is converted into Geometry. This is based on Simple Features, although the geometry classes are named based on OSM terminology (except for the Polygon class):

  • Geometry: Abstract parent class for all geometry. Has a list of tags.
  • NodeGeometry (Point): Equivalent to an OSM node.
  • WayGeometry (LineString): Equivalent to an OSM way.
  • PolygonGeometry (Polygon): Equivalent to a closed OSM way or multipolygon. Duplication is OK, so every single closed way is converted both to a WayGeometry and PolygonGeometry.
  • RelationGeometry (GeometryCollection): Equivalent to a relation. Duplication is OK, so every single multipolygon is converted to both a PolygonGeometry and RelationGeometry.

Revamped layers

Each layer type is currently made of two separate classes, a Layer that then compiles to a CompiledGeometry. The compilation process for each type of geometry (nodes, ways, etc.) is identical and thus repetitive. Furthermore, the creation of two tightly coupled classes for each layer is cumbersome and provides no benefit. Thus, it is proposed that each layer is a single class that handles rendering for that layer. With the introduction of Geometry, Layers will now operate on Geometry types rather than OSM types.

Since each layer follows the same XML pattern, just with different inputs, the Layer class should provide utilities to parse an XML layer, so no repetitive XML parsing is done by children.

  • Layer<T extends Geometry>: abstract class for a layer, with tools to create a layer from XML
  • NodeLayer extends Layer<NodeGeometry>
  • WayLayer extends Layer<WayGeometry>
  • PolygonLayer extends Layer<PolygonGeometry>
  • RelationLayer extends Layer<RelationGeometry>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions