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

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

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

Assert.shouldNeverReachHere介绍

[英]Always throws an AssertionFailedException.
[中]始终抛出AssertionFailedException

代码示例

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

/**
 *  Always throws an <code>AssertionFailedException</code>.
 *
 *@throws  AssertionFailedException  thrown always
 */
public static void shouldNeverReachHere() {
 shouldNeverReachHere(null);
}

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

public Object clone() {
 try {
  Coordinate coord = (Coordinate) super.clone();
  return coord; // return the clone
 } catch (CloneNotSupportedException e) {
  Assert.shouldNeverReachHere(
    "this shouldn't happen because this class is Cloneable");
  return null;
 }
}

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

/**
  * Clones this transformation
  * 
  * @return a copy of this transformation
  */
 public Object clone()
 {
   try {
     return super.clone();
   } catch(Exception ex) {
     Assert.shouldNeverReachHere();
   }
   return null;
 }
}

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

private int getClassSortIndex() {
   if (sortedClasses == null)
     initSortedClasses();
   for (int i = 0; i < sortedClasses.length; i++) {
     if (sortedClasses[i].isInstance(this))
       return i;
   }
   Assert.shouldNeverReachHere("Class not supported: " + this.getClass());
   return -1;
 }

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

public Geometry getBoundary() {
 checkNotGeometryCollection(this);
 Assert.shouldNeverReachHere();
 return null;
}

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

/**
 * Writes a {@link Geometry} in GML2 format to a String.
 * 
 * @param geom
 * @return String GML2 Encoded Geometry
 */
public String write(Geometry geom) 
{
  StringWriter writer = new StringWriter();
  try {
    write(geom, writer);
  }
catch (IOException ex) {
 Assert.shouldNeverReachHere();
}
  return writer.toString();
}

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

/**
 *  Converts a <code>Geometry</code> to its Well-known Text representation.
 *
 *@param  geometry  a <code>Geometry</code> to process
 *@return           a <Geometry Tagged Text> string (see the OpenGIS Simple
 *      Features Specification)
 */
public String write(Geometry geometry)
{
 Writer sw = new StringWriter();
 try {
  writeFormatted(geometry, isFormatted, sw);
 }
 catch (IOException ex) {
  Assert.shouldNeverReachHere();
 }
 return sw.toString();
}

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

/**
 * Creates and returns a full copy of this {@link Geometry} object
 * (including all coordinates contained by it).
 * Subclasses are responsible for overriding this method and copying
 * their internal data.  Overrides should call this method first.
 *
 * @return a clone of this instance
 */
public Object clone() {
 try {
  Geometry clone = (Geometry) super.clone();
  if (clone.envelope != null) { clone.envelope = new Envelope(clone.envelope); }
  return clone;
 }
 catch (CloneNotSupportedException e) {
  Assert.shouldNeverReachHere();
  return null;
 }
}

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

/**
 * Throws a formatted ParseException reporting that the current token
 * was unexpected.
 *
 * @param expected a description of what was expected
 * @throws ParseException
 * @throws AssertionFailedException if an invalid token is encountered
 */
private void parseErrorExpected(String expected)
  throws ParseException
{
 // throws Asserts for tokens that should never be seen
 if (tokenizer.ttype == StreamTokenizer.TT_NUMBER)
  Assert.shouldNeverReachHere("Unexpected NUMBER token");
 if (tokenizer.ttype == StreamTokenizer.TT_EOL)
  Assert.shouldNeverReachHere("Unexpected EOL token");
 String tokenStr = tokenString();
 parseErrorWithLine("Expected " + expected + " but found " + tokenStr);
}

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

/**
 *  Same as <code>write</code>, but with newlines and spaces to make the
 *  well-known text more readable.
 *
 *@param  geometry  a <code>Geometry</code> to process
 *@return           a <Geometry Tagged Text> string (see the OpenGIS Simple
 *      Features Specification), with newlines and spaces
 */
public String writeFormatted(Geometry geometry)
{
 Writer sw = new StringWriter();
 try {
  writeFormatted(geometry, true, sw);
 }
 catch (IOException ex) {
  Assert.shouldNeverReachHere();
 }
 return sw.toString();
}
/**

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

private Geometry reverse(Geometry linear)
{
 if (linear instanceof LineString)
  return ((LineString) linear).reverse();
 if (linear instanceof MultiLineString)
  return ((MultiLineString) linear).reverse();
 Assert.shouldNeverReachHere("non-linear geometry encountered");
 return null;
}
/**

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

private List itemsTree(AbstractNode node) 
{
 List valuesTreeForNode = new ArrayList();
 for (Iterator i = node.getChildBoundables().iterator(); i.hasNext(); ) {
  Boundable childBoundable = (Boundable) i.next();
  if (childBoundable instanceof AbstractNode) {
   List valuesTreeForChild = itemsTree((AbstractNode) childBoundable);
   // only add if not null (which indicates an item somewhere in this tree
   if (valuesTreeForChild != null)
    valuesTreeForNode.add(valuesTreeForChild);
  }
  else if (childBoundable instanceof ItemBoundable) {
   valuesTreeForNode.add(((ItemBoundable)childBoundable).getItem());
  }
  else {
   Assert.shouldNeverReachHere();
  }
 }
 if (valuesTreeForNode.size() <= 0) 
  return null;
 return valuesTreeForNode;
}

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

private void query(Object searchBounds, AbstractNode node, List matches) {
 List childBoundables = node.getChildBoundables();
 for (int i = 0; i < childBoundables.size(); i++) {
  Boundable childBoundable = (Boundable) childBoundables.get(i);
  if (! getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds)) {
   continue;
  }
  if (childBoundable instanceof AbstractNode) {
   query(searchBounds, (AbstractNode) childBoundable, matches);
  }
  else if (childBoundable instanceof ItemBoundable) {
   matches.add(((ItemBoundable)childBoundable).getItem());
  }
  else {
   Assert.shouldNeverReachHere();
  }
 }
}

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

Assert.shouldNeverReachHere("Unsupported Geometry class: " + geometry.getClass().getName());
return null;

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

private void query(Object searchBounds, AbstractNode node, ItemVisitor visitor) {
 List childBoundables = node.getChildBoundables();
 for (int i = 0; i < childBoundables.size(); i++) {
  Boundable childBoundable = (Boundable) childBoundables.get(i);
  if (! getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds)) {
   continue;
  }
  if (childBoundable instanceof AbstractNode) {
   query(searchBounds, (AbstractNode) childBoundable, visitor);
  }
  else if (childBoundable instanceof ItemBoundable) {
   visitor.visitItem(((ItemBoundable)childBoundable).getItem());
  }
  else {
   Assert.shouldNeverReachHere();
  }
 }
}

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

/**
 * 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(x, y);
  case 1:
    return create(-y, x);
  case 2:
    return create(-x, -y);
  case 3:
    return create(y, -x);
  }
  Assert.shouldNeverReachHere();
  return null;
}

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

public DirectedEdge getRightmostEdge()
{
 List edges = getEdges();
 int size = edges.size();
 if (size < 1) return null;
 DirectedEdge de0 = (DirectedEdge) edges.get(0);
 if (size == 1) return de0;
 DirectedEdge deLast = (DirectedEdge) edges.get(size - 1);
 int quad0 = de0.getQuadrant();
 int quad1 = deLast.getQuadrant();
 if (Quadrant.isNorthern(quad0) && Quadrant.isNorthern(quad1))
  return de0;
 else if (! Quadrant.isNorthern(quad0) && ! Quadrant.isNorthern(quad1))
  return deLast;
 else {
  // edges are in different hemispheres - make sure we return one that is non-horizontal
  //Assert.isTrue(de0.getDy() != 0, "should never return horizontal edge!");
  DirectedEdge nonHorizontalEdge = null;
  if (de0.getDy() != 0)
   return de0;
  else if (deLast.getDy() != 0)
   return deLast;
 }
 Assert.shouldNeverReachHere("found two horizontal edges incident on node");
 return null;
}
/**

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

Assert.shouldNeverReachHere("points in shell and hole appear to be equal");
return null;

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

(GeometryCollection) geom, os);
else {
 Assert.shouldNeverReachHere("Unknown Geometry type");

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

/**
 * Compares two {@link Coordinate}s for their relative position along a segment
 * lying in the specified {@link Octant}.
 *
 * @return -1 node0 occurs first;
 * 0 the two nodes are equal;
 * 1 node1 occurs first
 */
public static int compare(int octant, Coordinate p0, Coordinate p1)
{
 // nodes can only be equal if their coordinates are equal
 if (p0.equals2D(p1)) return 0;
 int xSign = relativeSign(p0.x, p1.x);
 int ySign = relativeSign(p0.y, p1.y);
 switch (octant) {
  case 0: return compareValue(xSign, ySign);
  case 1: return compareValue(ySign, xSign);
  case 2: return compareValue(ySign, -xSign);
  case 3: return compareValue(-xSign, ySign);
  case 4: return compareValue(-xSign, -ySign);
  case 5: return compareValue(-ySign, -xSign);
  case 6: return compareValue(-ySign, xSign);
  case 7: return compareValue(xSign, -ySign);
 }
 Assert.shouldNeverReachHere("invalid octant value");
 return 0;
}

相关文章