diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h index cfb62aa801..ef251c3ee4 100644 --- a/include/geos/algorithm/CGAlgorithmsDD.h +++ b/include/geos/algorithm/CGAlgorithmsDD.h @@ -87,7 +87,7 @@ class GEOS_DLL CGAlgorithmsDD { * * Uses an approach due to Jonathan Shewchuk, which is in the public domain. */ - static int orientationIndexFilter( + static inline int orientationIndexFilter( double pax, double pay, double pbx, double pby, double pcx, double pcy) diff --git a/include/geos/operation/relateng/RelateGeometry.h b/include/geos/operation/relateng/RelateGeometry.h index 3c071d0567..bf6b15377e 100644 --- a/include/geos/operation/relateng/RelateGeometry.h +++ b/include/geos/operation/relateng/RelateGeometry.h @@ -97,6 +97,13 @@ class GEOS_DLL RelateGeometry { static bool isZeroLength(const LineString* line); + bool isZeroLengthLine(const Geometry* g) { + // avoid expensive zero-length calculation if not linear + if (getDimension() != Dimension::L) + return false; + return isZeroLength(g); + }; + RelatePointLocator* getLocator(); Coordinate::ConstXYSet createUniquePoints(); diff --git a/include/geos/operation/relateng/TopologyComputer.h b/include/geos/operation/relateng/TopologyComputer.h index cad2a1bc3a..00b204693c 100644 --- a/include/geos/operation/relateng/TopologyComputer.h +++ b/include/geos/operation/relateng/TopologyComputer.h @@ -67,7 +67,9 @@ class GEOS_DLL TopologyComputer { void initExteriorEmpty(bool geomNonEmpty); - RelateGeometry& getGeometry(bool isA) const; + inline RelateGeometry& getGeometry(bool isA) const { + return isA ? geomA : geomB; + }; void updateDim(Location locA, Location locB, int dimension); @@ -135,16 +137,16 @@ class GEOS_DLL TopologyComputer { public: - TopologyComputer( - TopologyPredicate& p_predicate, - RelateGeometry& p_geomA, - RelateGeometry& p_geomB) - : predicate(p_predicate) - , geomA(p_geomA) - , geomB(p_geomB) - { - initExteriorDims(); - }; + TopologyComputer( + TopologyPredicate& p_predicate, + RelateGeometry& p_geomA, + RelateGeometry& p_geomB) + : predicate(p_predicate) + , geomA(p_geomA) + , geomB(p_geomB) + { + initExteriorDims(); + }; int getDimension(bool isA) const; diff --git a/src/operation/relateng/RelateGeometry.cpp b/src/operation/relateng/RelateGeometry.cpp index 94536c16ef..cb4a93b52c 100644 --- a/src/operation/relateng/RelateGeometry.cpp +++ b/src/operation/relateng/RelateGeometry.cpp @@ -56,7 +56,7 @@ RelateGeometry::RelateGeometry(const Geometry* input, bool isPrepared, const Bou , geomEnv(input->getEnvelopeInternal()) , boundaryNodeRule(bnRule) , geomDim(input->getDimension()) - , isLineZeroLen(isZeroLength(input)) + , isLineZeroLen(isZeroLengthLine(input)) , isGeomEmpty(input->isEmpty()) { analyzeDimensions(); diff --git a/src/operation/relateng/TopologyComputer.cpp b/src/operation/relateng/TopologyComputer.cpp index 984073e467..fe0c0735ea 100644 --- a/src/operation/relateng/TopologyComputer.cpp +++ b/src/operation/relateng/TopologyComputer.cpp @@ -111,11 +111,12 @@ TopologyComputer::initExteriorEmpty(bool geomNonEmpty) } -/* private */ -RelateGeometry& -TopologyComputer::getGeometry(bool isA) const +/* public */ +bool +TopologyComputer::isAreaArea() const { - return isA ? geomA : geomB; + return getDimension(RelateGeometry::GEOM_A) == Dimension::A + && getDimension(RelateGeometry::GEOM_B) == Dimension::A; } @@ -124,16 +125,7 @@ int TopologyComputer::getDimension(bool isA) const { return getGeometry(isA).getDimension(); -} - - -/* public */ -bool -TopologyComputer::isAreaArea() const -{ - return getDimension(RelateGeometry::GEOM_A) == Dimension::A - && getDimension(RelateGeometry::GEOM_B) == Dimension::A; -} +}; /* public */