-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect_point.php
50 lines (41 loc) · 1.34 KB
/
select_point.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include('../libs/config.php');
// Retrieve start point
// Connect to database
$sql = "select * ,ST_AsGeoJSON(geom) AS geojson from list_house2";
// Perform database query
$query = pg_query($db,$sql);
//echo $sql;
// Return route as GeoJSON
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
// Add geom to GeoJSON array
while($edge=pg_fetch_assoc($query)) {
$feature = array(
'type' => 'Feature',
'geometry' => json_decode($edge['geojson'], true),
'crs' => array(
'type' => 'EPSG',
'properties' => array('code' => '4326')
),
'properties' => array(
'gid' => $edge['id_list'],
'prov_nam' => $edge['prov_nam'],
'amp_nam' => $edge['amp_nam'],
'tam_nam' => $edge['tam_nam'],
'name_house' => $edge['name_house'],
'no_house' => $edge['no_house'],
'moo_house' => $edge['moo_house'],
'id_house' => $edge['id_house']
)
);
// Add feature array to feature collection array
array_push($geojson['features'], $feature);
}
// Close database connection
// Return routing result
// header('Content-type: application/json',true);
echo json_encode($geojson);
?>