Skip to content

Commit

Permalink
Merge pull request #3 from locationtech/master
Browse files Browse the repository at this point in the history
Catch up the latest JTS update
  • Loading branch information
jiayuasu committed Nov 23, 2020
2 parents 5d8c940 + 402acb6 commit 9683ba2
Show file tree
Hide file tree
Showing 89 changed files with 2,329 additions and 896 deletions.
3 changes: 3 additions & 0 deletions USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ module org.foo.baz {
requires org.locationtech.jts.io.sde; // jts-io-sde
}
```
## JTS System Properties

* `-Djts.overlay=ng` enables the use of OverlayNG in `Geometry` overlay methods. (*Note: in a future release this will become the default behaviour*)

## JTS Tools

Expand Down
16 changes: 14 additions & 2 deletions doc/JTSOp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Execute JTS operations on geometry to produce the results, in various spatial formats
* Chain together sequences of JTS operations to accomplish a spatial processing task
* Extract and transform geometry from data files
* Extract, subset, validate and transform geometry from data files
* Convert geometry from one format into another
* Generate geometry for testing or display purposes
* Summarize the contents of geometry datafiles
Expand All @@ -19,12 +19,16 @@
* standard input (WKT or WKB)
* files in various formats (WKT, WKB, GeoJSON, GML, SHP)
* a single input containing two geometries can supply both A and B (option `-ab`)
* Apply a limit and/or offset when reading from some file formats:
* `-limit` specifies a limit
* `-offseet` specified an offset
* supported for WKT, WKB, SHP file formats
* Execute any spatial or scalar function available in the JTS TestBuilder
* "spread" execution over each geometry component from one or both inputs
* `-each [ a | b | ab | aa ]`
* the `-each aa` parameter uses the A input for both arguments for binary operations
* the `-index` parameter uses a spatial index for binary operations
* Run an operation multiple times using a sequence of different argument values
* Run an operation multiple times using a set of different argument values
* `-args v1,v2,v3 ...`
* Repeat operation execution multiple times, to provide better timing results
* `-repeat n`
Expand All @@ -36,8 +40,12 @@
* `-explode`
* Display information about the input geometries and function timing
* `-v`
* Display timing information
* `-time`
* Load external spatial functions dynamically (as a Java class with static methods)
* `-geomfunc classname`
* List all available functions
* `-help`
* chain operations together by writing/reading input from `stdin` and using shell piping

## Examples
Expand Down Expand Up @@ -86,6 +94,10 @@

jtsop -a "POINT (10 10)" -f geojson

* Validate geometries from a WKT file using limit and offset

jtsop -a some-file-with-geom.wkt -limit 100 -offset 40 -f txt Geometry.isValid

* Compute an operation on a geometry and output only geometry metrics and timing

jtsop -v -a some-geom.wkt Buffer.buffer 10
Expand Down
20 changes: 20 additions & 0 deletions doc/JTS_Version_History.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,29 @@ Distributions for older JTS versions can be obtained at the
* Add `KMLReader` (#593)
* Add `Densifier.setValidated` method to allow disabling expensive polygon validation (#595)
* Add `OverlayNG` codebase (#599)
* Add system property `jts.overlay=ng` to enable use of OverlayNG in `Geometry` methods (#615)
* Add `SnapRoundingNoder` (#599)
* Add `SnappingNoder` (#599)
* Change `GeometryPrecisionReducer` to use OverlayNG with Snap-Rounding
* Change `GeometryNoder` to use `SnapRoundingNoder`
* Add `KdTree` `size` and `depth` methods (#603)
* Improve `WKBWriter` to write empty Polygons using a more compact representation (#623)

### Bug Fixes

* Fix `RayCrossingCounter` to handle XYZM coordinates (#589)
* Fix `PackedCoordinateSequence` to always use XYZM coordinates when dimension is 4 (#591)
* Fix `OrdinateFormat` to work around a JDK issue with the minus sign character in `Locale.NO` (#596)
* Fix `GeoJsonReader` to throw a `ParseException` for empty arrays (#600)
* Fix `WKTFileReader` handling of files with large amount of whitespace (#616)
* Fix `WKBWriter` to output 3D empty Points with 3 ordinates (#622)
* Fix `Geometry.reverse` to handle all geometry structures (#628)

## JTS TestBuilder

### Functionality Improvements

* Add Geometry Inspector sorting by Area or Length

<!-- ================================================================ -->

Expand Down Expand Up @@ -71,6 +86,11 @@ Distributions for older JTS versions can be obtained at the
* Enhance `-geomfunc` to load multiple function classes
* Fix function registry to replace matching loaded functions (#569)

## JtsOp

* Added `-limit` and `-offset` options for reading from file inputs (#617)


<!-- ================================================================ -->

# Version 1.17.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ public class CommandOptions {
public static final String FORMAT_GEOJSON = "geojson";
public static final String FORMAT_SVG = "svg";
public static final String TIME = "time";
public static final String LIMIT = "limit";
public static final String OFFSET = "offset";

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.WKTConstants;
import org.locationtech.jtstest.cmd.JTSOpRunner.OpParams;
import org.locationtech.jtstest.command.CommandLine;
import org.locationtech.jtstest.command.Option;
import org.locationtech.jtstest.command.OptionSpec;
Expand All @@ -37,6 +38,9 @@
* --- Compute the area of a WKT geometry, output it
* jtsop -a some-file-with-geom.wkt -f txt area
*
* --- Validate geometries from a WKT file using limit and offset
* jtsop -a some-file-with-geom.wkt -limit 100 -offset 40 -f txt isValid
*
* --- Compute the unary union of a WKT geometry, output as WKB
* jtsop -a some-file-with-geom.wkt -f wkb Overlay.unaryUnion
*
Expand Down Expand Up @@ -75,7 +79,7 @@ public static void main(String[] args)
JTSOpCmd cmd = new JTSOpCmd();
int rc = 1;
try {
JTSOpRunner.OpParams cmdArgs = cmd.parseArgs(args);
OpParams cmdArgs = cmd.parseArgs(args);
cmd.execute(cmdArgs);
rc = 0;
}
Expand Down Expand Up @@ -104,12 +108,14 @@ private static CommandLine createCmdLine() {
.addOptionSpec(new OptionSpec(CommandOptions.GEOMA, 1))
.addOptionSpec(new OptionSpec(CommandOptions.GEOMB, 1))
.addOptionSpec(new OptionSpec(CommandOptions.GEOMAB, 1))
.addOptionSpec(new OptionSpec(CommandOptions.SRID, 1))
.addOptionSpec(new OptionSpec(CommandOptions.EACH, 1))
.addOptionSpec(new OptionSpec(CommandOptions.INDEX, 0))
.addOptionSpec(new OptionSpec(CommandOptions.EXPLODE, 0))
.addOptionSpec(new OptionSpec(CommandOptions.FORMAT, 1))
.addOptionSpec(new OptionSpec(CommandOptions.LIMIT, 1))
.addOptionSpec(new OptionSpec(CommandOptions.OFFSET, 1))
.addOptionSpec(new OptionSpec(CommandOptions.REPEAT, 1))
.addOptionSpec(new OptionSpec(CommandOptions.SRID, 1))
.addOptionSpec(new OptionSpec(CommandOptions.VALIDATE, 0))
.addOptionSpec(new OptionSpec(OptionSpec.OPTION_FREE_ARGS, OptionSpec.NARGS_ONE_OR_MORE));
return commandLine;
Expand All @@ -121,37 +127,45 @@ private static CommandLine createCmdLine() {
" [ -a <wkt> | <wkb> | stdin | <filename.ext> ]",
" [ -b <wkt> | <wkb> | stdin | <filename.ext> ]",
" [ -ab <wkt> | <wkb> | stdin | <filename.ext> ]",
" [ -srid <SRID> ]",
" [ -limit <n> ]",
" [ -offset <n> ]",
" [ -each ( a | b | ab | aa ) ]",
" [ -index ]",
" [ -repeat <num> ]",
" [ -validate ]",
" [ -explode",
" [ -srid <SRID> ]",
" [ -f ( txt | wkt | wkb | geojson | gml | svg ) ]",
" [ -geomfunc <classname> ]",
" [ -time ]",
" [ -v, -verbose ]",
" [ -help ]",
" [ -geomfunc <classname> ]",
" [ -op ]",
" [ op [ args... ]]",
" op name of the operation (Category.op)",
" op name of the operation (in format Category.op)",
" args one or more scalar arguments to the operation",
" - To run over multiple arguments use v1,v2,v3 OR val(v1,v2,v3,..)",
"",
"===== Input options:",
" -a Geometry A: literal, stdin (WKT or WKB), or filename (extension: WKT, WKB, GeoJSON, GML, SHP)",
" -b Geometry A: literal, stdin (WKT or WKB), or filename (extension: WKT, WKB, GeoJSON, GML, SHP)",
" -srid Sets the SRID on output geometries",
" -limit Limits the number of geometries read from A, or B if specified",
" -offset Uses an offset to read geometries from A, or B if specified",
"===== Operation options:",
" -each execute op on each component of A, B, both A & B, or A & A",
" -index index geometry B",
" -repeat repeat the operation N times",
" -validate validate the result of each operation",
" -geomfunc specifies class providing geometry operations",
" -op separator to delineate operation arguments",
"===== Output options:",
" -srid Sets the SRID on output geometries",
" -explode output atomic geometries",
" -f output format to use. If omitted output is silent",
" -geomfunc specifies class providing geometry operations",
"===== Logging options:",
" -time display execution time",
" -v, -verbose display information about execution",
" -help print a list of available operations",
" -op separator for op arguments"
" -help print a list of available operations"
};

private void printHelp(boolean showFunctions) {
Expand Down Expand Up @@ -243,7 +257,7 @@ private static boolean isWKT(String arg) {
if (arg.toUpperCase().endsWith(" " + WKTConstants.EMPTY)) return true;
return false;
}

void execute(JTSOpRunner.OpParams cmdArgs) {
if (isHelp || isHelpWithFunctions) {
printHelp(isHelpWithFunctions);
Expand All @@ -261,7 +275,7 @@ JTSOpRunner.OpParams parseArgs(String[] args) throws ParseException, ClassNotFou
}
commandLine.parse(args);

JTSOpRunner.OpParams cmdArgs = new JTSOpRunner.OpParams();
OpParams cmdArgs = new JTSOpRunner.OpParams();

String argA = commandLine.getOptionArg(CommandOptions.GEOMA, 0);
if (argA != null) {
Expand Down Expand Up @@ -294,6 +308,14 @@ JTSOpRunner.OpParams parseArgs(String[] args) throws ParseException, ClassNotFou

cmdArgs.isExplode = commandLine.hasOption(CommandOptions.EXPLODE);

int paramLimit = commandLine.hasOption(CommandOptions.LIMIT)
? commandLine.getOptionArgAsInt(CommandOptions.LIMIT, 0)
: -1;

int paramOffset = commandLine.hasOption(CommandOptions.OFFSET)
? commandLine.getOptionArgAsInt(CommandOptions.OFFSET, 0)
: 0;

cmdArgs.format = commandLine.getOptionArg(CommandOptions.FORMAT, 0);

cmdArgs.srid = commandLine.hasOption(CommandOptions.SRID)
Expand Down Expand Up @@ -358,9 +380,28 @@ else if (each.equalsIgnoreCase("aa")) {
cmdArgs.argList = parseOpArg(freeArgs[1]);
}
}

/**
* ====== Apply extra parameter logic
*/
//--- apply limit to A if no B, or else to B
// This allows applying a binary op with a fixed LHS to a limited set of RHS geoms
if (OpParams.isGeometryInput(cmdArgs.fileB, cmdArgs.geomB)) {
cmdArgs.limitB = paramLimit;
cmdArgs.offsetB = paramOffset;
}
else {
cmdArgs.limitA = paramLimit;
cmdArgs.offsetA = paramOffset;
}

return cmdArgs;
}

private void applyParameters() {

}

private String[] parseOpArg(String arg) {
if (isArgMultiValues(arg)) {
return parseValues(arg);
Expand Down Expand Up @@ -420,7 +461,4 @@ private String[] parseMacroArgs(String macroTerm) {
String args = macroTerm.substring(indexLeft + 1, indexRight);
return args.split(",");
}



}
Loading

0 comments on commit 9683ba2

Please sign in to comment.