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

<?php
namespace OSM;
class GeoJsonConverter {
public static function convertRelationToPolygon(
\OSM\Element\Relation $relation
): \GeoJson\Geometry\Polygon
{
$positions = [];
foreach ($relation->getOrderedOuterWays() as $way) {
foreach ($way->points as $point) {
$positions[] = new \GeoJson\Geometry\Point([
$point->longitude,
$point->latitude
]);
}
}
return new \GeoJson\Geometry\Polygon([ $positions ]);
}
}