Need a standalone Java library for performing spatial calculations on lat/lon data [closed]
Asked Answered
L

5

21

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.

Likely answered 7/10, 2010 at 0:3 Comment(0)
T
12

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.

Tummy answered 7/10, 2010 at 0:7 Comment(2)
I'm setting up GeoTools now. It is somewhat annoying that they can't take a few minutes to fix all the mistakes in their GeoTools Quickstart tutorial page. Not a nice way to entice newcomers. I wasn't using Maven on this project, so I need to set that up also in order to use GeoTools. Not a big deal if the product does what I need.Likely
The GeoTools kit seems to cover all my requirements. The JTS library that is packaged with GeoTools appears to cover all my needs for "point/shape A" interacts with "point/shape B" use cases. The GeoTools GeodeticCalculator class handles Great Circle distance calculations in the getOrthodromicDistance() method. Maven 2 is pretty much required to setup the JAR dependencies, but I'll just have to sell that to the powers-that-be on the project. Thanks for the recommendation!Likely
S
5

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.

Smolder answered 29/11, 2014 at 19:17 Comment(1)
Spatial4J is a poor library in terms of online resources. You have to dig in to the code and try to find what you need. Not fun.Mundt
F
1

Simplelatlng gives more simple API for this:

https://code.google.com/p/simplelatlng/wiki/GettingStarted

Fianna answered 8/2, 2014 at 21:11 Comment(1)
Is this API have polygon methods?Galcha
M
0

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.

Mash answered 7/10, 2010 at 0:7 Comment(0)
G
0

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

Glooming answered 7/9, 2017 at 16:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.