Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Feb 13, 2024
1 parent 0795cd3 commit 5cce170
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.locationtech.jts.algorithm.RobustLineIntersector;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Dimension;
import org.locationtech.jts.noding.SegmentIntersector;
import org.locationtech.jts.noding.SegmentString;

Expand Down Expand Up @@ -110,17 +111,21 @@ private void processIntersectionAB(RelateSegmentString ssA, int segIndexA, Relat

private void addABIntersectionNonProper(NodeSection a, NodeSection b) {
//TODO: this needs to be determined from edge dimension
if (topoBuilder.isAreaArea()) {
if (isAreaArea(a, b)) {
topoBuilder.addAreaAreaIntersection(false, a, b);
return;
}
//-- this handles A/L, L/A, and L/L
topoBuilder.addABIntersection(a, b);

//-- node may be in interior or on boundary
//-- node is a vertex which may be in interior or on boundary
//TODO: more logic required?
//TODO: move to topoBuilder
topoBuilder.addEdgeIntersectionNode(a.nodePt());
topoBuilder.updateNodeLocation(a.nodePt());
}

private boolean isAreaArea(NodeSection a, NodeSection b) {
return a.dimension() == Dimension.A && b.dimension() == Dimension.A;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ private RelateGeometry getGeometry(boolean isA) {
return isA ? geomA : geomB;
}

public boolean isA(RelateGeometry geom) {
return geom == geomA;
}

public boolean isAreaArea() {
return dimA == Dimension.A && dimB == Dimension.A;
}

public boolean isSelfNodingRequired() {
//TODO: change to testing for lines or GC with > 1 polygon
if (geomA.isPointsOrPolygons()) return false;
Expand Down Expand Up @@ -167,18 +159,18 @@ private RelateNode getNode(Coordinate intPt) {
}

public void addABIntersectionProper(NodeSection a, NodeSection b) {
int dimA = a.dimension();
int dimB = b.dimension();
if (dimA == 2 && dimB == 2) {
//- a proper edge intersection is an edge cross.
addAreaAreaIntersection(true, a, b);
}

else if (dimA == 2 && dimB == 1) {
addAreaLineCross(a, b);
//addAreaLineCross(RelateGeometry.GEOM_A, a0, a1, b0, b1, intPt);
}
else if (dimA == 1 && dimB == 2) {
addAreaLineCross(b, a);
//addAreaLineCross(RelateGeometry.GEOM_B, b0, b1, a0, a1, intPt);
}
else if (dimA == 1 && dimB == 1) {
addLineLineCross(a, b);
Expand All @@ -189,8 +181,8 @@ else if (dimA == 1 && dimB == 1) {
}

private void addLineLineCross(NodeSection a, NodeSection b) {
//-- create a node at the crossing
addEdgeIntersectionNode(a.nodePt());
//-- create a node at the crossing, with location
updateNodeLocation(a.nodePt());
addABIntersection(a, b);
}

Expand All @@ -210,12 +202,6 @@ private void addAreaLineCross(NodeSection eArea, NodeSection eLine) {

//-- create a node to allow full topology computation
addABIntersection(eArea, eLine);
/*
addEdge(geomArea, Dimension.A, intPt, a0, RelateEdge.IS_REVERSE);
addEdge(geomArea, Dimension.A, intPt, a1, RelateEdge.IS_FORWARD);
addEdge(geomLine, Dimension.L, intPt, l0, RelateEdge.IS_REVERSE);
addEdge(geomLine, Dimension.L, intPt, l1, RelateEdge.IS_FORWARD);
*/
}

public void addAreaAreaIntersection(boolean isProper,
Expand Down Expand Up @@ -277,6 +263,7 @@ public void addSelfIntersection(NodeSection e0, NodeSection e1) {
}

public void addABIntersection(NodeSection e0, NodeSection e1) {
//TODO: add logic to determine topology
RelateNode node = getNode(e0.nodePt());
node.addEdge(e0);
node.addEdge(e1);
Expand Down Expand Up @@ -306,7 +293,7 @@ public void addEdge(boolean isA, int dim, Coordinate nodePt, Coordinate dirPt, b
*
* @param pt
*/
public void addEdgeIntersectionNode(Coordinate pt) {
public void updateNodeLocation(Coordinate pt) {
int locA = geomA.locateNode(pt);
int locB = geomB.locateNode(pt);
updateDim(locA, locB, Dimension.P);
Expand Down Expand Up @@ -465,5 +452,9 @@ private void evaluateNode(RelateNode node) {
e.location(RelateGeometry.GEOM_B, Position.ON), Dimension.L);
}
}

public boolean isAreaArea() {
return dimA == Dimension.A && dimB == Dimension.A;
}

}

0 comments on commit 5cce170

Please sign in to comment.