Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/api/geom/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ Common Geometry Methods
Tests if this geometry is within the other geometry. This is the
inverse of :func:`contains`.

.. function:: Geometry.getLargestEmptyCircle

:arg config: :`Object` tolerance property defaults to 1.0
:returns: :class:`geom.Geometry`




Get the largest empty circle in this Geometry.

11 changes: 11 additions & 0 deletions src/main/java/org/geoscript/js/geom/Geometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Objects;

import org.locationtech.jts.algorithm.construct.LargestEmptyCircle;
import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle;
import org.locationtech.jts.densify.Densifier;
import org.geoscript.js.GeoObject;
Expand Down Expand Up @@ -370,6 +371,16 @@ public ScriptableObject createDelaunayTriangles(boolean isConforming) {
return triangles;
}

@JSFunction
public Geometry getLargestEmptyCircle(NativeObject config) {
double tolerance = getDouble(config.getOrDefault("tolerance", 1.0));
LargestEmptyCircle algorithm = new LargestEmptyCircle(getGeometry(), tolerance);
return (Geometry) GeometryWrapper.wrap(
getParentScope(),
algorithm.getCenter().buffer(algorithm.getRadiusLine().getLength())
);
}

@JSFunction
public String getGeometryType() {
return geometry.getGeometryType();
Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/org/geoscript/js/tests/geoscript/test_geom.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ exports["test: create random points"] = function() {

}

exports["test: largest empty circle"] = function() {

var geom = new GEOM.Polygon([[
[-122.38855361938475, 47.5805786829606], [-122.38636493682861, 47.5783206388176],
[-122.38700866699219, 47.5750491969984], [-122.38177299499512, 47.57502024527343],
[-122.38481998443604, 47.5780600889959], [-122.38151550292969, 47.5805786829606],
[-122.38855361938475, 47.5805786829606]
]]);
ASSERT.ok(geom instanceof GEOM.Polygon);
var circle = geom.getLargestEmptyCircle({tolerance: 1.0});
ASSERT.ok(circle instanceof GEOM.Polygon);

}

exports["test: create conforming delaunay triangles"] = function() {

var geom = GEOM.Point([1,1]).buffer(50)
Expand Down