Geolocation not being called (GL200)?

AngeloBAN 9 years ago

I checked my Google Geolocation API usage in the Google Developer Console, and it isn't being called. Geocoder is properly being called though.

This is from my traccar.xml file:

   <entry key='geolocation.enable'>true</entry>
   <entry key='geolocation.type'>google</entry>
   <entry key='geolocation.key'>(key)</entry>

Here's a GTFRI command from the GL200 tracker.

+RESP:GTFRI,120113,(IMEI),,1,5,1,,,,,,,,310,260,2bcf,292d,86400,86,20161023002134,0001$

mcc = 310, max = 260, lac = 11215, cid/cellid = 10541

It should call the geolocation, and then post the latitude and longitude of (42.480677, -83.197322). Instead it's pulling the last known GPS location? I don't want it to do that. I looked at enabling this:

<entry key='geolocation.processInvalidPositions'>true</entry>

But this doesn't seem to pull the coordinates from geolocation. Unsure of what to do?

p.s. Also, google needs to be added as an option in the Support > Documentation > Configuration File.

AngeloBAN 9 years ago

I have also done this in my traccar.xml but still unable to process geolocation.

<entry key='processing.copyAttributes.enable'>false</entry>

Anton Tananaev 9 years ago

Probably the message hasn't been decoded properly because it doesn't match protocol documentation.

AngeloBAN 9 years ago

Hi Anton,

In the Gl200 decoder protocol (lines 404 through 430) decodeLocation it'll default to getLastLocation when lat/lng aren't present. I looked in the BaseProtocolDecoder and didn't see an option to do geolocate based on mcc/mnc/lac/cid?

if (parser.hasNext(8)) {
            position.setValid(true);
            position.setLongitude(parser.nextDouble());
            position.setLatitude(parser.nextDouble());
            position.setTime(parser.nextDateTime());
        } else {
            getLastLocation(position, null);
        }

What's the proper way to call UniversalGeolocationProvider to geolocate?

AngeloBAN 9 years ago

Nevermind, figured it out. For anyone in the future this is how you'd do it:

    ...
    {
        boolean cell = false;
        if (parser.hasNext(8)) {
            position.setValid(true);
            position.setLongitude(parser.nextDouble());
            position.setLatitude(parser.nextDouble());
            position.setTime(parser.nextDateTime());
        } else {
            gpsCell = true;
            getLastLocation(position, null);
        }
        
        if (parser.hasNext(4)) {
            Network network = new Network(CellTower.from(
                parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16)))
            position.setNetwork(network);
            if (gpsCell) {
                getLocationProviderGoogle(network, position);
            }
        }
    }
    
    public void getLocationProviderGoogle(Network network, final Position position) throws Exception {
        GoogleGeolocationProvider provider = new GoogleGeolocationProvider("key");

        provider.getLocation(network, new GeolocationProvider.LocationProviderCallback() {
            @Override
            public void onSuccess(double latitude, double longitude, double accuracy) {
                position.setValid(true);
                position.setLatitude(latitude);
                position.setLongitude(longitude);
                position.setTime(parser.nextDateTime());
                // set other values
            }

            @Override
            public void onFailure(Throwable e) {
                Assert.fail();
            }
        });
    }
Peter 7 years ago

thank you Angelo