Skip to content

Commit

Permalink
Remove TopologyPredicateValue
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jan 22, 2024
1 parent a4588d2 commit 28eed68
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,50 @@

public abstract class BasicPredicate implements TopologyPredicate {

private int value = TopologyPredicateValue.UNKNOWN;
public static final int UNKNOWN = -1;
public static final int FALSE = 0;
public static final int TRUE = 1;

public static boolean isKnown(int value) {
return value > UNKNOWN;
}

public static boolean toBoolean(int value) {
// TODO: check for unknown value?
return value == TRUE;
}

public static int toValue(boolean val) {
return val ? TRUE : FALSE;
}

/**
* Tests if two geometries intersect
* based on an interaction at given locations.
*
* @param locA the location on geometry A
* @param locB the location on geometry B
* @return true if the geometries intersect
*/
public static boolean isIntersection(int locA, int locB) {
//-- i.e. some location on both geometries intersects
return locA != Location.EXTERIOR && locB != Location.EXTERIOR;
}

private int value = UNKNOWN;

public boolean isSelfNodingRequired() {
return false;
}

@Override
public boolean isKnown() {
return TopologyPredicateValue.isKnown(value);
return isKnown(value);
}

@Override
public boolean value() {
return TopologyPredicateValue.toBoolean(value);
return toBoolean(value);
}

/**
Expand All @@ -41,7 +71,7 @@ protected void setValue(boolean val) {
//-- don't change already-known value
if (isKnown())
return;
value = TopologyPredicateValue.toValue(val);
value = toValue(val);
}

protected void setValue(int val) {
Expand All @@ -60,19 +90,4 @@ protected void setValueIf(boolean value, boolean cond) {
if (cond)
setValue(value);
}



/**
* Tests if two geometries intersect
* based on an interaction at given locations.
*
* @param locA the location on geometry A
* @param locB the location on geometry B
* @return true if the geometries intersect
*/
public static boolean isIntersection(int locA, int locB) {
//-- i.e. some location on both geometries intersects
return locA != Location.EXTERIOR && locB != Location.EXTERIOR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ public void updateDim(int locA, int locB, int dimension) {

intMatrix.set(locA, locB, dimension);
//-- set value if it is now known
int vp = valuePartial();
setValue( valuePartial());
}

protected int valuePartial() {
return TopologyPredicateValue.UNKNOWN;
return BasicPredicate.UNKNOWN;
}

protected void setRequireCovers(Envelope a, Envelope b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ private void computePointPointOpt(RelateGeometry geomB, TopologyBuilder topoBuil

private void computeAtPoints(RelateGeometry geomSrc, boolean isA,
RelateGeometry geomTarget, TopologyBuilder topoBuilder) {

boolean isResultKnown = false;
isResultKnown = computePoints(geomSrc, isA, geomTarget, topoBuilder);
if (isResultKnown)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,21 @@ public int valuePartial() {
if (dimA == Dimension.L && dimB == Dimension.L) {
//-- L/L interaction can only be dim = 0
if (getDim(Location.INTERIOR, Location.INTERIOR) > Dimension.P)
return TopologyPredicateValue.FALSE;
return BasicPredicate.FALSE;
}
if (dimA < dimB) {
if (isIntersects(Location.INTERIOR, Location.INTERIOR)
&& isIntersects(Location.INTERIOR, Location.EXTERIOR)) {
return TopologyPredicateValue.TRUE;
return BasicPredicate.TRUE;
}
}
else if (dimA > dimB) {
if (isIntersects(Location.INTERIOR, Location.INTERIOR)
&& isIntersects(Location.EXTERIOR, Location.INTERIOR)) {
return TopologyPredicateValue.TRUE;
return BasicPredicate.TRUE;
}
}
return TopologyPredicateValue.UNKNOWN;
return BasicPredicate.UNKNOWN;
}

@Override
Expand Down Expand Up @@ -265,15 +265,15 @@ public int valuePartial() {
if (isIntersects(Location.INTERIOR, Location.INTERIOR)
&& isIntersects(Location.INTERIOR, Location.EXTERIOR)
&& isIntersects(Location.EXTERIOR, Location.INTERIOR))
return TopologyPredicateValue.TRUE;
return BasicPredicate.TRUE;
}
if (dimA == Dimension.L) {
if (isDim(Location.INTERIOR, Location.INTERIOR, 1)
&& isIntersects(Location.INTERIOR, Location.EXTERIOR)
&& isIntersects(Location.EXTERIOR, Location.INTERIOR))
return TopologyPredicateValue.TRUE;
return BasicPredicate.TRUE;
}
return TopologyPredicateValue.UNKNOWN;
return BasicPredicate.UNKNOWN;
}

@Override
Expand Down Expand Up @@ -319,9 +319,9 @@ public boolean valueIM() {
*/
public static int valueIf(boolean value, boolean cond) {
if (cond) {
return TopologyPredicateValue.toValue(value);
return BasicPredicate.toValue(value);
}
return TopologyPredicateValue.UNKNOWN;
return BasicPredicate.UNKNOWN;
}

static boolean isDimsCompatibleWithCovers(int dim0, int dim1) {
Expand Down

This file was deleted.

0 comments on commit 28eed68

Please sign in to comment.