GisFeatureGeography implements DistanceCalculator<GisFeatureGeography> { public double distance(GisFeatureGeography o, Unit<Length> unit) { Unit<Length> targetUnit = (unit != null) ? unit : SI.METER; com.vividsolutions.jts.geom.Geometry me = location; com.vividsolutions.jts.geom.Geometry other = o.getLocation(); try { return SI.METER.getConverterTo(targetUnit).convert(JTS.orthodromicDistance(me.getCoordinate(), other.getCoordinate(), DefaultGeographicCRS.WGS84)); } catch (TransformException e) { throw new RuntimeException(e); } } private  GisFeatureGeography(); static GisFeatureGeography gisFeatureGeography(final Double longitude, final Double latitude); static GisFeatureGeography gisFeatureGeography(final Point location); GisFeatureGeography withLocation(final Point location); GisFeatureGeography withElevation(final Long elevation); GisFeatureGeography withGtopo30AverageElevation(final Long gtopo30AverageElevation); GisFeatureGeography withPopulation(final Long population); GisFeatureGeography withTimeZone(final DateTimeZone timeZone); @Override int hashCode(); @Override boolean equals(Object obj); Long getElevation(); Long getGtopo30AverageElevation(); Point getLocation(); double getLatitude(); double getLongitude(); Long getPopulation(); DateTimeZone getTimeZone(); double distance(GisFeatureGeography o, Unit<Length> unit); @Override String toString();  }
@Test public void shouldCalculateDistanceInMile() { Assert.assertTrue(losAngelesPplGisFeatureGeography().distance(marinaDelReyPplGisFeatureGeography(), NonSI.MILE) > 12d && marinaDelReyPplGisFeatureGeography().distance(losAngelesPplGisFeatureGeography(), NonSI.MILE) < 14d); }
@Test public void shouldCalculateDistanceInDefaultUnit() { Assert.assertTrue(losAngelesPplGisFeatureGeography().distance(marinaDelReyPplGisFeatureGeography(), null) > 20000d && marinaDelReyPplGisFeatureGeography().distance(losAngelesPplGisFeatureGeography(), null) < 22000d); }
@Test public void shouldCalculateDistanceInMeter() { Assert.assertTrue(losAngelesPplGisFeatureGeography().distance(marinaDelReyPplGisFeatureGeography(), SI.METER) > 20000d && marinaDelReyPplGisFeatureGeography().distance(losAngelesPplGisFeatureGeography(), SI.METER) < 22000d); }