Geotrouvetou – Javascript geo finder

For a recent project I make a library in javascript in order to find the nearest geo point given a coordinate (latitude/longitude).

Geotrouvetou, it is the name of this library, work totally separated from a server or a database. Everything happen on a client side. It’s a really small library, only 3kb when minify, and that does the job.

Geotrouvetou must be initialized with a bench of point. For the sample application, I use more than 26 000 geo localized points that are given by the San Francisco open data web site ( related to the crime of the last three months. The library is really fast, here is the output of the sample application.

Welcome to geotrouvetou example
Loading data file
0s 40.114 ms – file loaded
0s 89.722 ms – parsing json
Tree creation
0s 387.768 ms – building tree
26668 points loaded
The app is ready
Enter a location in San Francisco in order to find the nearest crime.
Press Ctrl+Z to close the app
prompt: Latitude: 37.786496
prompt: Longitude: -122.407908
{ latitude: ‘37.7865024401191’,
longitude: ‘-122.407567826112’,
getDirection: [Function],
equals: [Function],
closer: [Function],
[ 26158,
‘100 Block of OFARRELL ST’,
[ null, ‘37.7865024401191’, ‘-122.407567826112’, null, false ] ] }
0s 113.445 ms – found

The library can be used in node.js project (npm i geotrouvetou) or directly in a web site application.

As usual, I choose to publish this library under the MIT License. Everything is available in my github.

Fell free to fork it, use it, improve it and make pull request.

More to follow.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: