Spatial databases (e.g. Postgresql with PostGis) use algorithms that quickly look up data for a given latitude / longitude information. Since you want to use the Java library and have it in memory, you can look at the H2 Spatial database . I have never used it, so I can not comment on its performance.
Edit: Hm, looking closer to the link I provided, shows that this is a planned function ... Personally, I just used Postgresql / PostGis (with or without Java as the server interface) and ran with it. If your server has enough memory, it will still meet the "in-memory" requirement. Naturally, this does not meet the requirements of the Java library. However, there is JSI that can be used in memory and with Java.
source share