/** * @return the northing (y) value of the origin. */ public double getOriginNorthing() { return getOrigin()[1 - eastingAxis]; }
/** * Returns new RasterGeoReference with the origin set to the min[0],max[1] of the envelope but other values are * taken from this instance. Attention, the resulting origin is snapped to the location (center/outer) of the * underlying grid, so the min[0] and max[1] values are only approximations to the new origin! * * @param envelope * to get the origin from. * @return new RasterGeoReference or <code>null</code> if the envelope is <code>null</code> */ public RasterGeoReference createRelocatedReference( Envelope envelope ) { return this.createRelocatedReference( location, envelope ); }
/** * Get intersection of the requested rectangle with the rectangle of the grid file. * * @param original * @return the intersection with the grids raster rectangle and the given. */ protected RasterRect snapToGrid( RasterRect original ) { return RasterRect.intersection( rasterRect, original ); }
/** * Returns new RasterGeoReference with the origin set to the given target location. Other values are taken from this * instance. * * @param targetLocation * of the new reference * @return new RasterGeoReference or this if the target location is <code>null</code> or equals this one. */ public RasterGeoReference createRelocatedReference( OriginLocation targetLocation ) { if ( targetLocation == null || location == targetLocation ) { return this; } double[] newOrigin = getOrigin( targetLocation ); return new RasterGeoReference( targetLocation, this.getResolutionX(), this.getResolutionY(), this.getRotationX(), this.getRotationY(), newOrigin[0], newOrigin[1], this.crs ); }
/** * * @param id * @param level * @param raster */ public MyTile( int id, int level, SimpleRaster raster ) { super( id, level, raster.getEnvelope(), null, null, (float) raster.getRasterReference().getResolutionX(), (float) raster.getRasterReference().getResolutionY(), raster.getRasterReference().getOriginLocation() ); this.raster = raster; }
/** * Returns an Envelope for a raster with given size. * * The calculation considers the origin and resolution of the raster. * * @param targetLocation * of the origin, specifies if the the newly created envelope should consider the origin located at the * OUTER or CENTER of a pixel. * @param width * in raster coordinates * @param height * in raster coordinates * @param crs * the coordinate system for the envelope * * @return the calculated envelope */ public Envelope getEnvelope( OriginLocation targetLocation, int width, int height, ICRS crs ) { return getEnvelope( targetLocation, new RasterRect( 0, 0, width, height ), crs ); }
/** * Returns an Envelope for a raster with given size and given x,y raster location. * * The calculation considers the origin and resolution of the this raster. * * @param rasterRect * defining the x,y raster coordinates (as integers) as well as the width and height of the raster. * @param crs * the coordinate system for the envelope * * @return the calculated envelope */ public Envelope getEnvelope( RasterRect rasterRect, ICRS crs ) { return getEnvelope( location, rasterRect, crs ); }
/** * Returns the size in pixel of a raster that extends within given Envelope. * * @param env * Envelope for the * @return array with width and height of the raster */ public int[] getSize( Envelope env ) { RasterRect rr = convertEnvelopeToRasterCRS( env ); return new int[] { rr.width, rr.height }; }
/** * First get rid of any rounding errors before passing the value to {@link Math#ceil(double)}; * * @param val * to be ceiled * @return the {@link Math#ceil(double)} of the cleaned value. */ private final double ceil( double val ) { val = removeImprecisions( val ); return Math.ceil( val ); }
/** * Extends current RasterReference with rasterReference. Useful for extending the raster, e.g. adding a tile. * * @param rasterReference * The raster envelope to add to the current. */ protected void extendRasterReference( RasterGeoReference rasterReference ) { if ( this.rasterReference == null ) { this.rasterReference = rasterReference; } else { this.rasterReference = RasterGeoReference.merger( this.rasterReference, rasterReference ); } }
/** * Create a Gird for the given grid size and output envelope * * @param width * the width of the grid in pixel * @param height * the height of the grid in pixel * @param depth * the depth of the grid in pixel * @param targetEnvelope * the envelope of the output grid * @return a new grid */ public static Grid fromSize( int width, int height, int depth, Envelope targetEnvelope ) { return new Grid( width, height, depth, targetEnvelope ); }
@Override public boolean equals( Object other ) { if ( other != null && other instanceof DataView ) { final DataView that = (DataView) other; return super.equals( that ) && this.dataInfo.equals( that.dataInfo ); } return false; }
@Override public String toString() { StringBuffer sb = new StringBuffer( 200 ); double[] orig = getOrigin(); sb.append( "{location=" ).append( location ).append( "," ); sb.append( "orig_0=" ).append( orig[0] ).append( "," ); sb.append( "orig_1=" ).append( orig[1] ).append( "," ); sb.append( "xRes=" ).append( getResolutionX() ).append( "," ); sb.append( "yRes=" ).append( getResolutionY() ).append( "," ); sb.append( "xRpt=" ).append( getRotationX() ).append( "," ); sb.append( "yRot=" ).append( getRotationY() ).append( "}" ); return sb.toString(); }
/** * Calculates the envelope for a tile at a given position in the grid. * * @param column * column , must be in the range [0 ... #columns - 1] * @param row * row , must be in the range [0 ... #rows - 1] * @return the tile's envelope */ protected Envelope getTileEnvelope( int column, int row ) { int xOffset = column * tileRasterWidth; int yOffset = row * tileRasterHeight; RasterRect rect = new RasterRect( xOffset, yOffset, tileRasterWidth, tileRasterHeight ); return this.geoRef.getEnvelope( rect, null ); // double xOffset = column * tileWidth; // double yOffset = ( rows - row - 1 ) * tileHeight; // // double minX = envelope.getMin().get0() + xOffset; // double minY = envelope.getMin().get1() + yOffset; // double maxX = minX + tileWidth; // double maxY = minY + tileHeight; // // return geomFac.createEnvelope( minX, minY, maxX, maxY, envelope.getCoordinateSystem() ); }
/** * @return the world coordinate of the origin of the geo referenced raster. */ public double[] getOrigin() { return getOrigin( location ); }
/** * Returns an Envelope for a raster with given size. * * The calculation considers the origin and resolution of the raster. * * @param width * in raster coordinates * @param height * in raster coordinates * @param crs * the coordinate system for the envelope * * @return the calculated envelope */ public Envelope getEnvelope( int width, int height, ICRS crs ) { return getEnvelope( location, width, height, crs ); }
/** * First get rid of any rounding errors before passing the value to {@link Math#floor(double)}; * * @param val * to be floored * @return the {@link Math#floor(double)} of the cleaned value. */ private final double floor( double val ) { val = removeImprecisions( val ); return Math.floor( val ); }
/** * @return the easting (x) value of the origin. */ public double getOriginEasting() { return getOrigin()[eastingAxis]; }
/** * First get rid of any rounding errors before passing the value to {@link Math#round(double)}; * * @param val * to be rounded * @return the {@link Math#round(double)} of the cleaned value. */ private final double round( double val ) { val = removeImprecisions( val ); return Math.round( val ); }