My application is backed by PostGIS. There is a particular set of tables which have one of their columns being a geographic polygon. They are relatively small in size (few thousand rows) and can easily fit in memory. They do not change that frequently so I am thinking of caching them in memory and refreshing them every few hours in case there is a change.
The queries I will be getting is to find the polygon that contains a specific point. I might also need to get the closest polygon to the specific point (typically if it does not fall within any of the polygons in that specific table).
Is there a Java API that supports this functionality in memory? It will need to support the conventional geo indexes for fast lookup of these two queries I need to use. A lot of the Java GIS APIs I've seen seem to be backed by either Shape files or a database, so not really what I need, since I can already do that.
I was looking at this R-tree implementation: https://github.com/davidmoten/rtree But for some reason it feels too low level.
On a separate question, I read this API is also possible to use, but it uses a quad-tree implementation: https://github.com/Esri/geometry-api-java
Apparently a quad-tree is more complicated (requires tile sizing configuration and similar fine-tuning parameters) and generally performs worse than an R-Tree. http://www.dpi.inpe.br/livros/bdados/artigos/oracle_r_tree.pdf
I was wondering if there is something which operates at a higher level, which supports the queries to get polygons that contain a point, and get closest polygon to a point, that is efficient.
Further search after a hint from one of the answers led me to GeoTools, which from the documentation seems quite comprehensive, which will probably be the first one to try out.