use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class GeometryGraph method insertBoundaryPoint.
/**
* Adds candidate boundary points using the current {@link BoundaryNodeRule}.
* This is used to add the boundary
* points of dim-1 geometries (Curves/MultiCurves).
*/
private void insertBoundaryPoint(final int argIndex, final Point point) {
final NodeMap nodes = getNodeMap();
final Node n = nodes.addNode(point);
// nodes always have labels
final Label lbl = n.getLabel();
// the new point to insert is on a boundary
int boundaryCount = 1;
// determine the current location for the point (if any)
Location loc = Location.NONE;
loc = lbl.getLocation(argIndex, Position.ON);
if (loc == Location.BOUNDARY) {
boundaryCount++;
}
// determine the boundary status of the point according to the Boundary
// Determination Rule
final Location newLoc = determineBoundary(this.boundaryNodeRule, boundaryCount);
lbl.setLocation(argIndex, newLoc);
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class GeometryGraph method addPolygonRing.
/**
* Adds a polygon ring to the graph.
* Empty rings are ignored.
*
* The left and right topological location arguments assume that the ring is oriented CW.
* If the ring is in the opposite orientation,
* the left and right locations must be interchanged.
*/
private void addPolygonRing(final LinearRing ring, final Location cwLeft, final Location cwRight) {
if (!ring.isEmpty()) {
final LineString simplifiedRing;
try {
simplifiedRing = ring.removeDuplicatePoints();
final int vertexCount = simplifiedRing.getVertexCount();
if (vertexCount > 3) {
Location left;
Location right;
if (ring.isCounterClockwise()) {
left = cwRight;
right = cwLeft;
} else {
left = cwLeft;
right = cwRight;
}
final Label label = new Label(this.argIndex, Location.BOUNDARY, left, right);
final Edge e = new Edge(simplifiedRing, label);
this.lineEdgeMap.put(ring, e);
insertEdge(e);
// insert the endpoint as a node, to mark that it is on the boundary
insertPoint(this.argIndex, simplifiedRing.getPoint2D(0), Location.BOUNDARY);
} else if (vertexCount == 0) {
this.hasTooFewPoints = true;
this.invalidPoint = GeometryFactory.DEFAULT_2D.point();
} else {
this.hasTooFewPoints = true;
this.invalidPoint = simplifiedRing.getPoint2D(0);
}
} catch (final IllegalArgumentException e) {
this.hasTooFewPoints = true;
this.invalidPoint = ring.getPoint2D(0);
}
}
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class Node method computeMergedLocation.
/**
* The location for a given eltIndex for a node will be one
* of { null, INTERIOR, BOUNDARY }.
* A node may be on both the boundary and the interior of a geometry;
* in this case, the rule is that the node is considered to be in the boundary.
* The merged location is the maximum of the two input values.
*/
Location computeMergedLocation(final Label label2, final int eltIndex) {
Location loc = Location.NONE;
loc = this.label.getLocation(eltIndex);
if (!label2.isNull(eltIndex)) {
final Location nLoc = label2.getLocation(eltIndex);
if (loc != Location.BOUNDARY) {
loc = nLoc;
}
}
return loc;
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class EdgeEndStar method computeLabelling.
public void computeLabelling(final GeometryGraph[] geomGraph) {
computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());
// Propagate side labels around the edges in the star
// for each parent Geometry
// Debug.print(this);
propagateSideLabels(0);
// Debug.print(this);
// Debug.printIfWatch(this);
propagateSideLabels(1);
// Debug.print(this);
// Debug.printIfWatch(this);
/**
* If there are edges that still have null labels for a geometry
* this must be because there are no area edges for that geometry incident on this node.
* In this case, to label the edge for that geometry we must test whether the
* edge is in the interior of the geometry.
* To do this it suffices to determine whether the node for the edge is in the interior of an area.
* If so, the edge has location INTERIOR for the geometry.
* In all other cases (e.g. the node is on a line, on a point, or not on the geometry at all) the edge
* has the location EXTERIOR for the geometry.
* <p>
* Note that the edge cannot be on the BOUNDARY of the geometry, since then
* there would have been a parallel edge from the Geometry at this node also labelled BOUNDARY
* and this edge would have been labelled in the previous step.
* <p>
* This code causes a problem when dimensional collapses are present, since it may try and
* determine the location of a node where a dimensional collapse has occurred.
* The point should be considered to be on the EXTERIOR
* of the polygon, but locate() will return INTERIOR, since it is passed
* the original Geometry, not the collapsed version.
*
* If there are incident edges which are Line edges labelled BOUNDARY,
* then they must be edges resulting from dimensional collapses.
* In this case the other edges can be labelled EXTERIOR for this Geometry.
*
* MD 8/11/01 - NOT TRUE! The collapsed edges may in fact be in the interior of the Geometry,
* which means the other edges should be labelled INTERIOR for this Geometry.
* Not sure how solve this... Possibly labelling needs to be split into several phases:
* area label propagation, symLabel merging, then finally null label resolution.
*/
final boolean[] hasDimensionalCollapseEdge = { false, false };
for (final EdgeEnd e : this) {
final Label label = e.getLabel();
for (int geomi = 0; geomi < 2; geomi++) {
if (label.isLine(geomi) && label.getLocation(geomi) == Location.BOUNDARY) {
hasDimensionalCollapseEdge[geomi] = true;
}
}
}
// Debug.print(this);
for (final EdgeEnd e : this) {
final Label label = e.getLabel();
// Debug.println(e);
for (int geomi = 0; geomi < 2; geomi++) {
if (label.isAnyNull(geomi)) {
Location loc = Location.NONE;
if (hasDimensionalCollapseEdge[geomi]) {
loc = Location.EXTERIOR;
} else {
final double x = e.getX1();
final double y = e.getY1();
final Point c = e.getCoordinate();
loc = getLocation(geomi, x, y, geomGraph);
}
label.setAllLocationsIfNull(geomi, loc);
}
}
// Debug.println(e);
}
// Debug.print(this);
// Debug.printIfWatch(this);
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class TopologyLocation method flip.
public void flip() {
if (this.location.length <= 1) {
return;
}
final Location temp = this.location[Position.LEFT];
this.location[Position.LEFT] = this.location[Position.RIGHT];
this.location[Position.RIGHT] = temp;
}
Aggregations