Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java @ 806:2cea76f1112e
Added Javadoc in utils package.
gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 08 Apr 2010 13:10:39 +0000 |
parents | 9a828e5a2390 |
children | 05bf8534a35a |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java Thu Apr 08 11:31:44 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java Thu Apr 08 13:10:39 2010 +0000 @@ -37,6 +37,11 @@ import org.apache.log4j.Logger; +/** + * A helper class which supports some useful methods to work with wkt strings. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ public abstract class WKTUtils { private static Logger log = Logger.getLogger(WKTUtils.class); @@ -59,6 +64,14 @@ public static final String DEFAULT_COORDINATE_TEMPLATE = "{0}\u00b0N {1}'' {2}\u00b0E {3}''"; + /** + * Checks the difference of two <code>Result</code>s. + * + * @param a A Result. + * @param b Another Result. + * @param indices Indices to be checked. + * @return true, if <i>a</i> and <i>b</i> are different - otherwise false. + */ public static boolean different(Result a, Result b, int [] indices) { for (int i = 0; i < indices.length; ++i) { String oa = a.getString(indices[i]); @@ -79,6 +92,12 @@ return false; } + /** + * Turns a wkt string into a coordinate. + * + * @param shape A wkt string. + * @return wkt string as coordinate. + */ public static Coordinate toCoordinate(String shape) { try { return shape != null @@ -94,6 +113,12 @@ return null; } + /** + * Turns a wkt string into a polygon. + * + * @param shape A wkt string. + * @return wkt string as polygon. + */ public static Polygon toPolygon(String shape) { try { return (Polygon)new WKTReader().read(shape); @@ -107,11 +132,23 @@ return null; } + /** + * Returns a distance in km. + * + * @param distance A distance. + * @return distance in km. + */ public static final double toKM(double distance) { return (distance * NAUTICAL_MILE) / KILOMETER; } + /** + * Turns a coordinate into a wkt string. + * + * @param coordinate A coordinate. + * @return the coordinate as wkt string. + */ public static String toWKT(Coordinate coordinate) { StringBuilder sb = new StringBuilder("POINT("); sb.append(coordinate.x) @@ -121,6 +158,7 @@ return sb.toString(); } + public static final String indexBox( java.awt.Point a, java.awt.Point b, @@ -360,18 +398,46 @@ return null; } + /** + * Turns a wkt coordinate into a string format using the default locale of + * the virtual machine. + * + * @param wkt A wkt coordinate. + * @return A formatted coordinate. + */ public static String toText(String wkt) { return toText(Locale.getDefault(), wkt); } + /** + * Turns a point into a string format using the default locale of the + * virtual machine. + * + * @param p A point. + * @return A point formatted as string. + */ public static String toText(Point p) { return toText(Locale.getDefault(), toWKT(p.getCoordinate())); } + /** + * Turns a point into a string format using a given locale. + * + * @param locale A locale. + * @param p A point. + * @return a point formatted as string. + */ public static String toText(Locale locale, Point p) { return toText(locale, toWKT(p.getCoordinate())); } + /** + * Turns a wkt coordiante into a formatted text using a given locale. + * + * @param locale A locale. + * @param wkt A wkt coordinate. + * @return a formatted coordinate. + */ public static String toText(Locale locale, String wkt) { String formattedCoordinate = null; try { @@ -428,3 +494,4 @@ return null; } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file