org.locationtech.jts.geom.Geometry.norm()方法的使用及代码示例

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

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

Geometry.norm介绍

[英]Creates a new Geometry which is a normalized copy of this Geometry.
[中]创建一个新几何体,该几何体是该几何体的规范化副本。

代码示例

代码示例来源:origin: prestodb/presto

private static void assertGeometryEquals(Geometry actual, Geometry expected)
{
  assertEquals(actual.norm(), expected.norm());
}

代码示例来源:origin: locationtech/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: prestosql/presto

private static void assertGeometryEquals(Geometry actual, Geometry expected)
{
  assertEquals(actual.norm(), expected.norm());
}

代码示例来源:origin: io.prestosql/presto-geospatial-toolkit

private static void assertGeometryEquals(Geometry actual, Geometry expected)
{
  assertEquals(actual.norm(), expected.norm());
}

代码示例来源:origin: locationtech/jts

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);
}

代码示例来源:origin: orbisgis/h2gis

/**
 * Check Geometry type,X,Y,Z and SRID
 *
 * @param expectedWKT Expected value, in WKT
 * @param expectedSRID Expected SRID code,
 * @param valueObject Test value geometry ex rs.getObject(i)
 */
public static void assertGeometryEquals(String expectedWKT,int expectedSRID, Object valueObject) {
  if (expectedWKT == null) {
    assertNull(valueObject);
  } else {
    ValueGeometry expected = ValueGeometry.get(expectedWKT, expectedSRID);
    ValueGeometry actual = ValueGeometry.getFromGeometry(((Geometry)valueObject).norm());
    expected = ValueGeometry.getFromGeometry(expected.getGeometry().norm());
    String moreInfo = "";
    if(!actual.equals(expected)) {
      if(!GeometryCollection.class.getName().equals(expected.getGeometry().getClass().getName()) &&
          !GeometryCollection.class.getName().equals(actual.getGeometry().getClass().getName()) &&
          expected.getGeometry().equals(actual.getGeometry())) {
        moreInfo = "\n But are topologically equals";
      }
    }
    assertEquals("Expected:\n" + expected.getWKT() + "\nActual:\n" + actual.getWKT()+moreInfo, expected, actual);
  }
}
/**

代码示例来源:origin: locationtech/jts

private void checkDissolve(List geoms, Geometry expected) {
 LineDissolver d = new LineDissolver();
 d.add(geoms);
 Geometry result = d.getResult();
 boolean equal = result.norm().equalsExact(expected.norm());
 if (! equal) {
  //System.out.println("Expected = " + expected
  //    + " actual = " + result.norm());
 }
 assertTrue(equal);
}

代码示例来源:origin: locationtech/geogig

@Test
public void testEnforcesPolygonNormalization() throws Exception {
  // outer ring in cw order, inner rings in ccw order
  String normalizedWKT = "POLYGON((0 0, 0 9, 9 9, 9 0, 0 0), (3 3, 6 3, 6 6, 3 6, 3 3))";
  // outer ring in ccw order, inner rings in cc order
  String reversedWKT = "POLYGON((0 0, 9 0, 9 9, 0 9, 0 0), (3 3, 3 6, 6 6, 6 3, 3 3))";
  Geometry normalized = new WKTReader().read(normalizedWKT);
  Geometry reversed = new WKTReader().read(reversedWKT);
  assertTrue(normalized.equalsExact(normalized.norm()));
  assertFalse(reversed.equalsExact(reversed.norm()));
  RevFeatureBuilder builder = RevFeature.builder();
  RevFeature norm = builder.addValue(normalized).build();
  RevFeature rev = builder.reset().addValue(reversed).build();
  Geometry expected = (Geometry) norm.getValues().get(0).get();
  Geometry actual = (Geometry) rev.getValues().get(0).get();
  assertTrue(normalized.equalsExact(expected));
  assertTrue(normalized.equalsExact(actual));
}

代码示例来源:origin: locationtech/geogig

assertFalse(normalized.equalsExact(normalized.norm()));// the linestring is not normalized
assertTrue(normalized.getGeometryN(2).equalsExact(normalized.getGeometryN(2).norm()));
assertFalse(reversed.getGeometryN(2).equalsExact(reversed.getGeometryN(2).norm()));

相关文章