You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
557 B

7 days ago
7 days ago
7 days ago
7 days ago
  1. <?php
  2. namespace OSM;
  3. class GeoJsonConverter
  4. {
  5. public static function convertRelationToPolygon(
  6. Element\Relation $relation,
  7. ): \GeoJson\Geometry\Polygon {
  8. $positions = [];
  9. foreach ($relation->getOrderedOuterWays() as $way) {
  10. foreach ($way->points as $point) {
  11. $positions[] = new \GeoJson\Geometry\Point([
  12. $point->longitude,
  13. $point->latitude,
  14. ]);
  15. }
  16. }
  17. return new \GeoJson\Geometry\Polygon([$positions]);
  18. }
  19. }