问题
I'm looking for a Java library that is capable of performing spatial calculations on sets of lat/lon data. Here are some of the functions that I'm looking for:
- Calculate the Great Circle distance between two points
- Determine if a point lies within a simple closed polygon, where the polygon is defined by an ordered list of points
- Determine if the line between point "A" and point "B" intersects a simple closed polygon, where the polygon is defined by an ordered list of points
- Determine if point "A" is within a certain radius of point "B"
What I'm NOT looking for:
- I don't want a library that is dependent upon a database geospatial component, such as Oracle Spatial, and cannot function independently.
- I don't want a library whose purpose is to generate graphics/maps/etc. I am building an analysis module for an existing application and the end goal is not to create pretty pictures.
- I don't want a library for searching large amounts of spatial data. If it also happens to do this, that's ok, but I'm not going to use that feature.
The organization is planning to acquire a license for Oracle Spatial eventually (so spatial searching will be covered at that point), but for now I need to implement the analysis functions that I have mentioned above on small data sets without relying on database-supplied spatial support.
回答1:
I believe GeoTools would satisfy your requirements. Note that it does have facilities for doing graphics/maps, but they can be left unused easily enough.
回答2:
There is a new library Spatial4J that seems to fullfill your needs, it supports various spaces and shapes
Spatial4j is a general purpose spatial / geospatial ASL licensed open-source Java library (...)
I haven't used it so far but the README
is complete, and repositery is rather popular, and it's available on maven repositery
I was looking for such spatial library when I end up both on the repo and on this question.
回答3:
Simplelatlng gives more simple API for this:
https://code.google.com/p/simplelatlng/wiki/GettingStarted
回答4:
In spite of your desire to avoid a library that is used to draw maps, I'd recommend OpenMap. The com.bbn.openmap.geo package of that library does most if not all of the things you are asking for.
回答5:
I've used STRtree java class to index by lat lng data and distance queries https://locationtech.github.io/jts/javadoc/org/locationtech/jts/index/strtree/STRtree.html
来源:https://stackoverflow.com/questions/3877792/need-a-standalone-java-library-for-performing-spatial-calculations-on-lat-lon-da