本文整理了Java中org.locationtech.jts.geom.Geometry.equalsExact()
方法的一些代码示例,展示了Geometry.equalsExact()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.equalsExact()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:equalsExact
[英]Returns true if the two Geometry
s are exactly equal. Two Geometries are exactly equal iff:
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(几何体)更严格的相等性测试,它在某些情况下更有用(例如将几何体用作集合中的键)。
此方法不测试GeometryFactory
、SRID
或userData
字段的值。
为了正确测试不同几何体之间的相等性,通常需要首先对它们进行#规格化()。
代码示例来源:origin: geotools/geotools
public static boolean equalsExact(Geometry arg0, Geometry arg1) {
if (arg0 == null || arg1 == null) return false;
Geometry _this = arg0;
return _this.equalsExact(arg1);
}
代码示例来源:origin: geotools/geotools
public static 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: geoserver/geoserver
@Test
public void testLeaveNative() throws Exception {
FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.LINES.getLocalPart());
assertEquals("EPSG:3004", fti.getSRS());
assertEquals(ProjectionPolicy.NONE, fti.getProjectionPolicy());
FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures();
assertEquals(CRS.decode("EPSG:32615"), fc.getSchema().getCoordinateReferenceSystem());
FeatureIterator fi = fc.features();
Feature f = fi.next();
// test that the geometry was left in tact
Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue();
assertTrue(g.equalsExact(WKT.read("LINESTRING(500125 500025,500175 500075)")));
fi.close();
assertEquals(CRS.decode("EPSG:32615"), f.getType().getCoordinateReferenceSystem());
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testReproject() throws Exception {
FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.POLYGONS.getLocalPart());
assertEquals("EPSG:4326", fti.getSRS());
assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy());
FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures();
assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem());
FeatureIterator fi = fc.features();
Feature f = fi.next();
// test that geometry was actually reprojected
Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue();
assertFalse(
g.equalsExact(
WKT.read(
"POLYGON((500225 500025,500225 500075,500275 500050,500275 500025,500225 500025))")));
fi.close();
assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem());
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testWithRename() throws Exception {
FeatureTypeInfo fti = getCatalog().getFeatureTypeByName("MyPoints");
assertEquals("EPSG:4326", fti.getSRS());
assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy());
FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures();
assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem());
FeatureIterator fi = fc.features();
Feature f = fi.next();
// test that geometry was reprojected
Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue();
assertFalse(g.equalsExact(WKT.read("POINT(500050 500050)")));
fi.close();
assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem());
}
代码示例来源:origin: geotools/geotools
/** 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: geoserver/geoserver
@Test
public void testGetFeaturesFeatureSource() throws Exception {
// check the schemas in feature source and feature collection
SimpleFeatureSource fs = rts.getFeatureSource(RENAMED);
assertEquals(primitive, fs.getSchema());
SimpleFeatureCollection fc = fs.getFeatures();
assertEquals(primitive, fc.getSchema());
assertTrue(fc.size() > 0);
// make sure the feature schema is good as well
FeatureIterator<SimpleFeature> it = fc.features();
SimpleFeature sf = it.next();
it.close();
assertEquals(primitive, sf.getFeatureType());
// check the feature ids have been renamed as well
assertTrue(
"Feature id has not been renamed, it's still " + sf.getID(),
sf.getID().startsWith(RENAMED));
// check mappings occurred
assertEquals("description-f001", sf.getAttribute("description"));
assertTrue(
new WKTReader()
.read("MULTIPOINT(39.73245 2.00342)")
.equalsExact((Geometry) sf.getAttribute("pointProperty")));
assertEquals(Long.valueOf(155), sf.getAttribute("intProperty"));
assertNull(sf.getAttribute("newProperty"));
}
代码示例来源:origin: geotools/geotools
/** 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: geotools/geotools
@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: geotools/geotools
@DescribeProcess(
title = "Exactly Equal Test",
description = "Tests if two geometries are identical on a vertex-by-vertex basis."
)
@DescribeResult(description = "True if the geometries are vertex-identical")
public static boolean equalsExact(
@DescribeParameter(name = "a", description = "First input geometry") Geometry a,
@DescribeParameter(name = "b", description = "Second input geometry") Geometry b) {
return a.equalsExact(b);
}
代码示例来源:origin: geotools/geotools
@Override
public ROI intersect(ROI roi) {
final Geometry geom = getGeometry(roi);
// is it a rectangle?
if (geom != null && geom.equalsExact(geom.getEnvelope())) {
GeometryClipper clipper = new GeometryClipper(geom.getEnvelopeInternal());
Geometry intersect = clipper.clip(getAsGeometry(), true);
return new ROIGeometry(intersect);
} else {
return super.intersect(roi);
}
}
代码示例来源:origin: geotools/geotools
@Override
public ROI intersect(ROI roi) {
final Geometry geom = getGeometry(roi);
// is it a rectangle?
if (geom != null && geom.equalsExact(geom.getEnvelope())) {
GeometryClipper clipper = new GeometryClipper(geom.getEnvelopeInternal());
Geometry intersect = clipper.clip(getAsGeometry(), true);
return new ROIGeometry(intersect, hints);
} else {
return super.intersect(roi);
}
}
代码示例来源:origin: geotools/geotools
boolean hasSameValuesAndStructure(Geometry g1, Geometry g2) {
if (!g1.equalsExact(g2, ORD_TOLERANCE)) return false;
if (g1.getFactory() != g2.getFactory()) return false;
CoordinateSequence seq = CoordinateSequenceFinder.find(g1);
if (!CoordinateSequenceSchemaChecker.check(g2, seq.getClass(), seq.getDimension()))
return false;
return true;
}
代码示例来源:origin: geotools/geotools
@Test
public void testDonutCrossingInvalid() throws Exception {
Geometry g = wkt.read("POLYGON((6 2, 14 2, 14 8, 6 8, 6 2), (8 4, 12 4, 12 6, 8 6, 8 4))");
Geometry clipped = clipper.clip(g, false);
// System.out.println(clipped);
assertTrue(
clipped.equalsExact(
wkt.read(
"POLYGON ((10 2, 10 8, 6 8, 6 2, 10 2), (10 4, 10 6, 8 6, 8 4, 10 4))")));
showResult("Donut crossing, invalid geom", g, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testInsidePolygon() throws Exception {
Geometry g = wkt.read("POINT(5 5)").buffer(2);
Geometry clipped = clipper.clip(g, false);
assertTrue(g.equalsExact(clipped));
showResult("Polygon inside", g, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testDonutHoleOutside() throws Exception {
Geometry g =
wkt.read("POLYGON((6 2, 14 2, 14 8, 6 8, 6 2), (11 4, 12 4, 12 6, 11 6, 11 4))");
Geometry clipped = clipper.clip(g, false);
// System.out.println(clipped);
assertTrue(clipped.equalsExact(wkt.read("POLYGON ((10 2, 10 8, 6 8, 6 2, 10 2))")));
showResult("Donut crossing, invalid geom", g, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testDonutCrossingValid() throws Exception {
Geometry g = wkt.read("POLYGON((6 2, 14 2, 14 8, 6 8, 6 2), (8 4, 12 4, 12 6, 8 6, 8 4))");
Geometry clipped = clipper.clip(g, true);
assertTrue(
clipped.equalsExact(
wkt.read("POLYGON ((10 2, 6 2, 6 8, 10 8, 10 6, 8 6, 8 4, 10 4, 10 2))")));
showResult("Donut crossing, valid geom", g, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testTouchAndCross() throws Exception {
LineString ls = (LineString) wkt.read("LINESTRING(-5 0, 0 1, -5 2, 5 2, 5 3, -5 3, 0 4)");
Geometry clipped = clipper.clip(ls, false);
assertTrue(clipped.equalsExact(wkt.read("LINESTRING(0 2, 5 2, 5 3, 0 3)")));
showResult("Touch and cross", ls, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testTouchAndParallel() throws Exception {
LineString ls = (LineString) wkt.read("LINESTRING(-5 0, 0 1, -5 2, 0 2, 0 3, -5 3, 0 4)");
Geometry clipped = clipper.clip(ls, false);
assertTrue(clipped.equalsExact(wkt.read("LINESTRING(0 2, 0 3)")));
showResult("Touch and parallel", ls, clipped);
}
代码示例来源:origin: geotools/geotools
@Test
public void testPolygonCrossingThreeSides() throws Exception {
Geometry g = wkt.read("POLYGON((-2 2, 12 2, 12 12, -2 12, -2 2))");
Geometry clipped = clipper.clip(g, false);
assertTrue(clipped.equalsExact(wkt.read("POLYGON((0 2, 10 2, 10 10, 0 10, 0 2))")));
showResult("Crossing three sides", g, clipped);
}
内容来源于网络,如有侵权,请联系作者删除!