Skip to content

Commit e29cf0e

Browse files
committed
JTSOp method renames
1 parent a92aff4 commit e29cf0e

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

modules/app/src/main/java/org/locationtech/jtstest/cmd/GeometryOutput.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public GeometryOutput(CommandOutput out) {
3939
this.out = out;
4040
}
4141

42-
public void printGeometry(Geometry geom, int srid, String outputFormat) {
42+
public void write(Geometry geom, int srid, String outputFormat) {
43+
if (geom == null) return;
44+
if (outputFormat == null) return;
45+
4346
String txt = null;
4447
if (outputFormat.equalsIgnoreCase(CommandOptions.FORMAT_WKT)
4548
|| outputFormat.equalsIgnoreCase(CommandOptions.FORMAT_TXT)) {
@@ -79,23 +82,23 @@ private static String writeGeoJSON(Geometry geom) {
7982
return writer.write(geom);
8083
}
8184

82-
public static String writeGeometrySummary(String label,
85+
public static String writeSummary(String label,
8386
Geometry g)
8487
{
8588
if (g == null) return "";
8689
return String.format("%s: %s (%d)", label, g.getGeometryType().toUpperCase(), g.getNumPoints());
8790
}
8891

89-
public static String writeGeometrySummary(String label,
92+
public static String writeSummary(String label,
9093
List<Geometry> geoms)
9194
{
9295
if (geoms == null) return "";
9396
int nVert = getNumPoints(geoms);
9497
String geomTypes = getTypesSummary(geoms);
95-
return writeGeometrySummary(label, geoms.size(), geomTypes, nVert);
98+
return writeSummary(label, geoms.size(), geomTypes, nVert);
9699
}
97100

98-
public static String writeGeometrySummary(String label,
101+
public static String writeSummary(String label,
99102
int numGeoms, String geomTypes, int numVert)
100103
{
101104
return String.format("%s : %d %s, %d vertices", label, numGeoms, geomTypes, numVert);

modules/app/src/main/java/org/locationtech/jtstest/cmd/JTSOpRunner.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private void executeFunctionOverA(FunctionInvoker fun) {
296296
String header = "";
297297
for (int i = 0; i < numGeom; i++) {
298298
Geometry comp = geomA == null ? null : geomA.get(i);
299-
String hdr = GeometryOutput.writeGeometrySummary(SYM_A + "[" + i + "]", comp);
299+
String hdr = GeometryOutput.writeSummary(SYM_A + "[" + i + "]", comp);
300300
if (geomB == null) {
301301
executeFunction(comp, fun, hdr);
302302
}
@@ -311,7 +311,7 @@ private void executeFunctionOverB(Geometry geomA, FunctionInvoker fun, String he
311311
List<Integer> targetB = geomIndexB.query(geomA);
312312
for (int index : targetB) {
313313
Geometry gb = geomB.get(index);
314-
String hdr = header + ", " + GeometryOutput.writeGeometrySummary(symGeom2 + "[" + index + "]", gb);
314+
String hdr = header + ", " + GeometryOutput.writeSummary(symGeom2 + "[" + index + "]", gb);
315315
fun.setB(gb);
316316
executeFunction(geomA, fun, hdr);
317317
}
@@ -382,7 +382,7 @@ private Object executeFunctionOnce(Geometry geomA, GeometryFunction func, Object
382382
return result;
383383
}
384384

385-
private String errorMsg(Throwable ex) {
385+
private static String errorMsg(Throwable ex) {
386386
String msg = "ERROR excuting function: " + ex.getMessage() + "\n";
387387
msg += toStackString(ex);
388388
if (ex.getCause() != null) {
@@ -392,7 +392,7 @@ private String errorMsg(Throwable ex) {
392392
return msg;
393393
}
394394

395-
private String toStackString(Throwable ex) {
395+
private static String toStackString(Throwable ex) {
396396
StringWriter sw = new StringWriter();
397397
PrintWriter pw = new PrintWriter(sw);
398398
ex.printStackTrace(pw);
@@ -498,13 +498,14 @@ private void outputResult(Object result, boolean isExplode, String outputFormat)
498498
Geometry geom = (Geometry) result;
499499
if (isExplode && geom instanceof GeometryCollection) {
500500
for (int i = 0; i < geom.getNumGeometries(); i++) {
501-
printGeometry(geom.getGeometryN(i), param.srid, outputFormat);
501+
writeGeometry(geom.getGeometryN(i), param.srid, outputFormat);
502502
}
503503
}
504504
else {
505-
printGeometry(geom, param.srid, outputFormat);
505+
writeGeometry(geom, param.srid, outputFormat);
506506
}
507507
}
508+
508509
private void outputList(List<Geometry> geoms, String outputFormat) {
509510
if (geoms == null) return;
510511
if (outputFormat == null) return;
@@ -514,14 +515,11 @@ private void outputList(List<Geometry> geoms, String outputFormat) {
514515
}
515516
}
516517

517-
private void printGeometry(Geometry geom, int srid, String outputFormat) {
518-
if (geom == null) return;
519-
if (outputFormat == null) return;
520-
518+
private void writeGeometry(Geometry geom, int srid, String outputFormat) {
521519
if (captureGeometry) {
522520
resultGeoms.add((Geometry) geom);
523521
}
524-
geomOut.printGeometry((Geometry) geom, srid, outputFormat);
522+
geomOut.write((Geometry) geom, srid, outputFormat);
525523
}
526524

527525
private void printlnInfo(String s) {
@@ -535,13 +533,13 @@ private void printGeometrySummary(String label, List<Geometry> geom, String sour
535533

536534
String srcname = "";
537535
if (source != null) srcname = " -- " + source;
538-
printlnInfo( GeometryOutput.writeGeometrySummary(label, geom) + srcname);
536+
printlnInfo( GeometryOutput.writeSummary(label, geom) + srcname);
539537
}
540538

541539
private void printGeometrySummary(String label, Geometry geom) {
542540
// short-circuit to avoid cost
543541
if (! isVerbose) return;
544-
printlnInfo( GeometryOutput.writeGeometrySummary(label, geom));
542+
printlnInfo( GeometryOutput.writeSummary(label, geom));
545543
}
546544

547545
private static String fileInfo(String filename, int limit, int offset) {

0 commit comments

Comments
 (0)