diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69f7c43 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dev/geocoder/desktop.ini diff --git a/config/openapi.yaml b/config/openapi.yaml new file mode 100644 index 0000000..20967e2 --- /dev/null +++ b/config/openapi.yaml @@ -0,0 +1,602 @@ +openapi: 3.0.1 +info: + title: KomMonitor Geocoder Proxy + description: "KomMonitor Geocoder Proxy that defines a common query and response\ + \ interface for arbitrary geocoding services like nominatim, photon (datasource\ + \ is OSM)" + termsOfService: http://swagger.io/terms/ + contact: + email: christian.danowski-buhren@hs-bochum.de + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: 0.0.1 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://localhost:8092/ +- url: http://localhost/kommonitor/api/geocoderproxy/ +tags: +- name: geocode + description: geocode locations or reverse geocode coordinates +- name: reverse-geocode + description: "find address details for a given longitude, latitude point" +paths: + /geocoder/geocode/query-string: + get: + tags: + - geocode + summary: proxies search request to underlying geocoding service in order to + find coordinates for entered location + description: proxies search request to underlying geocoding service in order + to find coordinates for entered location + operationId: geocodeByQueryString + parameters: + - name: q + in: query + description: "the query string (e.g. 'Müllerstr. 3, Essen' or '3, Müllerstraß\ + e, 45147')" + required: true + style: form + explode: true + schema: + type: string + example: "3, Müllerstraße, 45147" + - name: lon + in: query + description: optional longitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "7.1234" + - name: lat + in: query + description: optional latitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "51.4321" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GeocodingOutputType' + "401": + description: Unauthorized + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} + "405": + description: Invalid input + content: {} + "500": + description: Internal Server Error + content: {} + x-swagger-router-controller: Geocode + /geocoder/geocode/query-string/batch: + post: + tags: + - geocode + summary: proxies search batch request to underlying geocoding service in order + to find coordinates for each entered location + description: proxies search batch request to underlying geocoding service in + order to find coordinates for each entered location + operationId: geocodeByQueryStringBatch + parameters: + - name: lon + in: query + description: optional longitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "7.1234" + - name: lat + in: query + description: optional latitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "51.4321" + requestBody: + description: "list of query string (e.g. 'Müllerstr. 3, Essen' or '3, Müllerstraß\ + e, 45147')" + content: + application/json: + schema: + type: array + items: + type: string + example: "3, Müllerstraße, 45147" + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GeocodingOutputType' + x-content-type: application/json + "401": + description: Unauthorized + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} + "405": + description: Invalid input + content: {} + "500": + description: Internal Server Error + content: {} + x-swagger-router-controller: Geocode + /geocoder/geocode/query-structured: + get: + tags: + - geocode + summary: "proxies search request to underlying geocoding service in order to\ + \ find coordinates for entered structured data. No parameter is required.\ + \ Instead any combination of structrured query elements may respond with 0\ + \ ... n result records in the form of a GeoJSON FeatureCollection, where each\ + \ feature has more or less details with regard to address details" + description: "proxies search request to underlying geocoding service in order\ + \ to find coordinates for entered structured data. No parameter is required.\ + \ Instead any combination of structrured query elements may respond with 0\ + \ ... n result records in the form of a GeoJSON FeatureCollection, where each\ + \ feature has more or less details with regard to address details" + operationId: geocodeByStructuredQuery + parameters: + - name: country + in: query + description: optional country name + required: false + style: form + explode: true + schema: + type: string + example: Deutschland + - name: state + in: query + description: optional state name + required: false + style: form + explode: true + schema: + type: string + example: Nordrhein-Westfalen + - name: city + in: query + description: optional city name + required: false + style: form + explode: true + schema: + type: string + example: Essen + - name: district + in: query + description: optional district name + required: false + style: form + explode: true + schema: + type: string + example: Holsterhausen + - name: postcode + in: query + description: optional postcode name + required: false + style: form + explode: true + schema: + type: string + example: "45147" + - name: street + in: query + description: required street name + required: false + style: form + explode: true + schema: + type: string + example: Müllerstraße + - name: housenumber + in: query + description: optional housenumber name + required: false + style: form + explode: true + schema: + type: string + example: 13c + - name: lon + in: query + description: optional longitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "7.1234" + - name: lat + in: query + description: optional latitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "51.4321" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GeocodingOutputType' + "401": + description: Unauthorized + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} + "405": + description: Invalid input + content: {} + "500": + description: Internal Server Error + content: {} + x-swagger-router-controller: Geocode + /geocoder/geocode/query-structured/batch: + post: + tags: + - geocode + summary: "proxies search batch request to underlying geocoding service in order\ + \ to find coordinates for entered structured data. No parameter is required.\ + \ Instead any combination of structrured query elements may respond with 0\ + \ ... n result records in the form of a GeoJSON FeatureCollection, where each\ + \ feature has more or less details with regard to address details" + description: "proxies search batch request to underlying geocoding service in\ + \ order to find coordinates for entered structured data. No parameter is required.\ + \ Instead any combination of structrured query elements may respond with 0\ + \ ... n result records in the form of a GeoJSON FeatureCollection, where each\ + \ feature has more or less details with regard to address details" + operationId: geocodeByStructuredQueryBatch + parameters: + - name: lon + in: query + description: optional longitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "7.1234" + - name: lat + in: query + description: optional latitude to prioritize results + required: false + style: form + explode: true + schema: + type: string + example: "51.4321" + requestBody: + description: list of structured geocoding inputs + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GeocodingStructuredBatchInputType' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GeocodingOutputType' + x-content-type: application/json + "401": + description: Unauthorized + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} + "405": + description: Invalid input + content: {} + "500": + description: Internal Server Error + content: {} + x-swagger-router-controller: Geocode + /geocoder/reverse: + get: + tags: + - reverse-geocode + summary: "proxies reverse-geocode request to underlying geocoding service in\ + \ order to find address details for given longitude, latitude coordinates" + description: "proxies reverse-geocode request to underlying geocoding service\ + \ in order to find address details for given longitude, latitude coordinates" + operationId: reverseGeocode + parameters: + - name: lon + in: query + description: required longitude + required: true + style: form + explode: true + schema: + type: string + example: "7.1234" + - name: lat + in: query + description: required latitude + required: true + style: form + explode: true + schema: + type: string + example: "51.4321" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GeocodingOutputType' + "401": + description: Unauthorized + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} + "405": + description: Invalid input + content: {} + "500": + description: Internal Server Error + content: {} + x-swagger-router-controller: ReverseGeocode +components: + schemas: + GeocodingStructuredBatchInputType: + type: object + properties: + country: + type: string + description: optional country name + example: Deutschland + state: + type: string + description: optional state name + example: Nordrhein-Westfalen + city: + type: string + description: optional city name + example: Essen + district: + type: string + description: optional district name + example: Holsterhausen + postcode: + type: string + description: optional postcode name + example: "45147" + street: + type: string + description: optional street name + example: Müllerstraße + housenumber: + type: string + description: optional housenumber name + example: 13 C + GeocodingOutputType: + type: object + properties: + type: + type: string + default: FeatureCollection + features: + type: array + items: + $ref: '#/components/schemas/GeocodingFeatureType' + description: output generated by a geocoding request. 0 or more records in the + form of a GeoJSON FeatureCollection (if emtpy then the returned FeatureCollection + has an empty features array) + example: + features: + - geometry: + coordinates: + - 7.1234 + - 51.4321 + type: Point + properties: + country: Deutschland + city: Essen + housenumber: 13c + street: Müllerstraße + district: Holsterhausen + postcode: "45147" + state: Nordrhein-Westfalen + category: building + type: apartments + display_name: "3, Müllerstraße, Holsterhausen, Essen, Nordrhein-Westfalen,\ + \ 45147, Deutschland" + - geometry: + coordinates: + - 7.1234 + - 51.4321 + type: Point + properties: + country: Deutschland + city: Essen + housenumber: 13c + street: Müllerstraße + district: Holsterhausen + postcode: "45147" + state: Nordrhein-Westfalen + category: building + type: apartments + display_name: "3, Müllerstraße, Holsterhausen, Essen, Nordrhein-Westfalen,\ + \ 45147, Deutschland" + type: FeatureCollection + GeocodingFeatureType: + type: object + properties: + geometry: + $ref: '#/components/schemas/GeocodingGeometryType' + properties: + $ref: '#/components/schemas/GeocodingPropertiesType' + example: + geometry: + coordinates: + - 7.1234 + - 51.4321 + type: Point + properties: + country: Deutschland + city: Essen + housenumber: 13c + street: Müllerstraße + district: Holsterhausen + postcode: "45147" + state: Nordrhein-Westfalen + category: building + type: apartments + display_name: "3, Müllerstraße, Holsterhausen, Essen, Nordrhein-Westfalen,\ + \ 45147, Deutschland" + GeocodingGeometryType: + type: object + properties: + type: + type: string + description: the geometry type of the feature - here in geocoding context + it is always point + default: Point + coordinates: + maximum: 2 + minimum: 2 + type: array + description: "coordinate array of feature point geometry using longitude,\ + \ latitude" + example: + - 7.1234 + - 51.4321 + items: + type: number + format: float + example: + coordinates: + - 7.1234 + - 51.4321 + type: Point + GeocodingPropertiesType: + type: object + properties: + category: + type: string + description: category of response (osm_key) + example: building + type: + type: string + description: type within category (osm_value) + example: apartments + display_name: + type: string + description: a descriptive string combining several address details within + one string (i.e. for display popup purposes) + example: "3, Müllerstraße, Holsterhausen, Essen, Nordrhein-Westfalen, 45147,\ + \ Deutschland" + country: + type: string + description: name of the country + example: Deutschland + state: + type: string + description: name of the state + example: Nordrhein-Westfalen + postcode: + type: string + description: postal code + example: "45147" + city: + type: string + description: name of the city + example: Essen + district: + type: string + description: name of the city district + example: Holsterhausen + street: + type: string + description: name of the street + example: Müllerstraße + housenumber: + type: string + description: house number (including any suffix) if available + example: 13c + geocoderank: + type: string + description: evaluation of geocoding result (unresolved = least accurate cause false street and/or city/postcode; low_accuracy = more accurate due to same street and same city/postcode but no housenumber; high_accuracy = most accurate due to same street and same city/postcode and same housenumber) + enum: + - "unresolved" + - "low_accuracy" + - "high_accuracy" + geocodedesc: + type: string + description: descriptive evaluation of geocoding result + example: + country: Deutschland + city: Essen + housenumber: 13c + street: Müllerstraße + geocoderank: "high_accuracy" + district: Holsterhausen + postcode: "45147" + state: Nordrhein-Westfalen + category: building + type: apartments + display_name: "3, Müllerstraße, Holsterhausen, Essen, Nordrhein-Westfalen,\ + \ 45147, Deutschland" + responses: + UnauthorizedError: + description: API key is missing or invalid + headers: + WWW_Authenticate: + style: simple + explode: false + schema: + type: string + content: {} diff --git a/config/templates/webClientAppConfig.js.template b/config/templates/webClientAppConfig.js.template index 6537299..7bcda95 100644 --- a/config/templates/webClientAppConfig.js.template +++ b/config/templates/webClientAppConfig.js.template @@ -119,6 +119,7 @@ try { // KomMonitor Geocoder Proxy //window.__env.targetUrlToGeocoderService = 'https://geocoder.fbg-hsbo.de/nominatim/'; + // window.__env.targetUrlToGeocoderService = 'http://localhost/kommonitor/api/processor/nominatim/'; window.__env.targetUrlToGeocoderService = 'http://localhost:8092/nominatim/'; // KomMonitor Spatial Data Processor diff --git a/dev-proxy/geocoder/docker-compose.yml b/dev-proxy/geocoder/docker-compose.yml index 8f02ca2..22e731e 100644 --- a/dev-proxy/geocoder/docker-compose.yml +++ b/dev-proxy/geocoder/docker-compose.yml @@ -1,5 +1,10 @@ version: "3" +networks: + kommonitor: + name: kommonitor + driver: bridge + services: nominatim: container_name: nominatim @@ -34,6 +39,10 @@ services: depends_on: nominatim: condition: service_healthy + volumes: + - ../../config/openapi.yaml:/code/api/openapi.yaml + networks: + - kommonitor volumes: nominatim-data: diff --git a/dev-proxy/kommonitor/storage/client/config-storage-server.json b/dev-proxy/kommonitor/storage/client/config-storage-server.json index e69de29..4dfd23c 100644 --- a/dev-proxy/kommonitor/storage/client/config-storage-server.json +++ b/dev-proxy/kommonitor/storage/client/config-storage-server.json @@ -0,0 +1,5 @@ +{ + "targetUrlToConfigStorageServer_appConfig" : "http://localhost/kommonitor/api/client-config/config/client-app-config", + "targetUrlToConfigStorageServer_keycloakConfig" : "http://localhost/kommonitor/api/client-config/config/client-keycloak-config", + "targetUrlToConfigStorageServer_controlsConfig" : "http://localhost/kommonitor/api/client-config/config/client-controls-config" +} \ No newline at end of file diff --git a/dev-proxy/nginx/docker-compose.yml b/dev-proxy/nginx/docker-compose.yml index 213d23a..c27cb27 100644 --- a/dev-proxy/nginx/docker-compose.yml +++ b/dev-proxy/nginx/docker-compose.yml @@ -22,5 +22,6 @@ services: - IMPORTER=kommonitor-importer:8087 - DATA_MANAGEMENT=kommonitor-data-management:8085 - SPATIAL_DATA_PROCESSOR=kommonitor-spatial-data-processor:8090 + - GEOCODER_PROXY=kommonitor-geocoder-proxy:8092 networks: - kommonitor \ No newline at end of file diff --git a/dev-proxy/nginx/templates/default.conf.template b/dev-proxy/nginx/templates/default.conf.template index a8b897c..76d0986 100644 --- a/dev-proxy/nginx/templates/default.conf.template +++ b/dev-proxy/nginx/templates/default.conf.template @@ -16,6 +16,9 @@ upstream data-management { upstream spatial-data-processor { server ${SPATIAL_DATA_PROCESSOR}; } +upstream geocoder-proxy { + server ${GEOCODER_PROXY}; +} server { listen ${NGINX_PORT}; @@ -44,6 +47,9 @@ server { location /kommonitor/api/processor/ { proxy_pass http://spatial-data-processor/; } + location /kommonitor/api/geocoderproxy/ { + proxy_pass http://geocoder-proxy/; + } } location /kommonitor/ { diff --git a/dev/geocoder/docker-compose.yml b/dev/geocoder/docker-compose.yml index 19fb23a..9c520d4 100644 --- a/dev/geocoder/docker-compose.yml +++ b/dev/geocoder/docker-compose.yml @@ -1,4 +1,9 @@ -version: "3" +version: "3.8" + +networks: + kommonitor: + name: kommonitor + driver: bridge services: nominatim: @@ -15,6 +20,7 @@ services: NOMINATIM_PASSWORD: admin volumes: - nominatim-data:/var/lib/postgresql/14/main + shm_size: 1gb healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/status"] @@ -34,6 +40,10 @@ services: depends_on: nominatim: condition: service_healthy + volumes: + - ../../config/openapi.yaml:/code/api/openapi.yaml + networks: + - kommonitor volumes: nominatim-data: diff --git a/prod/geocoder/docker-compose.yml b/prod/geocoder/docker-compose.yml index 8f02ca2..eef4efe 100644 --- a/prod/geocoder/docker-compose.yml +++ b/prod/geocoder/docker-compose.yml @@ -1,6 +1,12 @@ version: "3" +networks: + kommonitor: + name: kommonitor + driver: bridge + services: + nominatim: container_name: nominatim image: mediagis/nominatim:4.4 @@ -34,6 +40,11 @@ services: depends_on: nominatim: condition: service_healthy + volumes: + - ../../config/openapi.yaml:/code/api/openapi.yaml + + networks: + - kommonitor volumes: nominatim-data: diff --git a/prod/nginx/docker-compose.yml b/prod/nginx/docker-compose.yml index cc6cedd..1562dae 100644 --- a/prod/nginx/docker-compose.yml +++ b/prod/nginx/docker-compose.yml @@ -24,5 +24,6 @@ services: - IMPORTER=kommonitor-importer:8087 - DATA_MANAGEMENT=kommonitor-data-management:8085 - SPATIAL_DATA_PROCESSOR=kommonitor-spatial-data-processor:8090 + - GEOCODER_PROXY=kommonitor-geocoder-proxy:8092 networks: - kommonitor \ No newline at end of file diff --git a/prod/nginx/templates/default.conf.template b/prod/nginx/templates/default.conf.template index e43a58f..6b86c4f 100644 --- a/prod/nginx/templates/default.conf.template +++ b/prod/nginx/templates/default.conf.template @@ -16,6 +16,9 @@ upstream data-management { upstream spatial-data-processor { server ${SPATIAL_DATA_PROCESSOR}; } +upstream geocoder-proxy { + server ${GEOCODER_PROXY}; +} server { listen ${NGINX_PORT} ssl; @@ -48,6 +51,9 @@ server { location /kommonitor/api/processor/ { proxy_pass http://spatial-data-processor/; } + location /kommonitor/api/geocoderproxy/ { + proxy_pass http://geocoder-proxy/; + } } location /kommonitor/ {