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 1
1
package geoscript.geom
2
2
3
+ import org.locationtech.jts.algorithm.construct.LargestEmptyCircle
3
4
import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle
4
5
import org.locationtech.jts.geom.Geometry as JtsGeometry
5
6
import org.locationtech.jts.geom.GeometryFactory
@@ -525,6 +526,18 @@ class Geometry {
525
526
Geometry . wrap(centerPoint. buffer(radiusLineString. getLength()))
526
527
}
527
528
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
+
528
541
/**
529
542
* Get Delaunay Triangle Diagram for this Geometry
530
543
* @return A Delaunay Triangle Diagram Geometry
Original file line number Diff line number Diff line change @@ -519,6 +519,18 @@ class GeometryTestCase {
519
519
assertTrue (circle instanceof Polygon )
520
520
}
521
521
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
+
522
534
/* @Test void createFromText() {
523
535
Geometry g = Geometry.createFromText("B")
524
536
assertEquals "Polygon", g.geometryType
You can’t perform that action at this time.
0 commit comments