File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
main/groovy/geoscript/geom
test/groovy/geoscript/geom Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 11package geoscript.geom
22
3+ import org.locationtech.jts.algorithm.construct.LargestEmptyCircle
34import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle
45import org.locationtech.jts.geom.Geometry as JtsGeometry
56import org.locationtech.jts.geom.GeometryFactory
@@ -525,6 +526,18 @@ class Geometry {
525526 Geometry . wrap(centerPoint. buffer(radiusLineString. getLength()))
526527 }
527528
529+ /**
530+ * Get the largest empty circle for this Geometry
531+ * @param tolerance The tolerance which defaults to 1.0
532+ * @return The largest empty circle
533+ */
534+ Geometry getLargestEmptyCircle (double tolerance = 1.0 ) {
535+ LargestEmptyCircle algorithm = new LargestEmptyCircle (g, tolerance)
536+ def radiusLineString = algorithm. getRadiusLine()
537+ def centerPoint = radiusLineString. getStartPoint()
538+ Geometry . wrap(centerPoint. buffer(radiusLineString. getLength()))
539+ }
540+
528541 /**
529542 * Get Delaunay Triangle Diagram for this Geometry
530543 * @return A Delaunay Triangle Diagram Geometry
Original file line number Diff line number Diff line change @@ -519,6 +519,18 @@ class GeometryTestCase {
519519 assertTrue (circle instanceof Polygon )
520520 }
521521
522+ @Test void getLargestEmptyCircle () {
523+ Geometry g = Geometry . fromWKT(" POLYGON ((-122.38855361938475 47.5805786829606, -122.38636493682861 47.5783206388176, " +
524+ " -122.38700866699219 47.5750491969984, -122.38177299499512 47.57502024527343, " +
525+ " -122.38481998443604 47.5780600889959, -122.38151550292969 47.5805786829606, " +
526+ " -122.38855361938475 47.5805786829606))" )
527+ Geometry circle = g. getLargestEmptyCircle(1.0 )
528+ assertNotNull circle
529+ assertTrue circle. isValid()
530+ assertFalse circle. isEmpty()
531+ assertTrue (circle instanceof Polygon )
532+ }
533+
522534 /* @Test void createFromText() {
523535 Geometry g = Geometry.createFromText("B")
524536 assertEquals "Polygon", g.geometryType
You can’t perform that action at this time.
0 commit comments