Guest User

Untitled

a guest
Feb 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. require 'dataload.php';
  2. function get_objects($where,$name=false) {
  3.  
  4. global $epsg, $cnt_array;
  5.  
  6. $db = Dataload::getDB();
  7.  
  8. $columns="osm_id, ST_AsGeoJSON(ST_Transform(way,4326)) as way2, name, ward, "healthcare:speciality", information, description, social_facility, "social_facility:for", capacity, operator, official_name, official_status, phone, website, "addr:full", "addr:city", "addr:district", "addr:postcode", opening_hours, "addr:hamlet", "addr:street", fax, email, allhuman, adulthuman, childhuman, "healthcare:heart", "healthcare:mind", "healthcare:maternity_light", "healthcare:maternity_hard", "healthcare:dtp", "ward:speciality_gynaecology", "ward:speciality_maternity", "ward:speciality_infectious_diseases", "ward:speciality_neurology", "ward:speciality_paediatrics", "ward:speciality_general", "ward:speciality_surgery", "internet_access:operator", "internet_access:speed", "wifi_access:ssid"";
  9. $query="select ".$columns." from test_point where ".$where;
  10.  
  11. $result = pg_query($query);
  12. if (!$result) {
  13. echo "Problem with query " . $query . "<br/>";
  14. echo pg_last_error();
  15. exit();
  16. }
  17.  
  18. $geojson = array(
  19. 'type' => 'FeatureCollection',
  20. 'features' => array(),
  21. 'crs' => array(
  22. 'type' => 'EPSG',
  23. 'properties' => array('code' => '4326')
  24. )
  25. );
  26. while($myrow = pg_fetch_assoc($result)) {
  27.  
  28. $gos18_work = array();
  29. if($name=="gos18") {
  30. $query_gos18_work = "select * from gos18_work where obj=".$myrow["osm_id"];
  31. $result_gos18_work = pg_query($query_gos18_work);
  32. if (!$result_gos18_work) {
  33. echo "Problem with query " . $query_gos18_work . "<br/>";
  34. echo pg_last_error();
  35. exit();
  36. }
  37. while($myrow_gos18 = pg_fetch_assoc($result_gos18_work)) {
  38. $gos18_work[] = array(
  39. blah=>blah
  40. );
  41. }
  42. }
  43.  
  44. $feature = array(
  45. 'type' => 'Feature',
  46. 'id' => $myrow["osm_id"],
  47. 'layer' => $epsg,
  48. 'geometry' => json_decode($myrow["way2"], true),
  49. 'geometry_name' => 'way',
  50. 'properties' => array(
  51. 'name' => $myrow["name"],
  52. )
  53. );
  54. // Add feature array to feature collection array
  55. array_push($geojson['features'], $feature);
  56.  
  57. }
  58.  
  59. // Close database connection
  60. pg_close($db);
  61.  
  62. }
  63. if(blah) ......get_objects($where);....
  64.  
  65. public static function getDB() {
  66. return pg_connect('host=notlocalhost port=5432 user=user password=password dbname=dbname')
  67. or die("not connect".pg_last_error());
  68. }
  69.  
  70. Warning: pg_close() expects parameter 1 to be resource, boolean given in my.php on line....
Add Comment
Please, Sign In to add comment