Initial commit
This commit is contained in:
@@ -0,0 +1,261 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"query": [
|
||||
"los",
|
||||
"angeles"
|
||||
],
|
||||
"features": [
|
||||
{
|
||||
"id": "place.9962989141465270",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"place"
|
||||
],
|
||||
"relevance": 0.99,
|
||||
"properties": {
|
||||
"wikidata": "Q65"
|
||||
},
|
||||
"text": "Los Angeles",
|
||||
"place_name": "Los Angeles, California, United States",
|
||||
"bbox": [
|
||||
-118.529221009603,
|
||||
33.901599990108,
|
||||
-118.121099990025,
|
||||
34.1612200099034
|
||||
],
|
||||
"center": [
|
||||
-118.2439,
|
||||
34.0544
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-118.2439,
|
||||
34.0544
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "region.3591",
|
||||
"short_code": "US-CA",
|
||||
"wikidata": "Q99",
|
||||
"text": "California"
|
||||
},
|
||||
{
|
||||
"id": "country.3145",
|
||||
"short_code": "us",
|
||||
"wikidata": "Q30",
|
||||
"text": "United States"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "place.10952642230180310",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"place"
|
||||
],
|
||||
"relevance": 0.99,
|
||||
"properties": {
|
||||
"wikidata": "Q16910"
|
||||
},
|
||||
"text": "Los Ángeles",
|
||||
"place_name": "Los Ángeles, Bío Bío, Chile",
|
||||
"bbox": [
|
||||
-72.68248,
|
||||
-37.663862,
|
||||
-72.041277,
|
||||
-37.178368
|
||||
],
|
||||
"center": [
|
||||
-72.35,
|
||||
-37.46667
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-72.35,
|
||||
-37.46667
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "region.3552",
|
||||
"short_code": "CL-BI",
|
||||
"wikidata": "Q2170",
|
||||
"text": "Bío Bío"
|
||||
},
|
||||
{
|
||||
"id": "country.344",
|
||||
"short_code": "cl",
|
||||
"wikidata": "Q298",
|
||||
"text": "Chile"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.1611278850983920",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.99,
|
||||
"properties": {
|
||||
"address": "1 World Way",
|
||||
"category": "international airport, airport",
|
||||
"tel": "(310) 646-5252",
|
||||
"wikidata": "Q8731",
|
||||
"landmark": true,
|
||||
"maki": "airport"
|
||||
},
|
||||
"text": "Los Angeles International Airport",
|
||||
"place_name": "Los Angeles International Airport, 1 World Way, Los Angeles, California 90045, United States",
|
||||
"center": [
|
||||
-118.408056,
|
||||
33.9425
|
||||
],
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
-118.408056,
|
||||
33.9425
|
||||
],
|
||||
"type": "Point"
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "neighborhood.33720",
|
||||
"text": "Westchester"
|
||||
},
|
||||
{
|
||||
"id": "postcode.8081932850252730",
|
||||
"text": "90045"
|
||||
},
|
||||
{
|
||||
"id": "place.9962989141465270",
|
||||
"wikidata": "Q65",
|
||||
"text": "Los Angeles"
|
||||
},
|
||||
{
|
||||
"id": "region.3591",
|
||||
"short_code": "US-CA",
|
||||
"wikidata": "Q99",
|
||||
"text": "California"
|
||||
},
|
||||
{
|
||||
"id": "country.3145",
|
||||
"short_code": "us",
|
||||
"wikidata": "Q30",
|
||||
"text": "United States"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "neighborhood.2104633",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"neighborhood"
|
||||
],
|
||||
"relevance": 0.99,
|
||||
"properties": {},
|
||||
"text": "Los Angeles Heights - Keystone",
|
||||
"place_name": "Los Angeles Heights - Keystone, San Antonio, Texas 78201, United States",
|
||||
"bbox": [
|
||||
-98.534942,
|
||||
29.453364,
|
||||
-98.514652,
|
||||
29.485214
|
||||
],
|
||||
"center": [
|
||||
-98.52,
|
||||
29.47
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-98.52,
|
||||
29.47
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "postcode.7069290925572850",
|
||||
"text": "78201"
|
||||
},
|
||||
{
|
||||
"id": "place.7705127234253710",
|
||||
"wikidata": "Q975",
|
||||
"text": "San Antonio"
|
||||
},
|
||||
{
|
||||
"id": "region.3818",
|
||||
"short_code": "US-TX",
|
||||
"wikidata": "Q1439",
|
||||
"text": "Texas"
|
||||
},
|
||||
{
|
||||
"id": "country.3145",
|
||||
"short_code": "us",
|
||||
"wikidata": "Q30",
|
||||
"text": "United States"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.17555628334440500",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.99,
|
||||
"properties": {
|
||||
"address": "3939 S Figueroa St",
|
||||
"category": "stadium, arena",
|
||||
"tel": "(213) 747-7111",
|
||||
"wikidata": "Q849784",
|
||||
"landmark": true,
|
||||
"maki": "baseball"
|
||||
},
|
||||
"text": "Los Angeles Memorial Coliseum",
|
||||
"place_name": "Los Angeles Memorial Coliseum, 3939 S Figueroa St, Los Angeles, California 90037, United States",
|
||||
"center": [
|
||||
-118.287778,
|
||||
34.014167
|
||||
],
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
-118.287778,
|
||||
34.014167
|
||||
],
|
||||
"type": "Point"
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "neighborhood.293901",
|
||||
"text": "South Los Angeles"
|
||||
},
|
||||
{
|
||||
"id": "postcode.15612390715732530",
|
||||
"text": "90037"
|
||||
},
|
||||
{
|
||||
"id": "place.9962989141465270",
|
||||
"wikidata": "Q65",
|
||||
"text": "Los Angeles"
|
||||
},
|
||||
{
|
||||
"id": "region.3591",
|
||||
"short_code": "US-CA",
|
||||
"wikidata": "Q99",
|
||||
"text": "California"
|
||||
},
|
||||
{
|
||||
"id": "country.3145",
|
||||
"short_code": "us",
|
||||
"wikidata": "Q30",
|
||||
"text": "United States"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"attribution": "NOTICE: © 2017 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained."
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"query": [
|
||||
"plaza",
|
||||
"de",
|
||||
"barcelos"
|
||||
],
|
||||
"features": [
|
||||
{
|
||||
"id": "poi.10895640694945210",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.6666666666666666,
|
||||
"properties": {
|
||||
"landmark": true,
|
||||
"tel": "07524 914990",
|
||||
"category": "cafe, coffee, restaurant, tea, tea house",
|
||||
"address": "Ravensburger Straße 8"
|
||||
},
|
||||
"text": "Plaza",
|
||||
"place_name": "Plaza, Ravensburger Straße 8, Bad Waldsee, Baden-Württemberg 88339, Germany",
|
||||
"center": [
|
||||
9.754478,
|
||||
47.920347
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
9.754478,
|
||||
47.920347
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "postcode.11130053318616830",
|
||||
"text": "88339"
|
||||
},
|
||||
{
|
||||
"id": "place.11130053318505290",
|
||||
"wikidata": "Q515423",
|
||||
"text": "Bad Waldsee"
|
||||
},
|
||||
{
|
||||
"id": "region.3495",
|
||||
"short_code": "DE-BW",
|
||||
"wikidata": "Q985",
|
||||
"text": "Baden-Württemberg"
|
||||
},
|
||||
{
|
||||
"id": "country.3135",
|
||||
"short_code": "de",
|
||||
"wikidata": "Q183",
|
||||
"text": "Germany"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.13433334923344580",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.6666666666666666,
|
||||
"properties": {
|
||||
"landmark": true,
|
||||
"tel": "06403 74200",
|
||||
"category": "rail station, train station",
|
||||
"address": "Alte Heerstraße 27",
|
||||
"maki": "rail"
|
||||
},
|
||||
"text": "Platz",
|
||||
"place_name": "Platz, Alte Heerstraße 27, Bodolz, Bayern 88131, Germany",
|
||||
"center": [
|
||||
9.667166,
|
||||
47.567462
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
9.667166,
|
||||
47.567462
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "locality.13257312967514310",
|
||||
"wikidata": "Q11696975",
|
||||
"text": "Enzisweiler"
|
||||
},
|
||||
{
|
||||
"id": "postcode.7704245689115710",
|
||||
"text": "88131"
|
||||
},
|
||||
{
|
||||
"id": "place.11779142489218390",
|
||||
"wikidata": "Q552427",
|
||||
"text": "Bodolz"
|
||||
},
|
||||
{
|
||||
"id": "region.3186",
|
||||
"short_code": "DE-BY",
|
||||
"wikidata": "Q980",
|
||||
"text": "Bayern"
|
||||
},
|
||||
{
|
||||
"id": "country.3135",
|
||||
"short_code": "de",
|
||||
"wikidata": "Q183",
|
||||
"text": "Germany"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.11479188654945210",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.6666666666666666,
|
||||
"properties": {
|
||||
"landmark": true,
|
||||
"tel": "0921 5160544",
|
||||
"category": "restaurant",
|
||||
"address": "Kirchgasse 24",
|
||||
"maki": "restaurant"
|
||||
},
|
||||
"text": "Plaza",
|
||||
"place_name": "Plaza, Kirchgasse 24, Bayreuth, Bayern 95444, Germany",
|
||||
"center": [
|
||||
11.57395,
|
||||
49.94327
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
11.57395,
|
||||
49.94327
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "postcode.14977288459298330",
|
||||
"text": "95444"
|
||||
},
|
||||
{
|
||||
"id": "place.14796666081196300",
|
||||
"wikidata": "Q3923",
|
||||
"text": "Bayreuth"
|
||||
},
|
||||
{
|
||||
"id": "region.3186",
|
||||
"short_code": "DE-BY",
|
||||
"wikidata": "Q980",
|
||||
"text": "Bayern"
|
||||
},
|
||||
{
|
||||
"id": "country.3135",
|
||||
"short_code": "de",
|
||||
"wikidata": "Q183",
|
||||
"text": "Germany"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.9477875054945210",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.3333333333333333,
|
||||
"properties": {
|
||||
"landmark": true,
|
||||
"tel": "0226 344 306",
|
||||
"category": "restaurant",
|
||||
"maki": "restaurant"
|
||||
},
|
||||
"text": "Plaza",
|
||||
"place_name": "Plaza, Beringe, Limburg 5986, Netherlands",
|
||||
"center": [
|
||||
5.947389,
|
||||
51.337527
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
5.947389,
|
||||
51.337527
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "postcode.6633279068411020",
|
||||
"text": "5986"
|
||||
},
|
||||
{
|
||||
"id": "place.6017505065203911",
|
||||
"wikidata": "Q1878867",
|
||||
"text": "Beringe"
|
||||
},
|
||||
{
|
||||
"id": "region.213188",
|
||||
"short_code": "NL-LI",
|
||||
"wikidata": "Q1093",
|
||||
"text": "Limburg"
|
||||
},
|
||||
{
|
||||
"id": "country.3101",
|
||||
"short_code": "nl",
|
||||
"wikidata": "Q55",
|
||||
"text": "Netherlands"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "poi.6170918672945210",
|
||||
"type": "Feature",
|
||||
"place_type": [
|
||||
"poi"
|
||||
],
|
||||
"relevance": 0.3333333333333333,
|
||||
"properties": {
|
||||
"landmark": true,
|
||||
"tel": "0382 559413",
|
||||
"category": "hotel, lodging, motel",
|
||||
"address": "Via Togliatti 39"
|
||||
},
|
||||
"text": "Plaza",
|
||||
"place_name": "Plaza, Via Togliatti 39, San Martino Siccomario, Pavia 27028, Italy",
|
||||
"center": [
|
||||
9.130854,
|
||||
45.159336
|
||||
],
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
9.130854,
|
||||
45.159336
|
||||
]
|
||||
},
|
||||
"context": [
|
||||
{
|
||||
"id": "postcode.12821918527764180",
|
||||
"text": "27028"
|
||||
},
|
||||
{
|
||||
"id": "place.12821918528623280",
|
||||
"wikidata": "Q41026",
|
||||
"text": "San Martino Siccomario"
|
||||
},
|
||||
{
|
||||
"id": "region.3790",
|
||||
"short_code": "IT-PV",
|
||||
"wikidata": "Q16231",
|
||||
"text": "Pavia"
|
||||
},
|
||||
{
|
||||
"id": "country.333",
|
||||
"short_code": "it",
|
||||
"wikidata": "Q38",
|
||||
"text": "Italy"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"attribution": "NOTICE: © 2017 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained."
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
var mapboxGeocoder = require('../../../../src/geo/geocoder/mapbox-geocoder');
|
||||
var TOKEN = 'fake_token';
|
||||
describe('mapbox-geocoder', function () {
|
||||
describe('.geocode', function () {
|
||||
it('should build the right fetch url (add address and access_token)', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./mapbox-geocoder-response-0'); } }));
|
||||
mapboxGeocoder.geocode('fake_address', TOKEN).then(function (result) {
|
||||
var expectedFetchUrl = 'https://api.mapbox.com/geocoding/v5/mapbox.places-permanent/fake_address.json?access_token=fake_token';
|
||||
expect(window.fetch).toHaveBeenCalledWith(expectedFetchUrl);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should geocode a city location', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./mapbox-geocoder-response-0'); } }));
|
||||
mapboxGeocoder.geocode('Vigo', TOKEN)
|
||||
.then(function (results) {
|
||||
expect(results).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a well formated response [example 0]', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./mapbox-geocoder-response-0'); } }));
|
||||
mapboxGeocoder.geocode('Vigo', TOKEN)
|
||||
.then(function (result) {
|
||||
result = result[0];
|
||||
expect(result.center).toBeDefined();
|
||||
expect(result.center[0]).toEqual(34.0544);
|
||||
expect(result.center[1]).toEqual(-118.2439);
|
||||
// Bbox
|
||||
expect(result.boundingbox.south).toEqual(-118.529221009603);
|
||||
expect(result.boundingbox.west).toEqual(33.901599990108);
|
||||
expect(result.boundingbox.north).toEqual(-118.121099990025);
|
||||
expect(result.boundingbox.east).toEqual(34.1612200099034);
|
||||
// Type
|
||||
expect(result.type).toEqual('venue');
|
||||
done();
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
it('should return a well formated response when the response has no bbox [example 1]', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./mapbox-geocoder-response-1'); } }));
|
||||
mapboxGeocoder.geocode('Plaza de Barcelos', TOKEN)
|
||||
.then(function (result) {
|
||||
result = result[0];
|
||||
expect(result.center).toBeDefined();
|
||||
expect(result.center[0]).toEqual(47.920347);
|
||||
expect(result.center[1]).toEqual(9.754478);
|
||||
// Bbox
|
||||
expect(result.bbox).toBeUndefined();
|
||||
// Type
|
||||
expect(result.type).toEqual('venue');
|
||||
done();
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
it('should return an empty array when the response is empty', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return { features: [] }; } }));
|
||||
mapboxGeocoder.geocode('Vigo', TOKEN)
|
||||
.then(function (result) {
|
||||
expect(result).toEqual([]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,445 @@
|
||||
{
|
||||
"summary": {
|
||||
"query": "santander",
|
||||
"queryType": "NON_NEAR",
|
||||
"queryTime": 39,
|
||||
"numResults": 10,
|
||||
"offset": 0,
|
||||
"totalResults": 24811,
|
||||
"fuzzyLevel": 1
|
||||
},
|
||||
"results": [
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "ES/GEO/p0/7661",
|
||||
"score": 2.418,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Santander",
|
||||
"countrySecondarySubdivision": "Cantabria",
|
||||
"countrySubdivision": "Cantabria",
|
||||
"countryCode": "ES",
|
||||
"country": "Spain",
|
||||
"countryCodeISO3": "ESP",
|
||||
"freeformAddress": "Santander"
|
||||
},
|
||||
"position": {
|
||||
"lat": 43.46141,
|
||||
"lon": -3.8093
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 43.49482,
|
||||
"lon": -3.88905
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 43.43446,
|
||||
"lon": -3.76325
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 43.49482,
|
||||
"lon": -3.88905
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 43.43446,
|
||||
"lon": -3.76325
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-00007d2e35e3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "PH/GEO/p0/1587",
|
||||
"score": 2.382,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Santander",
|
||||
"countrySecondarySubdivision": "Cebu",
|
||||
"countrySubdivision": "Central Visayas",
|
||||
"countryCode": "PH",
|
||||
"country": "Philippines",
|
||||
"countryCodeISO3": "PHL",
|
||||
"freeformAddress": "Santander, Central Visayas"
|
||||
},
|
||||
"position": {
|
||||
"lat": 9.42242,
|
||||
"lon": 123.30378
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 9.47779,
|
||||
"lon": 123.29687
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 9.41298,
|
||||
"lon": 123.3632
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 9.47779,
|
||||
"lon": 123.29687
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 9.41298,
|
||||
"lon": 123.3632
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-000077378fa7"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "MX/GEO/p0/340",
|
||||
"score": 2.362,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Jiménez",
|
||||
"countrySubdivision": "Tamaulipas",
|
||||
"countryCode": "MX",
|
||||
"country": "Mexico",
|
||||
"countryCodeISO3": "MEX",
|
||||
"freeformAddress": "Jiménez"
|
||||
},
|
||||
"position": {
|
||||
"lat": 24.21378,
|
||||
"lon": -98.48187
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 24.47171,
|
||||
"lon": -98.72639
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 23.93939,
|
||||
"lon": -98.27799
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 24.47171,
|
||||
"lon": -98.72639
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 23.93939,
|
||||
"lon": -98.27799
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-00007737d289"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/252",
|
||||
"score": 2.36,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Puerto Santander",
|
||||
"countrySubdivision": "Norte de Santander",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Puerto Santander, Norte de Santander"
|
||||
},
|
||||
"position": {
|
||||
"lat": 8.36227,
|
||||
"lon": -72.40896
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 8.38354,
|
||||
"lon": -72.4475
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 8.26839,
|
||||
"lon": -72.38042
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 8.38354,
|
||||
"lon": -72.4475
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 8.26839,
|
||||
"lon": -72.38042
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-00007d30e01c"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/888",
|
||||
"score": 2.358,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Santander",
|
||||
"countrySubdivision": "Amazonas",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Santander, Amazonas"
|
||||
},
|
||||
"position": {
|
||||
"lat": -0.62217,
|
||||
"lon": -72.38281
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": -0.26464,
|
||||
"lon": -72.99754
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": -1.89121,
|
||||
"lon": -70.72647
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": -0.26464,
|
||||
"lon": -72.99754
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": -1.89121,
|
||||
"lon": -70.72647
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-00007d30ef7b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/1010",
|
||||
"score": 2.341,
|
||||
"entityType": "Municipality",
|
||||
"address": {
|
||||
"municipality": "Santander de Quilichao",
|
||||
"countrySubdivision": "Cauca",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Santander de Quilichao, Cauca"
|
||||
},
|
||||
"position": {
|
||||
"lat": 3.00879,
|
||||
"lon": -76.4859
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 3.1493,
|
||||
"lon": -76.61535
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 2.8461,
|
||||
"lon": -76.37358
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 3.1493,
|
||||
"lon": -76.61535
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 2.8461,
|
||||
"lon": -76.37358
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-00007d30eff7"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/6",
|
||||
"score": 2.255,
|
||||
"entityType": "CountrySubdivision",
|
||||
"address": {
|
||||
"countrySubdivision": "Santander",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Santander"
|
||||
},
|
||||
"position": {
|
||||
"lat": 6.92507,
|
||||
"lon": -73.50153
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 8.14342,
|
||||
"lon": -74.52666
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 5.70671,
|
||||
"lon": -72.4764
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 8.14342,
|
||||
"lon": -74.52666
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 5.70671,
|
||||
"lon": -72.4764
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-000077374466"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/5",
|
||||
"score": 2.211,
|
||||
"entityType": "CountrySubdivision",
|
||||
"address": {
|
||||
"countrySubdivision": "Norte de Santander",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Norte de Santander"
|
||||
},
|
||||
"position": {
|
||||
"lat": 8.08458,
|
||||
"lon": -72.84278
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 9.2961,
|
||||
"lon": -73.63743
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 6.87306,
|
||||
"lon": -72.04813
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 9.2961,
|
||||
"lon": -73.63743
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 6.87306,
|
||||
"lon": -72.04813
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "00005858-5800-1200-0000-000077374465"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/1668",
|
||||
"score": 2.177,
|
||||
"entityType": "MunicipalitySubdivision",
|
||||
"address": {
|
||||
"municipalitySubdivision": "Santander",
|
||||
"municipality": "Cali",
|
||||
"countrySubdivision": "Valle del Cauca",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Cali Santander, Valle del Cauca"
|
||||
},
|
||||
"position": {
|
||||
"lat": 3.46266,
|
||||
"lon": -76.51554
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 3.4665,
|
||||
"lon": -76.52026
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 3.45905,
|
||||
"lon": -76.51054
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 3.4665,
|
||||
"lon": -76.52026
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 3.45905,
|
||||
"lon": -76.51054
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "0000434f-3300-3c00-0000-000065ec89e3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Geography",
|
||||
"id": "CO/GEO/p0/2477",
|
||||
"score": 2.177,
|
||||
"entityType": "MunicipalitySubdivision",
|
||||
"address": {
|
||||
"municipalitySubdivision": "Santander",
|
||||
"municipality": "Medellín",
|
||||
"countrySubdivision": "Antioquia",
|
||||
"countryCode": "CO",
|
||||
"country": "Colombia",
|
||||
"countryCodeISO3": "COL",
|
||||
"freeformAddress": "Medellín Santander, Antioquia"
|
||||
},
|
||||
"position": {
|
||||
"lat": 6.30768,
|
||||
"lon": -75.57501
|
||||
},
|
||||
"viewport": {
|
||||
"topLeftPoint": {
|
||||
"lat": 6.31099,
|
||||
"lon": -75.57874
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 6.30185,
|
||||
"lon": -75.57128
|
||||
}
|
||||
},
|
||||
"boundingBox": {
|
||||
"topLeftPoint": {
|
||||
"lat": 6.31099,
|
||||
"lon": -75.57874
|
||||
},
|
||||
"btmRightPoint": {
|
||||
"lat": 6.30185,
|
||||
"lon": -75.57128
|
||||
}
|
||||
},
|
||||
"dataSources": {
|
||||
"geometry": {
|
||||
"id": "0000434f-3200-3c00-0000-000065a03d92"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
var tomtomGeocoder = require('../../../../src/geo/geocoder/tomtom-geocoder');
|
||||
var API_KEY = 'fake_api_key';
|
||||
describe('tomtom-geocoder', function () {
|
||||
describe('.geocode', function () {
|
||||
it('should build the right fetch url (add address and apiKey)', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return { results: [] }; } }));
|
||||
tomtomGeocoder.geocode('fake_address', API_KEY).then(function (result) {
|
||||
var expectedFetchUrl = 'https://api.tomtom.com/search/2/search/fake_address.json?key=fake_api_key';
|
||||
expect(window.fetch).toHaveBeenCalledWith(expectedFetchUrl);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should geocode a city location', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./tomtom-geocoder-response-0'); } }));
|
||||
tomtomGeocoder.geocode('Santander', API_KEY)
|
||||
.then(function (results) {
|
||||
expect(results).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a well formated response [example 0]', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return require('./tomtom-geocoder-response-0'); } }));
|
||||
tomtomGeocoder.geocode('Santander', API_KEY)
|
||||
.then(function (results) {
|
||||
let bestCandidate = results[0];
|
||||
expect(bestCandidate.center).toBeDefined();
|
||||
expect(bestCandidate.center[0]).toEqual(43.46141); // lat
|
||||
expect(bestCandidate.center[1]).toEqual(-3.8093); // lon
|
||||
// Bbox
|
||||
expect(bestCandidate.boundingbox.south).toEqual(43.43446);
|
||||
expect(bestCandidate.boundingbox.west).toEqual(-3.88905);
|
||||
expect(bestCandidate.boundingbox.north).toEqual(43.49482);
|
||||
expect(bestCandidate.boundingbox.east).toEqual(-3.76325);
|
||||
// Type
|
||||
expect(bestCandidate.type).toEqual('localadmin');
|
||||
done();
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
it('should return an empty array when the response is empty', function (done) {
|
||||
spyOn(window, 'fetch').and.returnValue(Promise.resolve({ json: function () { return { results: [] }; } }));
|
||||
tomtomGeocoder.geocode('ABCDEFGHIJ', API_KEY)
|
||||
.then(function (result) {
|
||||
expect(result).toEqual([]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user