Class OsmGeocoding

java.lang.Object
com.codename1.backend.osm.OsmGeocoding
All Implemented Interfaces:
HttpServer.Handler

public final class OsmGeocoding extends Object implements HttpServer.Handler

Answers place searches and reverse lookups in the shape of Nominatim's JSON API, from the places, addresses and named streets of an extract.

Mounted at a prefix, it answers:

  • GET {prefix}/search?q=...&limit=10: a JSON array of the best matches. Every word of the query must start a word of the place's name or address; case and Latin accents are ignored. limit is capped at 50.
  • GET {prefix}/reverse?lat=...&lon=...: the nearest address or named place within 75 meters, otherwise the nearest street within a kilometre, as one JSON object; {"error": "Unable to geocode"} when there is none.

format may be json or jsonv2 or absent; anything else is a 400. Each result carries place_id, osm_type, osm_id, lat and lon (as strings, as Nominatim writes them), display_name, name, class, type, importance and an address object.

This is a geocoder for the extract's own area, not a replacement for a full Nominatim installation: there is no address interpolation, no administrative hierarchy and no spelling correction.