Traccar and Nominatim.

vdovin8 years ago

Hi, Anton!I install nominatim and import address for my country. I test nominatim with coordinates and it worked.For example

Request

http://localhost/nominatim/reverse.php?format=xml&lat=47.060821&lon=28.863214&zoom=18&addressdetails=1

Response

<?xml version="1.0" encoding="UTF-8"?>
<reversegeocode timestamp="Tue, 21 Feb 17 18:56:11 +0200" attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" querystring="format=xml&amp;lat=47.060821&amp;lon=28.863214&amp;zoom=18&amp;addressdetails=1">
   <result place_id="165312" osm_type="way" osm_id="32443448" ref="Arhiva UTM" lat="47.06087465" lon="28.8632109407468">Arhiva UTM, 3/1, Strada Studenților, Rîșcani, Chișinău, Municipiul Chișinău, MD-2045, Moldova</result>
   <addressparts>
      <building>Arhiva UTM</building>
      <house_number>3/1</house_number>
      <road>Strada Studenților</road>
      <suburb>Rîșcani</suburb>
      <city>Chișinău</city>
      <county>Municipiul Chișinău</county>
      <postcode>MD-2045</postcode>
      <country>Moldova</country>
      <country_code>md</country_code>
   </addressparts>
</reversegeocode>

So after it i try to connect nominatim to traccar. So i have next default.xml file

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <!-- SERVER CONFIG -->

    <entry key='web.enable'>true</entry>
    <entry key='web.port'>8082</entry>
    <entry key='web.path'>./web</entry>

    <entry key='geocoder.enable'>true</entry>
    <entry key='geocoder.type'>nominatim</entry>
    <entry key='geocoder.url'>http://localhost/nominatim/reverse.php</entry>

    <entry key='logger.enable'>true</entry>
    <entry key='logger.level'>all</entry>
    <entry key='logger.file'>./logs/tracker-server.log</entry>

    <entry key='event.enable'>true</entry>
    <entry key='event.overspeedHandler'>true</entry>
    <entry key='event.overspeed.notRepeat'>true</entry>
    <entry key='event.motionHandler'>true</entry>
    <entry key='event.geofenceHandler'>true</entry>
    <entry key='event.alertHandler'>true</entry>
    <entry key='event.ignitionHandler'>true</entry>
    <entry key='event.statusHandler'>true</entry>
    <entry key='event.maintenanceHandler'>true</entry>

    <!-- DATABASE CONFIG -->

    <entry key='database.ignoreUnknown'>true</entry>

    <entry key='database.changelog'>./schema/changelog-master.xml</entry>

    <entry key='database.selectServers'>
        SELECT * FROM server
    </entry>

    ....

    <entry key='maestro.port'>5129</entry>

</properties>

And my last updates in tracker-server.log:

2017-02-21 09:34:25  WARN: [10205C19] error - Connection reset by peer - IOException (...)
2017-02-21 09:34:25  INFO: [10205C19] disconnected
2017-02-21 09:34:25  INFO: [B3D7C8C8] connected
2017-02-21 09:34:25 DEBUG: [B3D7C8C8: 5001 < 45.33.91.156] HEX: 47494f500100010024000000000000000100000001000000060000006162636465660000040000006765740000000000
2017-02-21 09:34:27  WARN: [B3D7C8C8] error - Connection reset by peer - IOException (...)
2017-02-21 09:34:27  INFO: [B3D7C8C8] disconnected
2017-02-21 09:34:27  INFO: [0DCBE8FE] connected
2017-02-21 09:34:27 DEBUG: [0DCBE8FE: 5001 < 45.33.91.156] HEX: 101000044d5154540402001e000462650000
2017-02-21 09:34:28  WARN: [0DCBE8FE] error - Connection reset by peer - IOException (...)
2017-02-21 09:34:28  INFO: [0DCBE8FE] disconnected
2017-02-21 09:34:28  INFO: [03311BAB] connected
2017-02-21 09:34:28 DEBUG: [03311BAB: 5001 < 45.33.91.156] HEX: 009c00011a2b3c4d00010000010000000000000100000001ffff00016e6f6e6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2017-02-21 09:34:30  WARN: [03311BAB] error - Connection reset by peer - IOException (...)
2017-02-21 09:34:30  INFO: [03311BAB] disconnected
2017-02-21 10:53:14  INFO: [00E54F5E] connected
2017-02-21 10:53:14 DEBUG: [00E54F5E: 5007 < 106.75.81.90] HEX: 57000000001111070000ffff030000fe03000014001c080a0800000000000000040101010000000001
2017-02-21 10:53:24  INFO: [00E54F5E] disconnected
2017-02-21 10:53:27  INFO: [A7AE05E7] connected
2017-02-21 10:53:27 DEBUG: [A7AE05E7: 5007 < 106.75.81.90] HEX: 474554202f20485454502f312e300d0a486f73743a203138382e3133382e3139342e3137343a353030370d0a0d0a
2017-02-21 10:53:34  INFO: [A7AE05E7] disconnected
2017-02-21 18:16:56  INFO: [3D896364] connected
2017-02-21 18:16:56  INFO: [1E049446] connected
2017-02-21 18:16:56 DEBUG: [1E049446: 5055 < 94.243.71.92] HEX: 474554202f20485454502f312e310d0a486f73743a203138382e3133382e3139342e3137343a353035350d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e3020284c696e75783b20416e64726f696420372e303b204d492035204275696c642f4e524439304d29204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f35362e302e323932342e3837204d6f62696c65205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174652c20736463680d0a4163636570742d4c616e67756167653a20656e2d47422c656e2d55533b713d302e382c656e3b713d302e360d0a0d0a
2017-02-21 18:16:56 DEBUG: [1E049446: 5055 > 94.243.71.92] HEX: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d4c656e6774683a20300d0a0d0a
2017-02-21 18:16:56 DEBUG: [1E049446: 5055 < 94.243.71.92] HEX: 474554202f66617669636f6e2e69636f20485454502f312e310d0a486f73743a203138382e3133382e3139342e3137343a353035350d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204d6f7a696c6c612f352e3020284c696e75783b20416e64726f696420372e303b204d492035204275696c642f4e524439304d29204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f35362e302e323932342e3837204d6f62696c65205361666172692f3533372e33360d0a4163636570743a20696d6167652f776562702c696d6167652f2a2c2a2f2a3b713d302e380d0a526566657265723a20687474703a2f2f3138382e3133382e3139342e3137343a353035352f0d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174652c20736463680d0a4163636570742d4c616e67756167653a20656e2d47422c656e2d55533b713d302e382c656e3b713d302e360d0a0d0a
2017-02-21 18:16:56 DEBUG: [1E049446: 5055 > 94.243.71.92] HEX: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d4c656e6774683a20300d0a0d0a
2017-02-21 18:17:07  INFO: [3D896364] disconnected

But i was really surprised when i connected to my db and don't saw any raw in positions table, no address, no coordinates, nothing.... Table devices have one row with my device id. So do you have any idea, what it is? What is wrong??

Anton Tananaev8 years ago

Traccar is expecting JSON format, not XML.

vdovin8 years ago

It's not a problem. I use url with format=xml only for testing purpose. So i could use

http://localhost/nominatim/reverse.php?format=json&lat=47.060821&lon=28.863214&zoom=18&addressdetails=1
{
   "place_id":"165312",
   "licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright",
   "osm_type":"way",
   "osm_id":"32443448",
   "lat":"47.06087465",
   "lon":"28.8632109407468",
   "display_name":"Arhiva UTM, 3\/1, Strada Studenților, Rîșcani, Chișinău, Municipiul Chișinău, MD-2045, Moldova",
   "address":{
      "building":"Arhiva UTM",
      "house_number":"3\/1",
      "road":"Strada Studenților",
      "suburb":"Rîșcani",
      "city":"Chișinău",
      "county":"Municipiul Chișinău",
      "postcode":"MD-2045",
      "country":"Moldova",
      "country_code":"md"
   }
}

I don't think that there is problem with nominatim server, because in default.xml i put only path to the reverse.php file and don't choose format.

    <entry key='geocoder.enable'>true</entry>
    <entry key='geocoder.type'>nominatim</entry>
    <entry key='geocoder.url'>http://localhost/nominatim/reverse.php</entry>

I couldn't understand why positions table is empty because I send info with my device and server get some information.I thought that he should insert lat and lon in database. And then he try to make request to nominatim and if he got some address details by this coordinates he update positions' row

Anton Tananaev8 years ago

I would need access to the geocoder to see what's wrong.

As for inserting data into the database, it won't work for the last position because it's cached.

vdovin8 years ago

Team Viewer?

Anton Tananaev8 years ago

No, I need access to the geocoder directly, so I can test it on my local instance of Traccar.

vdovin8 years ago

Why do you think that problem is in geocoder?I should see my lon and lat in positions table even i don't use geocoder...

Anton Tananaev8 years ago

Does it work without Nominatim?

vdovin8 years ago

Anton, you are right! I delete geocoder entry in default.xml and I saw some rows with lat/lon in table positions. My address with nominatim 188.138.194.174/nominatim/

Anton Tananaev8 years ago

I've just tested your geocoder and it works for me on my local server. The location was in United States, so it just returned "US" as an address.

vdovin8 years ago

Good! It's because I only import data for my country. So this is my nominatim settings

    <entry key='geocoder.enable'>true</entry>
    <entry key='geocoder.type'>nominatim</entry>
    <entry key='geocoder.url'>http://localhost/nominatim/reverse.php</entry>

Maybe I wrote something wrong?

Anton Tananaev8 years ago

I have used this URL and it worked for me:

http://188.138.194.174/nominatim/reverse.php
vdovin8 years ago

This request make server.So for this logic this should work http://localhost/nominatim/reverse.php
I use traccar 3.9

Anton Tananaev8 years ago

I'm not sure what the problem is, but it's not with Traccar server. You must be missing something.

vdovin8 years ago

Do you have same geocoder lines in default.xml as me?