WS_OK_7.4.33 HEX
HEX
Server: nginx/1.21.4
System: Linux v12674 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User: endtheignorance (1014)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v12674/lcalansdale/public_html/wp-content/plugins/wpgmza-tools/pages/geo-to-polygon.php
<?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 . '&params=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>