本文整理汇总了Java中com.vividsolutions.jts.util.Assert类的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assert类属于com.vividsolutions.jts.util包,在下文中一共展示了Assert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runCheck
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
@Test
public void runCheck() throws Exception {
TransitSchedule s = ScheduleToolsTest.initSchedule();
Network n = NetworkToolsTest.initNetwork();
PlausibilityCheck check = new PlausibilityCheck(s, n, null);
check.setDirectionChangeThreshold("bus", Math.PI * 95 / 180);
check.setTtRange(0);
check.runCheck();
Map<PlausibilityWarning.Type, Set<PlausibilityWarning>> warnings = check.getWarnings();
Assert.equals(0, warnings.get(PlausibilityWarning.Type.ArtificialLinkWarning).size());
Assert.equals(0, warnings.get(PlausibilityWarning.Type.LoopWarning).size());
Assert.equals(4, warnings.get(PlausibilityWarning.Type.DirectionChangeWarning).size());
Assert.equals(0, warnings.get(PlausibilityWarning.Type.TravelTimeWarning).size());
}
示例2: rotateByQuarterCircle
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Rotates a vector by a given number of quarter-circles (i.e. multiples of 90
* degrees or Pi/2 radians). A positive number rotates counter-clockwise, a
* negative number rotates clockwise. Under this operation the magnitude of
* the vector and the absolute values of the ordinates do not change, only
* their sign and ordinate index.
*
* @param numQuarters the number of quarter-circles to rotate by
* @return the rotated vector.
*/
public Vector2D rotateByQuarterCircle(int numQuarters) {
int nQuad = numQuarters % 4;
if (numQuarters < 0 && nQuad != 0) {
nQuad = nQuad + 4;
}
switch (nQuad) {
case 0:
return create(this.x, this.y);
case 1:
return create(-this.y, this.x);
case 2:
return create(-this.x, -this.y);
case 3:
return create(this.y, -this.x);
}
Assert.shouldNeverReachHere();
return null;
}
示例3: labelIsolatedNodes
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Isolated nodes are nodes whose labels are incomplete
* (e.g. the location for one Geometry is null).
* This is the case because nodes in one graph which don't intersect
* nodes in the other are not completely labelled by the initial process
* of adding nodes to the nodeList.
* To complete the labelling we need to check for nodes that lie in the
* interior of edges, and in the interior of areas.
*/
private void labelIsolatedNodes() {
for (Iterator ni = this.nodes.iterator(); ni.hasNext(); ) {
Node n = (Node) ni.next();
Label label = n.getLabel();
// isolated nodes should always have at least one geometry in their label
Assert.isTrue(label.getGeometryCount() > 0, "node with empty label found");
if (n.isIsolated()) {
if (label.isNull(0)) {
this.labelIsolatedNode(n, 0);
} else {
this.labelIsolatedNode(n, 1);
}
}
}
}
示例4: findIntersectionNodes
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Finds all nodes in a maximal edgering which are self-intersection nodes
*
* @param startDE
* @param label
* @return the list of intersection nodes found,
* or <code>null</code> if no intersection nodes were found
*/
private static List findIntersectionNodes(PolygonizeDirectedEdge startDE, long label) {
PolygonizeDirectedEdge de = startDE;
List intNodes = null;
do {
Node node = de.getFromNode();
if (getDegree(node, label) > 1) {
if (intNodes == null) {
intNodes = new ArrayList();
}
intNodes.add(node);
}
de = de.getNext();
Assert.isTrue(de != null, "found null DE in ring");
Assert.isTrue(de == startDE || !de.isInRing(), "found DE already in ring");
} while (de != startDE);
return intNodes;
}
示例5: checkShellInsideHole
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* This routine checks to see if a shell is properly contained in a hole.
* It assumes that the edges of the shell and hole do not
* properly intersect.
*
* @return <code>null</code> if the shell is properly contained, or
* a Coordinate which is not inside the hole if it is not
*/
private Coordinate checkShellInsideHole(LinearRing shell, LinearRing hole, GeometryGraph graph) {
Coordinate[] shellPts = shell.getCoordinates();
Coordinate[] holePts = hole.getCoordinates();
// TODO: improve performance of this - by sorting pointlists for instance?
Coordinate shellPt = findPtNotNode(shellPts, hole, graph);
// if point is on shell but not hole, check that the shell is inside the hole
if (shellPt != null) {
boolean insideHole = CGAlgorithms.isPointInRing(shellPt, holePts);
if (!insideHole) {
return shellPt;
}
}
Coordinate holePt = findPtNotNode(holePts, shell, graph);
// if point is on hole but not shell, check that the hole is outside the shell
if (holePt != null) {
boolean insideShell = CGAlgorithms.isPointInRing(holePt, shellPts);
if (insideShell) {
return holePt;
}
return null;
}
Assert.shouldNeverReachHere("points in shell and hole appear to be equal");
return null;
}
示例6: visitInteriorRing
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
private void visitInteriorRing(LineString ring, PlanarGraph graph) {
Coordinate[] pts = ring.getCoordinates();
Coordinate pt0 = pts[0];
/**
* Find first point in coord list different to initial point.
* Need special check since the first point may be repeated.
*/
Coordinate pt1 = findDifferentPoint(pts, pt0);
Edge e = graph.findEdgeInSameDirection(pt0, pt1);
DirectedEdge de = (DirectedEdge) graph.findEdgeEnd(e);
DirectedEdge intDe = null;
if (de.getLabel().getLocation(0, Position.RIGHT) == Location.INTERIOR) {
intDe = de;
} else if (de.getSym().getLabel().getLocation(0, Position.RIGHT) == Location.INTERIOR) {
intDe = de.getSym();
}
Assert.isTrue(intDe != null, "unable to find dirEdge with Interior on RHS");
this.visitLinkedDirectedEdges(intDe);
}
示例7: computeSequence
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
private void computeSequence() {
if (this.isRun) {
return;
}
this.isRun = true;
List sequences = this.findSequences();
if (sequences == null) {
return;
}
this.sequencedGeometry = this.buildSequencedGeometry(sequences);
this.isSequenceable = true;
int finalLineCount = this.sequencedGeometry.getNumGeometries();
Assert.isTrue(this.lineCount == finalLineCount, "Lines were missing from result");
Assert.isTrue(this.sequencedGeometry instanceof LineString
|| this.sequencedGeometry instanceof MultiLineString,
"Result is not lineal");
}
示例8: addReverseSubpath
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
private void addReverseSubpath(DirectedEdge de, ListIterator lit, boolean expectedClosed) {
// trace an unvisited path *backwards* from this de
Node endNode = de.getToNode();
Node fromNode = null;
while (true) {
lit.add(de.getSym());
de.getEdge().setVisited(true);
fromNode = de.getFromNode();
DirectedEdge unvisitedOutDE = findUnvisitedBestOrientedDE(fromNode);
// this must terminate, since we are continually marking edges as visited
if (unvisitedOutDE == null) {
break;
}
de = unvisitedOutDE.getSym();
}
if (expectedClosed) {
// the path should end at the toNode of this de, otherwise we have an error
Assert.isTrue(fromNode == endNode, "path not contiguous");
}
}
示例9: collectBoundaryTouchEdge
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Collect edges from Area inputs which should be in the result but
* which have not been included in a result area.
* This happens ONLY:
* <ul>
* <li>during an intersection when the boundaries of two
* areas touch in a line segment
* <li> OR as a result of a dimensional collapse.
* </ul>
*/
private void collectBoundaryTouchEdge(DirectedEdge de, int opCode, List edges) {
Label label = de.getLabel();
if (de.isLineEdge()) {
return; // only interested in area edges
}
if (de.isVisited()) {
return; // already processed
}
if (de.isInteriorAreaEdge()) {
return; // added to handle dimensional collapses
}
if (de.getEdge().isInResult()) {
return; // if the edge linework is already included, don't include it again
}
// sanity check for labelling of result edgerings
Assert.isTrue(!(de.isInResult() || de.getSym().isInResult()) || !de.getEdge().isInResult());
// include the linework if it's in the result of the operation
if (OverlayOp.isResultOfOp(label, opCode)
&& opCode == OverlayOp.INTERSECTION) {
edges.add(de.getEdge());
de.setVisitedEdge(true);
}
}
示例10: findRightmostEdgeAtVertex
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
private void findRightmostEdgeAtVertex() {
/**
* The rightmost point is an interior vertex, so it has a segment on either side of it.
* If these segments are both above or below the rightmost point, we need to
* determine their relative orientation to decide which is rightmost.
*/
Coordinate[] pts = this.minDe.getEdge().getCoordinates();
Assert.isTrue(this.minIndex > 0 && this.minIndex < pts.length, "rightmost point expected to be interior vertex of edge");
Coordinate pPrev = pts[this.minIndex - 1];
Coordinate pNext = pts[this.minIndex + 1];
int orientation = CGAlgorithms.computeOrientation(this.minCoord, pNext, pPrev);
boolean usePrev = false;
// both segments are below min point
if (pPrev.y < this.minCoord.y && pNext.y < this.minCoord.y
&& orientation == CGAlgorithms.COUNTERCLOCKWISE) {
usePrev = true;
} else if (pPrev.y > this.minCoord.y && pNext.y > this.minCoord.y
&& orientation == CGAlgorithms.CLOCKWISE) {
usePrev = true;
}
// if both segments are on the same side, do nothing - either is safe
// to select as a rightmost segment
if (usePrev) {
this.minIndex = this.minIndex - 1;
}
}
示例11: cleanRing
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* @param vertices the vertices of a linear ring, which may or may not be
* flattened (i.e. vertices collinear)
* @return the coordinates with unnecessary (collinear) vertices
* removed
*/
private Coordinate[] cleanRing(Coordinate[] original) {
Assert.equals(original[0], original[original.length - 1]);
ArrayList cleanedRing = new ArrayList();
Coordinate previousDistinctCoordinate = null;
for (int i = 0; i <= original.length - 2; i++) {
Coordinate currentCoordinate = original[i];
Coordinate nextCoordinate = original[i + 1];
if (currentCoordinate.equals(nextCoordinate)) {
continue;
}
if (previousDistinctCoordinate != null
&& this.isBetween(previousDistinctCoordinate, currentCoordinate, nextCoordinate)) {
continue;
}
cleanedRing.add(currentCoordinate);
previousDistinctCoordinate = currentCoordinate;
}
cleanedRing.add(original[original.length - 1]);
Coordinate[] cleanedRingCoordinates = new Coordinate[cleanedRing.size()];
return (Coordinate[]) cleanedRing.toArray(cleanedRingCoordinates);
}
示例12: add
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Adds an intersection into the list, if it isn't already there.
* The input segmentIndex and dist are expected to be normalized.
*
* @return the SegmentIntersection found or added
*/
public SegmentNode add(Coordinate intPt, int segmentIndex) {
SegmentNode eiNew = new SegmentNode(this.edge, intPt, segmentIndex, this.edge.getSegmentOctant(segmentIndex));
SegmentNode ei = (SegmentNode) this.nodeMap.get(eiNew);
if (ei != null) {
// debugging sanity check
Assert.isTrue(ei.coord.equals2D(intPt), "Found equal nodes with different coordinates");
// if (! ei.coord.equals2D(intPt))
// Debug.println("Found equal nodes with different coordinates");
return ei;
}
// node does not exist, so create it
this.nodeMap.put(eiNew, eiNew);
return eiNew;
}
示例13: computePoints
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* Collect all the points from the DirectedEdges of this ring into a contiguous list
*/
protected void computePoints(DirectedEdge start) {
//System.out.println("buildRing");
this.startDe = start;
DirectedEdge de = start;
boolean isFirstEdge = true;
do {
// Assert.isTrue(de != null, "found null Directed Edge");
if (de == null) {
throw new TopologyException("Found null DirectedEdge");
}
if (de.getEdgeRing() == this) {
throw new TopologyException("Directed Edge visited twice during ring-building at " + de.getCoordinate());
}
this.edges.add(de);
//Debug.println(de);
//Debug.println(de.getEdge());
Label label = de.getLabel();
Assert.isTrue(label.isArea());
this.mergeLabel(label);
this.addPoints(de.getEdge(), de.isForward(), isFirstEdge);
isFirstEdge = false;
this.setEdgeRing(de, this);
de = this.getNext(de);
} while (de != this.startDe);
}
示例14: addLineString
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
private void addLineString(LineString line) {
Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
if (coord.length < 2) {
this.hasTooFewPoints = true;
this.invalidPoint = coord[0];
return;
}
// add the edge for the LineString
// line edges do not have locations for their left and right sides
Edge e = new Edge(coord, new Label(this.argIndex, Location.INTERIOR));
this.lineEdgeMap.put(line, e);
this.insertEdge(e);
/**
* Add the boundary points of the LineString, if any.
* Even if the LineString is closed, add both points as if they were endpoints.
* This allows for the case that the node already exists and is a boundary point.
*/
Assert.isTrue(coord.length >= 2, "found LineString with single point");
this.insertBoundaryPoint(this.argIndex, coord[0]);
this.insertBoundaryPoint(this.argIndex, coord[coord.length - 1]);
}
示例15: insertContained
import com.vividsolutions.jts.util.Assert; //导入依赖的package包/类
/**
* insert an item which is known to be contained in the tree rooted at
* the given Node. Lower levels of the tree will be created
* if necessary to hold the item.
*/
private void insertContained(Node tree, Interval itemInterval, Object item) {
Assert.isTrue(tree.getInterval().contains(itemInterval));
/**
* Do NOT create a new node for zero-area intervals - this would lead
* to infinite recursion. Instead, use a heuristic of simply returning
* the smallest existing node containing the query
*/
boolean isZeroArea = IntervalSize.isZeroWidth(itemInterval.getMin(), itemInterval.getMax());
NodeBase node;
if (isZeroArea) {
node = tree.find(itemInterval);
} else {
node = tree.getNode(itemInterval);
}
node.add(item);
}