Skip to content

Commit

Permalink
Dedicated LocationIQ geocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Dec 12, 2022
1 parent 867e800 commit b274f55
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
3 changes: 1 addition & 2 deletions setup/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<entry key='web.persistSession'>false</entry>

<entry key='geocoder.enable'>true</entry>
<entry key='geocoder.type'>nominatim</entry>
<entry key='geocoder.url'>https://us1.locationiq.com/v1/reverse.php</entry>
<entry key='geocoder.type'>locationiq</entry>
<entry key='geocoder.key'>pk.689d849289c8c63708068b2ff1f63b2d</entry>
<entry key='geocoder.onRequest'>true</entry>
<entry key='geocoder.ignorePositions'>true</entry>
Expand Down
23 changes: 4 additions & 19 deletions src/main/java/org/traccar/MainModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,7 @@
import org.traccar.forward.PositionForwarderJson;
import org.traccar.forward.PositionForwarderKafka;
import org.traccar.forward.PositionForwarderUrl;
import org.traccar.geocoder.AddressFormat;
import org.traccar.geocoder.BanGeocoder;
import org.traccar.geocoder.BingMapsGeocoder;
import org.traccar.geocoder.FactualGeocoder;
import org.traccar.geocoder.GeoapifyGeocoder;
import org.traccar.geocoder.GeocodeFarmGeocoder;
import org.traccar.geocoder.GeocodeXyzGeocoder;
import org.traccar.geocoder.Geocoder;
import org.traccar.geocoder.GisgraphyGeocoder;
import org.traccar.geocoder.GoogleGeocoder;
import org.traccar.geocoder.HereGeocoder;
import org.traccar.geocoder.MapQuestGeocoder;
import org.traccar.geocoder.MapTilerGeocoder;
import org.traccar.geocoder.MapboxGeocoder;
import org.traccar.geocoder.MapmyIndiaGeocoder;
import org.traccar.geocoder.NominatimGeocoder;
import org.traccar.geocoder.OpenCageGeocoder;
import org.traccar.geocoder.PositionStackGeocoder;
import org.traccar.geocoder.TomTomGeocoder;
import org.traccar.geocoder.*;
import org.traccar.geolocation.GeolocationProvider;
import org.traccar.geolocation.GoogleGeolocationProvider;
import org.traccar.geolocation.MozillaGeolocationProvider;
Expand Down Expand Up @@ -183,6 +165,9 @@ public static Geocoder provideGeocoder(Config config, Client client, StatisticsM
case "nominatim":
geocoder = new NominatimGeocoder(client, url, key, language, cacheSize, addressFormat);
break;
case "locationiq":
geocoder = new LocationIqGeocoder(client, url, key, language, cacheSize, addressFormat);
break;
case "gisgraphy":
geocoder = new GisgraphyGeocoder(client, url, cacheSize, addressFormat);
break;
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/traccar/geocoder/LocationIqGeocoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2022 Anton Tananaev ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.traccar.geocoder;

import javax.ws.rs.client.Client;

public class LocationIqGeocoder extends NominatimGeocoder {

private static final String DEFAULT_URL = "https://us1.locationiq.com/v1/reverse.php";

public LocationIqGeocoder(
Client client, String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
super(client, url != null ? url : DEFAULT_URL, key, language, cacheSize, addressFormat);
}

}

0 comments on commit b274f55

Please sign in to comment.