Skip to content

Commit

Permalink
Merge branch 'locationtech:master' into rjm-master
Browse files Browse the repository at this point in the history
  • Loading branch information
RichMacDonald authored Jul 27, 2023
2 parents ac39c37 + 46d2cfd commit 662aca1
Show file tree
Hide file tree
Showing 89 changed files with 3,350 additions and 1,147 deletions.
6 changes: 3 additions & 3 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The XML test format can be executed using the **JTS TestRunner**, or imported in

## Eclipse Configuration

Project:
### Project

1. Startup eclipse, creating a new `jts-workspace` location. This folder is used by eclipse to keep track of settings alongside your jts source code.

Expand All @@ -107,7 +107,7 @@ Project:

Do not try the *maven-checkstyle-plugin* connector as it fails to install.

Plugins:
### Plugins

* Install *Eclipse-CS* from the market place.

Expand Down Expand Up @@ -149,7 +149,7 @@ Plugins:

You can use *PMD > Check code* to list errors and warnings. The results are shown in their own view, and quickfixes are not available.

Run Configurations:
### Run Configurations

* **JTS TestRunner** - for executing XML tests:

Expand Down
16 changes: 13 additions & 3 deletions doc/JTS_Version_History.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,33 @@ Distributions for older JTS versions can be obtained at the
* Improve `TopologyPreservingSimplifier` to prevent edge-disjoint line collapse (#925)
* Improve `OffsetCurve` to return more linework for some input situations (#956)
* Reduce buffer curve short fillet segments (#960)
* Added ability to specify boundary for `LargestEmptyCircle` (#973)

### Bug Fixes
* Fix `PreparedGeometry` handling of EMPTY elements (#904)
* Fix `WKBReader` parsing of WKB containing multiple empty elements (#905)
* Fix `LineSegment.orientationIndex(LineSegment)` to correct orientation for non-collinear segments on right (#914)
* Fix `LineSegment.orientationIndex(LineSegment)` to correct orientation for non-collinear segments on right (#914)
* Fix `DepthSegment` compareTo method (#920)
* Ensure `GeometryFixer` does not change coordinate dimension (#922)
* Improve `ConvexHull` radial sort robustness (#927)
* Improve robustness of Delaunay Triangulation frame size heuristic (#931)
* Fix `PreparedLineString.intersects` to handle mixed GCs correctly (#944)
* Fix `QuadEdgeSubdivision.TriangleEdgesListVisitor` (#945)
* Fix `PolygonHoleJoiner` to handle all valid inputs
* Fix `PolygonHoleJoiner` to handle all valid inputs
(allows `PolygonTriangulator`, `ConstrainedDelaunayTriangulator`, and `ConcaveHullOfPolygons` to work correctly) (#946)
* Fix `OffsetCurve` handling of input with repeated points (#956)
* Fix `OffsetCurve` handling zero offset distance (#971)
* Fix `MaximumInscribedCircle` and `LargestEmptyCircle` to avoid long looping for thin inputs (#978)
* Fix `OffsetCurve` to use a minimum QuadrantSegs value (#981)
* Fix `HilbertEncoder` Y extent handling
* Fix `Geometry.getCoordinate` to return non-null coordinate for collections with empty first element (#987)
* Fix `LargestEmptyCircle` to handle polygonal obstacles (#988)
* Make intersection computation more robust (#989)

### Performance Improvements

* Improve `Polygonizer` performance in some cases with many islands (#906)
* Improve Convex Hull performance by avoiding duplicate uniquing (#985)

# Version 1.19

Expand All @@ -68,6 +77,7 @@ Distributions for older JTS versions can be obtained at the
* Add `ConcaveHullOfPolygons` class (#870)
* Add `PolygonHullSimplifier` class (#861, #880)
* TWKB read and write implementation (#854)
* Add `CubicBezierCurve` class

### Functionality Improvements

Expand All @@ -85,7 +95,7 @@ Distributions for older JTS versions can be obtained at the

### Performance Improvements

* Improve performance of `CoveageUnion` by using boundary chains (#891)
* Improve performance of `CoverageUnion` by using boundary chains (#891)

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.locationtech.jts.algorithm.Angle;
import org.locationtech.jts.algorithm.MinimumBoundingCircle;
import org.locationtech.jts.algorithm.MinimumDiameter;
import org.locationtech.jts.algorithm.MinimumAreaRectangle;
import org.locationtech.jts.algorithm.construct.LargestEmptyCircle;
import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle;
import org.locationtech.jts.algorithm.hull.ConcaveHull;
Expand All @@ -29,9 +30,10 @@ public class ConstructionFunctions {

public static Geometry minimumDiameter(Geometry g) { return (new MinimumDiameter(g)).getDiameter(); }
public static double minimumDiameterLength(Geometry g) { return (new MinimumDiameter(g)).getDiameter().getLength(); }
public static Geometry minimumDiameterRectangle(Geometry g) { return MinimumDiameter.getMinimumRectangle(g); }

public static Geometry minimumRectangle(Geometry g) { return (new MinimumDiameter(g)).getMinimumRectangle(); }

public static Geometry minimumAreaRectangle(Geometry g) { return MinimumAreaRectangle.getMinimumRectangle(g); }
public static Geometry minimumBoundingCircle(Geometry g) { return (new MinimumBoundingCircle(g)).getCircle(); }
public static double minimumBoundingCircleDiameterLen(Geometry g) { return 2 * (new MinimumBoundingCircle(g)).getRadius(); }

Expand Down Expand Up @@ -86,27 +88,27 @@ public static double maximumInscribedCircleRadiusLen(Geometry g,
//--------------------------------------------

@Metadata(description="Constructs the Largest Empty Circle in a set of obstacles")
public static Geometry largestEmptyCircle(Geometry g,
@Metadata(title="Distance tolerance")
public static Geometry largestEmptyCircle(Geometry obstacles, Geometry boundary,
@Metadata(title="Accuracy distance tolerance")
double tolerance) {
LineString radiusLine = LargestEmptyCircle.getRadiusLine(g, tolerance);
LineString radiusLine = LargestEmptyCircle.getRadiusLine(obstacles, boundary, tolerance);
return circleByRadiusLine(radiusLine, 60);
}

@Metadata(description="Computes a radius line of the Largest Empty Circle in a set of obstacles")
public static Geometry largestEmptyCircleCenter(Geometry g,
@Metadata(title="Distance tolerance")
public static Geometry largestEmptyCircleCenter(Geometry obstacles, Geometry boundary,
@Metadata(title="Accuracy distance tolerance")
double tolerance) {
return LargestEmptyCircle.getCenter(g, tolerance);
return LargestEmptyCircle.getCenter(obstacles, boundary, tolerance);
}

@Metadata(description="Computes a radius line of the Largest Empty Circle in a set of obstacles")
public static Geometry largestEmptyCircleRadius(Geometry g,
@Metadata(title="Distance tolerance")
public static Geometry largestEmptyCircleRadius(Geometry obstacles, Geometry boundary,
@Metadata(title="Accuracy distance tolerance")
double tolerance) {
return LargestEmptyCircle.getRadiusLine(g, tolerance);
return LargestEmptyCircle.getRadiusLine(obstacles, boundary, tolerance);
}

//--------------------------------------------

@Metadata(description="Constructs an n-point circle from a 2-point line giving the radius")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ public static Geometry validatePolygonWithGaps(Geometry geom, Geometry adjacentP
return CoveragePolygonValidator.validate(geom, toGeometryArray(adjacentPolys), gapWidth);
}

public static Geometry validateCoverage(Geometry geom) {
public static Geometry validate(Geometry geom) {
Geometry[] invalid = CoverageValidator.validate(toGeometryArray(geom));
return FunctionsUtil.buildGeometry(invalid);
return FunctionsUtil.buildGeometryCollection(invalid, geom.getFactory().createLineString());
}

public static Geometry validateCoverageWithGaps(Geometry geom,
public static Geometry validateWithGaps(Geometry geom,
@Metadata(title="Gap width")
double gapWidth) {
Geometry[] invalid = CoverageValidator.validate(toGeometryArray(geom), gapWidth);
return FunctionsUtil.buildGeometry(invalid);
return FunctionsUtil.buildGeometryCollection(invalid, geom.getFactory().createLineString());
}

public static Geometry findGaps(Geometry geom,
Expand All @@ -53,7 +53,7 @@ public static Geometry findGaps(Geometry geom,
}

@Metadata(description="Fast Union of a coverage")
public static Geometry unionCoverage(Geometry coverage) {
public static Geometry union(Geometry coverage) {
Geometry[] cov = toGeometryArray(coverage);
return CoverageUnion.union(cov);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ public static void showIndicator(Geometry geom)

public static void showIndicator(Geometry geom, Color lineClr)
{
if (! isShowingIndicators()) return;

GeometryEditPanel panel = JTSTestBuilderFrame
.instance().getTestCasePanel()
.getGeometryEditPanel();
Graphics2D gr = (Graphics2D) panel.getGraphics();
GeometryPainter.paint(geom, panel.getViewport(), gr,
lineClr,
AppConstants.INDICATOR_FILL_CLR);
JTSTestBuilder.controller().indicatorShow(geom, lineClr);
}

public static Geometry buildGeometry(List geoms, Geometry parentGeom)
Expand All @@ -87,10 +79,7 @@ public static Geometry buildGeometry(List geoms, Geometry parentGeom)

public static Geometry buildGeometry(Geometry[] geoms)
{
GeometryFactory gf = JTSTestBuilder.getGeometryFactory();
if (geoms.length > 0) {
gf = getFactoryOrDefault(geoms[0]);
}
GeometryFactory gf = getFactory(geoms);

List<Geometry> geomList = new ArrayList<Geometry>();
for (Geometry geom : geoms) {
Expand All @@ -103,6 +92,28 @@ public static Geometry buildGeometry(Geometry[] geoms)
return gf.buildGeometry(geomList);
}

public static Geometry buildGeometryCollection(Geometry[] geoms, Geometry nullGeom)
{
GeometryFactory gf = getFactory(geoms);

Geometry[] geomArray = new Geometry[geoms.length];
for (int i = 0; i < geoms.length; i++) {
Geometry srcGeom = geoms[i] == null ? nullGeom : geoms[i];
if (srcGeom != null) {
geomArray[i] = srcGeom.copy();
}
}
return gf.createGeometryCollection(geomArray);
}

private static GeometryFactory getFactory(Geometry[] geoms) {
GeometryFactory gf = JTSTestBuilder.getGeometryFactory();
if (geoms.length > 0) {
gf = getFactoryOrDefault(geoms[0]);
}
return gf;
}

public static Geometry buildGeometry(Geometry a, Geometry b) {
Geometry[] geoms = toGeometryArray(a, b);
return getFactoryOrDefault(a, b).createGeometryCollection(geoms); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.locationtech.jts.noding.FastNodingValidator;
import org.locationtech.jts.noding.IntersectionAdder;
import org.locationtech.jts.noding.MCIndexNoder;
import org.locationtech.jts.noding.NodedSegmentString;
import org.locationtech.jts.noding.Noder;
import org.locationtech.jts.noding.NodingIntersectionFinder;
import org.locationtech.jts.noding.SegmentStringUtil;
Expand Down Expand Up @@ -107,51 +108,66 @@ private static void processNodes(Geometry geom, NodingIntersectionFinder intFind
noder.computeNodes( SegmentStringUtil.extractBasicSegmentStrings(geom) );
}

public static Geometry MCIndexNodingWithPrecision(Geometry geom, double scaleFactor)
public static Geometry MCIndexNodingWithPrecision(Geometry geom,
@Metadata(isRequired=false)
Geometry geom2,
@Metadata(title="Precision Scale")
double scaleFactor)
{
List<NodedSegmentString> segs = extractNodedSegmentStrings(geom, geom2);
PrecisionModel fixedPM = new PrecisionModel(scaleFactor);

LineIntersector li = new RobustLineIntersector();
li.setPrecisionModel(fixedPM);

Noder noder = new MCIndexNoder(new IntersectionAdder(li));
noder.computeNodes( SegmentStringUtil.extractNodedSegmentStrings(geom) );
noder.computeNodes( segs );
return SegmentStringUtil.toGeometry( noder.getNodedSubstrings(), FunctionsUtil.getFactoryOrDefault(geom) );
}

public static Geometry MCIndexNoding(Geometry geom)
public static Geometry MCIndexNoding(Geometry geom,
@Metadata(isRequired=false)
Geometry geom2)
{
List<NodedSegmentString> segs = extractNodedSegmentStrings(geom, geom2);
Noder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector()));
noder.computeNodes( SegmentStringUtil.extractNodedSegmentStrings(geom) );
noder.computeNodes( segs );
return SegmentStringUtil.toGeometry(noder.getNodedSubstrings(), FunctionsUtil.getFactoryOrDefault(geom));
}

@Metadata(description="Nodes input using the SnappingNoder")
public static Geometry snappingNoder(Geometry geom, Geometry geom2,
public static Geometry snappingNoder(Geometry geom,
@Metadata(isRequired=false)
Geometry geom2,
@Metadata(title="Snap distance")
double snapDistance)
{
List segs = SegmentStringUtil.extractNodedSegmentStrings(geom);
if (geom2 != null) {
List segs2 = SegmentStringUtil.extractNodedSegmentStrings(geom2);
segs.addAll(segs2);
}
List<NodedSegmentString> segs = extractNodedSegmentStrings(geom, geom2);
Noder noder = new SnappingNoder(snapDistance);
noder.computeNodes(segs);
Collection nodedSegStrings = noder.getNodedSubstrings();
return SegmentStringUtil.toGeometry(nodedSegStrings, FunctionsUtil.getFactoryOrDefault(geom));
}

@Metadata(description="Nodes input using the SnapRoundingNoder")
public static Geometry snapRoundingNoder(Geometry geom, Geometry geom2,
@Metadata(title="Scale factor")
double scaleFactor)
{
List segs = SegmentStringUtil.extractNodedSegmentStrings(geom);
private static List<NodedSegmentString> extractNodedSegmentStrings(Geometry geom1, Geometry geom2) {
@SuppressWarnings("unchecked")
List<NodedSegmentString> segs = SegmentStringUtil.extractNodedSegmentStrings(geom1);
if (geom2 != null) {
List segs2 = SegmentStringUtil.extractNodedSegmentStrings(geom2);
@SuppressWarnings("unchecked")
List<NodedSegmentString> segs2 = SegmentStringUtil.extractNodedSegmentStrings(geom2);
segs.addAll(segs2);
}
return segs;
}

@Metadata(description="Nodes input using the SnapRoundingNoder")
public static Geometry snapRoundingNoder(Geometry geom,
@Metadata(isRequired=false)
Geometry geom2,
@Metadata(title="Precision Scale")
double scaleFactor)
{
List<NodedSegmentString> segs = extractNodedSegmentStrings(geom, geom2);
PrecisionModel pm = new PrecisionModel(scaleFactor);
Noder noder = new SnapRoundingNoder(pm);
noder.computeNodes(segs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static Geometry fixInvalid(Geometry geom) {
return GeometryFixer.fix(geom);
}

public static Geometry fixIfInvalid(Geometry geom) {
if (geom.isValid())
return geom.copy();
return GeometryFixer.fix(geom);
}

public static Geometry fixInvalidKeepCollapse(Geometry geom) {
GeometryFixer fixer = new GeometryFixer(geom);
fixer.setKeepCollapsed(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public class AppConstants
public static final Color HIGHLIGHT_FILL_CLR = new Color(255, 240, 192, 200);

public static final Color BAND_CLR = new Color(255, 0, 0, 255);
public static final Color INDICATOR_FILL_CLR = GeometryDepiction.GEOM_RESULT_FILL_CLR;
public static final Color INDICATOR_FILL_CLR = new Color(255, 200, 255, 100);
public static final Color INDICATOR_LINE_CLR = new Color(150, 0, 150);
//public static final Color INDICATOR_LINE_COLOR = new Color(255, 0, 0, 255);
//public static final Color INDICATOR_FILL_COLOR = new Color(255, 200, 200, 200);
public static final Color INDICATOR_LINE_CLR = GeometryDepiction.GEOM_RESULT_LINE_CLR;

public static final int AXIS_WIDTH = 3;
public static final Color AXIS_CLR = Color.lightGray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class AppIcons {
public final static ImageIcon GEOM_EXCHANGE = load("ExchangeGeoms.png");

public final static ImageIcon GEOFUNC_BINARY = load("BinaryGeomFunction.png");
public final static ImageIcon EDIT_GRID = load("DrawingGrid.png");

public final static ImageIcon DOWN = load("Down.png");
public final static ImageIcon UP = load("Up.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class AppStrings {

public static final String TIP_ALLOW_INVERTED_RINGS = "Allow valid inverted shells and exverted holes";

public static final String LYR_INDICATORS = "Indicators";




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ private LayerList getLayerList()
return tbModel.getLayers();
}

public void setShowingGrid(boolean isEnabled)
{
viewStyle.setGridEnabled(isEnabled);
forceRepaint();
}

public void setShowingInput(boolean isEnabled)
{
if (tbModel == null) return;
Expand Down Expand Up @@ -428,6 +434,11 @@ private void drawRevealMask(Graphics2D g) {
g.fill(mask);
}

public void draw(Geometry geom, Color lineClr, Color fillClr) {
Graphics2D gr = (Graphics2D) getGraphics();
GeometryPainter.paint(geom, getViewport(), gr, lineClr, fillClr);
}

public void flash(Geometry g)
{
Graphics2D gr = (Graphics2D) getGraphics();
Expand Down
Loading

0 comments on commit 662aca1

Please sign in to comment.