Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. $data_query ="SELECT replace(ST_AsGeoJSON(geom),'','') As
  2. geometry,taluk from s50k.aptaluk50soi2001";
  3.  
  4. {"type":"FeatureCollection","features":
  5. [{"type":"Feature","geometry":"
  6. {"type":"MultiPolygon","coordinates":
  7. [[[[84.7316718809388,19.0302775870258],... etc.
  8.  
  9. <?php
  10. $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
  11.  
  12. $data_query ="SELECT replace(ST_AsGeoJSON(geom),'','') As geometry,taluk from s50k.aptaluk50soi2001";
  13. //"select replace(replace(replace(ST_AsText(geom),'MULTIPOLYGON',''),'(','['),')',']') As geometry ,taluk FROM s50k.aptaluk50soi2001";
  14.  
  15. $data = pg_query($db,$data_query);
  16. $geojson = array(
  17. 'type' => 'FeatureCollection',
  18. 'features' => array()
  19. );
  20.  
  21. while($edge=pg_fetch_assoc($data)) {
  22. // echo $edge['geometry'];
  23. // $feature = $edge['geometry'];
  24.  
  25. $feature = array(
  26. 'type' => 'Feature',
  27. 'geometry' => $edge['geometry'],
  28. 'properties' => array(
  29. 'taluk' => $edge['taluk']
  30. ));
  31.  
  32. array_push($geojson['features'], $feature);
  33. }
  34. echo json_encode( $geojson);
  35. ?>
  36.  
  37. {"type":"FeatureCollection","features":
  38. [{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":
  39. [[[[81.1303718809389,16.3617775870258],
  40. [81.1277718809389,16.3566775870258],
  41. [81.1187718809389,16.3511775870258],
  42. [81.1058718809388,16.3404775870258],
  43. [81.1055718809389,16.3355775870258]... etc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement