@@ -16,6 +16,7 @@ |
import org.apache.tomcat.jdbc.pool.DataSourceProxy; |
import org.apache.tomcat.jdbc.pool.PoolProperties; |
import java.net.URL; |
+import java.util.ArrayList; |
|
/** |
* |
@@ -222,5 +223,105 @@ |
datasourceWQM = null; |
System.out.println("Closed WQM datasource."); |
} |
- } |
+ } |
+ |
+ public static class PolygonLatLon{ |
+ private ArrayList<WQMTools.PolygonLatLon.PointLatLon> points; |
+ private Boolean bValid; |
+ |
+ public PolygonLatLon(){ |
+ this.bValid = true; |
+ this.points = new ArrayList<>(); |
+ } |
+ |
+ public PolygonLatLon( ArrayList<WQMTools.PolygonLatLon.PointLatLon> tPoints ){ |
+ if ( null != tPoints ){ |
+ this.bValid = true; |
+ this.points = new ArrayList<>( tPoints ); |
+ for ( WQMTools.PolygonLatLon.PointLatLon tPoint : tPoints ){ |
+ if ( !tPoint.isValid() ){ |
+ this.bValid = false; |
+ break; |
+ } |
+ } |
+ } |
+ } |
+ |
+ public void add( WQMTools.PolygonLatLon.PointLatLon tPoint ){ |
+ this.points.add( tPoint ); |
+ if ( !tPoint.isValid() ){ |
+ this.bValid = false; |
+ } |
+ } |
+ |
+ public void add( Double Lat, Double Lon ){ |
+ WQMTools.PolygonLatLon.PointLatLon tPoint = new WQMTools.PolygonLatLon.PointLatLon( Lat, Lon ); |
+ this.points.add( tPoint ); |
+ if ( !tPoint.isValid() ){ |
+ this.bValid = false; |
+ } |
+ } |
+ |
+ public String toWKT(){ |
+ String ret_val = "'POLYGON(("; |
+ int currentPoint = 0; |
+ if ( this.bValid ){ |
+ for ( WQMTools.PolygonLatLon.PointLatLon tPoint : this.points ){ |
+ if ( currentPoint > 0 ){ |
+ ret_val += ", "; |
+ } |
+ // Remember Lon is X and Lat is Y... |
+ ret_val += tPoint.getLon().toString() + " " + tPoint.getLat().toString(); |
+ currentPoint++; |
+ } |
+ |
+ ret_val += "))'"; |
+ } |
+ else{ |
+ ret_val = ""; |
+ } |
+ |
+ return ret_val; |
+ } |
+ |
+ public Boolean isValid(){return this.bValid;} |
+ |
+ public static class PointLatLon{ |
+ private Double Lat; |
+ private Double Lon; |
+ private Boolean bValid; |
+ |
+ public PointLatLon( Double Lat, Double Lon ){ |
+ this.Lat = Lat; |
+ this.Lon = Lon; |
+ this.bValid = true; |
+ |
+ if ( Math.abs( Lon ) > 180 ){ |
+ this.bValid = false; |
+ } |
+ |
+ if ( Math.abs( Lat ) > 90 ){ |
+ this.bValid = false; |
+ } |
+ } |
+ |
+ public Boolean isValid(){return this.bValid;} |
+ public Double getLat(){return this.Lat;} |
+ public Double getLon(){return this.Lon;} |
+ |
+ public void setLon( Double Lon ){ |
+ this.Lon = Lon; |
+ if ( Math.abs( Lon ) > 180 ){ |
+ this.bValid = false; |
+ } |
+ } |
+ |
+ public void setLat( Double Lat ){ |
+ this.Lat = Lat; |
+ if ( Math.abs( Lat ) > 90 ){ |
+ this.bValid = false; |
+ } |
+ } |
+ } |
+ } |
} |