I'm currently importing Europe maps because I need a reverse geocoder. While playing with the OSM website I encountered 2 issues: 1. When centering the map to: http://www.openstreetmap.org/search?query=42.70988%2C23.29388 it displays the wrong address. It prefers the 173 Видин (173 Vidin) instead бул.Сливница (boulevard Slivnica). Looking the source code it filters the nearest one while 173 Vidin is not (I tested with a lat, lon exactly on the Slivnica main street). 2. When centering the map to: http://www.openstreetmap.org/search?query=42.39311%2C23.63431 it shows not the village Ново Село (Novo selo) but Ихтиман (Ihtiman) which is far away from that point. I understand that the reverse geocoder goes the hierarchy up while looking up the parents of the road found, but still this is not optimal. Google reverser somehow shows the nearest city/town/village. https://www.google.com/maps/place/42%C2%B023%2737.5%22N+23%C2%B038%2703.3%22E/@42.393736,23.634251,14z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0 Similar issues to be found when asking for reverse on a highway between two cities and when in the middle of the highway there is another town near or on the road. Is there a way to fix this? I believe this would be a nice feature to have. Or somehow as a mapper I may split the road into sub part and attach that part to the city of interest? I was unable to find the way how to define a residential area as a village or town or city and attach the roads to it. I saw that some smaller towns and villages have a residential polygon surrounding but it is not named, nor belongs to a relation. Nevertheless, nominatim somehow knows for their streets that they are in that town. Well, I'd like to be able to do something about that but I do not how. The mapping tutorials I read are not sufficient for fixing the above problems. Any help is highly appreciated. Regards Boris asked 23 Mar '14, 14:01 bkamenov |
Me again, I have investigated deeply through the source of the reverse geocoder. Unfortunately, it is wrong. I have rewritten the core code and now I get results even better than google does. But my code is almost 3 times as slower than the original one. If I could get faulty results in 36 ms for DB only Bulgaria map only (my Europe map import has failed, I'll try again later), now for 97 ms I get perfect results. I'll paste my changes if someone needs them later, but my algorithm works as follows: for the GPS point I find nearest city/town/village place, then a second query searches for the nearest road in range of 200 meters near my point. Finally, I search with a third query the nearest feature with rank > 28 which are houses and buildings but the trick is to search for nearest one in range of 40 meters and the parent should be the road found in the previous query. In that way I resolve all issues I had. Would be nice if someone could optimize the queries a little. Here is my code (please note that I ignore the zoom level factor): In lib/ReverseGeocode.php I replaced the lookup() method body with: function lookup() { $sPointSQL = 'ST_SetSRID(ST_Point('.$this->fLon.','.$this->fLat.'),4326)'; $iMaxRank = $this->iMaxRank;
In my own reverse.php I use the reverse place to build an address as follows: $oReverseGeocode = new ReverseGeocode($oDB); $oReverseGeocode->setLanguagePreference($aLangPrefOrder); $oReverseGeocode->setIncludeAddressDetails(true); $oReverseGeocode->setLatLon($request[$i]['lat'], $request[$i]['lon']); $aPlace = $oReverseGeocode->lookup();
} Now $addr will have your desired address. Hope someone could optimize that. answered 24 Mar '14, 19:31 bkamenov I'm trying to use your code, but obtain the next one: <reversegeocode timestamp="Wed, 04 Jun 14 14:50:24 +0000" attribution="Data © OpenStreetMap contributors, ODbL 1.0. <a href=" http:="" www.openstreetmap.org="" copyright""="">http://www.openstreetmap.org/copyright" querystring="format=xml&lat=50.90921&lon=4.46187"> <error>Unable to geocode</error> </reversegeocode> Did you change anything in PlaceLookup.php? Did you make change only in ReverseGeocode.php and reverse.php? I imagine that I need to make a change in /lib/template/address.php , could you tell me what I'm doing wrong? Thanks in advance!
(04 Jun '14, 16:06)
soyeya
2
This is the wrong place for discussing code. Please use https://github.com/twain47/Nominatim/ for asking question and suggesting changes.
(04 Jun '14, 16:19)
scai ♦
|