[erlang-questions] Any Erlang GIS software out there?

Anthony Molinaro anthonym@REDACTED
Sun Dec 25 00:02:16 CET 2011

On Tue, Dec 20, 2011 at 06:40:26PM +0100, Benoit Chesneau wrote:
> >
> > Thanks for the pointer, but the trick is the interesting stuff, which
> > AFAIK is not readily available (ie, city bounding box data is not
> > easily available, even country data is not readily available as far
> > as I can tell).  I ended up solving this issue by using a nearest
> > neighbor type of setup, where I had the latitude and longitude of a
> > number of cities (about 60K cities), so created an ets table which
> > I could query using a bounding box around the current latitude and
> > longitude then calculating the distance to all the points in the box
> > and minimizing.  The nice thing about this is its very fast, is very
> > little code and easily fits in memory on a box.
> >
> anything available somewhere that we could see? It sounds interresting.

Not at the moment the data we use is purchased, so the code is not too
useful.  I might try to import some lat/long data from somewhere else and
put it out there at some point.  To describe it in a bit more depth, I have
an ets table with entries {Lat, Lon, Geo}, which is ordered.  Then given a
lat/long pair as input I then do several ets:lookup/2, ets:prev/2, and
ets:next/2 to get all entries within a box around the input (I use a 0.2
degree on a side box).  I tried using a match spec and ets:match but it
ended up being slower than getting the values myself.  Once I have the
list of locations in the box, I use the equirectangular approximation in
a foldl to find the distance to the point nearest the given point.

It's fast (about 0.1 milliseconds on average) with about 60000 entries
in the ets table.

> Someone added knn recently to geocouch:
> https://github.com/tsauerwein/geocouch/commit/512e67111916bfaa1192f6c1229bdf4989d84192

That's interesting, it seems like it uses straight euclidean distance
calculation, so will have bit more error than equirectangular approximation
(which itself has error, but is cheaper than more correct distance
calculations).  However, for knn that probably only matters for points in
the far north or far south.

Anyway, if I ever end with something I can share I will definitely post

Happy Holidays,


Anthony Molinaro                           <anthonym@REDACTED>

More information about the erlang-questions mailing list