Skip to content
Commits on Source (6)
......@@ -71,6 +71,15 @@ There are two kinds of unit tests:
### JUnit tests
Used for verifying API code, internal data structures, and ancillary algorithms.
These tests are written in Java.
This allows testing all parts of the codebase,
and can provide richer error detection and reporting.
However, the tests are not as readable or portable
as the XML tests.
* To run the unit tests in a module (`jts-core`):
mvn test -pl modules/core
### XML Tests
......
......@@ -18,7 +18,7 @@ During that transition, the Java package names and Maven GAVs have changed. For
| Maven GroupId | com.vividsolutions | org.locationtech.jts |
| Package names | com.vividsolutions.jts.* | org.locationtech.jts.* |
To upgrade a Maven project (or another build tool using Maven dependency management), one can do a find and replace on ```pom.xml``` files (or similiar build files). In the source code, one could do a find and replace on the package names. As a concrete example, one could use these two commands to handle most of the migration.
To upgrade a Maven project (or another build tool using Maven dependency management), one can do a find and replace on ```pom.xml``` files (or similar build files). In the source code, one could do a find and replace on the package names. As a concrete example, one could use these two commands to handle most of the migration.
```
git grep -l com.vividsolutions | grep pom.xml | xargs sed -i "s/com.vividsolutions/org.locationtech.jts/g"
......
......@@ -8,17 +8,23 @@ The JTS Topology Suite is a Java library for creating and manipulating vector ge
[![Build Status](https://api.travis-ci.org/locationtech/jts.svg)](http://travis-ci.org/locationtech/jts) [![Join the chat at https://gitter.im/locationtech/jts](https://badges.gitter.im/locationtech/jts.svg)](https://gitter.im/locationtech/jts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
JTS is in incubation with the [LocationTech](http://www.locationtech.org) working group of the Eclipse Foundation.
JTS is a project in the [LocationTech](http://www.locationtech.org) working group of the Eclipse Foundation.
![LocationTech](locationtech_mark.png)
## Locations
* Git Repo: [github.com/locationtech/jts](https://github.com/locationtech/jts)
* Mailing List: [locationtech.org/mailman/listinfo/jts-dev](https://locationtech.org/mailman/listinfo/jts-dev)
* LocationTech Home: [locationtech.org/projects/technology.jts](https://locationtech.org/projects/technology.jts)
* GitHub web pages: [locationtech.github.io/jts/](https://locationtech.github.io/jts/)
* Gitter Channel: [gitter.im/locationtech/jts](https://gitter.im/locationtech/jts)
### Code
* [GitHub Repo](https://github.com/locationtech/jts)
* [Maven Central group](https://mvnrepository.com/artifact/org.locationtech.jts)
### Websites
* [LocationTech Home](https://locationtech.org/projects/technology.jts)
* [GitHub web site](https://locationtech.github.io/jts/)
### Communication
* [Mailing List](https://locationtech.org/mailman/listinfo/jts-dev)
* [Gitter Channel](https://gitter.im/locationtech/jts)
## License
......@@ -34,11 +40,16 @@ See also:
## Documentation
* [**Javadoc**](https://locationtech.github.io/jts/javadoc)
* Frequently Asked Questions are documented in the [**FAQ**](https://locationtech.github.io/jts/jts-faq.html)
* Installing and using JTS is described in the [**User Guide**](USING.md).
* Building and developing with JTS is described in the [**Developing Guide**](DEVELOPING.md).
* Migrating from previous versions of JTS is described in the [**Upgrade Guide**](MIGRATION.md).
* [**Javadoc**](https://locationtech.github.io/jts/javadoc) for the latest version of JTS
* [**FAQ**](https://locationtech.github.io/jts/jts-faq.html) - Frequently Asked Questions
* [**User Guide**](USING.md) - Installing and using JTS (as a library and using included tools)
* [**Developing Guide**](DEVELOPING.md) - how to build and develop for JTS
* [**Upgrade Guide**](MIGRATION.md) - How to migrate from previous versions of JTS
## History
* History from the previous JTS SourceForge repo is in the branch [`_old/history`](https://github.com/locationtech/jts/tree/_old/history)
* Older versions of JTS can be found on SourceForge and [here](https://github.com/dr-jts/jts-versions)
## Contributing
......
......@@ -5,13 +5,31 @@ to assist them in preparing releases of the project.
## Release Checklist
* Create a Release Milestone, and tag it to Issues and PRs wanted in the release
* Confirm Maven build executes with no errors
* Update the Version History, to record significant changes
* Set the version number in the following artifacts:
* Java class `JTSVersion`
* Maven POMs (using the Maven release plugin)
* Review scripts in `bin` to confirm correctness
* Review and update the release notes
* Release to Maven central with the release property and profile ("mvn clean install -Drelease")
### Preparation
1. Create a [Release Milestone](https://github.com/locationtech/jts/milestones)
1. tag it to Issues and PRs wanted in the release
1. Confirm Maven build executes with no errors
1. `mvn clean install`
### Update Artifacts
1. Update the [Version History](https://github.com/locationtech/jts/blob/master/doc/JTS_Version_History.html), to record significant changes
1. Set the version number in the following artifacts:
1. Java class `org.locationtech.jts.JTSVersion`
1. Maven POMs (run the Maven release plugin at project root: `mvn versions:set -DnewVersion=<version>` )
1. Review scripts in `bin` to confirm correctness
1. Commit changes back to the repo
### Create Release Artifacts
1. **Execute the final Maven release build**
1. `mvn clean install`
### Deploy the Release
1. Create a [JTS GitHub release](https://github.com/locationtech/jts/releases)
1. Add release artifacts
1. Update release notes
1. Release to Maven Central with the release property and profile
1. `mvn clean install -Drelease `
1. Update [Javadoc on JTS Github IO](http://locationtech.github.io/jts/javadoc/)
1. Javadoc is generated by the Maven build
1. Update by: check out [`gh-pages`](https://github.com/locationtech/jts/tree/gh-pages) branch; copy new Javadoc; commit
......@@ -97,3 +97,19 @@ module org.foo.baz {
requires org.locationtech.jts.io.sde; // jts-io-sde
}
```
## JTS Tools
JTS includes some application tools.
### TestBuilder
The TestBuilder is a GUI application which allows creating and visualizing geometry, and executing JTS functions.
* Run from project root:
java -jar modules/app/target/JTSTestBuilder.jar
* Run with Metal L&F (useful for Mac)
java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -jar modules/app/target/JTSTestBuilder.jar
jts (1.16.0+ds-2) UNRELEASED; urgency=medium
jts (1.16.1+ds-1~exp1) experimental; urgency=medium
* Team upload.
* New upstream release.
* Bump Standards-Version to 4.3.0, no changes.
* Update copyright years for Martin Davis.
* Update doc paths.
-- Bas Couwenberg <sebastic@debian.org> Tue, 25 Dec 2018 22:26:48 +0100
-- Bas Couwenberg <sebastic@debian.org> Tue, 19 Feb 2019 06:41:35 +0100
jts (1.16.0+ds-1) unstable; urgency=medium
......
......@@ -6,11 +6,11 @@ Source: https://github.com/locationtech/jts
Files-Excluded: doc/*.pdf
Files: *
Copyright: 2016, 2018, Vivid Solutions
Copyright: 2016, 2019, Martin Davis
2016, 2018, Vivid Solutions
2018, Contributors to the Eclipse Foundation
2018, Felix Obermaier
2017, Jia Yu
2016, Martin Davis
2003, Open Source Geospatial Foundation
License: EPL-1.0 or EDL-1.0
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-modules</artifactId>
<version>1.16.0</version>
<version>1.16.1-SNAPSHOT</version>
</parent>
<artifactId>jts-app</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
......
......@@ -14,9 +14,11 @@ package org.locationtech.jtstest.function;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.geom.util.*;
import org.locationtech.jtstest.geomfunction.Metadata;
public class AffineTransformationFunctions
{
@Metadata(description="Transforms a geometry using one to three control vectors")
public static Geometry transformByVectors(Geometry g, Geometry control)
{
int nControl = control.getNumGeometries();
......@@ -33,6 +35,7 @@ public class AffineTransformationFunctions
return trans.transform(g);
}
@Metadata(description="Transforms a geometry by mapping envelope baseline to target vector")
public static Geometry transformByBaseline(Geometry g, Geometry destBaseline)
{
Envelope env = g.getEnvelopeInternal();
......@@ -57,7 +60,7 @@ public class AffineTransformationFunctions
return new Coordinate(env.getMinX(), env.getMinY());
}
public static Geometry viewport(Geometry g, Geometry gViewport)
public static Geometry transformToViewport(Geometry g, Geometry gViewport)
{
Envelope viewEnv = gViewport.getEnvelopeInternal();
Envelope env = g.getEnvelopeInternal();
......@@ -103,14 +106,20 @@ public class AffineTransformationFunctions
return trans.transform(g);
}
public static Geometry rotateByPiMultiple(Geometry g, double multipleOfPi)
@Metadata(description="Rotate a geometry by an multiple of Pi radians")
public static Geometry rotateByPiMultiple(Geometry g,
@Metadata(title="Angle (multiple of Pi)")
double multipleOfPi)
{
Coordinate centre = envelopeCentre(g);
AffineTransformation trans = AffineTransformation.rotationInstance(multipleOfPi * Math.PI, centre.x, centre.y);
return trans.transform(g);
}
public static Geometry rotateByPiMultipleAroundPoint(Geometry g, Geometry pt, double multipleOfPi)
@Metadata(description="Rotate a geometry around a point by an multiple of Pi radians")
public static Geometry rotateByPiMultipleAroundPoint(Geometry g, Geometry pt,
@Metadata(title="Angle (multiple of Pi)")
double multipleOfPi)
{
Coordinate loc;
if (pt == null) {
......@@ -123,14 +132,20 @@ public class AffineTransformationFunctions
return trans.transform(g);
}
public static Geometry rotate(Geometry g, double angle)
@Metadata(description="Rotate a geometry by an angle in radians")
public static Geometry rotate(Geometry g,
@Metadata(title="Angle (radians)")
double angle)
{
Coordinate centre = envelopeCentre(g);
AffineTransformation trans = AffineTransformation.rotationInstance(angle, centre.x, centre.y);
return trans.transform(g);
}
public static Geometry rotateAroundPoint(Geometry g, Geometry pt, double angle)
@Metadata(description="Rotate a geometry around a point by an angle in radians")
public static Geometry rotateAroundPoint(Geometry g, Geometry pt,
@Metadata(title="Angle (radians)")
double angle)
{
Coordinate loc;
if (pt == null) {
......
......@@ -13,8 +13,11 @@
package org.locationtech.jtstest.function;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.shape.fractal.HilbertCurveBuilder;
import org.locationtech.jts.shape.fractal.KochSnowflakeBuilder;
import org.locationtech.jts.shape.fractal.MortonCurveBuilder;
import org.locationtech.jts.shape.fractal.SierpinskiCarpetBuilder;
import org.locationtech.jtstest.geomfunction.Metadata;
public class CreateFractalShapeFunctions
{
......@@ -33,4 +36,53 @@ public class CreateFractalShapeFunctions
builder.setNumPoints(n);
return builder.getGeometry();
}
@Metadata(description="Generates a Hilbert Curve")
public static Geometry hilbertCurve(Geometry g,
@Metadata(title="Number of points")
int n) {
HilbertCurveBuilder builder = new HilbertCurveBuilder(FunctionsUtil.getFactoryOrDefault(g));
if (g != null) {
builder.setExtent(FunctionsUtil.getEnvelopeOrDefault(g));
}
builder.setNumPoints(n);
return builder.getGeometry();
}
@Metadata(description="Generates a Hilbert Curve at a given level")
public static Geometry hilbertCurveAtLevel(Geometry g,
@Metadata(title="Level (1-16)")
int level) {
HilbertCurveBuilder builder = new HilbertCurveBuilder(FunctionsUtil.getFactoryOrDefault(g));
if (g != null) {
builder.setExtent(FunctionsUtil.getEnvelopeOrDefault(g));
}
builder.setLevel(level);
return builder.getGeometry();
}
@Metadata(description="Generates a Morton Curve")
public static Geometry mortonCurve(Geometry g,
@Metadata(title="Number of points")
int n) {
MortonCurveBuilder builder = new MortonCurveBuilder(FunctionsUtil.getFactoryOrDefault(g));
if (g != null) {
builder.setExtent(FunctionsUtil.getEnvelopeOrDefault(g));
}
builder.setNumPoints(n);
return builder.getGeometry();
}
@Metadata(description="Generates a Morton Curve at a given level")
public static Geometry mortonCurveAtLevel(Geometry g,
@Metadata(title="Level (1-16)")
int level) {
MortonCurveBuilder builder = new MortonCurveBuilder(FunctionsUtil.getFactoryOrDefault(g));
if (g != null) {
builder.setExtent(FunctionsUtil.getEnvelopeOrDefault(g));
}
// builder.setNumPoints(n);
builder.setLevel(level);
return builder.getGeometry();
}
}
......@@ -124,16 +124,19 @@ public class CreateRandomShapeFunctions {
return geomFact.buildGeometry(pts);
}
@Metadata(description="Create Halton points using bases 2 and 3")
public static Geometry haltonPoints(Geometry g, int nPts)
{
return haltonPointsWithBases(g, nPts, 2, 3);
}
@Metadata(description="Create Halton points using bases 5 and 7")
public static Geometry haltonPoints57(Geometry g, int nPts)
{
return haltonPointsWithBases(g, nPts, 5, 7);
}
@Metadata(description="Create Halton points using provided bases")
public static Geometry haltonPointsWithBases(Geometry g, int nPts,
@Metadata(title="Base 1")
int basei,
......
......@@ -63,4 +63,25 @@ public class DistanceFunctions {
return dist.orientedDistance();
}
public static double distanceIndexed(Geometry a, Geometry b) {
return IndexedFacetDistance.distance(a, b);
}
public static Geometry nearestPointsIndexed(Geometry a, Geometry b) {
Coordinate[] pts = IndexedFacetDistance.nearestPoints(a, b);
return a.getFactory().createLineString(pts);
}
public static Geometry nearestPointsIndexedAll(Geometry a, Geometry b) {
IndexedFacetDistance ifd = new IndexedFacetDistance(a);
int n = b.getNumGeometries();
LineString[] lines = new LineString[n];
for (int i = 0; i < n; i++) {
Coordinate[] pts = ifd.nearestPoints(b.getGeometryN(i));
lines[i] = a.getFactory().createLineString(pts);
}
return a.getFactory().createMultiLineString(lines);
}
}
package org.locationtech.jtstest.function;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jtstest.testbuilder.geom.ConstrainedInteriorPoint;
public class LabellingFunctions {
public static Geometry labelPoint(Geometry g) {
Coordinate pt = ConstrainedInteriorPoint.getCoordinate((Polygon) g);
return g.getFactory().createPoint(pt);
}
public static Geometry labelPointConstrained(Geometry g, Geometry con) {
Envelope envCon = con.getEnvelopeInternal();
Coordinate pt = ConstrainedInteriorPoint.getCoordinate((Polygon) g, envCon);
return g.getFactory().createPoint(pt);
}
}
......@@ -137,6 +137,15 @@ public class SelectionFunctions
});
}
public static Geometry interiorPointWithin(Geometry a, final Geometry mask)
{
return select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return g.getInteriorPoint().within(mask);
}
});
}
private static Geometry select(Geometry geom, GeometryPredicate pred)
{
List selected = new ArrayList();
......
......@@ -70,7 +70,7 @@ public class TriangulationFunctions
}
catch (LocateFailureException ex) {
System.out.println(ex);
// ignore this exception and drop thru
// ignore this exception and drop through
}
/**
* Get the triangles created up until the error
......
......@@ -18,18 +18,24 @@ public class GeometryFunctionInvocation {
private GeometryFunction function;
private Object[] args;
private Geometry target;
public GeometryFunctionInvocation(GeometryFunction function, Object[] args) {
public GeometryFunctionInvocation(GeometryFunction function, Geometry target, Object[] args) {
this.function = function;
this.target = target;
this.args = args;
}
public String getSignature() {
if (function == null)
return null;
String funArgs = toString(target);
if (args.length > 0) {
funArgs += ", " + toString(args);
}
return function.getCategory()
+ "." + function.getName()
+ "(" + toString(args) + ")";
+ "( " + funArgs + " )";
}
public GeometryFunction getFunction() {
......@@ -55,8 +61,11 @@ public class GeometryFunctionInvocation {
public static String toString(Object o)
{
if (o == null) return "null";
if (o instanceof Geometry)
return ((Geometry) o).getGeometryType();
if (o instanceof Geometry) {
Geometry g = (Geometry) o;
int npts = g.getNumPoints();
return g.getGeometryType() + "[" + npts + "]";
}
return o.toString();
}
}
package org.locationtech.jtstest.geomfunction;
import java.util.ArrayList;
import java.util.List;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.util.GeometryMapper;
import org.locationtech.jts.geom.util.GeometryMapper.MapOp;
import org.locationtech.jtstest.function.FunctionsUtil;
import org.locationtech.jtstest.util.ClassUtil;
......@@ -85,15 +90,17 @@ public class RepeaterGeometryFunction implements GeometryFunction {
return 0;
}
private Object invokeRepeated(Geometry geom, Object[] args, double argStart) {
Geometry[] results = new Geometry[count];
List results = new ArrayList();
int repeatArgIndex = repeatableArgIndex(fun);
for (int i = 1; i <= count; i++) {
double val = argStart * i;
Geometry result = (Geometry) fun.invoke(geom, copyArgs(args, repeatArgIndex, val));
if (result == null) continue;
FunctionsUtil.showIndicator(result);
results[i-1] = result;
results.add(result);
}
return geom.getFactory().createGeometryCollection(results);
return geom.getFactory().buildGeometry(results);
}
private Object[] copyArgs(Object[] args, int replaceIndex, double val) {
......