com.vividsolutions.jts.util.Assert.isTrue()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(326)

本文整理了Java中com.vividsolutions.jts.util.Assert.isTrue()方法的一些代码示例,展示了Assert.isTrue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.isTrue()方法的具体详情如下:
包路径:com.vividsolutions.jts.util.Assert
类名称:Assert
方法名:isTrue

Assert.isTrue介绍

[英]Throws an AssertionFailedException if the given assertion is not true.
[中]如果给定的断言不正确,则抛出AssertionFailedException

代码示例

代码示例来源:origin: com.vividsolutions/jts

/**
 * Constructs an AbstractSTRtree with the specified maximum number of child
 * nodes that a node may have
 * 
 * @param nodeCapacity the maximum number of child nodes in a node
 */
public AbstractSTRtree(int nodeCapacity) {
 Assert.isTrue(nodeCapacity > 1, "Node capacity must be greater than 1");
 this.nodeCapacity = nodeCapacity;
}

代码示例来源:origin: com.vividsolutions/jts

public Interval(double min, double max) {
 Assert.isTrue(min <= max);
 this.min = min;
 this.max = max;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 *  Throws an <code>AssertionFailedException</code> if the given assertion is
 *  not true.
 *
 *@param  assertion                  a condition that is supposed to be true
 *@throws  AssertionFailedException  if the condition is false
 */
public static void isTrue(boolean assertion) {
 isTrue(assertion, null);
}

代码示例来源:origin: com.vividsolutions/jts

/**
  * Adds either an AbstractNode, or if this is a leaf node, a data object
  * (wrapped in an ItemBoundable)
  */
 public void addChildBoundable(Boundable childBoundable) {
  Assert.isTrue(bounds == null);
  childBoundables.add(childBoundable);
 }
}

代码示例来源:origin: com.vividsolutions/jts

protected void insert(Object bounds, Object item) {
 Assert.isTrue(!built, "Cannot insert items into an STR packed R-tree after it has been built.");
 itemBoundables.add(new ItemBoundable(bounds, item));
}

代码示例来源:origin: com.vividsolutions/jts

protected void init(Coordinate p0, Coordinate p1)
{
 this.p0 = p0;
 this.p1 = p1;
 dx = p1.x - p0.x;
 dy = p1.y - p0.y;
 quadrant = Quadrant.quadrant(dx, dy);
 Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
}

代码示例来源:origin: com.vividsolutions/jts

private List createParentBoundablesFromVerticalSlices(List[] verticalSlices, int newLevel) {
 Assert.isTrue(verticalSlices.length > 0);
 List parentBoundables = new ArrayList();
 for (int i = 0; i < verticalSlices.length; i++) {
  parentBoundables.addAll(
     createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel));
 }
 return parentBoundables;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * This function is non-robust, since it may compute the square of large numbers.
 * Currently not sure how to improve this.
 */
public static double nonRobustComputeEdgeDistance(
   Coordinate p,
   Coordinate p1,
   Coordinate p2)
{
 double dx = p.x - p1.x;
 double dy = p.y - p1.y;
 double dist = Math.sqrt(dx * dx + dy * dy);   // dummy value
 Assert.isTrue(! (dist == 0.0 && ! p.equals(p1)), "Invalid distance calculation");
 return dist;
}

代码示例来源:origin: com.vividsolutions/jts

private void computeSequence() {
 if (isRun) { return; }
 isRun = true;
 List sequences = findSequences();
 if (sequences == null)
  return;
 sequencedGeometry = buildSequencedGeometry(sequences);
 isSequenceable = true;
 int finalLineCount = sequencedGeometry.getNumGeometries();
 Assert.isTrue(lineCount == finalLineCount, "Lines were missing from result");
 Assert.isTrue(sequencedGeometry instanceof LineString
        || sequencedGeometry instanceof MultiLineString,
        "Result is not lineal");
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates the parent level for the given child level. First, orders the items
 * by the x-values of the midpoints, and groups them into vertical slices.
 * For each slice, orders the items by the y-values of the midpoints, and
 * group them into runs of size M (the node capacity). For each run, creates
 * a new (parent) node.
 */
protected List createParentBoundables(List childBoundables, int newLevel) {
 Assert.isTrue(!childBoundables.isEmpty());
 int minLeafCount = (int) Math.ceil((childBoundables.size() / (double) getNodeCapacity()));
 ArrayList sortedChildBoundables = new ArrayList(childBoundables);
 Collections.sort(sortedChildBoundables, xComparator);
 List[] verticalSlices = verticalSlices(sortedChildBoundables,
   (int) Math.ceil(Math.sqrt(minLeafCount)));
 return createParentBoundablesFromVerticalSlices(verticalSlices, newLevel);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates the levels higher than the given level
 *
 * @param boundablesOfALevel
 *            the level to build on
 * @param level
 *            the level of the Boundables, or -1 if the boundables are item
 *            boundables (that is, below level 0)
 * @return the root, which may be a ParentNode or a LeafNode
 */
private AbstractNode createHigherLevels(List boundablesOfALevel, int level) {
 Assert.isTrue(!boundablesOfALevel.isEmpty());
 List parentBoundables = createParentBoundables(boundablesOfALevel, level + 1);
 if (parentBoundables.size() == 1) {
  return (AbstractNode) parentBoundables.get(0);
 }
 return createHigherLevels(parentBoundables, level + 1);
}

代码示例来源:origin: com.vividsolutions/jts

protected void visitLinkedDirectedEdges(DirectedEdge start)
{
 DirectedEdge startDe = start;
 DirectedEdge de = start;
 do {
  Assert.isTrue(de != null, "found null Directed Edge");
  de.setVisited(true);
  de = de.getNext();
 } while (de != startDe);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Update the IM with the contribution for this component.
 * A component only contributes if it has a labelling for both parent geometries
 */
public void updateIM(IntersectionMatrix im)
{
 Assert.isTrue(label.getGeometryCount() >= 2, "found partial label");
 computeIM(im);
}

代码示例来源:origin: com.vividsolutions/jts

private void buildEdgeStringsForUnprocessedNodes() {
 for (Iterator i = graph.getNodes().iterator(); i.hasNext(); ) {
  Node node = (Node) i.next();
  if (!node.isMarked()) { 
   Assert.isTrue(node.getDegree() == 2);
   buildEdgeStringsStartingAt(node);
   node.setMarked(true);
  }
 }
}  
private void buildEdgeStringsForNonDegree2Nodes() {

代码示例来源:origin: com.vividsolutions/jts

private EdgeRing findEdgeRing(PolygonizeDirectedEdge startDE)
{
 PolygonizeDirectedEdge de = startDE;
 EdgeRing er = new EdgeRing(factory);
 do {
  er.add(de);
  de.setRing(er);
  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 er;
}

代码示例来源:origin: com.vividsolutions/jts

private void init(CoordinateSequence coordinates)
{
 if (coordinates == null) {
  coordinates = getFactory().getCoordinateSequenceFactory().create(new Coordinate[]{});
 }
 Assert.isTrue(coordinates.size() <= 1);
 this.coordinates = coordinates;
}

代码示例来源:origin: com.vividsolutions/jts

void insert(Node node)
{
 Assert.isTrue(interval == null || interval.contains(node.interval));
 int index = getSubnodeIndex(node.interval, centre);
 if (node.level == level - 1) {
  subnode[index] = node;
 }
 else {
  // the node is not a direct child, so make a new child node to contain it
  // and recursively insert the node
  Node childNode = createSubnode(index);
  childNode.insert(node);
  subnode[index] = childNode;
 }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Removes an item from the tree.
 * (Builds the tree, if necessary.)
 */
protected boolean remove(Object searchBounds, Object item) {
 build();
 if (itemBoundables.isEmpty()) {
  Assert.isTrue(root.getBounds() == null);
 }
 if (getIntersectsOp().intersects(root.getBounds(), searchBounds)) {
  return remove(searchBounds, root, item);
 }
 return false;
}

代码示例来源:origin: com.vividsolutions/jts

/**
  * Returns the directed edge that starts at this directed edge's end point, or null
  * if there are zero or multiple directed edges starting there.  
  * @return the directed edge
  */
 public LineMergeDirectedEdge getNext() {
  if (getToNode().getDegree() != 2) {
   return null;
  }
  if (getToNode().getOutEdges().getEdges().get(0) == getSym()) {
   return (LineMergeDirectedEdge) getToNode().getOutEdges().getEdges().get(1);
  }
  Assert.isTrue(getToNode().getOutEdges().getEdges().get(1) == getSym());

  return (LineMergeDirectedEdge) getToNode().getOutEdges().getEdges().get(0);
 }
}

代码示例来源:origin: com.vividsolutions/jts

private boolean isInside(LinearRing innerRing, LinearRing searchRing)
{
 Coordinate[] innerRingPts = innerRing.getCoordinates();
 Coordinate[] searchRingPts = searchRing.getCoordinates();
 if (! innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal()))
  return false;
 Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph);
 Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
 boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
 if (isInside) {
  nestedPt = innerRingPt;
  return true;
 }
 return false;
}

相关文章