aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/geocoder/GeocoderTest.java
blob: 2aa7ab77cff857b4e332c88a25f7ad0b66e3e194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package org.traccar.geocoder;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import java.util.Locale;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class GeocoderTest {

    static {
        Locale.setDefault(Locale.US);
    }

    private final Client client = ClientBuilder.newClient();

    @Disabled
    @Test
    public void testGoogle() {
        Geocoder geocoder = new GoogleGeocoder(client, null, null, null, 0, new AddressFormat());
        String address = geocoder.getAddress(31.776797, 35.211489, null);
        assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", address);
    }

    @Disabled
    @Test
    public void testNominatim() {
        Geocoder geocoder = new NominatimGeocoder(client, null, null, null, 0, new AddressFormat());
        String address = geocoder.getAddress(40.7337807, -73.9974401, null);
        assertEquals("35 West 9th Street, NYC, New York, US", address);
    }

    @Disabled
    @Test
    public void testGisgraphy() {
        Geocoder geocoder = new GisgraphyGeocoder(client, null, 0, new AddressFormat());
        String address = geocoder.getAddress(48.8530000, 2.3400000, null);
        assertEquals("Rue du Jardinet, Paris, Île-de-France, FR", address);
    }

    @Disabled
    @Test
    public void testOpenCage() {
        Geocoder geocoder = new OpenCageGeocoder(
                client, "http://api.opencagedata.com/geocode/v1", "SECRET", null, 0, new AddressFormat());
        String address = geocoder.getAddress(34.116302, -118.051519, null);
        assertEquals("Charleston Road, California, US", address);
    }

    @Disabled
    @Test
    public void testGeocodeFarm() {
        Geocoder geocoder = new GeocodeFarmGeocoder(client, null, null, 0, new AddressFormat());
        String address = geocoder.getAddress(34.116302, -118.051519, null);
        assertEquals("Estrella Avenue, Arcadia, California, United States", address);
    }

    @Disabled
    @Test
    public void testGeocodeXyz() {
        Geocoder geocoder = new GeocodeXyzGeocoder(client, null, 0, new AddressFormat());
        String address = geocoder.getAddress(34.116302, -118.051519, null);
        assertEquals("605 ESTRELLA AVE, ARCADIA, California United States of America, US", address);
    }

    @Disabled
    @Test
    public void testBan() {
        Geocoder geocoder = new BanGeocoder(client, 0, new AddressFormat());
        String address = geocoder.getAddress(48.8575, 2.2944, null);
        assertEquals("8 Avenue Gustave Eiffel, Paris, FR", address);
    }

    @Disabled
    @Test
    public void testHere() {
        Geocoder geocoder = new HereGeocoder(client, null, "aDc9qgsCpRbO9ioJIIAXzF6JYU7w8H5O260e9hsGrms", null, 0, new AddressFormat());
        String address = geocoder.getAddress(48.8575, 2.2944, null);
        assertEquals("1 Tour Eiffel, Paris, Île-de-France, FRA", address);
    }

    @Disabled
    @Test
    public void testMapmyIndia() {
        Geocoder geocoder = new MapmyIndiaGeocoder(client, "", "", 0, new AddressFormat("%f"));
        String address = geocoder.getAddress(28.6129602407977, 77.2294557094574, null);
        assertEquals("New Delhi, Delhi. 1 m from India Gate pin-110001 (India)", address);
    }

    @Disabled
    @Test
    public void testPositionStack() {
        Geocoder geocoder = new PositionStackGeocoder(client, "", 0, new AddressFormat("%f"));
        String address = geocoder.getAddress(28.6129602407977, 77.2294557094574, null);
        assertEquals("India Gate, New Delhi, India", address);
    }

    @Disabled
    @Test
    public void testMapbox() {
        Geocoder geocoder = new MapboxGeocoder(client, "", 0, new AddressFormat("%f"));
        String address = geocoder.getAddress(40.733, -73.989, null);
        assertEquals("120 East 13th Street, New York, New York 10003, United States", address);
    }

    @Disabled
    @Test
    public void testMapTiler() {
        Geocoder geocoder = new MapTilerGeocoder(client, "", 0, new AddressFormat());
        String address = geocoder.getAddress(40.733, -73.989, null);
        assertEquals("East 13th Street, New York City, New York, United States", address);
    }

    @Disabled
    @Test
    public void testGeoapify() {
        Geocoder geocoder = new GeoapifyGeocoder(client, "", null, 0, new AddressFormat());
        String address = geocoder.getAddress(40.733, -73.989, null);
        assertEquals("114 East 13th Street, New York, New York, US", address);
    }

    @Disabled
    @Test
    public void testGeocodeJSON() {
        Geocoder geocoder = new GeocodeJsonGeocoder(client, null, null, null, 0, new AddressFormat());
        String address = geocoder.getAddress(40.7337807, -73.9974401, null);
        assertEquals("35 West 9th Street, New York, New York, US", address);
    }
}