Skip to content

Commit

Permalink
add note about deploying geolocator bucket content along side new code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Vautour committed Feb 8, 2024
1 parent 2c3fa75 commit 8307358
Show file tree
Hide file tree
Showing 16 changed files with 1,896 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/lambda/geolocator/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# README

## Deployment steps

- the content of the `geolocator-bucket-content` folder must be deployed manually the the `webpresence-geolocator-${Environment}` bucket. the lambda will read it's config from there at runtime.

## Deployment quirks

- the lambda name needs to change on every release to be correctly picked up by the cloudformation. this name change should be also reflected in the `geolocator-web-presence` cloudformation.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "API Geolocator Input Config Schema",
"type": "object",
"version": 1.0,
"comments": "Schema for GeoView-API-geolocator input-query. The items inside parameters properties are the parameters provided by the URL.",

"properties": {
"params": {
"type": "object",
"description": "Query parameter coming from the API call url",
"properties": {
"querystring": {
"type": "array",
"description": "Dictionary containing the parameters and values passed with the url",
"properties": {
"q": {
"type": "string",
"default": "none",
"description": "The query to parse and send to supported API's."
},
"lang": {
"type": "string",
"enum": ["en", "fr"],
"default" : "en",
"description": "The language on wich to filter the query."
},
"dev": {
"type": "string",
"enum": ["true", "false"],
"default" : "false",
"description": "show fields that are null or undefined"
},
"table": {
"type": "string",
"enum": ["category", "component", "generic", "province", "tableurl", "none"],
"default" : "none",
"description": "return json dump of table"
},
"keys": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"enum": ["geonames", "nominatim", "locate"]
},
"description": "The list of supported API key to query. Optional parameter, if missing, all supported key will be query."
}
},
"required": ["q","table"],
"requiredAll": "false",
"additionalProperties": false
}
},
"required": ["querystring"],
"additionalProperties": false
}
},
"required": ["params"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "API Geolocator Output Config Schema",
"type": "object",
"version": 1.0,
"comments": "Schema for GeoView-API-geolocator output-query results.",
"additionalProperties": false,

"definitions": {
"output": {
"type": "array",
"description": "Array of results were each item is the output from the requested API key.",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "Origin API key value."
},
"name": {
"type": "string",
"description": "Name information of the item."
},
"lat": {
"type": "number",
"minimum": -90,
"maximum": 90,
"description": "Latitude of the item."
},
"lng": {
"type": "number",
"minimum": -180,
"maximum": 180,
"description": "Longitude of the item."
},
"bbox": {
"type": "array",
"minItems": 4,
"items": [
{
"type": "number",
"minimum": -180,
"maximum": 180,
"description": "West border of the bounding box."
},
{
"type": "number",
"minimum": -90,
"maximum": 90,
"description": "South border of the bounding box."
},
{
"type": "number",
"minimum": -180,
"maximum": 180,
"description": "East border of the bounding box."
},
{
"type": "number",
"minimum": -90,
"maximum": 90,
"description": "North border of the bounding box."
}
],
"description": "The bbox of the item [minX, minY, maxX, maxY]. Optional return value."
},
"province": {
"type": "string",
"description": "The province the item belongs to. Optional return value, may be derived from the name parameter."
},
"tag": {
"type": "array",
"minItems": 0,
"items": {
"type": "string",
"description": "The content of this field might vary depending of the sources."
},
"description": "The tag value of the item. Optional return value. tags may be different from one API to the other, it is a value to help understand what type of item it is."
}
},
"required": ["name", "lat", "lng"],
"additionalProperties": false
}
}
},
"properties": {
"geonames": {
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/output" },
"description": "The Geoname api result set."
},
"nominatim": {
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/output" },
"description": "The Nominatim api result set."
},
"locate": {
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/output" },
"description": "The locate api result set."
},
"nts": {
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/output" },
"description": "The ens api result set."
}
},
"description": "List of supported key for the API. As we add key, we need to had an entry in the schema. The entry MUST be the same key as the in in-api-schema.json (keys enum parameter)."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# in-api-schema keys parameter

valid keys: geonames, nominatim and locate.

nts key (https://geogratis.gc.ca/services/delimitation/en/nts) not used as there is no query parameter (only search by spatial bbox).
Static table and filtering capacity would need to be implemented.



Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"url" : "https://maps.googleapis.com/maps/api/place/findplacefromtext/json",

"urlParams" : {
},
"staticParams" : {
"inputtype" : "textquery",
"fields" : "name,geometry",
"key" : "AIzaSyASQcYTDCw4fRr_GY5WHxIAqeTsDmvAh_8"
},
"urlCodeTables" : {},
"lookup" : {
"in" : {
"q" : "input"
},
"out" : {
"structure" : {
"type": "dict",
"key": "candidates"
},
"data" : {
"name": {
"field": "name",
"lookup": ""
},
"lat": {
"field":"geometry.location.lat",
"lookup": ""
},
"lng": {
"field": "geometry.location.lng",
"lookup": ""
},
"bbox" : [
{
"field": "geometry.viewport.southwest.lng",
"lookup": ""
},
{
"field": "geometry.viewport.southwest.lat",
"lookup": ""
},
{
"field": "geometry.viewport.northeast.lng",
"lookup": ""
},
{
"field": "geometry.viewport.northeast.lat",
"lookup": ""
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"url" : "https://maps.googleapis.com/maps/api/geocode/json",

"urlParams" : {
},
"staticParams" : {
"key" : "AIzaSyASQcYTDCw4fRr_GY5WHxIAqeTsDmvAh_8"
},
"urlCodeTables" : {},
"lookup" : {
"in" : {
"q" : "address"
},
"out" : {
"structure" : {
"type": "dict",
"key": "results"
},
"data" : {
"name": {
"field": "formatted_address",
"lookup": ""
},
"lat": {
"field":"geometry.location.lat",
"lookup": ""
},
"lng": {
"field": "geometry.location.lng",
"lookup": ""
},
"bbox" : [
{
"field": "geometry.viewport.southwest.lng",
"lookup": ""
},
{
"field": "geometry.viewport.southwest.lat",
"lookup": ""
},
{
"field": "geometry.viewport.northeast.lng",
"lookup": ""
},
{
"field": "geometry.viewport.northeast.lat",
"lookup": ""
}
],
"province": {
"field": "address_components",
"lookup": {
"type": "search",
"search_field": "types",
"contains": "administrative_area_level_1",
"return_field": "long_name"
}
},
"tag": {
"field": "types",
"lookup": ""
}

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"url": "https://geogratis.gc.ca/services/geoname/_PARAM1_/geonames.json",
"urlParams": {
"param1": "lang"
},
"staticParams": {},
"urlCodeTables": {
"province" : {
"url": "https://geogratis.gc.ca/services/geoname/_PARAM1_/codes/province.json",
"type": "array",
"name": "definitions",
"fields": {
"code": "code",
"description": "description"
}
},
"generic": {
"url": "https://geogratis.gc.ca/services/geoname/_PARAM1_/codes/generic.json",
"type": "array",
"name": "definitions",
"fields": {
"code": "code",
"description": "term"
}
}
},
"lookup": {
"in": {
"q": "q"
},
"out": {
"structure" : {
"type": "dict",
"key": "items"
},
"data": {
"name": {
"field": "name",
"lookup": ""
},
"province": {
"field": "province.code",
"lookup": {
"type": "table",
"field": "description"
}
},
"category": {
"field": "generic.code",
"lookup": {
"type": "table",
"field": "term"
}
},
"lat": {
"field":"latitude",
"lookup": ""
},
"lng": {
"field": "longitude",
"lookup": ""
},
"bbox": {
"field": "bbox",
"lookup": ""
},
"tag": [
{
"field": "location",
"lookup": ""
}
]
}
}
}
}
Loading

0 comments on commit 8307358

Please sign in to comment.