Java Code Examples for com.vividsolutions.jts.geom.Geometry#equalsExact()

The following examples show how to use com.vividsolutions.jts.geom.Geometry#equalsExact() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvalidHoleRemoverTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void checkEqual(Geometry expected, Geometry actual) {
  Geometry actualNorm = actual.norm();
  boolean equal = actualNorm.equalsExact(expected.norm());
  if (! equal) {
    System.out.println("FAIL - Expected = " + expected
        + " actual = " + actual.norm());
  }
  assertTrue(equal);
}
 
Example 2
Source File: SmallHoleRemoverTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void checkEqual(Geometry expected, Geometry actual) {
  Geometry actualNorm = actual.norm();
  boolean equal = actualNorm.equalsExact(expected.norm());
  if (! equal) {
    System.out.println("FAIL - Expected = " + expected
        + " actual = " + actual.norm());
  }
  assertTrue(equal);
}
 
Example 3
Source File: GeometryResult.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean equals(Result other, double tolerance) {
  if (!(other instanceof GeometryResult)) {
    return false;
  }
  GeometryResult otherGeometryResult = (GeometryResult) other;
  Geometry otherGeometry = otherGeometryResult.geometry;

  Geometry thisGeometryClone = geometry.copy();
  Geometry otherGeometryClone = otherGeometry.copy();
  thisGeometryClone.normalize();
  otherGeometryClone.normalize();
  return thisGeometryClone.equalsExact(otherGeometryClone, tolerance);
}
 
Example 4
Source File: TestFileGeometryExtractor.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void add(Geometry geometry, ArrayList geometries) {
  if (geometry == null) { return; }
  for (Iterator i = geometries.iterator(); i.hasNext(); ) {
    Geometry existingGeometry = (Geometry) i.next();
    if (geometry.equalsExact(existingGeometry)) { return; }
  }
  geometries.add(geometry);
}
 
Example 5
Source File: LineMergerTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static boolean contains(Collection geometries, Geometry g, boolean exact) {
  for (Iterator i = geometries.iterator(); i.hasNext();) {
    Geometry element = (Geometry) i.next();
    if (exact && element.equalsExact(g)) {
      return true;
    }
    if (!exact && element.equalsTopo(g)) {
      return true;
    }      
  }

  return false;
}
 
Example 6
Source File: GeometryOperationValidator.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void testExpectedResult()
    throws Exception
{
  if (wktExpected == null) return;
  Geometry expectedGeom = rdr.read(wktExpected);
  boolean isEqual = expectedGeom.equalsExact(ioGeometry[1]);
  if (! isEqual) {
    System.out.println("Result not expected: " + ioGeometry[1]);
  }
  Assert.assertTrue("Expected result not found",isEqual);

}
 
Example 7
Source File: AffineTransformationTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
void checkTransformation(String geomStr) throws IOException, ParseException,
    NoninvertibleTransformationException {
  Geometry geom = rdr.read(geomStr);
  AffineTransformation trans = AffineTransformation
      .rotationInstance(Math.PI / 2);
  AffineTransformation inv = trans.getInverse();
  Geometry transGeom = geom.copy();
  transGeom.apply(trans);
  // System.out.println(transGeom);
  transGeom.apply(inv);
  // check if transformed geometry is equal to original
  boolean isEqual = geom.equalsExact(transGeom, 0.0005);
  assertTrue(isEqual);
}
 
Example 8
Source File: AbstractIndexedLineTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void checkExpected(Geometry result, String expected)
{
  Geometry subLine = read(expected);
  boolean isEqual = result.equalsExact(subLine, 1.0e-5);
  if (! isEqual) {
    System.out.println("Computed result is: " + result);
  }
  assertTrue(isEqual);
}
 
Example 9
Source File: GeometryTestCase.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void checkEqual(Geometry expected, Geometry actual) {
  Geometry actualNorm = actual.norm();
  Geometry expectedNorm = expected.norm();
  boolean equal = actualNorm.equalsExact(expectedNorm);
  if (! equal) {
    System.out.println("FAIL - Expected = " + expectedNorm
        + " actual = " + actualNorm );
  }
  assertTrue(equal);
}