<?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 ]);
|
|
}
|
|
|
|
}
|