Changeset 30466 in osm for applications/editors/josm/plugins/pointInfo/servers/RUIAN
- Timestamp:
- 2014-05-21T22:41:44+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pointInfo/servers/RUIAN/index.php
r30373 r30466 4 4 $lon=$_REQUEST['lon']; 5 5 if ( !is_numeric($lat) or !is_numeric($lon) ) die; 6 7 8 // From: http://www.sitepoint.com/forums/showthread.php?656315-Adding-Distance-To-GPS-Coordinates-To-Get-Bounding-Box&p=4519646&viewfull=1#post4519646 9 function new_coords($lat, $lon, $bearing, $distance) 10 { 11 // Radius of Earth in meters 12 $radius = 6371000; 13 14 // New latitude in degrees. 15 $new_lat = rad2deg(asin(sin(deg2rad($lat)) * cos($distance / $radius) + cos(deg2rad($lat)) * sin($distance / $radius) * cos(deg2rad($bearing)))); 16 17 // New longitude in degrees. 18 $new_lon = rad2deg(deg2rad($lon) + atan2(sin(deg2rad($bearing)) * sin($distance / $radius) * cos(deg2rad($lat)), cos($distance / $radius) - sin(deg2rad($lat)) * sin(deg2rad($new_lat)))); 19 20 // Assign new latitude and longitude to an array to be returned to the caller. 21 $coord['lat'] = $new_lat; 22 $coord['lon'] = $new_lon; 23 24 return $coord; 25 } 26 27 // Boundary box 20x20 meters around the point 28 $x1_coor = new_coords($lat, $lon, 315, 10); // Left upper point 29 $x2_coor = new_coords($lat, $lon, 135, 10); // Right down point 30 31 $x1_lon = $x1_coor['lon']; 32 $x2_lon = $x2_coor['lon']; 33 $x1_lat = $x1_coor['lat']; 34 $x2_lat = $x2_coor['lat'];; 35 36 $boundary_polygon=($x1_lon) . " " . ($x1_lat) . ", " . ($x1_lon) . " " . ($x2_lat) . ", " . ($x2_lon) . " " . ($x2_lat) . ", " . ($x2_lon) . " " . ($x1_lat) . ", " . ($x1_lon) . " " . ($x1_lat); 37 6 38 header('Content-Type: application/json'); 7 39 … … 43 75 } else 44 76 $data["stavebni_objekt"] = array(); 77 78 // Ghosts: Buildings without geometry in close neighbourhood 79 $query=" 80 select * from ( 81 select s.kod, 82 s.pocet_podlazi, a.nazev zpusob_vyuziti, s.plati_od, s.pocet_bytu, s.dokonceni, 83 s.zpusob_vyuziti_kod, a.osmtag_k, a.osmtag_v, 84 s.definicni_bod, 85 st_distance( (st_transform(s.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.",".$lat."),4326))::geography ) dist 86 from rn_stavebni_objekt s 87 left outer join osmtables.zpusob_vyuziti_objektu a on s.zpusob_vyuziti_kod = a.kod 88 where st_intersects(s.definicni_bod, st_transform(st_geometryfromtext( 89 'POLYGON (( $boundary_polygon ))' ,4326),900913)) 90 and not s.deleted 91 and s.hranice is null 92 order by definicni_bod <-> 93 st_transform(st_setsrid(st_makepoint(".$lon.",".$lat."),4326),900913) 94 limit 5) as x 95 order by dist; 96 "; 97 $result=pg_query($CONNECT,$query); 98 99 if (pg_num_rows($result) > 0) 100 { 101 $so = array(); 102 for ($i = 0; $i < pg_num_rows($result); $i++) 103 { 104 $row = pg_fetch_array($result, $i); 105 array_push($so, 106 array( "ruian_id" => $row["kod"], 107 "pocet_podlazi" => $row["pocet_podlazi"], 108 "zpusob_vyuziti" => $row["zpusob_vyuziti"], 109 "zpusob_vyuziti_kod" => $row["zpusob_vyuziti_kod"], 110 "zpusob_vyuziti_key" => $row["osmtag_k"], 111 "zpusob_vyuziti_val" => $row["osmtag_v"], 112 "pocet_bytu" => $row["pocet_bytu"], 113 "dokonceni" => $row["dokonceni"], 114 "plati_od" => $row["plati_od"], 115 "vzdalenost" => $row["dist"] 116 )); 117 } 118 $data["so_bez_geometrie"] = $so; 119 } else 120 $data["so_bez_geometrie"] = array(); 45 121 46 122 // Addresses … … 136 212 am.adrp_psc psc, ul.nazev ulice, c.nazev cast_obce, 137 213 momc.nazev mestska_cast, 138 ob.nazev obec, ok.nazev okres, vu.nazev kraj 214 ob.nazev obec, ok.nazev okres, vu.nazev kraj, 215 st_distance( (st_transform(am.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography ) dist 139 216 from ( select kod, stavobj_kod, 140 217 cislo_domovni, cislo_orientacni_hodnota, cislo_orientacni_pismeno, … … 155 232 left outer join rn_vusc vu on ok.vusc_kod = vu.kod and not vu.deleted 156 233 where st_distance( (st_transform(am.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography ) < 100 157 order by st_distance( (st_transform(am.definicni_bod,4326))::geography, 158 (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography) 234 order by dist 159 235 limit 5 160 236 ; … … 183 259 "okres" => $row["okres"], 184 260 "kraj" => $row["kraj"], 185 "psc" => $row["psc"] 261 "psc" => $row["psc"], 262 "vzdalenost" => $row["dist"] 186 263 )); 187 264 }
Note:
See TracChangeset
for help on using the changeset viewer.