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

<?php
namespace OSM;
class GeoJsonConverter
{
public static function convertRelationToPolygon(
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]);
}
}