/** * Returns a flag indicating if the geometry matches that of the specified grid geometry. The * geometries are considered a match if they contain the same corner points, number of rows and * number of columns. * * @param geometry the geometry to compare. * @return <i>true</i> if geometries match; <i>false</i> if not. */ public boolean matchesGeometry(final GridGeometry2d gridGeometry) { // Check that the number of lines are equal. if (getNumLines() != gridGeometry.getNumLines()) { return false; } // Check each line. int numLines = getNumLines(); for (int i = 0; i < numLines; i++) { // Check that the # of points in each line are equal. CoordinateSeries points1 = getLine(i).getPoints(); CoordinateSeries points2 = gridGeometry.getLine(i).getPoints(); if (points1.getNumPoints() != points2.getNumPoints()) { return false; } // Check that the point x,y coordinates are equal. for (int j = 0; j < points1.getNumPoints(); j++) { if (!MathUtil.isEqual(points1.getX(j), points2.getX(j)) || !MathUtil.isEqual(points1.getY(j), points2.getY(j))) { return false; } } } // The match conditions have been satisfied. return true; }