Skip to content

Commit 36cc1ee

Browse files
author
Philip (flip) Kromer
committed
toString() on Geometry and OGCGeometry
1 parent f1b1db0 commit 36cc1ee

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/main/java/com/esri/core/geometry/Geometry.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
package com.esri.core.geometry;
2727

2828
import com.esri.core.geometry.VertexDescription.Semantics;
29+
import com.esri.core.geometry.GeometryEngine;
30+
import com.esri.core.geometry.WktExportFlags;
2931
import java.io.ObjectStreamException;
3032
import java.io.Serializable;
3133

@@ -507,6 +509,12 @@ static Geometry _clone(Geometry src) {
507509
return geom;
508510
}
509511

512+
public String toString() {
513+
String snippet = GeometryEngine.geometryToWkt(this, WktExportFlags.wktExportDefaults);
514+
if (snippet.length() > 200) { snippet = snippet.substring(0, 197)+"..."; }
515+
return String.format("%s: %s", this.getClass().getSimpleName(), snippet);
516+
}
517+
510518
/**
511519
* The stateFlag value changes with changes applied to this geometry. This
512520
* allows the user to keep track of the geometry's state.

src/main/java/com/esri/core/geometry/ogc/OGCGeometry.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public String asText() {
8484
return GeometryEngine.geometryToWkt(getEsriGeometry(), 0);
8585
}
8686

87+
public String toString() {
88+
String snippet = asText();
89+
if (snippet.length() > 200) { snippet = snippet.substring(0, 197)+"..."; }
90+
return String.format("%s: %s", this.getClass().getSimpleName(), snippet);
91+
}
92+
8793
public ByteBuffer asBinary() {
8894
OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
8995
.getInstance().getOperator(Operator.Type.ExportToWkb);

0 commit comments

Comments
 (0)