* at intersections */
for (MapOverlap<?,?> overlap : segment.getOverlaps()) {
MapElement other = overlap.getOther(segment);
WorldObject otherWO = other.getPrimaryRepresentation();
if (otherWO == null
|| otherWO.getGroundState() != ON) //TODO remove the ground state check
continue;
boolean thisIsUpper = this.getGroundState() == ABOVE; //TODO check layers
double distance = 10.0; //TODO base on clearing
if (overlap instanceof MapIntersectionWW) {
MapIntersectionWW intersection = (MapIntersectionWW) overlap;
if (otherWO instanceof AbstractNetworkWaySegmentWorldObject) {
AbstractNetworkWaySegmentWorldObject otherANWSWO =
((AbstractNetworkWaySegmentWorldObject)otherWO);
EleConnector thisConn = primaryRep.getEleConnectors()
.getConnector(intersection.pos);
EleConnector otherConn = otherANWSWO.getEleConnectors()
.getConnector(intersection.pos);
if (thisIsUpper) {
enforcer.requireVerticalDistance(
MIN, distance, thisConn, otherConn);
} else {
enforcer.requireVerticalDistance(
MIN, distance, otherConn, thisConn);
}
}
} else if (overlap instanceof MapOverlapWA) {
/*
* require minimum distance at intersection points
* (these have been inserted into this segment,
* but not into the area)
*/
MapOverlapWA overlapWA = (MapOverlapWA) overlap;
if (overlap.type == MapOverlapType.INTERSECT
&& otherWO instanceof AbstractAreaWorldObject) {
AbstractAreaWorldObject otherAAWO =
((AbstractAreaWorldObject)otherWO);
for (int i = 0; i < overlapWA.getIntersectionPositions().size(); i++) {
VectorXZ pos =
overlapWA.getIntersectionPositions().get(i);
MapAreaSegment areaSegment =
overlapWA.getIntersectingAreaSegments().get(i);
EleConnector thisConn = primaryRep.getEleConnectors()
.getConnector(pos);
EleConnector base1 = otherAAWO.getEleConnectors()
.getConnector(areaSegment.getStartNode().getPos());
EleConnector base2 = otherAAWO.getEleConnectors()
.getConnector(areaSegment.getEndNode().getPos());
if (thisConn != null && base1 != null && base2 != null) {
if (thisIsUpper) {
enforcer.requireVerticalDistance(MIN, distance,
thisConn, base1, base2);
} else {
enforcer.requireVerticalDistance(MAX, -distance,
thisConn, base1, base2);
}
}
}
}
/*
* require minimum distance to the area's elevation connectors.
* There is usually no direct counterpart for these in this segment.
* Examples include trees on terrain above tunnels.
*/
if (!(otherWO instanceof Forest)) continue; //TODO enable and debug for other WO classes
eleConnectors:
for (EleConnector c : otherWO.getEleConnectors()) {
if (outlinePolygonXZ == null ||
!outlinePolygonXZ.contains(c.pos))
continue eleConnectors;