@Override public double[] getLower() { return value.getMin().getAsArray(); }
private void writeEnvelope( DataOutputStream out, Envelope env ) throws IOException { double[] min = env.getMin().getAsArray(); double[] max = env.getMax().getAsArray(); out.writeDouble( min[0] ); out.writeDouble( min[1] ); out.writeDouble( min[2] ); out.writeDouble( max[0] ); out.writeDouble( max[1] ); out.writeDouble( max[2] ); }
private boolean isDefaultBBox() { Envelope env = getDefaultBBox(); return ( Math.abs( bbox.getSpan0() - env.getSpan0() ) < 1E-11 ) && ( Math.abs( bbox.getSpan1() - env.getSpan1() ) < 1E-11 ) && ( Math.abs( bbox.getMin().get0() - env.getMin().get0() ) < 1E-11 ) && ( Math.abs( bbox.getMin().get1() - env.getMin().get1() ) < 1E-11 ) && ( Math.abs( bbox.getMin().get2() - env.getMin().get2() ) < 1E-11 ); }
private static void exportBbox( AdHocQuery query, Map<String, String> kvp ) { Envelope bbox = ( (BBoxQuery) query ).getBBox(); if ( bbox != null ) { StringBuilder sb = new StringBuilder(); sb.append( DECIMAL_FORMAT.format( bbox.getMin().get0() ) ).append( "," ); sb.append( DECIMAL_FORMAT.format( bbox.getMin().get1() ) ).append( "," ); sb.append( DECIMAL_FORMAT.format( bbox.getMax().get0() ) ).append( "," ); sb.append( DECIMAL_FORMAT.format( bbox.getMax().get1() ) ); if ( bbox.getCoordinateSystem() != null ) sb.append( ',' ).append( bbox.getCoordinateSystem().getName() ); kvp.put( "BBOX", sb.toString() ); } }
private float[] calcOptimalEye( Envelope bBox ) { float[] eye = new float[] { 0, 1, 1 }; if ( bBox != null ) { double[] min = bBox.getMin().getAsArray(); double[] max = bBox.getMax().getAsArray(); double centerX = min[0] + ( ( max[0] - min[0] ) * 0.5f ); double centerY = min[1] + ( ( max[1] - min[1] ) * 0.5f ); // float centerZ = bBox[2] + ( ( bBox[2] - bBox[5] ) * 0.5f ); double eyeZ = 2 * ( ( Math.max( bBox.getSpan0(), bBox.getSpan1() ) / 2 ) / Math.tan( Math.toRadians( fov * 0.5 ) ) ); eye = new float[] { (float) centerX, (float) centerY, (float) eyeZ }; } return eye; }
private static void exportGMLEnvelope( XMLStreamWriter writer, Envelope envelope ) throws XMLStreamException { writer.writeStartElement( GML_NS, "Envelope" ); writer.writeNamespace( GML_PREFIX, GML_NS ); writer.writeAttribute( "srsName", envelope.getCoordinateSystem().getAlias() ); exportGMLPos( writer, envelope.getMin().get0(), envelope.getMin().get1() ); exportGMLPos( writer, envelope.getMax().get0(), envelope.getMax().get1() ); writer.writeEndElement(); // Envelope }
private void render( final BufferedImage img, final Envelope box ) { if ( envelope != null && box != null ) { int minx = 0, miny = 0, maxx = width, maxy = height; minx = round( ( box.getMin().get0() - envelope.getMin().get0() ) / resx ); miny = round( ( box.getMin().get1() - envelope.getMin().get1() ) / resy ); maxx = width - round( ( envelope.getMax().get0() - box.getMax().get0() ) / resx ); maxy = height - round( ( envelope.getMax().get1() - box.getMax().get1() ) / resy ); graphics.drawImage( img, minx, miny, maxx - minx, maxy - miny, null ); } else { graphics.drawImage( img, worldToScreen, null ); } }
/** * * @return the raster reference of this tilefile */ public RasterGeoReference getEnvelope() { // rb: should the axis of the crs not been taken into account? return new RasterGeoReference( location, xRes, yRes, env.getMin().get0(), env.getMax().get1() ); }
public Envelope calcClickBox( int radius ) { radius = parameters.get( "RADIUS" ) == null ? radius : parseInt( parameters.get( "RADIUS" ) ); GeometryFactory fac = new GeometryFactory(); double dw = envelope.getSpan0() / width; double dh = envelope.getSpan1() / height; int r2 = radius / 2; r2 = r2 <= 0 ? 1 : r2; return fac.createEnvelope( new double[] { envelope.getMin().get0() + ( x - r2 ) * dw, envelope.getMax().get1() - ( y + r2 ) * dh }, new double[] { envelope.getMin().get0() + ( x + r2 ) * dw, envelope.getMax().get1() - ( y - r2 ) * dh }, envelope.getCoordinateSystem() ); } }
private void enforceCrs( ICRS crs, Envelope boundingBox ) { boundingBox.getMin().setCoordinateSystem( crs ); boundingBox.getMax().setCoordinateSystem( crs ); boundingBox.setCoordinateSystem( crs ); }
/** * @param crs */ public void setCoordinateSystem( ICRS crs ) { this.crs = crs; if ( envelope != null ) { // rb: this is not correct, the values of the envelope should be converted to the given crs, shouldn't they. this.envelope = geomFactory.createEnvelope( envelope.getMin().getAsArray(), envelope.getMax().getAsArray(), crs ); } }
private static double getEnvDepth( Envelope env ) { double result = Double.NaN; if ( env.getCoordinateDimension() == 3 ) { result = env.getMax().get2() - env.getMin().get2(); } return result; }
/** * @param crs */ public void setCoordinateSystem( ICRS crs ) { this.crs = crs; bbox = fac.createEnvelope( bbox.getMin().getAsArray(), bbox.getMax().getAsArray(), crs ); }
private Polygon calculateClippingArea( final Envelope bbox, final int width ) { double resolution = bbox.getSpan0() / width; double delta = resolution * 100; double[] minCords = new double[] { bbox.getMin().get0() - delta, bbox.getMin().get1() - delta }; double[] maxCords = new double[] { bbox.getMax().get0() + delta, bbox.getMax().get1() + delta }; Point min = new DefaultPoint( null, bbox.getCoordinateSystem(), null, minCords ); Point max = new DefaultPoint( null, bbox.getCoordinateSystem(), null, maxCords ); Envelope enlargedBBox = new DefaultEnvelope( min, max ); return (Polygon) Geometries.getAsGeometry( enlargedBBox ); }
private Envelope copyEnvelope( Envelope envelopeToCopy ) { if ( envelopeToCopy != null ) { Point min = envelopeToCopy.getMin(); Point max = envelopeToCopy.getMax(); ICRS crs = envelopeToCopy.getCoordinateSystem(); return GEOM_FACTORY.createEnvelope( min.get0(), min.get1(), max.get0(), max.get1(), crs ); } return null; }
/** * @return string representation of the envelope */ protected String envelopeString() { String epsg = ""; if ( getEnvelope().getCoordinateSystem() != null ) { epsg = getEnvelope().getCoordinateSystem().getAlias(); } return epsg + " " + getEnvelope().getMin().get0() + " " + getEnvelope().getMin().get1() + " " + getEnvelope().getMax().get0() + " " + getEnvelope().getMax().get1(); }
/** * @param env * @return a polygon */ public static Polygon envelopeToPolygon( Envelope env ) { GeometryFactory fac = new GeometryFactory(); Point a = env.getMin(); Point b = fac.createPoint( null, a.get0() + env.getSpan0(), a.get1(), env.getCoordinateSystem() ); Point c = env.getMax(); Point d = fac.createPoint( null, a.get0(), a.get1() + env.getSpan1(), env.getCoordinateSystem() ); LinearRing ring = fac.createLinearRing( null, env.getCoordinateSystem(), new PointsArray( a, b, c, d, a ) ); return fac.createPolygon( null, env.getCoordinateSystem(), ring, null ); }