Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
  4.  
  5. $data_query = "SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features";
  6. $data_query .= " FROM (SELECT 'Feature' As type";
  7. $data_query .= ", ST_AsGeoJSON(lg.geom)::json As geometry";
  8. $data_query .= ", row_to_json((SELECT l FROM (SELECT taluk) As l";
  9. $data_query .=" )) As properties";
  10. $data_query .= " FROM s50k.aptaluk50soi2001 As lg ) As f ) As fc";
  11.  
  12. $data = pg_query($db,$data_query);
  13.  
  14. while ($row_p = pg_fetch_row($data) )
  15. {
  16. $count = count($row_p);
  17. $y = 0;
  18. while ($y < $count)
  19. {
  20. $c_row = current($row_p);
  21. $lat_lon.= $c_row . ",";
  22. next($row_p);
  23. $y = $y + 1;
  24. }
  25. }
  26.  
  27. echo $lat_lon;
  28. ?>
  29.  
  30. <?php
  31.  
  32. $db = pg_connect("host=172.31.4.61 port=5432 dbname=geoserver user=postgres password=ndem$123") or die ("cant");
  33.  
  34. $mapa = "SELECT geom FROM s50d.aptirupatiff50dsc01042014";
  35.  
  36. $dbquery = pg_query($db,$mapa);
  37. //echo("hello");
  38.  
  39. $geojson = array( 'type' => 'FeatureCollection', 'features' => array());
  40.  
  41. while($row = pg_fetch_array($dbquery)){
  42.  
  43. $marker = array(
  44. 'type' => 'Feature',
  45. 'features' => array(
  46. 'type' => 'Feature',
  47. 'properties' => array(
  48. 'gid' => "serial"
  49.  
  50. )
  51.  
  52.  
  53. )
  54.  
  55. );
  56. array_push($geojson['features'], $marker['features']);
  57. }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement