npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

togs

v0.2.1

Published

Trivial OGR-based geocoding server with Nominatim-like inteface

Downloads

11

Readme

togs: a simple feature based geocoder

The name togs stands for trivial OGR-based geocoding server, and togs is just that. It takes a number of OGR readable feature files (ESRI shapefiles, GeoJSONs, etc.) and turns them into Nominatim -like searchable intefaces.

Togs has been built to provide search functionality for planetary maps built with VTS 3D geospatial software stack atop of IAU planetary nomenclature files but it may be readily used with other libraries and tools.

Installation and configuration

To install locally, do:

	$ npm install togs

Now edit the togs configuration file at $(npm root)/togs/conf/togs.conf to include definition of your geocoding interfaces.

Togs comes with an example dataset, a GeoJSON containing a list of power plants in the state of Washington. The corresponding interface is configured as follows:

	[interface.powerplants-wa]
	; path to the dataset
	dataset = ./datasets/GIS_Layer__PowerPlants_WA.geojson

	; property uniquely identifying each feature 
	idProperty = UTILITY_ID

	; properties matching this regexp shall not be indexed  
	searchExclude = ^Latitude|Longitude$

	; templates for some of the response entry values
	class=landuse
	type=industrial
	displayName = {PLANT_NAME}, {UTILITY_NA} ({primary_fu})
	addressRegion = {PLANT_NAME}
	addressState = {UTILITY_NA}

The most important parts of this configuration are the path to the dataset (relative to $(npm root)/togs), the property considered to be feature ID (idProperty) and the template for display name (displayName). In all templates, property names enclosed in braces are expanded to their corresponding values when geocoder response is formed.

Usage

You can start the server as follows:

	$ $(npm root)/.bin/togs

Pointing your browser to

	http://<yourserver:8100>/powerplants-wa?q=wind&format=json&limit=1

will give you the following output:

    [
    	{
            "lon": -120.75305600043436,
            "lat": 47.13916700003981,
            "boundingbox": [
                47.13916700003981,
                47.13916700003981,
                -120.75305600043436,
                -120.75305600043436
            ],
            "display_name": "Swauk Wind LLC, Gamesa Wind US LLC (WND)",
            "class": "landuse",
            "type": "industrial",
            "importance": 1,
            "icon": null,
            "address": {
                "region": "Swauk Wind LLC",
                "state": "Gamesa Wind US LLC"
            },
            "place_id": null,
            "osm_type": null,
            "licence": null,
            "osm_id": null
        }
    ]

Limitations

Nominatim geocoding interface is OSM specific. Togs input files are not OSM, thus togs can only mimic Nominatim output format: place_id, osm_type and osm_id are all set to null in togs output.

Togs relies on elasticlunr for in-memory indexing and stores every dataset in memory in its entirety. It won't scale to very large datasets.

Currently, JSON is the only supported output format, though adding support for XML is probably trivial.

Development

    $ git clone https://github.com/melown/togs.git
    $ npm install
    $ node bin/togs