# Re: [open-location-code] Best way to determine adjacency and overlap?

```Wow - that's really cool Andreas, I can imagine those functions would be
useful to other people too.```
```
Can you / have you open sourced them? I'm happy to provide a link from the
OLC github project.

Doug Rinckes, Technical Program Manager, Google Switzerland GmbH; 9GHJ+P88 Z

On Wed, Nov 15, 2017 at 1:53 PM, Andreas B <andr...@bocops.de> wrote:

> Doug,
>
> those are exactly the functions I'm already using:
>
> *getNeighbors(olc)* - returns 8 codes of the same length as the input for
> "tiles" that are adjacent to it
> *isNeighbor(olcA, olcB)* - returns true iff the "tiles" of olcA and olcB
> share a "side", independent of their code length
> *contains(olcA, olcB)* - returns true iff the "tile" of olcA is contained
> in olcB (= if olcB is a prefix of olcA)
>
> I also played around with distance functions, like
>
> *getDistance(olcA, olcB)* - which, for codes of the same length returns
> the number of same-sized "tiles" inbetween, either as Chebyshev or
> Manhatten distance. This can be useful as an approximation of travel
> distance from one location to another
> *getDirection(olcA, olcB)* - which returns an approximate direction, for
> example in degrees, to get from olcA to olcB
>
> and something like "areas", a structure to hold an arbitrary number of
> "tiles" identified by their OLC, with functionality like
>
> *Area.contains(olc)*
> *Area.contains(otherArea)*
> *Area.getSize()*
> *Area.closestTileTo(olcNotInArea)*
>
> the latter could be useful to answer questions like "Which of the
> (potentially many) subsidiary/branches of a store is closest to my current
> location, how far away is it, and how do I get there?" Obviously, distance
> and direction can also be calculated by using the center lat/lng of a tile,
> so might not be that useful an addition.
>
> --
> Public site: http://www.openlocationcode.com/
> Demo site: http://plus.codes/
> ---
> You received this message because you are subscribed to the Google Groups
> "open-location-code" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> To post to this group, send email to open-location-code@googlegroups.com.
> Visit this group at https://groups.google.com/group/open-location-code.
> To view this discussion on the web, visit https://groups.google.com/d/
> msgid/open-location-code/5f0eb999-830c-423a-a0d1-
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

--
Public site: http://www.openlocationcode.com/
Demo site: http://plus.codes/
---
You received this message because you are subscribed to the Google Groups
"open-location-code" group.
To unsubscribe from this group and stop receiving emails from it, send an email