File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
main/groovy/geoscript/geom
test/groovy/geoscript/geom Expand file tree Collapse file tree 2 files changed +26
-1
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.MaximumInscribedCircle
3
4
import org.locationtech.jts.geom.Geometry as JtsGeometry
4
5
import org.locationtech.jts.geom.GeometryFactory
5
6
import org.locationtech.jts.geom.Coordinate
@@ -512,6 +513,18 @@ class Geometry {
512
513
Geometry . wrap(oct. toGeometry(factory))
513
514
}
514
515
516
+ /**
517
+ * Get the maximum inscribed circle for this Geometry
518
+ * @param tolerance The tolerance which defaults to 1.0
519
+ * @return The maximum inscribed circle
520
+ */
521
+ Geometry getMaximumInscribedCircle (double tolerance = 1.0 ) {
522
+ MaximumInscribedCircle algorithm = new MaximumInscribedCircle (g, tolerance)
523
+ def radiusLineString = algorithm. getRadiusLine()
524
+ def centerPoint = radiusLineString. getStartPoint()
525
+ Geometry . wrap(centerPoint. buffer(radiusLineString. getLength()))
526
+ }
527
+
515
528
/**
516
529
* Get Delaunay Triangle Diagram for this Geometry
517
530
* @return A Delaunay Triangle Diagram Geometry
Original file line number Diff line number Diff line change @@ -506,7 +506,19 @@ class GeometryTestCase {
506
506
assertTrue octalEnvelope. isValid()
507
507
assertFalse octalEnvelope. isEmpty()
508
508
}
509
-
509
+
510
+ @Test void getMaximumInscribedCircle () {
511
+ Geometry g = Geometry . fromWKT(" POLYGON ((-122.38855361938475 47.5805786829606, -122.38636493682861 47.5783206388176, " +
512
+ " -122.38700866699219 47.5750491969984, -122.38177299499512 47.57502024527343, " +
513
+ " -122.38481998443604 47.5780600889959, -122.38151550292969 47.5805786829606, " +
514
+ " -122.38855361938475 47.5805786829606))" )
515
+ Geometry circle = g. getMaximumInscribedCircle(1.0 )
516
+ assertNotNull circle
517
+ assertTrue circle. isValid()
518
+ assertFalse circle. isEmpty()
519
+ assertTrue (circle instanceof Polygon )
520
+ }
521
+
510
522
/* @Test void createFromText() {
511
523
Geometry g = Geometry.createFromText("B")
512
524
assertEquals "Polygon", g.geometryType
You can’t perform that action at this time.
0 commit comments