forked from klausschreiber/GarchingPowerGisFrontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowerlines.php
More file actions
26 lines (23 loc) · 852 Bytes
/
powerlines.php
File metadata and controls
26 lines (23 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
include('import/config.inc.php');
$dbconn = pg_connect('host=' . DB_HOST . ' dbname=' . DB_NAME . ' user=' . DB_USER . ' password=' . DB_PASS)
or die('Verbindungsaufbau fehlgeschlagen: ' . pg_last_error());
$query = "SELECT ST_AsGeoJSON(ST_Transform(way, 4326)) as way FROM dijkstra_powerlines WHERE osm_id = 999999999990005 AND way IS NOT NULL;";
$result = pg_query($dbconn, $query);
$i = 1;
$rows = pg_num_rows($result);
if ($rows > 0) {
echo '{ "type": "FeatureCollection",' . "\n" . ' "features": [' . "\n";
while ($data = pg_fetch_object($result)) {
echo '{ "type": "Feature",' . "\n" . ' "geometry": ';
echo $data->way;
echo '}';
if ($i != $rows) {
echo ',';
}
echo "\n";
//echo '},' . "\n";
$i++;
}
echo "\n" . ']' . "\n" . ' }';
}