I'm looking for a java API, a free one, that provides basic functionality for calculating distances between GPS coordinates. I need the basic getDistance between two points, Points of Interest in a radius around a point.
I've done a bit of research and found on the one hand some options.
On the one hand there is Apache SIS (http://incubator.apache.org/sis/index.html) but this is still under development and might change some. On the other there is GeoTools (http://docs.geotools.org/), but this is rather complex for my needs.
Are there any other easy to use and simpler APIs out there?
One other option would be to simply implement all this myself, I've seen some examples of own implementations, but all of them have some comments of the sort: "this doesn't realy work, it provides a distance that is off by 100 meters". How reliable would such an implementation be?
Using GeoTools and Maven, it should not be too difficult. Maven will take care of the dependencies. And luckily you won't need the whole Geotools suite to do the "headless" calculations.
I hope it's what you're looking for.
The pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.bar</groupId>
<artifactId>geo</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>opengeo</id>
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>9.0</version>
</dependency>
</dependencies>
</project>
The code:
package org.bar;
import org.geotools.referencing.GeodeticCalculator;
import java.awt.geom.Point2D;
/**
* How far is NY from London ?
*/
public class DistanceTest {
public final static void main(final String[] args) {
final GeodeticCalculator calc = new GeodeticCalculator();
final Point2D london = new Point2D.Double(-0.127512, 51.507222);
final Point2D ny = new Point2D.Double(-73.94, 40.67 );
calc.setStartingGeographicPoint(london);
calc.setDestinationGeographicPoint(ny);
System.out.println("Distance London-NY: " + calc.getOrthodromicDistance()/1000 + " kms");
}
}
Did you try http://www.dinopolis.org/gpsylon/. I provides features like :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With