@Override public boolean equals( Geometry geometry ) { if ( !( geometry instanceof Point ) ) { return false; } double[] coordinates = ( (Point) geometry ).getAsArray(); if ( coordinates.length != this.coordinates.length ) { return false; } for ( int i = 0; i < coordinates.length; i++ ) { if ( !( coordinates[i] == this.coordinates[i] ) ) { return false; } } return true; }
@Override public void setOrdinate( int index, int ordinateIndex, double value ) { double[] coords = points.get( index ).getAsArray(); if ( coords.length > ordinateIndex && ordinateIndex >= 0 ) coords[ordinateIndex] = value; else throw new IndexOutOfBoundsException(); }
@Override public Point getCentroid() { if ( centroid == null ) { double[] coordinates = new double[max.getAsArray().length]; for ( int i = 0; i < coordinates.length; i++ ) { coordinates[i] = min.getAsArray()[i] + ( max.getAsArray()[i] - min.getAsArray()[i] ) / 2d; } centroid = new DefaultPoint( null, getCoordinateSystem(), getPrecision(), coordinates ); } return centroid; }
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] ); }
@Override public double[] getAsArray() { return getReferencedObject().getAsArray(); }
@Override public double[] getUpper() { return value.getMax().getAsArray(); }
@Override public double[] getLower() { return value.getMin().getAsArray(); }
@Override public float[] getModelBBox() { if ( modelBBox == null ) { modelBBox = new float[6]; double[] min = bbox.getMin().getAsArray(); double[] max = bbox.getMax().getAsArray(); modelBBox[0] = (float) min[0]; modelBBox[1] = (float) min[1]; modelBBox[2] = (float) min[2]; modelBBox[3] = (float) max[0]; modelBBox[4] = (float) max[1]; modelBBox[5] = (float) max[2]; } return modelBBox; } }
/** * @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 ); } }
/** * @param crs */ public void setCoordinateSystem( ICRS crs ) { this.crs = crs; bbox = fac.createEnvelope( bbox.getMin().getAsArray(), bbox.getMax().getAsArray(), crs ); }
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 void exportAsPos( Point point ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( gmlNs, "pos" ); double[] ordinates = getTransformedCoordinate( point.getCoordinateSystem(), point.getAsArray() ); writer.writeCharacters( formatter.format( ordinates[0] ) ); for ( int i = 1; i < ordinates.length; i++ ) { writer.writeCharacters( " " + formatter.format( ordinates[i] ) ); } writer.writeEndElement(); }
private final String encodePropValue( Envelope env ) { if ( env == null ) { return ""; } StringBuilder sb = new StringBuilder(); sb.append( env.getCoordinateSystem().getId() ); Point p = env.getMin(); for ( double d : p.getAsArray() ) { sb.append( ',' ); sb.append( d ); } p = env.getMax(); for ( double d : p.getAsArray() ) { sb.append( ',' ); sb.append( d ); } return sb.toString(); } }
@Override public double[] getAsArray() { double[] coords = new double[getDimension() * size()]; int i = 0; for ( Point p : this ) { for ( double coord : p.getAsArray() ) { coords[i++] = coord; } } return coords; }
private void exportCubicSpline( CubicSpline cubicSpline ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( "gml", "CubicSpline", gmlNs ); writer.writeAttribute( "interpolation", "cubicSpline" ); int dim = cubicSpline.getCoordinateDimension(); export( cubicSpline.getControlPoints(), dim ); writer.writeStartElement( "gml", "vectorAtStart", gmlNs ); double[] array = cubicSpline.getVectorAtStart().getAsArray(); for ( int i = 0; i < array.length; i++ ) { writer.writeCharacters( String.valueOf( array[i] ) + " " ); } writer.writeEndElement(); writer.writeStartElement( "gml", "vectorAtEnd", gmlNs ); array = cubicSpline.getVectorAtEnd().getAsArray(); for ( int i = 0; i < array.length; i++ ) writer.writeCharacters( String.valueOf( array[i] ) + " " ); writer.writeEndElement(); writer.writeEndElement(); }
@Override public double[] getAsArray() { double[] coords = new double[getDimension() * size()]; int i = 0; for ( Point p : this ) { for ( double coord : p.getAsArray() ) { coords[i++] = coord; } } return coords; }
@Override public double[] getAsArray() { double[] coords = new double[getDimension() * size()]; int i = 0; for ( Point p : this ) { for ( double coord : p.getAsArray() ) { coords[i++] = coord; } } return coords; }
@Override public double[] getAsArray() { double[] coords = new double[getDimension() * size()]; int i = 0; for ( Point p : this ) { for ( double coord : p.getAsArray() ) { coords[i++] = coord; } } return coords; }
@Override public double[] getAsArray() { double[] coords = new double[getDimension() * ( size() - startIdx )]; int i = 0; int j = 0; for ( Point p : this ) { if ( i++ >= startIdx ) { for ( double coord : p.getAsArray() ) { coords[j++] = coord; } } } return coords; }
private void exportCoord( Point point ) throws XMLStreamException, TransformationException, UnknownCRSException { double[] ords = getTransformedCoordinate( point.getCoordinateSystem(), point.getAsArray() ); writer.writeStartElement( "gml", "coord", GML21NS ); writer.writeStartElement( "gml", "X", GML21NS ); writer.writeCharacters( formatter.format( ords[0] ) ); writer.writeEndElement(); if ( ords.length > 1 ) { writer.writeStartElement( "gml", "Y", GML21NS ); writer.writeCharacters( formatter.format( ords[1] ) ); writer.writeEndElement(); if ( ords.length > 2 ) { writer.writeStartElement( "gml", "Z", GML21NS ); writer.writeCharacters( formatter.format( ords[2] ) ); writer.writeEndElement(); } } writer.writeEndElement(); // </gml:coord> }