package com.planetmayo.debrief.satc.util;

import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Polygon;

/** utility class providing geospatial support
 * 
 * @author ian
 *
 */
public class GeoSupport
{
	private static GeometryFactory _factory;

	/** get our geometry factory
	 * 
	 * @return
	 */
	public static GeometryFactory getFactory()
	{
		if(_factory == null)
			_factory = new GeometryFactory();
		
		return _factory;
	}

	public static double m2deg(double metres)
	{
		return metres / 111200d;
	}
	
	public static double deg2m(double degs)
	{
		return degs * 111200d;
	}
	
	public static double kts2MSec(double kts)
	{
		return kts * 0.514444444;
	}
	
	public static double MSec2kts(double m_sec)
	{
		return m_sec / 0.514444444;
	}
}

@@ -71,31 +71,222 @@
 ts.geom.
-GeometryFactory
+Coordinate;%0Aimport com.vividsolutions.jts.geom.Geometry;%0Aimport com.vividsolutions.jts.geom.GeometryFactory;%0Aimport com.vividsolutions.jts.geom.LineString;%0Aimport com.vividsolutions.jts.geom.MultiLineString
 ;%0Aimport
@@ -926,24 +926,24 @@
 e m_sec)%0A%09%7B%0A
-
 %09%09return m_s
@@ -963,10 +963,942 @@
 444;%0A%09%7D%0A
+%09%0A%09public static void writeGeometry(String title, Geometry geo)%0A%09%7B%0A%09%09if(geo == null)%0A%09%09%09return;%0A%09%09%0A%09%09if(geo instanceof LineString)%0A%09%09%7B%0A%09%09%09LineString ring = (LineString) geo;%0A%09%09%09Coordinate%5B%5D coords = ring.getCoordinates();%0A%09%09%09writeGeometry(title, coords);%0A%09%09%7D%0A%09%09else if(geo instanceof Polygon)%0A%09%09%7B%0A%09%09%09Polygon poly = (Polygon) geo;%0A%09%09%09writeGeometry(title + %22 boundary %22 ,poly.getBoundary());%0A%09%09%7D%0A%09%09else if(geo instanceof MultiLineString)%0A%09%09%7B%0A%09%09%09MultiLineString lineS = (MultiLineString) geo;%0A%09%09%09int n = lineS.getNumGeometries();%0A%09%09%09for(int i=0;i%3Cn;i++)%0A%09%09%09%7B%0A%09%09%09%09Geometry thisGeo = lineS.getGeometryN(i);%0A%09%09%09%09writeGeometry(title + %22 geo:%22 + i, thisGeo);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09private static void writeGeometry(String title, Coordinate%5B%5D coords)%0A%09%7B%0A%09%09System.out.println(%22== %22 + title + %22 ==%22);%0A%09%09for (int i = 0; i %3C coords.length; i++)%0A%09%09%7B%0A%09%09%09Coordinate coordinate = coords%5Bi%5D;%0A%09%09%09System.out.println(coordinate.x + %22, %22 + coordinate.y);%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

include utils to output coords