Skip to content

Commit

Permalink
Match JTS MaximumInscribedCircle
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jan 14, 2025
1 parent 3c42d2d commit d9a8448
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/geos/algorithm/construct/MaximumInscribedCircle.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class GEOS_DLL MaximumInscribedCircle {
geom::CoordinateXY radiusPt;

/* private methods */
double distanceToBoundary(const geom::Coordinate& c);
double distanceToBoundary(geom::Point& pt);
double distanceToBoundary(double x, double y);
void compute();

Expand Down
24 changes: 12 additions & 12 deletions src/algorithm/construct/MaximumInscribedCircle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/LineString.h>
#include <geos/geom/Point.h>
#include <geos/geom/Polygon.h>
#include <geos/geom/MultiPolygon.h>
#include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
Expand Down Expand Up @@ -142,31 +143,30 @@ MaximumInscribedCircle::createInitialGrid(const Envelope* env, Cell::CellQueue&

/* private */
double
MaximumInscribedCircle::distanceToBoundary(const Coordinate& c)
MaximumInscribedCircle::distanceToBoundary(double x, double y)
{
std::unique_ptr<Point> pt(factory->createPoint(c));
double dist = indexedDistance.distance(pt.get());
// double dist = inputGeomBoundary->distance(pt.get());
bool isOutside = (Location::EXTERIOR == ptLocator.locate(&c));
if (isOutside) return -dist;
return dist;
Coordinate coord(x, y);
std::unique_ptr<Point> pt(factory->createPoint(coord));
return distanceToBoundary(*pt.get());
}

/* private */
double
MaximumInscribedCircle::distanceToBoundary(double x, double y)
MaximumInscribedCircle::distanceToBoundary(Point& pt)
{
Coordinate coord(x, y);
return distanceToBoundary(coord);
double dist = indexedDistance.distance(&pt);
// double dist = inputGeomBoundary->distance(pt.get());
bool isOutside = (Location::EXTERIOR == ptLocator.locate(pt.getCoordinate()));
if (isOutside) return -dist;
return dist;
}

/* private */
MaximumInscribedCircle::Cell
MaximumInscribedCircle::createInteriorPointCell(const Geometry* geom)
{
std::unique_ptr<Point> p = geom->getInteriorPoint();
Coordinate c(p->getX(), p->getY());
Cell cell(p->getX(), p->getY(), 0, distanceToBoundary(c));
Cell cell(p->getX(), p->getY(), 0, distanceToBoundary(*p.get()));
return cell;
}

Expand Down

0 comments on commit d9a8448

Please sign in to comment.