Is there any existing Java library that allows you to quickly, in memory, search for zipcodes (bonus, state and city) from latitude / longitude?

I have seen many so-called reverse geocoding libraries in different languages; it all depends on calling an external provider via REST or some similar method. However, you cannot call a REST provider if you have to process thousands of requests per second.

On the other hand, the problem should be easy to solve - CSV-based databases are available for free with this information. The problem is the time and cost of writing an effective and well-tested implementation of the search in memory compared to downloading or buying an existing one.

I cannot find any details, but I cannot believe that they cannot be. Is there any pre-written library that does this?

This question:

The fastest way to find location (zip, city, state) based on latitude / longitude

became the closest, but essentially indicates how to write a solution, and not something accessible from the shelf. But this requires some kind of library. This problem has a dozen people a day.

+6
source share
1 answer

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.

+3
source

Source: https://habr.com/ru/post/913654/


All Articles