@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((xAxis == null) ? 0 : xAxis.hashCode()); result = prime * result + ((yAxis == null) ? 0 : yAxis.hashCode()); return result; }
@Override public BoundingBox getBoundingBox() { return new BoundingBoxImpl( xAxis.getCoordinateExtent().getLow(), yAxis.getCoordinateExtent().getLow(), xAxis.getCoordinateExtent().getHigh(), yAxis.getCoordinateExtent().getHigh(), crs); }
@Override public boolean contains(HorizontalPosition position) { if (position == null) return false; if (GISUtils.crsMatch(crs, position.getCoordinateReferenceSystem())) { return xAxis.contains(position.getX()) && yAxis.contains(position.getY()); } else { HorizontalPosition transformedPos = GISUtils.transformPosition(position, crs); return xAxis.contains(transformedPos.getX()) && yAxis.contains(transformedPos.getY()); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; RectilinearGridImpl other = (RectilinearGridImpl) obj; if (xAxis == null) { if (other.xAxis != null) return false; } else if (!xAxis.equals(other.xAxis)) return false; if (yAxis == null) { if (other.yAxis != null) return false; } else if (!yAxis.equals(other.yAxis)) return false; return true; }
@Override public GridCoordinates2D findIndexOf(HorizontalPosition position) { int x; int y; if (GISUtils.crsMatch(position.getCoordinateReferenceSystem(), crs)) { x = xAxis.findIndexOf(position.getX()); y = yAxis.findIndexOf(position.getY()); } else { HorizontalPosition gridPos = GISUtils.transformPosition(position, crs); x = xAxis.findIndexOf(gridPos.getX()); y = yAxis.findIndexOf(gridPos.getY()); } if (x >= 0 && y >= 0) { return new GridCoordinates2D(x, y); } else { return null; } }
@Override public Array<GridCell2D> getDomainObjects() { if (domainObjects == null) { domainObjects = new AbstractImmutableArray<GridCell2D>(new int[] {yAxis.size(), xAxis.size()}) { @Override public GridCell2D get(int... coords) { int xIndex = coords[1]; int yIndex = coords[0]; return new GridCell2DImpl( new GridCoordinates2D(xIndex, yIndex), new HorizontalPosition( xAxis.getCoordinateValue(xIndex), yAxis.getCoordinateValue(yIndex), crs), new BoundingBoxImpl( xAxis.getCoordinateBounds(xIndex), yAxis.getCoordinateBounds(yIndex), crs), RectilinearGridImpl.this); } }; } return domainObjects; }
@Override public int getYSize() { return yAxis.size(); }
@Override public int getXSize() { return xAxis.size(); }
@Override public long size() { return xAxis.size() * yAxis.size(); }