@Override public boolean equals( Value other ) { if ( other instanceof PointValue ) { PointValue pv = (PointValue) other; return Arrays.equals( this.coordinate, pv.coordinate ) && this.getCoordinateReferenceSystem().equals( pv.getCoordinateReferenceSystem() ); } return false; }
@Override public boolean acceptsValue( Value value ) { if ( value == null ) { return false; } if ( value instanceof PointValue ) { PointValue point = (PointValue) value; if ( point.getCoordinateReferenceSystem().equals( crs ) ) { Boolean within = point.withinRange( from, fromInclusive, to, toInclusive ); return within == null ? false : within; } } return false; }
@Override public String newSpatial( CoordinateReferenceSystem crs ) { for ( int i = 0; i < coordinateReferenceSystems.length; i++ ) { if ( coordinateReferenceSystems[i].equals( crs ) ) { int count = counters[i].incrementAndGet(); if ( count > 1 ) { throw new IllegalStateException( "called new on same crs multiple times" ); } break; } } return crs.toString(); } }
public static byte[] encodePointArray( PointValue[] points ) { int dimension = points[0].coordinate().length; CoordinateReferenceSystem crs = points[0].getCoordinateReferenceSystem(); for ( int i = 1; i < points.length; i++ ) { if ( dimension != points[i].coordinate().length ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent dimension. Point " + i + " has a different dimension." ); } if ( !crs.equals( points[i].getCoordinateReferenceSystem() ) ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent CRS. Point " + i + " has a different CRS." ); } } double[] data = new double[points.length * dimension]; for ( int i = 0; i < data.length; i++ ) { data[i] = points[i / dimension].coordinate()[i % dimension]; } GeometryHeader geometryHeader = new GeometryHeader( GeometryType.GEOMETRY_POINT.gtype, dimension, crs ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.GEOMETRY_HEADER_SIZE ); geometryHeader.writeArrayHeaderTo( bytes ); return bytes; }
private static Value calculateDistance( PointValue p1, PointValue p2 ) { if ( p1.getCoordinateReferenceSystem().equals( p2.getCoordinateReferenceSystem() ) ) { return doubleValue( p1.getCoordinateReferenceSystem().getCalculator().distance( p1, p2 ) ); } else { return NO_VALUE; } }
case range: GeometryRangePredicate rangePredicate = (GeometryRangePredicate) predicate; if ( !rangePredicate.crs().equals( spatial.crs ) )
@Override public boolean equals( Value other ) { if ( other instanceof PointValue ) { PointValue pv = (PointValue) other; return Arrays.equals( this.coordinate, pv.coordinate ) && this.getCoordinateReferenceSystem().equals( pv.getCoordinateReferenceSystem() ); } return false; }
@Override public boolean acceptsValue( Value value ) { if ( value == null ) { return false; } if ( value instanceof PointValue ) { PointValue point = (PointValue) value; if ( point.getCoordinateReferenceSystem().equals( crs ) ) { Boolean within = point.withinRange( from, fromInclusive, to, toInclusive ); return within == null ? false : within; } } return false; }
public static byte[] encodePointArray( PointValue[] points ) { int dimension = points[0].coordinate().length; CoordinateReferenceSystem crs = points[0].getCoordinateReferenceSystem(); for ( int i = 1; i < points.length; i++ ) { if ( dimension != points[i].coordinate().length ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent dimension. Point " + i + " has a different dimension." ); } if ( !crs.equals( points[i].getCoordinateReferenceSystem() ) ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent CRS. Point " + i + " has a different CRS." ); } } double[] data = new double[points.length * dimension]; for ( int i = 0; i < data.length; i++ ) { data[i] = points[i / dimension].coordinate()[i % dimension]; } GeometryHeader geometryHeader = new GeometryHeader( GeometryType.GEOMETRY_POINT.gtype, dimension, crs ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.GEOMETRY_HEADER_SIZE ); geometryHeader.writeArrayHeaderTo( bytes ); return bytes; }
private static Value calculateDistance( PointValue p1, PointValue p2 ) { if ( p1.getCoordinateReferenceSystem().equals( p2.getCoordinateReferenceSystem() ) ) { return doubleValue( p1.getCoordinateReferenceSystem().getCalculator().distance( p1, p2 ) ); } else { return NO_VALUE; } }
case range: GeometryRangePredicate rangePredicate = (GeometryRangePredicate) predicate; if ( !rangePredicate.crs().equals( spatial.crs ) )