OSMNames

From OpenStreetMap Wiki
Jump to navigation Jump to search
OSMNames
OSMNames search for Zurich.png
Authors Klokan Technologies, Geonick and other contributors.
License GPL2
Platforms Windows, Linux, and macOS via Docker
Website http://osmnames.org/
Source code https://github.com/osmnames/osmnames
Programming languages Python and SQL

Fulltext search of OpenStreetMap database


OSMNames is a project offering a downloadable list of place names for fulltext search, which is based on OpenStreetMap database.

Every gazetteer record contains coverage area defined by bounding box, administrative hierarchy, several identifiers, alternative names and rank based on the popularity of related Wikipedia page.

The total size of compressed dump for the whole planet is less than 1.5GB. It contains place as well as street search. Address lookup and POI search may be supported in the future.

Data

Data for the whole planet are available for download on the project page in the Download section.

Data can be extracted for individual countries as well. In that case use command similar to this:

$ zcat planet-latest.tsv.gz | awk -F '\t' -v OFS='\t' 'NR == 1 || $16 == "ch"' > switzerland.tsv

Download defined by bounding box is possible as well:

zcat planet-latest.tsv.gz | awk -F '\t' -v OFS='\t' 'NR == 1 || ($8 > 47.225 && $8 < 47.533 && $7 > 8.275 && $7 < 8.800)' > zurich_switzerland.tsv

Data format details are available on the project download page.

API

OSMNames SphinxSearch, the open-sourced engine, is compatible with Nominatim API.

There is already a system developed by Klokan Technologies you can use. All you need to do is to go MapTiler.com/Cloud/ to get your free key.

The autocomplete is then available through

/q/<query>.js?key=<key>

, which will show you first 20 results.

You can bound your query by country, example below shows 20 results from country specified by its <country_code>

/<country_code>/q/<query>.js?key=<key>

You can easily integrate the autocomplete with your web page using JavaScript:

<html>
  <head>
    <script src="https://osmnames.org/api/v1/autocomplete.js"></script>
    <link href="https://osmnames.org/api/v1/autocomplete.css" rel="stylesheet" />
  </head>
  <body>
    <input autocomplete="off" id="search" type="text" />
    <script>
      var autocomplete = new kt.OsmNamesAutocomplete(
          'search', 'https://search.osmnames.org/', '{API_KEY}');
      // Replace {API_KEY} with your own key

      autocomplete.registerCallback(function(item) {
        alert(JSON.stringify(item, ' ', 2));
      });
    </script>
  </body>
</html>

Development

The project is developed and maintained by OSM community and Klokan Technologies with some support by Hochschule für Technik Rapperswil (represented by User:Geonick).

Source Code

OSMNames is available under free licence (GNU GPL 2).

The source code is available on GitHub: https://github.com/osmnames/osmnames.

Bug reporting

Bug reports, as well as other issues, should be reported through the GitHub repository.