graphhopper/graphhopper-maps

Could not get geocoding results with geocoder-convertor

Closed this issue · 1 comments

Hello,

I am trying to get graphopper-maps to work with local graphhopper-map, geocode convertor and nominatim, but i am having a problem that i am unable to solve.

Config:

routingApi: 'https://graphoppertest.local.test/',
geocodingApi: 'http://192.168.1.10:8080/nominatim',

Geocoding-convertor is conneted to local nominatim server.

Curl to geocoding-convertor:
curl -X GET "http://192.168.1.10:8080/nominatim?q=Berlin&locale=en"

{"hits":[{"point":{"lat":48.2150228,"lng":16.3709128},"extent":[16.3708628,48.2149728,16.3709628,48.2150728],"name":"Club Berlin, 12, Gonzagagasse, Textilviertel, Innere Stadt, Vienna, 1010, Austria","country":"Austria","city":"Vienna","street":"Gonzagagasse","postcode":"1010","osm_id":1949411509,"osm_type":"N","housenumber":"12","osm_value":"bar","house_number":"12"},{"point":{"lat":47.0763571,"lng":15.496707},"extent":[15.496657,47.0763071,15.496757,47.0764071],"name":"Berlin-Graz, Berliner Ring, Lustbühel, Waltendorf, Graz, Styria, 8047, Austria","country":"Austria","city":"Graz","state":"Styria","street":"Berliner Ring","postcode":"8047","osm_id":6965943583,"osm_type":"N","osm_value":"artwork"},{"point":{"lat":48.3684464,"lng":14.0261276},"extent":[14.0260776,48.3683964,14.0261776,48.3684964],"name":"Red Berlin, 12, Kurzwernhartplatz, Ruprechting, Aschach an der Donau, Bezirk Eferding, Upper Austria, 4082, Austria","country":"Austria","city":"Aschach an der Donau","state":"Upper Austria","county":"Bezirk Eferding","street":"Kurzwernhartplatz","postcode":"4082","osm_id":9802045527,"osm_type":"N","housenumber":"12","osm_value":"cafe","house_number":"12"},{"point":{"lat":47.9765447,"lng":16.8511357},"extent":[16.8510857,47.9764947,16.8511857,47.9765947],"name":"Liebeskind Berlin, 1, Designer-Outlet-Straße, Parndorf/Pandrof, Bezirk Neusiedl am See, Burgenland, 7111, Austria","country":"Austria","city":"Parndorf/Pandrof","state":"Burgenland","county":"Bezirk Neusiedl am See","street":"Designer-Outlet-Straße","postcode":"7111","osm_id":9082209523,"osm_type":"N","housenumber":"1","osm_value":"bag","house_number":"1"}],"locale":"en"}%

Nominatim log

"GET /search?q=Berlin&limit=5&format=json&email=ybo%40gmail.com&addressdetails=1&accept-language=en HTTP/1.1" 200 3335 "-" "graphhopper-geocoder-converter (graphhopper-geocoder-converter)

But graphhopper is allays throwing me an error:

Error:

Could not get geocoding results because: TypeError: NetworkError when attempting to fetch resource.
requestAsync@http://192.168.1.10:3000/bundle.83488de722b6bf099361.js:71298:19

Am i doing something wrong, or it is a bug ? Would appreciate any help.

Hi @K1kc4,
since GH maps is built around the GraphHopper APIs, it also depends on the /geocode endpoint of the GraphHopper Gecoding API. With your config, graphhopper-maps would try to fetch from

http://192.168.1.10:8080/nominatimgeocode?q=...

In the code it is descriped here:

async geocode(query: string, provider: string): Promise<GeocodingResult> {
if (!this.supportsGeocoding())
return {
hits: [],
took: 0,
}
const url = this.getGeocodingURLWithKey('geocode')
url.searchParams.append('q', query)
url.searchParams.append('provider', provider)
const langAndCountry = getTranslation().getLang().split('_')
url.searchParams.append('locale', langAndCountry.length > 0 ? langAndCountry[0] : 'en')
// routing makes not much sense between areas and it is unclear if the center is on a road
url.searchParams.append('osm_tag', '!place:county')
url.searchParams.append('osm_tag', '!boundary')
url.searchParams.append('osm_tag', '!historic')
const response = await fetch(url.toString(), {
headers: { Accept: 'application/json' },
})
if (response.ok) {
return (await response.json()) as GeocodingResult
} else {
throw new Error('Geocoding went wrong ' + response.status)
}
}

private getGeocodingURLWithKey(endpoint: string) {
const url = new URL(this.geocodingApi + endpoint)
url.searchParams.append('key', this.apiKey)
return url
}

I hope that I helped you with this.