Geocoding service
This bundle provides a store for accessing the service for geocoding addresses and geonames by the Bundesamt für Kartographie und Geodäsie (BKG).
It works in combination with both the omnisearch
and the search-ui
bundles.
By clicking on a suggestion, the map zooms to the according location.
Activating the service
To get access to the geocoding service, you are required to obtain an activation key or an application key.
We recommend to use an application key in favor of an activation key. The application key is used to generate a temporary session ID which is then appended to the geocoding requests coming from the clients. The application key is not publicly visible. In contrast, the activation key can be read by everyone who accesses your web app. For more information, see the article on the BKG website. |
To obtain a key, please contact:
Configuration
For security reasons, we recommend to use an application key in favor of an activation key.
Activation key
After you completed the activation process, configure the app with the service URL you received (containing a unique activation key).
Open the map.apps application.properties
file and add the following parameter:
geocoding.service.url=https://sg.geodatenzentrum.de/gdz_ortssuche__[yourKey]
Application key (recommended way)
Install the backend component that ships with map.apps SDI. It connects to the BKG service to obtain a temporary session ID that is only valid for a limited period of time.
The backend component contains a filter servlet for map.apps that replaces the bkg.session.key
variable inside an app.json
file with a valid BKG session key.
Installation
-
Copy the file
bkg-geocoder/ct-sdi-extension-bkg-<version>.jar
to thelib
folder inside the map.apps webapp. -
Inside the map.apps webapp, edit
WEB-INF\classes\spring-filter-config.xml
and add the newbean
element right before theref
element for thepropertiesReplacementFilter
:<bean id="FilterChain" class="de.conterra.rest.support.filter.ChainingFilter"> <description>javax.servlet FilterChain used to process non jax-rs resources</description> <property name="filters"> <list> ... <!-- Start --> <bean class="de.conterra.sdiextension.bkg.filter.SessionKeyFilter" p:acceptPath="**/app.json"> <constructor-arg index="0" value="${bkg.session.key.url}"/> </bean> <!-- End --> <ref bean="propertiesReplacementFilter"/> ... </list> </property> </bean>
-
Open the map.apps
application.properties
file and add the following parameter:bkg.session.key.url=https://sg.geodatenzentrum.de/gdz_getSession?bkg_appid=<your_api_key>&domain=<your_domain>
In the URL replace
<your_api_key>
and<your_domain>
with the values you obtained from the BKG after registering for the service. -
Restart the Tomcat server.
-
In your
app.json
files, use the placeholder@@bkg.session.key@@
where the session key should be inserted:{ "sdi_geocodingservice": { "GeoCodingStore": { "url": "https://sg.geodatenzentrum.de/gdz_ortssuche__@@bkg.session.key@@" } } }