001package ca.bc.webarts.tools; 002 003import java.io.IOException; 004import org.geotools.geometry.jts.JTS; 005import org.geotools.referencing.crs.DefaultGeographicCRS; 006import org.opengis.referencing.operation.TransformException; 007import com.vividsolutions.jts.geom.Coordinate; 008public class GisDistance 009{ 010 public static void main( String[] args ) 011 { 012 Coordinate coord1 = new Coordinate(4.47, 51.92 ); 013 Coordinate coord2 = new Coordinate(4.86, 52.38 ); 014 015 try 016 { 017 // create a WGS CRS 018 DefaultGeographicCRS crs = new DefaultGeographicCRS(DefaultGeographicCRS.WGS84); 019 double distance = JTS.orthodromicDistance( coord1, coord2, crs ); 020 System.out.println( "The Distance : " + distance ); 021 } 022 catch ( TransformException e ) 023 { 024 System.err.println( e ); 025 } 026 } 027}