Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/com/esri/core/geometry/ogc/OGCCurve.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.esri.core.geometry.ogc;

import com.esri.core.geometry.MultiPoint;
import com.esri.core.geometry.Point;

public abstract class OGCCurve extends OGCGeometry {
public abstract double length();
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/com/esri/core/geometry/ogc/OGCGeometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.esri.core.geometry.ogc;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -205,16 +204,27 @@ public boolean isMeasured() {
abstract public OGCGeometry boundary();

/**
* OGC equals
*
* OGC equals. Performs topological comparison with tolerance.
* This is different from equals(Object), that uses exact comparison.
*/
public boolean equals(OGCGeometry another) {
public boolean Equals(OGCGeometry another) {
if (this == another)
return true;

if (another == null)
return false;

com.esri.core.geometry.Geometry geom1 = getEsriGeometry();
com.esri.core.geometry.Geometry geom2 = another.getEsriGeometry();
return com.esri.core.geometry.GeometryEngine.equals(geom1, geom2,
getEsriSpatialReference());
}

@Deprecated
public boolean equals(OGCGeometry another) {
return Equals(another);
}

public boolean disjoint(OGCGeometry another) {
com.esri.core.geometry.Geometry geom1 = getEsriGeometry();
com.esri.core.geometry.Geometry geom2 = another.getEsriGeometry();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/esri/core/geometry/ogc/OGCMultiPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import java.nio.ByteBuffer;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.GeometryCursor;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MultiPoint;
import com.esri.core.geometry.Operator;
import com.esri.core.geometry.OperatorExportToWkb;
import com.esri.core.geometry.OperatorFactoryLocal;
import com.esri.core.geometry.OperatorUnion;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.WkbExportFlags;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/esri/core/geometry/ogc/OGCPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.nio.ByteBuffer;

import com.esri.core.geometry.GeometryCursor;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MultiPoint;
import com.esri.core.geometry.Operator;
Expand Down
28 changes: 18 additions & 10 deletions src/test/java/com/esri/core/geometry/TestOGC.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,36 @@ public void testPolygon() throws Exception {
OGCLineString ls = p.exteriorRing();
// assertTrue(ls.pointN(1).equals(OGCGeometry.fromText("POINT(10 -10)")));
boolean b = ls
.equals(OGCGeometry
.Equals(OGCGeometry
.fromText("LINESTRING(-10 -10, 10 -10, 10 10, -10 10, -10 -10)"));
assertTrue(b);
OGCLineString lsi = p.interiorRingN(0);
b = lsi.equals(OGCGeometry
b = lsi.Equals(OGCGeometry
.fromText("LINESTRING(-5 -5, -5 5, 5 5, 5 -5, -5 -5)"));
assertTrue(b);
b = lsi.equals((Object)OGCGeometry
.fromText("LINESTRING(-5 -5, -5 5, 5 5, 5 -5, -5 -5)"));
assertTrue(!lsi.equals(ls));
assertTrue(!lsi.Equals(ls));
OGCMultiCurve boundary = p.boundary();
String s = boundary.asText();
assertTrue(s.equals("MULTILINESTRING ((-10 -10, 10 -10, 10 10, -10 10, -10 -10), (-5 -5, -5 5, 5 5, 5 -5, -5 -5))"));

{
OGCGeometry g2 = OGCGeometry.fromGeoJson("{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
OGCGeometry.fromGeoJson("{\"type\": \"LineString\", \"coordinates\": [[1.00000001,1.00000001], [7.00000001,8.00000001]]}").intersects(g2);
OGCGeometry.fromGeoJson("{\"type\": \"LineString\", \"coordinates\": [[2.449,4.865], [7.00000001,8.00000001]]}").intersects(g2);

OGCGeometry g3 = OGCGeometry.fromGeoJson("{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
boolean bb = g2.equals((Object)g3);
assertTrue(bb);
OGCGeometry g2 = OGCGeometry.fromGeoJson(
"{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
OGCGeometry
.fromGeoJson(
"{\"type\": \"LineString\", \"coordinates\": [[1.00000001,1.00000001], [7.00000001,8.00000001]]}")
.intersects(g2);
OGCGeometry
.fromGeoJson(
"{\"type\": \"LineString\", \"coordinates\": [[2.449,4.865], [7.00000001,8.00000001]]}")
.intersects(g2);

OGCGeometry g3 = OGCGeometry.fromGeoJson(
"{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
boolean bb = g2.equals((Object) g3);
assertTrue(bb);
}
}

Expand Down