public void accept()

in baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java [47:67]


  public void accept(Way way) {
    try {
      List<Coordinate> list = way.getNodes().stream().map(coordinateMap::get).toList();
      Coordinate[] array = list.toArray(new Coordinate[list.size()]);
      LineString line = GEOMETRY_FACTORY_WGS84.createLineString(array);
      if (!line.isEmpty()) {
        // Ways can be open or closed depending on the geometry or the tags:
        // https://wiki.openstreetmap.org/wiki/Way
        if (!line.isClosed() || way.getTags().containsKey("highway")
            || way.getTags().containsKey("barrier")) {
          way.setGeometry(line);
        } else {
          Polygon polygon = GEOMETRY_FACTORY_WGS84.createPolygon(line.getCoordinates());
          way.setGeometry(polygon);
        }
      }
    } catch (Exception e) {
      logger.debug("Unable to build the geometry for way #" + way.id(), e);
      way.setGeometry(GEOMETRY_FACTORY_WGS84.createEmpty(0));
    }
  }