本文整理了Java中com.vividsolutions.jts.geom.Geometry.norm()
方法的一些代码示例,展示了Geometry.norm()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.norm()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:norm
[英]Creates a new Geometry which is a normalized copy of this Geometry.
[中]创建一个新几何体,该几何体是该几何体的规范化副本。
代码示例来源: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: com.vividsolutions/jts-core
/**
* 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.orbisgis/test-utilities
/**
* 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)
* @throws SQLException If WKT or WKB is not valid
*/
public static void assertGeometryEquals(String expectedWKT,int expectedSRID, Object valueObject) throws SQLException {
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: org.orbisgis/h2gis-test-utilities
/**
* 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)
* @throws SQLException If WKT or WKB is not valid
*/
public static void assertGeometryEquals(String expectedWKT,int expectedSRID, Object valueObject) throws SQLException {
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: org.locationtech.geogig/geogig-core
@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 = 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: org.locationtech.geogig/geogig-core
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()));
内容来源于网络,如有侵权,请联系作者删除!