Skip to content

Commit

Permalink
Check Location::UNDEF to Location::NONE to match JTS
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Aug 10, 2020
1 parent cae4a88 commit e727df5
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion include/geos/geom/Location.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum class GEOS_DLL Location : char {
/**
* Used for uninitialized location values.
*/
UNDEF = (char)(-1), // Instead of NULL
NONE = (char)(-1), // Instead of NULL

/**
* DE-9IM row index of the interior of the first geometry and
Expand Down
6 changes: 3 additions & 3 deletions include/geos/geomgraph/Label.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GEOS_DLL Label {
* for the given Geometry.
*
* Other geometry location will be set to
* Location::UNDEF.
* Location::NONE.
*/
Label(int geomIndex, geom::Location onLoc);

Expand All @@ -96,7 +96,7 @@ class GEOS_DLL Label {
Label& operator= (const Label& l);

/** \brief
* Initialize both locations to Location::UNDEF
* Initialize both locations to Location::NONE
*
* isNull() should return true after this kind of construction
*/
Expand All @@ -106,7 +106,7 @@ class GEOS_DLL Label {
* Construct a Label with On, Left and Right locations for the
* given Geometries.
* Initialize the locations for the other Geometry to
* Location::UNDEF
* Location::NONE
*/
Label(int geomIndex, geom::Location onLoc, geom::Location leftLoc, geom::Location rightLoc);

Expand Down
10 changes: 5 additions & 5 deletions include/geos/geomgraph/Label.inl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace geomgraph { // geos.geomgraph
INLINE Label
Label::toLineLabel(const Label& label)
{
Label lineLabel(geom::Location::UNDEF);
Label lineLabel(geom::Location::NONE);
for(int i = 0; i < 2; i++) {
lineLabel.setLocation(i, label.getLocation(i));
}
Expand All @@ -50,7 +50,7 @@ Label::Label(geom::Location onLoc) :
/*public*/
INLINE
Label::Label(int geomIndex, geom::Location onLoc) :
elt{TopologyLocation(geom::Location::UNDEF), TopologyLocation(geom::Location::UNDEF)}
elt{TopologyLocation(geom::Location::NONE), TopologyLocation(geom::Location::NONE)}
{
assert(geomIndex >= 0 && geomIndex < 2);
elt[geomIndex].setLocation(onLoc);
Expand All @@ -66,7 +66,7 @@ Label::Label(geom::Location onLoc, geom::Location leftLoc, geom::Location rightL
/*public*/
INLINE
Label::Label()
: elt{TopologyLocation(geom::Location::UNDEF), TopologyLocation(geom::Location::UNDEF)}
: elt{TopologyLocation(geom::Location::NONE), TopologyLocation(geom::Location::NONE)}
{
}

Expand All @@ -90,8 +90,8 @@ Label::operator=(const Label& l)
INLINE
Label::Label(int geomIndex, geom::Location onLoc, geom::Location leftLoc, geom::Location rightLoc)
{
elt[0] = TopologyLocation(geom::Location::UNDEF, geom::Location::UNDEF, geom::Location::UNDEF);
elt[1] = TopologyLocation(geom::Location::UNDEF, geom::Location::UNDEF, geom::Location::UNDEF);
elt[0] = TopologyLocation(geom::Location::NONE, geom::Location::NONE, geom::Location::NONE);
elt[1] = TopologyLocation(geom::Location::NONE, geom::Location::NONE, geom::Location::NONE);
elt[geomIndex].setLocations(onLoc, leftLoc, rightLoc);
}

Expand Down
8 changes: 4 additions & 4 deletions include/geos/geomgraph/TopologyLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace geomgraph { // geos.geomgraph
* topological relationship attribute, ON.
*
* The possible values of a topological location are
* {Location::UNDEF, Location::EXTERIOR, Location::BOUNDARY, Location::INTERIOR}
* {Location::NONE, Location::EXTERIOR, Location::BOUNDARY, Location::INTERIOR}
*
* The labelling is stored in an array location[j] where
* where j has the values ON, LEFT, RIGHT
Expand All @@ -71,7 +71,7 @@ class GEOS_DLL TopologyLocation {
* Geometry.
*
* Possible values for the
* parameters are Location::UNDEF, Location::EXTERIOR, Location::BOUNDARY,
* parameters are Location::NONE, Location::EXTERIOR, Location::BOUNDARY,
* and Location::INTERIOR.
*
* @see Location
Expand All @@ -87,12 +87,12 @@ class GEOS_DLL TopologyLocation {
geom::Location get(std::size_t posIndex) const;

/**
* @return true if all locations are Location::UNDEF
* @return true if all locations are Location::NONE
*/
bool isNull() const;

/**
* @return true if any locations is Location::UNDEF
* @return true if any locations is Location::NONE
*/
bool isAnyNull() const;

Expand Down
10 changes: 5 additions & 5 deletions include/geos/geomgraph/TopologyLocation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ INLINE
TopologyLocation::TopologyLocation(Location on):
locationSize(1)
{
location.fill(Location::UNDEF);
location.fill(Location::NONE);
location[Position::ON] = on;
}

Expand Down Expand Up @@ -76,15 +76,15 @@ TopologyLocation::get(size_t posIndex) const
if(posIndex < locationSize) {
return location[posIndex];
}
return Location::UNDEF;
return Location::NONE;
}

/*public*/
INLINE bool
TopologyLocation::isNull() const
{
for(size_t i = 0; i < locationSize; ++i) {
if(location[i] != Location::UNDEF) {
if(location[i] != Location::NONE) {
return false;
}
}
Expand All @@ -96,7 +96,7 @@ INLINE bool
TopologyLocation::isAnyNull() const
{
for(size_t i = 0; i < locationSize; ++i) {
if(location[i] == Location::UNDEF) {
if(location[i] == Location::NONE) {
return true;
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ INLINE void
TopologyLocation::setAllLocationsIfNull(Location locValue)
{
for(size_t i = 0; i < locationSize; ++i) {
if(location[i] == Location::UNDEF) {
if(location[i] == Location::NONE) {
location[i] = locValue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/geos/operation/overlay/OverlayOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class GEOS_DLL OverlayOp: public GeometryGraphOperation {
* the result of overlaying the geometries using
* a given overlay operation.
*
* The method handles arguments of [Location::UNDEF](@ref geom::Location::UNDEF) correctly
* The method handles arguments of [Location::NONE](@ref geom::Location::NONE) correctly
*
* @param label the topological label of the point
* @param opCode the code for the overlay operation to test
Expand Down
2 changes: 1 addition & 1 deletion include/geos/operation/overlayng/OverlayLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class GEOS_DLL OverlayLabel {

public:

static constexpr Location LOC_UNKNOWN = Location::UNDEF;
static constexpr Location LOC_UNKNOWN = Location::NONE;

enum {
DIM_UNKNOWN = -1,
Expand Down
2 changes: 1 addition & 1 deletion src/geom/IntersectionMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ IntersectionMatrix::setAtLeast(Location row, Location col, int minimumDimensionV
void
IntersectionMatrix::setAtLeastIfValid(Location row, Location col, int minimumDimensionValue)
{
if(row != Location::UNDEF && col != Location::UNDEF) {
if(row != Location::NONE && col != Location::NONE) {
setAtLeast(row, col, minimumDimensionValue);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/geom/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ operator<<(std::ostream& os, const Location& loc)
case Location::INTERIOR:
os << 'i';
break;
case Location::UNDEF:
case Location::NONE:
os << '-';
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/geom/prep/PreparedPolygonPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct LocationNotMatchingFilter : public GeometryComponentFilter {
struct OutermostLocationFilter : public GeometryComponentFilter {
explicit OutermostLocationFilter(algorithm::locate::PointOnGeometryLocator* locator) :
pt_locator(locator),
outermost_loc(geom::Location::UNDEF),
outermost_loc(geom::Location::NONE),
done(false) {}

algorithm::locate::PointOnGeometryLocator* pt_locator;
Expand All @@ -96,7 +96,7 @@ struct OutermostLocationFilter : public GeometryComponentFilter {
const Coordinate* pt = g->getCoordinate();
auto loc = pt_locator->locate(pt);

if (outermost_loc == Location::UNDEF || outermost_loc == Location::INTERIOR) {
if (outermost_loc == Location::NONE || outermost_loc == Location::INTERIOR) {
outermost_loc = loc;
} else if (loc == Location::EXTERIOR) {
outermost_loc = loc;
Expand Down
6 changes: 3 additions & 3 deletions src/geomgraph/DirectedEdgeStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ DirectedEdgeStar::computeLabelling(std::vector<GeometryGraph*>* geom)

// determine the overall labelling for this DirectedEdgeStar
// (i.e. for the node it is based at)
label = Label(Location::UNDEF);
label = Label(Location::NONE);
EdgeEndStar::iterator endIt = end();
for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
EdgeEnd* ee = *it;
Expand Down Expand Up @@ -364,7 +364,7 @@ DirectedEdgeStar::findCoveredLineEdges()
* - INTERIOR if the edge is outgoing
* - EXTERIOR if the edge is incoming
*/
Location startLoc = Location::UNDEF;
Location startLoc = Location::NONE;

EdgeEndStar::iterator endIt = end();
for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
Expand All @@ -387,7 +387,7 @@ DirectedEdgeStar::findCoveredLineEdges()
}

// no A edges found, so can't determine if L edges are covered or not
if(startLoc == Location::UNDEF) {
if(startLoc == Location::NONE) {
return;
}

Expand Down
24 changes: 12 additions & 12 deletions src/geomgraph/EdgeEndStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ EdgeEndStar::EdgeEndStar()
:
edgeMap()
{
ptInAreaLocation[0] = Location::UNDEF;
ptInAreaLocation[1] = Location::UNDEF;
ptInAreaLocation[0] = Location::NONE;
ptInAreaLocation[1] = Location::NONE;
}

/*public*/
Expand Down Expand Up @@ -163,7 +163,7 @@ EdgeEndStar::computeLabelling(std::vector<GeometryGraph*>* geomGraph)
Label& label = e->getLabel();
for(int geomi = 0; geomi < 2; ++geomi) {
if(label.isAnyNull(geomi)) {
Location loc = Location::UNDEF;
Location loc = Location::NONE;
if(hasDimensionalCollapseEdge[geomi]) {
loc = Location::EXTERIOR;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ EdgeEndStar::getLocation(int geomIndex,
const Coordinate& p, std::vector<GeometryGraph*>* geom)
{
// compute location only on demand
if(ptInAreaLocation[geomIndex] == Location::UNDEF) {
if(ptInAreaLocation[geomIndex] == Location::NONE) {
ptInAreaLocation[geomIndex] = algorithm::locate::SimplePointInAreaLocator::locate(p,
(*geom)[geomIndex]->getGeometry());
}
Expand Down Expand Up @@ -230,7 +230,7 @@ EdgeEndStar::checkAreaLabelsConsistent(int geomIndex)
Location startLoc = startLabel.getLocation(geomIndex, Position::LEFT);

// Found unlabelled area edge
assert(startLoc != Location::UNDEF);
assert(startLoc != Location::NONE);

Location currLoc = startLoc;

Expand Down Expand Up @@ -268,7 +268,7 @@ EdgeEndStar::propagateSideLabels(int geomIndex)
// Since edges are stored in CCW order around the node,
// As we move around the ring we move from the right to the
// left side of the edge
Location startLoc = Location::UNDEF;
Location startLoc = Location::NONE;

EdgeEndStar::iterator beginIt = begin();
EdgeEndStar::iterator endIt = end();
Expand All @@ -280,13 +280,13 @@ EdgeEndStar::propagateSideLabels(int geomIndex)
assert(e);
const Label& label = e->getLabel();
if(label.isArea(geomIndex) &&
label.getLocation(geomIndex, Position::LEFT) != Location::UNDEF) {
label.getLocation(geomIndex, Position::LEFT) != Location::NONE) {
startLoc = label.getLocation(geomIndex, Position::LEFT);
}
}

// no labelled sides found, so no labels to propagate
if(startLoc == Location::UNDEF) {
if(startLoc == Location::NONE) {
return;
}

Expand All @@ -296,7 +296,7 @@ EdgeEndStar::propagateSideLabels(int geomIndex)
assert(e);
Label& label = e->getLabel();
// set null ON values to be in current location
if(label.getLocation(geomIndex, Position::ON) == Location::UNDEF) {
if(label.getLocation(geomIndex, Position::ON) == Location::NONE) {
label.setLocation(geomIndex, Position::ON, currLoc);
}

Expand All @@ -311,11 +311,11 @@ EdgeEndStar::propagateSideLabels(int geomIndex)

// if there is a right location, that is the next
// location to propagate
if(rightLoc != Location::UNDEF) {
if(rightLoc != Location::NONE) {
if(rightLoc != currLoc)
throw util::TopologyException("side location conflict",
e->getCoordinate());
if(leftLoc == Location::UNDEF) {
if(leftLoc == Location::NONE) {
// found single null side at e->getCoordinate()
assert(0);
}
Expand All @@ -335,7 +335,7 @@ EdgeEndStar::propagateSideLabels(int geomIndex)
*/
// found single null side
assert(label.getLocation(geomIndex,
Position::LEFT) == Location::UNDEF);
Position::LEFT) == Location::NONE);

label.setLocation(geomIndex, Position::RIGHT,
currLoc);
Expand Down
6 changes: 3 additions & 3 deletions src/geomgraph/EdgeRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ EdgeRing::EdgeRing(DirectedEdge* newStart,
holes(),
maxNodeDegree(-1),
edges(),
label(Location::UNDEF), // new Label(Location::UNDEF)),
label(Location::NONE), // new Label(Location::NONE)),
ring(nullptr),
isHoleVar(false),
shell(nullptr)
Expand Down Expand Up @@ -292,12 +292,12 @@ EdgeRing::mergeLabel(const Label& deLabel, int geomIndex)

Location loc = deLabel.getLocation(geomIndex, Position::RIGHT);
// no information to be had from this label
if(loc == Location::UNDEF) {
if(loc == Location::NONE) {
return;
}

// if there is no current RHS value, set it
if(label.getLocation(geomIndex) == Location::UNDEF) {
if(label.getLocation(geomIndex) == Location::NONE) {
label.setLocation(geomIndex, loc);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/geomgraph/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace geomgraph { // geos.geomgraph
/*public*/
Node::Node(const Coordinate& newCoord, EdgeEndStar* newEdges)
:
GraphComponent(Label(0, Location::UNDEF)),
GraphComponent(Label(0, Location::NONE)),
coord(newCoord),
edges(newEdges)

Expand Down Expand Up @@ -177,7 +177,7 @@ Node::mergeLabel(const Label& label2)
for(int i = 0; i < 2; i++) {
Location loc = computeMergedLocation(label2, i);
Location thisLoc = label.getLocation(i);
if(thisLoc == Location::UNDEF) {
if(thisLoc == Location::NONE) {
label.setLocation(i, loc);
}
}
Expand Down Expand Up @@ -225,7 +225,7 @@ Node::setLabelBoundary(int argIndex)
Location
Node::computeMergedLocation(const Label& label2, int eltIndex)
{
Location loc = Location::UNDEF;
Location loc = Location::NONE;
loc = label.getLocation(eltIndex);
if(!label2.isNull(eltIndex)) {
Location nLoc = label2.getLocation(eltIndex);
Expand Down
6 changes: 3 additions & 3 deletions src/geomgraph/TopologyLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ TopologyLocation::merge(const TopologyLocation& gl)
size_t glsz = gl.locationSize;
if(glsz > sz) {
locationSize = 3;
location[Position::LEFT] = Location::UNDEF;
location[Position::RIGHT] = Location::UNDEF;
location[Position::LEFT] = Location::NONE;
location[Position::RIGHT] = Location::NONE;
}
for(size_t i = 0; i < locationSize; ++i) {
if(location[i] == Location::UNDEF && i < glsz) {
if(location[i] == Location::NONE && i < glsz) {
location[i] = gl.location[i];
}
}
Expand Down
Loading

0 comments on commit e727df5

Please sign in to comment.