getNote.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require 'db.php';
  3. require 'func.php';
  4. // Same as error_reporting(E_ALL);
  5. ini_set('display_errors', 1);
  6. ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
  7. if((isset($_GET['nid'])) && (isset($_GET['type']))){
  8. $note_id = $_GET['nid'];
  9. $type = $_GET['type'];
  10. } else {
  11. $ajxres=array();
  12. $ajxres['resp']=4;
  13. $ajxres['dberror']=0;
  14. $ajxres['msg']='missing bounding box or type of data';
  15. send($ajxres);
  16. }
  17. $ways = array();
  18. $info = array();
  19. $ways['type'] = 'FeatureCollection';
  20. if($type==1){
  21. $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, ST_AsGeoJSON(geom)
  22. from hicheck.notes where hicheck.notes.id = '$note_id'";
  23. } else if($type==2){
  24. $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, ST_AsGeoJSON(geom)
  25. from hicheck.parts where hicheck.parts.id = '$note_id'";
  26. }
  27. $data = pg_query($db, $query_string);
  28. while($row = pg_fetch_assoc($data)){
  29. $geom = json_decode($row['st_asgeojson']);
  30. $aux = array();
  31. $prop = array();
  32. $prop['id']=$row['id'];
  33. $prop['timestamp']=$row['tstamp'];
  34. $prop['date']=$row['date'];
  35. $prop['user']=$row['hi_user_id'];
  36. $prop['note']=$row['note'];
  37. $prop['type']=$row['type'];
  38. $aux['type']='Feature';
  39. $aux['id'] = $row['id'];
  40. $aux['properties']=$prop;
  41. $aux['geometry']=$geom;
  42. $info[] = $aux;
  43. }
  44. $ways['features']=$info;
  45. exit(prepareData($ways));