com.vividsolutions.jts.geom.Geometry.equalsExact()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.vividsolutions.jts.geom.Geometry.equalsExact()方法的一些代码示例,展示了Geometry.equalsExact()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.equalsExact()方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:equalsExact

Geometry.equalsExact介绍

[英]Returns true if the two Geometrys are exactly equal. Two Geometries are exactly equal iff:

  • they have the same structure
  • they have the same values for their vertices, in exactly the same order.
    This provides a stricter test of equality than #equalsTopo(Geometry), which is more useful in certain situations (such as using geometries as keys in collections).

This method does not test the values of the GeometryFactory, the SRID, or the userData fields.

To properly test equality between different geometries, it is usually necessary to #normalize() them first.
[中]如果两个Geometry完全相等,则返回true。两个几何体完全相等:
*它们具有相同的结构
*它们的顶点具有相同的值,顺序完全相同。
这提供了比#equalsTopo(几何体)更严格的相等性测试,它在某些情况下更有用(例如将几何体用作集合中的键)。
此方法不测试GeometryFactorySRIDuserData字段的值。
为了正确测试不同几何体之间的相等性,通常需要首先对它们进行#规格化()。

代码示例

代码示例来源:origin: com.vividsolutions/jts

/**
 * Returns true if the two <code>Geometry</code>s are exactly equal.
 * Two Geometries are exactly equal iff:
 * <ul>
 * <li>they have the same structure
 * <li>they have the same values for their vertices,
 * in exactly the same order.
 * </ul>
 * This provides a stricter test of equality than
 * {@link #equalsTopo(Geometry)}, which is more useful
 * in certain situations
 * (such as using geometries as keys in collections).
 * <p>
 * This method does <i>not</i>
 * test the values of the <code>GeometryFactory</code>, the <code>SRID</code>, 
 * or the <code>userData</code> fields.
 * <p>
 * To properly test equality between different geometries,
 * it is usually necessary to {@link #normalize()} them first.
 *
 *@param  other  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return <code>true</code> if this and the other <code>Geometry</code>
 *      have identical structure and point values.
 *      
 * @see #equalsExact(Geometry, double)
 * @see #normalize()
 * @see #norm()
 */
public boolean equalsExact(Geometry other) { return equalsExact(other, 0); }

代码示例来源:origin: com.vividsolutions/jts

return equalsExact(g);

代码示例来源:origin: com.vividsolutions/jts

public boolean equalsExact(Geometry other, double tolerance) {
 if (!isEquivalentClass(other)) {
  return false;
 }
 Polygon otherPolygon = (Polygon) other;
 Geometry thisShell = shell;
 Geometry otherPolygonShell = otherPolygon.shell;
 if (!thisShell.equalsExact(otherPolygonShell, tolerance)) {
  return false;
 }
 if (holes.length != otherPolygon.holes.length) {
  return false;
 }
 for (int i = 0; i < holes.length; i++) {
  if (!((Geometry) holes[i]).equalsExact(otherPolygon.holes[i], tolerance)) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: com.vividsolutions/jts

public boolean equalsExact(Geometry other, double tolerance) {
 if (!isEquivalentClass(other)) {
  return false;
 }
 GeometryCollection otherCollection = (GeometryCollection) other;
 if (geometries.length != otherCollection.geometries.length) {
  return false;
 }
 for (int i = 0; i < geometries.length; i++) {
  if (!((Geometry) geometries[i]).equalsExact(otherCollection.geometries[i], tolerance)) {
   return false;
  }
 }
 return true;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Tests whether two geometries are exactly equal
 * in their normalized forms.
 * This is a convenience method which creates normalized
 * versions of both geometries before computing
 * {@link #equalsExact(Geometry)}.
 * <p>
 * This method is relatively expensive to compute.  
 * For maximum performance, the client 
 * should instead perform normalization on the individual geometries
 * at an appropriate point during processing.
 * 
 * @param g a Geometry
 * @return true if the input geometries are exactly equal in their normalized form
 */
public boolean equalsNorm(Geometry g)
{
 if (g == null) return false;
 return norm().equalsExact(g.norm());
}

代码示例来源:origin: org.geotools/gt-main

static public boolean equalsExactTolerance(Geometry arg0,Geometry arg1, Double arg2)
{
   if (arg0 == null || arg1 == null || arg2 == null) return false;
   Geometry _this = arg0;
   return _this.equalsExact(arg1,arg2);
}

代码示例来源:origin: org.geotools/gt2-main

static public boolean equalsExact(Geometry arg0,Geometry arg1)
{
   Geometry _this = arg0;
   return _this.equalsExact(arg1);
}

代码示例来源:origin: org.geotools/gt2-main

static public boolean equalsExactTolerance(Geometry arg0,Geometry arg1,double arg2)
{
   Geometry _this = arg0;
   return _this.equalsExact(arg1,arg2);
}

代码示例来源:origin: org.geotools/gt-main

static public boolean equalsExact(Geometry arg0,Geometry arg1)
{
   if (arg0 == null || arg1 == null) return false;
   Geometry _this = arg0;
   return _this.equalsExact(arg1);
}

代码示例来源:origin: org.hibernatespatial/hibernate-spatial

public boolean equals(Object x, Object y) throws HibernateException {
  if (x == y)
    return true;
  if (x == null || y == null)
    return false;
  return ((Geometry) x).equalsExact((Geometry) y);
}

代码示例来源:origin: com.spatial4j/spatial4j

@Override
public boolean equals(Object o) {
 if (this == o) return true;
 if (o == null || getClass() != o.getClass()) return false;
 JtsGeometry that = (JtsGeometry) o;
 return geom.equalsExact(that.geom);//fast equality for normalized geometries
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

private static boolean geomEquals(@Nullable Geometry g1, @Nullable Geometry g2) {
  if (g1 == null || g2 == null) {
    return g1 == null && g2 == null;
  }
  return g1.equalsExact(g2);
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

private boolean geomEquals(@Nullable Geometry g1, @Nullable Geometry g2) {
  if (g1 == null || g2 == null) {
    return g1 == null && g2 == null;
  }
  return g1.equalsExact(g2);
}

代码示例来源:origin: harbby/presto-connectors

@Override
public boolean equals(Object o) {
 if (this == o) return true;
 if (o == null || getClass() != o.getClass()) return false;
 JtsGeometry that = (JtsGeometry) o;
 return geom.equalsExact(that.geom);//fast equality for normalized geometries
}

代码示例来源:origin: org.geotools/gt-main

/**
 * Compares two geometries for equality.
 */
protected void assertEquals(Geometry expected, Geometry actual) {
  if (expected == actual) {
    return;
  }
  assertNotNull(expected);
  assertNotNull(actual);
  assertTrue(expected.equalsExact(actual));
}

代码示例来源:origin: org.geotools/gt-main

@Override
  public boolean evaluateInternal(Geometry left, Geometry right) {
  Envelope envLeft = left.getEnvelopeInternal();
  Envelope envRight = right.getEnvelopeInternal();
  if (envRight.equals(envLeft))
    return left.equalsExact(right);
  else
    return false;
}

代码示例来源:origin: org.geotools/gt-main

/**
 * Compares two geometries for equality.
 */
protected void assertEquals(String message, Geometry expected, Geometry actual) {
  if (expected == actual) {
    return;
  }
  assertNotNull(message, expected);
  assertNotNull(message, actual);
  assertTrue(message, expected.equalsExact(actual));
}

代码示例来源:origin: bcdev/beam

private void testFormatting(Geometry expectedGeometry) throws ParseException {
  final WKTReader wktReader = new WKTReader();
  final String geometryWkt = converter.format(expectedGeometry);
  final Geometry geometry = wktReader.read(geometryWkt);
  assertTrue(expectedGeometry.equalsExact(geometry));
}

代码示例来源:origin: bcdev/beam

private void testParsing(Geometry expectedGeometry) throws ConversionException {
    final WKTWriter wktWriter = new WKTWriter();
    final String geometryWkt = wktWriter.write(expectedGeometry);
    final Geometry geometry = converter.parse(geometryWkt);
    assertTrue(expectedGeometry.equalsExact(geometry));

    assertEquals(null, converter.parse(""));
  }
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

@Test
  public void testNoConflictIfSameDiff2() throws Exception {
    String wkt = "MULTIPOLYGON (((-75.0740073 38.6938098, -75.0739683 38.6935296, "
        + "-75.0745695 38.6934786, -75.0745824 38.6935715, -75.0741091 38.6936117, "
        + "-75.0741352 38.6937989, -75.0740073 38.6938098)))";

    Geometry oldGeom = new WKTReader().read(wkt);
    Geometry newGeom = new WKTReader().read(wkt);
    assertTrue(oldGeom.equalsExact(newGeom));

    GeometryAttributeDiff diff = new GeometryAttributeDiff(oldGeom, newGeom);
    GeometryAttributeDiff diff2 = new GeometryAttributeDiff(oldGeom, newGeom);
    assertFalse(diff.conflicts(diff2));
  }
}

相关文章