Browse Source

Merge pull request #341 from pelias/master

production merge
pull/364/merge
Peter Johnson a.k.a. insertcoffee 9 years ago
parent
commit
fe171d2211
  1. 3
      app.js
  2. 2
      controller/place.js
  3. 2
      controller/search.js
  4. 63
      docs/404.md
  5. 52
      docs/cors.md
  6. 97
      docs/doc/msuccess.md
  7. 80
      docs/doc/success.md
  8. 82
      docs/index.md
  9. 50
      docs/jsonp.md
  10. 80
      docs/reverse/success.md
  11. 233
      docs/search/success.md
  12. 111
      docs/suggest/success.md
  13. 223
      docs/suggest/success_nearby.md
  14. 10
      helper/labelSchema.json
  15. 2
      middleware/404.js
  16. 15
      middleware/408.js
  17. 8
      middleware/confidenceScore.js
  18. 37
      middleware/sendJSON.js
  19. 2
      package.json
  20. 2
      public/apiDoc.md
  21. 3
      query/autocomplete.js
  22. 17
      query/defaults.js
  23. 2
      query/reverse.js
  24. 8
      query/search.js
  25. 2
      routes/v1.js
  26. 2
      sanitiser/sanitizeAll.js
  27. 4
      test/ciao/autocomplete/focus_point_invalid_lat.coffee
  28. 4
      test/ciao/autocomplete/focus_point_invalid_lon.coffee
  29. 6
      test/ciao/autocomplete/focus_point_missing_lat.coffee
  30. 6
      test/ciao/autocomplete/focus_point_missing_lon.coffee
  31. 4
      test/ciao/autocomplete/no_params.coffee
  32. 4
      test/ciao/autocomplete/text_invalid.coffee
  33. 2
      test/ciao/place/missing_id.coffee
  34. 17
      test/ciao/reverse/boundary_circle_invalid_radius.coffee
  35. 15
      test/ciao/reverse/boundary_circle_valid_radius.coffee
  36. 4
      test/ciao/reverse/boundary_country_invalid_alpha2.coffee
  37. 4
      test/ciao/reverse/boundary_country_invalid_alpha3.coffee
  38. 4
      test/ciao/reverse/boundary_country_invalid_iso3166.coffee
  39. 2
      test/ciao/reverse/duplicate_parameter_name.coffee
  40. 2
      test/ciao/reverse/layers_invalid.coffee
  41. 2
      test/ciao/reverse/layers_mix_invalid_valid.coffee
  42. 2
      test/ciao/reverse/non_scalar_parameter.coffee
  43. 4
      test/ciao/reverse/point_invalid_lat.coffee
  44. 4
      test/ciao/reverse/point_invalid_lon.coffee
  45. 6
      test/ciao/reverse/point_missing_lat.coffee
  46. 6
      test/ciao/reverse/point_missing_lon.coffee
  47. 4
      test/ciao/reverse/sources_invalid.coffee
  48. 2
      test/ciao/reverse/sources_layers_invalid_combo.coffee
  49. 2
      test/ciao/reverse/sources_multiple.coffee
  50. 2
      test/ciao/reverse/sources_single.coffee
  51. 4
      test/ciao/search/boundary_circle_invalid_lat_lon_types.coffee
  52. 8
      test/ciao/search/boundary_circle_invalid_radius.coffee
  53. 6
      test/ciao/search/boundary_circle_missing_lat.coffee
  54. 6
      test/ciao/search/boundary_circle_missing_lon.coffee
  55. 4
      test/ciao/search/boundary_country_invalid_alpha2.coffee
  56. 4
      test/ciao/search/boundary_country_invalid_alpha3.coffee
  57. 4
      test/ciao/search/boundary_country_invalid_iso3166.coffee
  58. 6
      test/ciao/search/boundary_rect_partially_specified.coffee
  59. 4
      test/ciao/search/focus_point_invalid_lat.coffee
  60. 4
      test/ciao/search/focus_point_invalid_lon.coffee
  61. 6
      test/ciao/search/focus_point_missing_lat.coffee
  62. 6
      test/ciao/search/focus_point_missing_lon.coffee
  63. 2
      test/ciao/search/layers_invalid.coffee
  64. 2
      test/ciao/search/layers_mix_invalid_valid.coffee
  65. 4
      test/ciao/search/no_params.coffee
  66. 4
      test/ciao/search/sources_invalid.coffee
  67. 2
      test/ciao/search/sources_layers_invalid_combo.coffee
  68. 6
      test/ciao/search/sources_multiple.coffee
  69. 2
      test/ciao/search/sources_single.coffee
  70. 4
      test/ciao/search/text_invalid.coffee
  71. 2
      test/ciao/search/text_valid.coffee
  72. 73
      test/unit/fixture/autocomplete_linguistic_focus.js
  73. 71
      test/unit/fixture/autocomplete_linguistic_focus_null_island.js
  74. 70
      test/unit/fixture/autocomplete_linguistic_only.js
  75. 68
      test/unit/fixture/search_boundary_country.js
  76. 67
      test/unit/fixture/search_full_address.js
  77. 72
      test/unit/fixture/search_linguistic_bbox.js
  78. 75
      test/unit/fixture/search_linguistic_focus.js
  79. 75
      test/unit/fixture/search_linguistic_focus_bbox.js
  80. 73
      test/unit/fixture/search_linguistic_focus_null_island.js
  81. 70
      test/unit/fixture/search_linguistic_only.js
  82. 70
      test/unit/fixture/search_partial_address.js
  83. 70
      test/unit/fixture/search_regions_address.js
  84. 25
      test/unit/fixture/sort_default.js
  85. 238
      test/unit/helper/labelGenerator.js
  86. 12
      test/unit/helper/labelSchema.js
  87. 91
      test/unit/helper/type_mapping.js
  88. 11
      test/unit/query/search.js

3
app.js

@ -26,7 +26,6 @@ v1.addRoutes(app, peliasConfig);
/** ----------------------- error middleware ----------------------- **/
app.use( require('./middleware/404') );
app.use( require('./middleware/408') );
app.use( require('./middleware/500') );
module.exports = app;
module.exports = app;

2
controller/place.js

@ -29,7 +29,7 @@ function setup( backend ){
// error handler
if( err ){
req.errors.push( err.message ? err.message : err );
req.errors.push( err );
}
// set response data
else {

2
controller/search.js

@ -31,7 +31,7 @@ function setup( backend, query ){
// error handler
if( err ){
req.errors.push( err.message ? err.message : err );
req.errors.push( err );
}
// set response data
else {

63
docs/404.md

@ -1,63 +0,0 @@
# invalid path
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/notexist"
}
```
## Response
```javascript
Status: 404
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=300",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "35",
"etag": "W/\"23-dfdfa185\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"error": "not found: invalid path"
}
```
## Tests
### ✓ not found
```javascript
response.statusCode.should.equal 404
```
### ✓ content-type header correctly set
```javascript
response.should.have.header 'Content-Type','application/json; charset=utf-8'
```
### ✓ cache-control header correctly set
```javascript
response.should.have.header 'Cache-Control','public,max-age=300'
```
### ✓ should respond in json with server info
```javascript
should.exist json
should.exist json.error
json.error.should.equal 'not found: invalid path'
```

52
docs/cors.md

@ -1,52 +0,0 @@
# cross-origin resource sharing
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "50",
"etag": "W/\"32-85536434\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"name": "pelias-api",
"version": {
"number": "0.0.0"
}
}
```
## Tests
### ✓ access control headers correctly set
```javascript
response.should.have.header 'Access-Control-Allow-Origin','*'
response.should.have.header 'Access-Control-Allow-Methods','GET'
response.should.have.header 'Access-Control-Allow-Headers','X-Requested-With,content-type'
response.should.have.header 'Access-Control-Allow-Credentials','true'
```

97
docs/doc/msuccess.md

@ -1,97 +0,0 @@
# valid doc query
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/doc?id=geoname:4221195&id=geoname:4193595"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "555",
"etag": "W/\"22b-dd736629\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.9207,
34.36094
]
},
"properties": {
"name": "Sanders Grove Cemetery",
"admin0": "United States",
"admin1": "Georgia",
"admin2": "Hart County",
"text": "Sanders Grove Cemetery, Hart County, Georgia"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-83.94213,
33.32262
]
},
"properties": {
"name": "Etheredge Cemetery",
"admin0": "United States",
"admin1": "Georgia",
"admin2": "Butts County",
"text": "Etheredge Cemetery, Butts County, Georgia"
}
}
],
"date": 1415292259726
}
```
## Tests
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```

80
docs/doc/success.md

@ -1,80 +0,0 @@
# valid doc query
*Generated: Thu Nov 06 2014 11:44:20 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/doc?id=geoname:4221195"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "311",
"etag": "W/\"137-1644173e\"",
"date": "Thu, 06 Nov 2014 16:44:20 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.9207,
34.36094
]
},
"properties": {
"name": "Sanders Grove Cemetery",
"admin0": "United States",
"admin1": "Georgia",
"admin2": "Hart County",
"text": "Sanders Grove Cemetery, Hart County, Georgia"
}
}
],
"date": 1415292260057
}
```
## Tests
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```

82
docs/index.md

@ -1,82 +0,0 @@
# api root
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "50",
"etag": "W/\"32-85536434\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"name": "pelias-api",
"version": {
"number": "0.0.0"
}
}
```
## Tests
### ✓ charset header correctly set
```javascript
response.should.have.header 'Charset','utf8'
```
### ✓ endpoint available
```javascript
response.statusCode.should.equal 200
```
### ✓ server header correctly set
```javascript
response.should.have.header 'Server'
response.headers.server.should.match /Pelias\/\d{1,2}\.\d{1,2}\.\d{1,2}/
```
### ✓ should respond in json with server info
```javascript
should.exist json
should.exist json.name
should.exist json.version
```
### ✓ vanity header correctly set
```javascript
response.should.have.header 'X-Powered-By','mapzen'
```
### ✓ content-type header correctly set
```javascript
response.should.have.header 'Content-Type','application/json; charset=utf-8'
```
### ✓ cache-control header correctly set
```javascript
response.should.have.header 'Cache-Control','public,max-age=60'
```

50
docs/jsonp.md

@ -1,50 +0,0 @@
# jsonp
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/?callback=test"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/javascript; charset=utf-8",
"content-length": "57",
"etag": "W/\"39-b8a2aba1\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```html
test({"name":"pelias-api","version":{"number":"0.0.0"}});
```
## Tests
### ✓ content-type header correctly set
```javascript
response.should.have.header 'Content-Type','application/javascript; charset=utf-8'
```
### ✓ should respond with jsonp
```javascript
should.exist response.body
response.body.substr(0,5).should.equal 'test(';
```

80
docs/reverse/success.md

@ -1,80 +0,0 @@
# valid reverse query
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/reverse?lat=29.49136&lon=-82.50622"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "282",
"etag": "W/\"11a-efcd00c9\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.50622,
29.49136
]
},
"properties": {
"name": "Adam",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Adam, Alachua County, Florida"
}
}
],
"date": 1415292259729
}
```
## Tests
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```

233
docs/search/success.md

@ -1,233 +0,0 @@
# valid search query
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/search?text=lake&lat=29.49136&lon=-82.50622"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "2398",
"etag": "W/\"NldeHivz2maJ3rqa73a+2w==\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.5052,
29.50312
]
},
"properties": {
"name": "Blue Pete Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Blue Pete Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.52097,
29.47185
]
},
"properties": {
"name": "Sawgrass Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Sawgrass Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.39141,
29.4468
]
},
"properties": {
"name": "Johnson Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Marion County",
"text": "Johnson Lake, Marion County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.35435,
29.49526
]
},
"properties": {
"name": "Ledwith Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Ledwith Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.35316,
29.52469
]
},
"properties": {
"name": "Levy Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Levy Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.66311,
29.54036
]
},
"properties": {
"name": "Fox Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Fox Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.40502,
29.61705
]
},
"properties": {
"name": "Lake Kanapaha",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Lake Kanapaha, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.70856,
29.53293
]
},
"properties": {
"name": "Doorshutter Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Doorshutter Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.30215,
29.52978
]
},
"properties": {
"name": "Wauberg Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Wauberg Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.47914,
29.30795
]
},
"properties": {
"name": "Lake Stafford",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Lake Stafford, Levy County, Florida"
}
}
],
"date": 1415292259730
}
```
## Tests
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```

111
docs/suggest/success.md

@ -1,111 +0,0 @@
# valid suggest query
*Generated: Thu Nov 06 2014 11:44:19 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/suggest?text=a&lat=0&lon=0"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "571",
"etag": "W/\"23b-5d6e3dd3\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-8.481618,
43.125692
]
},
"properties": {
"text": "A Coruña",
"score": 14,
"type": "admin1",
"id": "3374:adm1:es:esp:a_coru_a"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
7.56019,
5.419786
]
},
"properties": {
"text": "Abia",
"score": 14,
"type": "admin1",
"id": "1775:adm1:ng:nga:abia"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
33.772337,
2.826081
]
},
"properties": {
"text": "Abim",
"score": 14,
"type": "admin1",
"id": "2848:adm1:ug:uga:abim"
}
}
],
"date": 1415292259700
}
```
## Tests
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```

223
docs/suggest/success_nearby.md

@ -1,223 +0,0 @@
# valid suggest query
*Generated: Thu Nov 06 2014 11:44:20 GMT-0500 (EST)*
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
"path": "/suggest/nearby?text=a&lat=29.49136&lon=-82.50622"
}
```
## Response
```javascript
Status: 200
{
"x-powered-by": "mapzen",
"charset": "utf8",
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "2034",
"etag": "W/\"Do9VJ5hCbynTxDjtm5fNlg==\"",
"date": "Thu, 06 Nov 2014 16:44:19 GMT",
"connection": "close"
}
```
```javascript
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.05231,
29.17998
]
},
"properties": {
"text": "Abiding Hope E V Lutheran Church, Marion County, Florida",
"score": 1,
"type": "geoname",
"id": "4145572"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.10231,
29.21942
]
},
"properties": {
"text": "Abundant Harvest Ministries, Marion County, Florida",
"score": 1,
"type": "geoname",
"id": "4145578"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.50622,
29.49136
]
},
"properties": {
"text": "Adam, Alachua County, Florida",
"score": 1,
"type": "geoname",
"id": "4145612"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.75374,
35.17789
]
},
"properties": {
"text": "Adams Branch, Transylvania County, North Carolina",
"score": 1,
"type": "geoname",
"id": "4452189"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.83012,
29.4783
]
},
"properties": {
"text": "Adamsville Cemetery, Levy County, Florida",
"score": 1,
"type": "geoname",
"id": "4145634"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.01511,
35.17289
]
},
"properties": {
"text": "Africa School (historical), Spartanburg County, South Carolina",
"score": 1,
"type": "geoname",
"id": "4569065"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.20426,
29.25192
]
},
"properties": {
"text": "Agape Baptist Church, Marion County, Florida",
"score": 1,
"type": "geoname",
"id": "4145673"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.14954,
29.19248
]
},
"properties": {
"text": "Agnew Cemetery, Marion County, Florida",
"score": 1,
"type": "geoname",
"id": "4145677"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.75429,
35.16928
]
},
"properties": {
"text": "Aiken Mountain, Transylvania County, North Carolina",
"score": 1,
"type": "geoname",
"id": "4452268"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.15912,
29.47877
]
},
"properties": {
"text": "Alachua County Fire Rescue Station 31, Alachua County, Florida",
"score": 1,
"type": "geoname",
"id": "4152402"
}
}
],
"date": 1415292259785
}
```
## Tests
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```

10
helper/labelSchema.json

@ -11,8 +11,12 @@
"local": ["neighbourhood", "region", "county", "localadmin", "locality"],
"regional": ["county","country","region"]
},
"SWE": {
"local": ["neighbourhood", "region", "county", "localadmin", "locality"],
"regional": ["country"]
},
"default": {
"local": ["localadmin", "locality", "neighbourhood", "county"],
"regional": ["region_a", "region", "country"]
"local": ["localadmin", "locality", "neighbourhood", "county", "region"],
"regional": ["country"]
}
}
}

2
middleware/404.js

@ -5,4 +5,4 @@ function middleware(req, res) {
res.status(404).json({ error: 'not found: invalid path' });
}
module.exports = middleware;
module.exports = middleware;

15
middleware/408.js

@ -1,15 +0,0 @@
// handle time out errors
function middleware(err, req, res, next) {
res.header('Cache-Control','public');
var error = (err && err.message) ? err.message : err;
if( res.statusCode === 408 || (error.toLowerCase().indexOf('request timeout') !== -1) ){
res.status(408);
res.json({ error: typeof error === 'string' ? error : 'request timeout' });
} else {
next(err);
}
}
module.exports = middleware;

8
middleware/confidenceScore.js

@ -82,6 +82,14 @@ function computeConfidenceScore(req, mean, stdev, hit) {
return hit;
}
/*
* Check for clearly mismatching properties in a result
* zip code and state (admin1) are currently checked if present
*
* @param {object|undefined} text
* @param {object} hit
* @returns {bool}
*/
function checkForDealBreakers(req, hit) {
if (check.undefined(req.clean.parsed_text)) {
return false;

37
middleware/sendJSON.js

@ -1,12 +1,43 @@
var check = require('check-types');
function sendJSONResponse(req, res, next) {
// do nothing if no result data set
if (!res || !res.body) {
if (!res || !check.object(res.body) || !check.object(res.body.geocoding)) {
return next();
}
// default status
var statusCode = 200;
// vary status code whenever an error was reported
var geocoding = res.body.geocoding;
if( check.array( geocoding.errors ) && geocoding.errors.length ){
// default status for errors is 400 Bad Request
statusCode = 400; // 400 Bad Request
// iterate over all reported errors
geocoding.errors.forEach( function( err ){
// custom status codes for instances of the Error() object.
if( err instanceof Error ){
// we can extract the error type from the constructor name
switch( err.constructor.name ){
// elasticsearch errors
// see: https://github.com/elastic/elasticsearch-js/blob/master/src/lib/errors.js
case 'RequestTimeout': statusCode = 408; break; // 408 Request Timeout
case 'NoConnections': statusCode = 502; break; // 502 Bad Gateway
case 'ConnectionFault': statusCode = 502; break; // 502 Bad Gateway
case 'Serialization': statusCode = 500; break; // 500 Internal Server Error
case 'Generic': statusCode = 500; break; // 500 Internal Server Error
default: statusCode = 500; // 500 Internal Server Error
}
}
});
}
// respond
return res.status(200).json(res.body);
return res.status(statusCode).json(res.body);
}
module.exports = sendJSONResponse;
module.exports = sendJSONResponse;

2
package.json

@ -51,7 +51,7 @@
"pelias-config": "^1.0.1",
"pelias-esclient": "0.0.25",
"pelias-logger": "^0.0.8",
"pelias-query": "2.0.0",
"pelias-query": "^5.0.0",
"pelias-schema": "1.0.0",
"pelias-suggester-pipeline": "2.0.2",
"stats-lite": "^1.0.3",

2
public/apiDoc.md

@ -1 +1 @@
## DETAILED DOCUMENTATION COMING SOON!
## [View our documentation on GitHub](https://github.com/pelias/pelias-doc/blob/master/index.md)

3
query/autocomplete.js

@ -14,7 +14,8 @@ query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost
query.score( peliasQuery.view.phrase );
query.score( peliasQuery.view.focus( peliasQuery.view.ngrams ) );
query.score( peliasQuery.view.popularity(['admin0','admin1','admin2']) );
query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
query.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
// --------------------------------

17
query/defaults.js

@ -8,7 +8,7 @@ module.exports = extend( false, peliasQuery.defaults, {
'track_scores': true,
'centroid:field': 'center_point',
'sort:distance:order': 'asc',
'sort:distance:distance_type': 'plane',
@ -33,6 +33,7 @@ module.exports = extend( false, peliasQuery.defaults, {
'focus:offset': '1km',
'focus:scale': '50km',
'focus:decay': 0.5,
'focus:weight': 2,
'function_score:score_mode': 'avg',
'function_score:boost_mode': 'replace',
@ -79,6 +80,16 @@ module.exports = extend( false, peliasQuery.defaults, {
'admin:neighborhood:analyzer': 'peliasAdmin',
'admin:neighborhood:field': 'neighborhood',
'admin:neighborhood:boost': 1
'admin:neighborhood:boost': 1,
'popularity:field': 'popularity',
'popularity:modifier': 'log1p',
'popularity:max_boost': 20,
'popularity:weight': 1,
'population:field': 'population',
'population:modifier': 'log1p',
'population:max_boost': 20,
'population:weight': 2
});
});

2
query/reverse.js

@ -44,7 +44,7 @@ function generateQuery( clean ){
// bounding circle
// note: the sanitizers will take care of the case
// where point.lan/point.lon are provided in the
// where point.lan/point.lon are provided in the
// absense of boundary.circle.lat/boundary.circle.lon
if( check.number(clean['boundary.circle.lat']) &&
check.number(clean['boundary.circle.lon']) &&

8
query/search.js

@ -15,7 +15,8 @@ query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost
query.score( peliasQuery.view.phrase );
query.score( peliasQuery.view.focus( peliasQuery.view.phrase ) );
query.score( peliasQuery.view.popularity(['admin0','admin1','admin2']) );
query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
query.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
// address components
query.score( peliasQuery.view.address('housenumber') );
@ -36,11 +37,6 @@ query.score( peliasQuery.view.admin('neighborhood') );
query.filter( peliasQuery.view.boundary_circle );
query.filter( peliasQuery.view.boundary_rect );
// groovy scripts used to handle tie-breaking
query.sort( peliasQuery.view.sort_numeric_script('admin_boost') );
query.sort( peliasQuery.view.sort_numeric_script('popularity') );
query.sort( peliasQuery.view.sort_numeric_script('population') );
// --------------------------------
/**

2
routes/v1.js

@ -17,7 +17,7 @@ var middleware = {
/** ----------------------- controllers ----------------------- **/
var controllers = {
var controllers = {
mdToHTML: require('../controller/markdownToHtml'),
place: require('../controller/place'),
search: require('../controller/search'),

2
sanitiser/sanitizeAll.js

@ -36,4 +36,4 @@ function sanitize( req, sanitizers, cb ){
}
// export function
module.exports = sanitize;
module.exports = sanitize;

4
test/ciao/autocomplete/focus_point_invalid_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete?text=a&focus.point.lat=foo&focus.point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

4
test/ciao/autocomplete/focus_point_invalid_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete?text=a&focus.point.lat=40.744243&focus.point.lon='
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['focus.point.lat'].should.eql 40.744243
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

6
test/ciao/autocomplete/focus_point_missing_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete?text=a&focus.point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'focus.point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters focus.point.lat and focus.point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

6
test/ciao/autocomplete/focus_point_missing_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete?text=a&focus.point.lat=40.744243'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'focus.point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters focus.point.lat and focus.point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

4
test/ciao/autocomplete/no_params.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -30,4 +30,4 @@ json.geocoding.errors.should.eql [ 'invalid param \'text\': text length, must be
should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query['size'].should.eql 10

4
test/ciao/autocomplete/text_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/autocomplete?text='
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
should.not.exist json.geocoding.query['text']
json.geocoding.query['size'].should.eql 10
json.geocoding.query['size'].should.eql 10

2
test/ciao/place/missing_id.coffee

@ -3,7 +3,7 @@
path: '/v1/place'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

17
test/ciao/reverse/boundary_circle_invalid_radius.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=40.744243&point.lon=-73.990342&boundary.circle.radius=foo'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -27,12 +27,13 @@ should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing param \'boundary.circle.radius\'' ]
#? expected warnings
should.not.exist json.geocoding.warnings
should.exist json.geocoding.warnings
json.geocoding.warnings.should.eql [ 'boundary.circle is currently unsupported' ]
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query['point.lat'].should.eql 40.744243
json.geocoding.query['point.lon'].should.eql -73.990342
json.geocoding.query['boundary.circle.lat'].should.eql 40.744243
json.geocoding.query['boundary.circle.lon'].should.eql -73.990342
should.not.exist json.geocoding.query['boundary.circle.radius']
# json.geocoding.query['size'].should.eql 10
# json.geocoding.query['point.lat'].should.eql 40.744243
# json.geocoding.query['point.lon'].should.eql -73.990342
# json.geocoding.query['boundary.circle.lat'].should.eql 40.744243
# json.geocoding.query['boundary.circle.lon'].should.eql -73.990342
# should.not.exist json.geocoding.query['boundary.circle.radius']

15
test/ciao/reverse/boundary_circle_valid_radius.coffee

@ -26,12 +26,13 @@ json.features.should.be.instanceof Array
should.not.exist json.geocoding.errors
#? expected warnings
should.not.exist json.geocoding.warnings
should.exist json.geocoding.warnings
json.geocoding.warnings.should.eql [ 'boundary.circle is currently unsupported' ]
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query['point.lat'].should.eql 40.744243
json.geocoding.query['point.lon'].should.eql -73.990342
json.geocoding.query['boundary.circle.lat'].should.eql 40.744243
json.geocoding.query['boundary.circle.lon'].should.eql -73.990342
json.geocoding.query['boundary.circle.radius'].should.eql 999.9
# json.geocoding.query['size'].should.eql 10
# json.geocoding.query['point.lat'].should.eql 40.744243
# json.geocoding.query['point.lon'].should.eql -73.990342
# json.geocoding.query['boundary.circle.lat'].should.eql 40.744243
# json.geocoding.query['boundary.circle.lon'].should.eql -73.990342
# json.geocoding.query['boundary.circle.radius'].should.eql 999.9

4
test/ciao/reverse/boundary_country_invalid_alpha2.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=1&boundary.country=ZZ'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

4
test/ciao/reverse/boundary_country_invalid_alpha3.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=1&boundary.country=ZZZ'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

4
test/ciao/reverse/boundary_country_invalid_iso3166.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=1&boundary.country=FOOBAR'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

2
test/ciao/reverse/duplicate_parameter_name.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=1&param=value1&param=value2'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

2
test/ciao/reverse/layers_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=2&layers=notlayer'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

2
test/ciao/reverse/layers_mix_invalid_valid.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=2&layers=country,notlayer'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

2
test/ciao/reverse/non_scalar_parameter.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=1&parameter[idx]=value'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

4
test/ciao/reverse/point_invalid_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=foo&point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['point.lat']
should.not.exist json.geocoding.query['point.lon']
should.not.exist json.geocoding.query['point.lon']

4
test/ciao/reverse/point_invalid_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=40.744243&point.lon='
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query['point.lat'].should.eql 40.744243
should.not.exist json.geocoding.query['point.lon']
should.not.exist json.geocoding.query['point.lon']

6
test/ciao/reverse/point_missing_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters point.lat and point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['point.lat']
should.not.exist json.geocoding.query['point.lon']
should.not.exist json.geocoding.query['point.lon']

6
test/ciao/reverse/point_missing_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=40.744243'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters point.lat and point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['point.lat']
should.not.exist json.geocoding.query['point.lon']
should.not.exist json.geocoding.query['point.lon']

4
test/ciao/reverse/sources_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=2&sources=openstreetmap,notasource'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['types']
should.not.exist json.geocoding.query['type']
should.not.exist json.geocoding.query['type']

2
test/ciao/reverse/sources_layers_invalid_combo.coffee

@ -3,7 +3,7 @@
path: '/v1/reverse?point.lat=1&point.lon=2&sources=quattroshapes&layers=address'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

2
test/ciao/reverse/sources_multiple.coffee

@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query.types['from_sources'].should.eql ["osmaddress","osmnode","osmway","geoname"]
json.geocoding.query['type'].should.eql ["osmaddress","osmnode","osmway","geoname"]
json.geocoding.query['type'].should.eql ["geoname","osmnode","osmway","osmaddress"]

2
test/ciao/reverse/sources_single.coffee

@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query.types['from_sources'].should.eql ["osmaddress","osmnode","osmway"]
json.geocoding.query['type'].should.eql ["osmaddress","osmnode","osmway"]
json.geocoding.query['type'].should.eql ["osmnode","osmway","osmaddress"]

4
test/ciao/search/boundary_circle_invalid_lat_lon_types.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.circle.lat=foo&boundary.circle.lon=bar'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -34,4 +34,4 @@ json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.circle.lat']
should.not.exist json.geocoding.query['boundary.circle.lon']
should.not.exist json.geocoding.query['boundary.circle.radius']
should.not.exist json.geocoding.query['boundary.circle.radius']

8
test/ciao/search/boundary_circle_invalid_radius.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.circle.lat=40.744243&boundary.circle.lon=-73.990342&boundary.circle.radius=foo'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,6 +32,6 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['boundary.circle.lat'].should.eql 40.744243
json.geocoding.query['boundary.circle.lon'].should.eql -73.990342
should.not.exist json.geocoding.query['boundary.circle.radius']
should.not.exist json.geocoding.query['boundary.circle.lat']
should.not.exist json.geocoding.query['boundary.circle.lon']
should.not.exist json.geocoding.query['boundary.circle.radius']

6
test/ciao/search/boundary_circle_missing_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.circle.lon=-73.990342&boundary.circle.radius=100'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing circle param \'boundary.circle\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters boundary.circle.lat and boundary.circle.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -32,6 +32,6 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['boundary.circle.radius'].should.eql 100
should.not.exist json.geocoding.query['boundary.circle.lat']
should.not.exist json.geocoding.query['boundary.circle.lon']
should.not.exist json.geocoding.query['boundary.circle.radius']

6
test/ciao/search/boundary_circle_missing_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.circle.lat=40.744243&boundary.circle.radius=100'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing circle param \'boundary.circle\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters boundary.circle.lat and boundary.circle.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -32,6 +32,6 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['boundary.circle.radius'].should.eql 100
should.not.exist json.geocoding.query['boundary.circle.lat']
should.not.exist json.geocoding.query['boundary.circle.lon']
should.not.exist json.geocoding.query['boundary.circle.radius']

4
test/ciao/search/boundary_country_invalid_alpha2.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.country=ZZ'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

4
test/ciao/search/boundary_country_invalid_alpha3.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.country=ZZZ'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

4
test/ciao/search/boundary_country_invalid_iso3166.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.country=FOOBAR'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.country']
should.not.exist json.geocoding.query['boundary.country']

6
test/ciao/search/boundary_rect_partially_specified.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&boundary.rect.min_lat=-40.659'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing rect param \'boundary.rect\' requires all of: \'min_lat\',\'max_lat\',\'min_lon\',\'max_lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters boundary.rect.min_lat, boundary.rect.max_lat, boundary.rect.min_lon and boundary.rect.max_lon must all be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -35,4 +35,4 @@ json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['boundary.rect.min_lat']
should.not.exist json.geocoding.query['boundary.rect.max_lat']
should.not.exist json.geocoding.query['boundary.rect.min_lon']
should.not.exist json.geocoding.query['boundary.rect.max_lon']
should.not.exist json.geocoding.query['boundary.rect.max_lon']

4
test/ciao/search/focus_point_invalid_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&focus.point.lat=foo&focus.point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

4
test/ciao/search/focus_point_invalid_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&focus.point.lat=40.744243&focus.point.lon='
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['focus.point.lat'].should.eql 40.744243
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

6
test/ciao/search/focus_point_missing_lat.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&focus.point.lon=-73.990342'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'focus.point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters focus.point.lat and focus.point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

6
test/ciao/search/focus_point_missing_lon.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&focus.point.lat=40.744243'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'missing point param \'focus.point\' requires all of: \'lat\',\'lon\' to be present' ]
json.geocoding.errors.should.eql [ 'parameters focus.point.lat and focus.point.lon must both be specified' ]
#? expected warnings
should.not.exist json.geocoding.warnings
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['focus.point.lat']
should.not.exist json.geocoding.query['focus.point.lon']
should.not.exist json.geocoding.query['focus.point.lon']

2
test/ciao/search/layers_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&layers=notlayer'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

2
test/ciao/search/layers_mix_invalid_valid.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&layers=country,notlayer'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

4
test/ciao/search/no_params.coffee

@ -3,7 +3,7 @@
path: '/v1/search'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -30,4 +30,4 @@ json.geocoding.errors.should.eql [ 'invalid param \'text\': text length, must be
should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['size'].should.eql 10
json.geocoding.query['size'].should.eql 10

4
test/ciao/search/sources_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&sources=openstreetmap,notasource'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -33,4 +33,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
should.not.exist json.geocoding.query['types']
should.not.exist json.geocoding.query['type']
should.not.exist json.geocoding.query['type']

2
test/ciao/search/sources_layers_invalid_combo.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text=a&sources=quattroshapes&layers=address'
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'

6
test/ciao/search/sources_multiple.coffee

@ -1,10 +1,10 @@
#> sources filter
path: '/v1/search?text=a&sources=openstreetmap,geonames'
path: "/v1/search?text=a&sources=openstreetmap,geonames"
#? 200 ok
response.statusCode.should.be.equal 200
response.should.have.header 'charset', 'utf8'
response.should.have.header "charset", 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
#? valid geocoding block
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query.types['from_sources'].should.eql ["osmaddress","osmnode","osmway","geoname"]
json.geocoding.query['type'].should.eql ["osmaddress","osmnode","osmway","geoname"]
json.geocoding.query['type'].should.eql ["geoname","osmnode","osmway","osmaddress"]

2
test/ciao/search/sources_single.coffee

@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query.types['from_sources'].should.eql ["osmaddress","osmnode","osmway"]
json.geocoding.query['type'].should.eql ["osmaddress","osmnode","osmway"]
json.geocoding.query['type'].should.eql ["osmnode","osmway","osmaddress"]

4
test/ciao/search/text_invalid.coffee

@ -3,7 +3,7 @@
path: '/v1/search?text='
#? 200 ok
response.statusCode.should.be.equal 200
response.statusCode.should.be.equal 400
response.should.have.header 'charset', 'utf8'
response.should.have.header 'content-type', 'application/json; charset=utf-8'
@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs
should.not.exist json.geocoding.query['text']
json.geocoding.query['size'].should.eql 10
json.geocoding.query['size'].should.eql 10

2
test/ciao/search/text_valid.coffee

@ -30,4 +30,4 @@ should.not.exist json.geocoding.warnings
#? inputs
json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10
json.geocoding.query['size'].should.eql 10

73
test/unit/fixture/autocomplete_linguistic_focus.js

@ -45,53 +45,70 @@ module.exports = {
'scale': '50km',
'decay': 0.5
}
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}
@ -100,4 +117,4 @@ module.exports = {
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

71
test/unit/fixture/autocomplete_linguistic_focus_null_island.js

@ -45,53 +45,70 @@ module.exports = {
'scale': '50km',
'decay': 0.5
}
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}

70
test/unit/fixture/autocomplete_linguistic_only.js

@ -23,48 +23,64 @@ module.exports = {
'slop': 2
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}
@ -73,4 +89,4 @@ module.exports = {
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

68
test/unit/fixture/search_boundary_country.js

@ -33,48 +33,64 @@ module.exports = {
'slop': 2
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}

67
test/unit/fixture/search_full_address.js

@ -30,44 +30,61 @@ module.exports = {
{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': '123 main st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': '123 main st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
},{
'match': {
'address.number': {
@ -164,4 +181,4 @@ module.exports = {
'size': 10,
'sort': [ '_score' ],
'track_scores': true
};
};

72
test/unit/fixture/search_linguistic_bbox.js

@ -23,48 +23,64 @@ module.exports = {
'slop': 2
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
},
@ -86,7 +102,7 @@ module.exports = {
}
}
},
'sort': [ '_sort' ],
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

75
test/unit/fixture/search_linguistic_focus.js

@ -47,59 +47,76 @@ module.exports = {
'scale': '50km',
'decay': 0.5
}
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}
}
},
'sort': [ '_sort' ],
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

75
test/unit/fixture/search_linguistic_focus_bbox.js

@ -47,53 +47,70 @@ module.exports = {
'scale': '50km',
'decay': 0.5
}
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
},
@ -115,7 +132,7 @@ module.exports = {
}
}
},
'sort': [ '_sort' ],
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

73
test/unit/fixture/search_linguistic_focus_null_island.js

@ -47,59 +47,76 @@ module.exports = {
'scale': '50km',
'decay': 0.5
}
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}
}
},
'sort': [ '_sort' ],
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

70
test/unit/fixture/search_linguistic_only.js

@ -23,48 +23,64 @@ module.exports = {
'slop': 2
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
}]
}
}
@ -73,4 +89,4 @@ module.exports = {
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};
};

70
test/unit/fixture/search_partial_address.js

@ -26,48 +26,64 @@ module.exports = {
'boost': 1
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': 'soho grand',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'soho grand',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
},{
'match': {
'admin0': {
@ -132,4 +148,4 @@ module.exports = {
'size': 10,
'sort': [ '_score' ],
'track_scores': true
};
};

70
test/unit/fixture/search_regions_address.js

@ -26,48 +26,64 @@ module.exports = {
'boost': 1
}
}
},
{
},{
'function_score': {
'query': {
'filtered': {
'filter': {
'exists': {
'field': 'popularity'
}
'match': {
'phrase.default': {
'query': '1 water st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 2,
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'or': [
{
'type': {
'value': 'admin0'
}
},
{
'type': {
'value': 'admin1'
}
},
{
'type': {
'value': 'admin2'
}
}
]
'exists': {
'field': 'popularity'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'sqrt',
'modifier': 'log1p',
'field': 'popularity'
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': '1 water st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'filter': {
'exists': {
'field': 'population'
}
},
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population'
},
'weight': 2
}]
}
},{
'match': {
'address.number': {
@ -148,4 +164,4 @@ module.exports = {
'size': 10,
'sort': [ '_score' ],
'track_scores': true
};
};

25
test/unit/fixture/sort_default.js

@ -1,25 +0,0 @@
module.exports = [
'_score',
{
'_script': {
'file': 'admin_boost',
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'file': 'popularity',
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'file': 'population',
'type': 'number',
'order': 'desc'
}
}
];

238
test/unit/helper/labelGenerator.js

@ -49,6 +49,45 @@ module.exports.tests.nyc_office = function(test, common) {
});
};
// USA NYC eatery
module.exports.tests.nyc_bakery = function(test, common) {
test('New York Bakery', function(t) {
var doc = {
'name': { 'default': 'New York Bakery' },
'housenumber': '51 W',
'street': '29th',
'country_a': 'USA',
'country': 'United States',
'region': 'New York',
'region_a': 'NY',
'county': 'New York County',
'localadmin': 'Manhattan',
'locality': 'New York',
'neighbourhood': 'Koreatown'
};
t.equal(generator(doc),'New York Bakery, Manhattan, NY');
t.end();
});
};
// USA SFC building
module.exports.tests.ferry_building = function(test, common) {
test('Ferry Building', function(t) {
var doc = {
'name': { 'default': 'Ferry Building' },
'country_a': 'USA',
'country': 'United States',
'region': 'California',
'region_a': 'CA',
'county': 'San Francisco County',
'locality': 'San Francisco',
'neighbourhood': 'Financial District'
};
t.equal(generator(doc),'Ferry Building, San Francisco, CA');
t.end();
});
};
// AUS state
module.exports.tests.new_south_wales = function(test, common) {
test('new south wales', function(t) {
@ -92,6 +131,69 @@ module.exports.tests.west_bengal = function(test, common) {
});
};
// IND city
module.exports.tests.bangalore = function(test, common) {
test('bangalore', function(t) {
var doc = {
'name': { 'default': 'Bangalore' },
'country_a': 'IND',
'country': 'India',
'region': 'Karnataka',
'county': 'Bangalore',
'locality': 'Bangalore'
};
t.equal(generator(doc),'Bangalore, Karnataka, India');
t.end();
});
};
// IND region of city
module.exports.tests.sarjapur = function(test, common) {
test('Sarjapur', function(t) {
var doc = {
'name': { 'default': 'Sarjapur' },
'country_a': 'IND',
'country': 'India',
'region': 'Karnataka'
};
t.equal(generator(doc),'Sarjapur, Karnataka, India');
t.end();
});
};
// IND region of city 2
module.exports.tests.bengaluru_east = function(test, common) {
test('Bengaluru East', function(t) {
var doc = {
'name': { 'default': 'Bengaluru East' },
'country_a': 'IND',
'country': 'India',
'region': 'Karnataka',
'county': 'Bangalore',
'locality': 'Bangalore',
'neighbourhood': 'Fraser Town'
};
t.equal(generator(doc),'Bengaluru East, Bangalore, India');
t.end();
});
};
// AUS area
// https://en.wikipedia.org/wiki/Shire_of_Wellington
module.exports.tests.wellington_victoria = function(test, common) {
test('Wellington, Victoria, Australia', function(t) {
var doc = {
'name': { 'default': 'Wellington' },
'country_a': 'AUS',
'country': 'Australia',
'region': 'Victoria',
'county': 'Wellington'
};
t.equal(generator(doc),'Wellington, Victoria, Australia');
t.end();
});
};
// SGP region
module.exports.tests.north_west_singapore = function(test, common) {
test('north west singapore', function(t) {
@ -134,6 +236,37 @@ module.exports.tests.madrid = function(test, common) {
});
};
// SWE city
module.exports.tests.skane1 = function(test, common) {
test('skåne 1', function(t) {
var doc = {
'name': { 'default': 'Malmö' },
'country_a': 'SWE',
'country': 'Sweden',
'region': 'Skåne',
'county': 'Malmö'
};
t.equal(generator(doc),'Malmö, Skåne, Sweden');
t.end();
});
};
// SWE city
module.exports.tests.skane2 = function(test, common) {
test('skåne 2', function(t) {
var doc = {
'name': { 'default': 'Malmö' },
'country_a': 'SWE',
'country': 'Sweden',
'region': 'Skåne',
'county': 'Malmö',
'locality': 'Malmö'
};
t.equal(generator(doc),'Malmö, Skåne, Sweden');
t.end();
});
};
// GBR street address
module.exports.tests.one_main_street_uk = function(test, common) {
test('one main street uk', function(t) {
@ -201,6 +334,34 @@ module.exports.tests.new_zealand = function(test, common) {
});
};
// GBR country
module.exports.tests.wales = function(test, common) {
test('wales', function(t) {
var doc = {
'name': { 'default': 'Wales' },
'country_a': 'GBR',
'country': 'United Kingdom',
'region': 'Wales'
};
t.equal(generator(doc),'Wales, United Kingdom');
t.end();
});
};
// IRL country
module.exports.tests.republic_of_ireland = function(test, common) {
test('northern ireland', function(t) {
var doc = {
'name': { 'default': 'Ireland' },
'country_a': 'IRL',
'country': 'Ireland'
};
// !! this is not part of the UK !!
t.equal(generator(doc),'Ireland');
t.end();
});
};
// SGP venue
module.exports.tests.singapore_mcdonalds = function(test, common) {
test('singapore_mcdonalds', function(t) {
@ -216,6 +377,81 @@ module.exports.tests.singapore_mcdonalds = function(test, common) {
});
};
// THA province
module.exports.tests.krabi_province = function(test, common) {
test('Krabi Provence', function(t) {
var doc = {
'name': { 'default': 'Krabi' },
'country_a': 'THA',
'country': 'Thailand',
'region': 'Krabi'
};
t.equal(generator(doc),'Krabi, Thailand');
t.end();
});
};
// THA island
module.exports.tests.koh_lanta = function(test, common) {
test('Koh Lanta', function(t) {
var doc = {
'name': { 'default': 'Ko Lanta' },
'country_a': 'THA',
'country': 'Thailand',
'region': 'Krabi'
};
t.equal(generator(doc),'Ko Lanta, Krabi, Thailand');
t.end();
});
};
// NZD cafe
module.exports.tests.black_dog_cafe = function(test, common) {
test('Black Dog Cafe', function(t) {
var doc = {
'name': { 'default': 'Black Dog Cafe' },
'country_a': 'NZL',
'country': 'New Zealand',
'region': 'Auckland Region',
'county': 'Auckland'
};
t.equal(generator(doc),'Black Dog Cafe, Auckland, New Zealand');
t.end();
});
};
// NZD cafe 2
module.exports.tests.beach_bablyon = function(test, common) {
test('Beach Bablyon', function(t) {
var doc = {
'name': { 'default': 'Beach Bablyon' },
'country_a': 'NZL',
'country': 'New Zealand',
'region': 'Wellington Region',
'county': 'Wellington City',
'locality': 'Wellington',
'neighbourhood': 'Oriental Bay'
};
t.equal(generator(doc),'Beach Bablyon, Wellington, New Zealand');
t.end();
});
};
// NZD tourism
module.exports.tests.waiotapu = function(test, common) {
test('Waiotapu', function(t) {
var doc = {
'name': { 'default': 'Waiotapu' },
'country_a': 'NZL',
'country': 'New Zealand',
'region': 'Bay of Plenty',
'county': 'Rotorua District'
};
t.equal(generator(doc),'Waiotapu, Rotorua District, New Zealand');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
@ -225,4 +461,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};

12
test/unit/helper/labelSchema.js

@ -15,16 +15,16 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.valid = function(test, common) {
var valid_keys = ['localadmin', 'locality', 'neighbourhood', 'county', 'region_a', 'region', 'country'];
var default_schema = {
local: ['localadmin', 'locality', 'neighbourhood', 'county'],
regional: ['region_a', 'region', 'country']
local: ['localadmin', 'locality', 'neighbourhood', 'county', 'region'],
regional: ['country']
};
var isValid = function(keys, schema) {
test('valid key/object (' + keys + ')' , function(t) {
if (keys === 'default') {
if (keys === 'default') {
t.deepEqual(schema, default_schema, 'valid default schema');
} else {
t.equal(alpha3.hasOwnProperty(keys), true, 'valid key');
t.equal(alpha3.hasOwnProperty(keys), true, 'valid key');
}
t.equal(typeof schema, 'object', 'valid object');
t.notEqual(Object.getOwnPropertyNames(schema).length, 0, 'object not empty');
@ -39,7 +39,7 @@ module.exports.tests.valid = function(test, common) {
});
};
for (var keys in schemas) {
for (var keys in schemas) {
isValid(keys, schemas[keys]);
}
};
@ -53,4 +53,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};

91
test/unit/helper/type_mapping.js

@ -39,6 +39,97 @@ module.exports.tests.interfaces = function(test, common) {
t.ok(check.hasLength(Object.keys(type_mapping.layer_with_aliases_to_type), 9), 'has correct number of elements');
t.end();
});
test('\'osm\' and \'openstreetmap\' sources should only successfully map to \'venue\' and \'address\' layers', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'venue'), ['osmnode', 'osmway']);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'address'), ['osmaddress']);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'venue'), ['osmnode', 'osmway']);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'address'), ['osmaddress']);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'coarse'), []);
t.end();
});
test('\'gn\' and \'geonames\' sources should only successfully map to \'venue\' layers', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'venue'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'venue'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'coarse'), []);
t.end();
});
test('\'oa\' and \'openaddresses\' sources should only successfully map to \'address\' layer', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'address'), ['openaddresses']);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'address'), ['openaddresses']);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'coarse'), []);
t.end();
});
test('\'qs\' and \'quattroshapes\' sources should only successfully map to \'address\' layer', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'country'), ['admin0']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'region'), ['admin1']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'county'), ['admin2']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'locality'), ['locality']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'localadmin'), ['local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'neighbourhood'), ['neighborhood']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'coarse'),
['admin0','admin1','admin2','neighborhood','locality','local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'country'), ['admin0']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'region'), ['admin1']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'county'), ['admin2']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'locality'), ['locality']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'localadmin'), ['local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'neighbourhood'), ['neighborhood']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'coarse'),
['admin0','admin1','admin2','neighborhood','locality','local_admin']);
t.end();
});
};
module.exports.all = function (tape, common) {

11
test/unit/query/search.js

@ -10,8 +10,6 @@ module.exports.tests.interface = function(test, common) {
});
};
var sort = require('../fixture/sort_default');
module.exports.tests.query = function(test, common) {
test('valid search + focus + bbox', function(t) {
var query = generate({
@ -26,7 +24,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -44,7 +41,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -58,7 +54,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -73,7 +68,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -88,7 +82,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -105,7 +98,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_full_address');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -122,7 +114,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_partial_address');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -139,7 +130,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_regions_address');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid search query');
t.end();
@ -154,7 +144,6 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country');
expected.sort = sort;
t.deepEqual(compiled, expected, 'valid boundary.country query');
t.end();

Loading…
Cancel
Save