WS_OK_7.4.33
<?php
$output_string = "";
if ( isset( $_POST['geojson-submit'] ) ) :
$relation_id = isset( $_POST['relation-id'] ) ? $_POST['relation-id'] : '';
$geojson_url = 'http://polygons.openstreetmap.fr/get_geojson.py';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $geojson_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"id=" . $relation_id . '¶ms=0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
$data = json_decode( $server_output, true );
$polygon_data = $data['geometries'][0]['coordinates'];
foreach ( (array) $polygon_data[0][0] as $data) {
$output_string .= '(' . $data[1] . ', ' . $data[0] . '),';
}
?>
<?php endif; ?>
<h1>GeoJSON to Polygon Converter</h1>
<form id="geo-search-from" method="post">
<input type="text" id="relation-id" name="relation-id" placeholder="Relation ID" />
<button id="geojson-submit" name="geojson-submit">Get Polygon Data</button>
</form>
<h3>Your Polygon Data</h3>
<code id="wpgmza-mt-polygon-data" class="wpgmza-mt-code"><?php echo $output_string !== "" ? $output_string : 'No polygon data found. Please make sure the polygon data is correct.'; ?></code>
<h3>How to get the Polygon relation code for any area:</h3>
<p>
<ol>
<li>Go to <a href="https://nominatim.openstreetmap.org/" target="_blank">Open Street Maps</a></li>
<li>Search any location you want to get the polygon for</li>
<li>Select the desired result in the left panel and click on the 'Details' button.</li>
<li>In the place details, scroll down to the 'OSM' option and copy the relation number/ID</li>
<li>Enter this relation ID into the field above and hit 'Get Polygon Data'</li>
</ol>
</p>