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.

25 lines
568 B

  1. <?php
  2. namespace OSM;
  3. class GeoJsonConverter {
  4. public static function convertRelationToPolygon(
  5. \OSM\Element\Relation $relation
  6. ): \GeoJson\Geometry\Polygon
  7. {
  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. }