com.vividsolutions.jts.geom.Geometry.getDimension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(113)

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

Geometry.getDimension介绍

[英]Returns the dimension of this geometry. The dimension of a geometry is is the topological dimension of its embedding in the 2-D Euclidean plane. In the JTS spatial model, dimension values are in the set {0,1,2}.

Note that this is a different concept to the dimension of the vertex Coordinates. The geometry dimension can never be greater than the coordinate dimension. For example, a 0-dimensional geometry (e.g. a Point) may have a coordinate dimension of 3 (X,Y,Z).
[中]

代码示例

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

public int getDimension() {
 int dimension = Dimension.FALSE;
 for (int i = 0; i < geometries.length; i++) {
  dimension = Math.max(dimension, geometries[i].getDimension());
 }
 return dimension;
}

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

private static int resultDimension(int opCode, Geometry g0, Geometry g1)
 {
   int dim0 = g0.getDimension();
   int dim1 = g1.getDimension();
   
   int resultDimension = -1;
   switch (opCode) {
   case INTERSECTION: 
     resultDimension = Math.min(dim0, dim1);
     break;
   case UNION: 
     resultDimension = Math.max(dim0, dim1);
     break;
   case DIFFERENCE: 
     resultDimension = dim0;
     break;
   case SYMDIFFERENCE: 
    /**
     * This result is chosen because
     * <pre>
     * SymDiff = Union(Diff(A, B), Diff(B, A)
     * </pre>
     * and Union has the dimension of the highest-dimension argument.
     */
     resultDimension = Math.max(dim0, dim1);
     break;
   }
   return resultDimension;
 }
}

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

/**
 * Finds the index of the "most polygonal" input geometry.
 * This optimizes the computation of the best-fit plane, 
 * since it is cached only for the left-hand geometry.
 * 
 * @return the index of the most polygonal geometry
 */
private int mostPolygonalIndex() {
  int dim0 = geom[0].getDimension();
  int dim1 = geom[1].getDimension();
  if (dim0 >= 2 && dim1 >= 2) {
    if (geom[0].getNumPoints() > geom[1].getNumPoints())
      return 0;
    return 1;
  }
  // no more than one is dim 2
  if (dim0 >= 2) return 0;
  if (dim1 >= 2) return 1;
  // both dim <= 1 - don't flip
  return 0;
}

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

private void checkExpectedEmpty()
{
  // can't check areal features
  if (input.getDimension() >= 2) return;
  // can't check positive distances
  if (distance > 0.0) return;
    
  // at this point can expect an empty result
  if (! result.isEmpty()) {
    isValid = false;
    errorMsg = "Result is non-empty";
  errorIndicator = result;
  }
 report("ExpectedEmpty");
}

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

if (geom.getDimension() == 1) return false;
if (geom.getDimension() == 2
    && prepLine.isAnyTargetComponentInTest(geom)) return true;
if (geom.getDimension() == 0)
  return isAnyTestPointInTarget(geom);

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

/**
 * Tests whether this geometry overlaps the
 * specified geometry.
 * <p>
 * The <code>overlaps</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have at least one point each not shared by the other
 * (or equivalently neither covers the other),
 * they have the same dimension,
 * and the intersection of the interiors of the two geometries has
 * the same dimension as the geometries themselves.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 *   <code>[T*T***T**]</code> (for two points or two surfaces)
 *   or <code>[1*T***T**]</code> (for two curves)
 * </ul>
 * If the geometries are of different dimension this predicate returns <code>false</code>.
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s overlap.
 */
public boolean overlaps(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isOverlaps(getDimension(), g.getDimension());
}

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

/**
 * Tests whether this geometry touches the
 * argument geometry.
 * <p>
 * The <code>touches</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have at least one point in common, but their interiors do not intersect.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 * at least one of the following patterns
 *  <ul>
 *   <li><code>[FT*******]</code>
 *   <li><code>[F**T*****]</code>
 *   <li><code>[F***T****]</code>
 *  </ul>
 * </ul>
 * If both geometries have dimension 0, this predicate returns <code>false</code>.
 * 
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s touch;
 *      Returns <code>false</code> if both <code>Geometry</code>s are points
 */
public boolean touches(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isTouches(getDimension(), g.getDimension());
}

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

/**
 * Tests whether this geometry crosses the
 * argument geometry.
 * <p>
 * The <code>crosses</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have some but not all interior points in common.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 * one of the following patterns:
 *   <ul>
 *    <li><code>[T*T******]</code> (for P/L, P/A, and L/A situations)
 *    <li><code>[T*****T**]</code> (for L/P, A/P, and A/L situations)
 *    <li><code>[0********]</code> (for L/L situations)
 *   </ul>
 * </ul>
 * For any other combination of dimensions this predicate returns <code>false</code>.
 * <p>
 * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations.
 * In order to make the relation symmetric,
 * JTS extends the definition to apply to L/P, A/P and A/L situations as well.
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s cross.
 */
public boolean crosses(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isCrosses(getDimension(), g.getDimension());
}

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

return relate(g).isEquals(getDimension(), g.getDimension());

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

/**
 * If the Geometries are disjoint, we need to enter their dimension and
 * boundary dimension in the Ext rows in the IM
 */
private void computeDisjointIM(IntersectionMatrix im)
{
 Geometry ga = arg[0].getGeometry();
 if (! ga.isEmpty()) {
  im.set(Location.INTERIOR, Location.EXTERIOR, ga.getDimension());
  im.set(Location.BOUNDARY, Location.EXTERIOR, ga.getBoundaryDimension());
 }
 Geometry gb = arg[1].getGeometry();
 if (! gb.isEmpty()) {
  im.set(Location.EXTERIOR, Location.INTERIOR, gb.getDimension());
  im.set(Location.EXTERIOR, Location.BOUNDARY, gb.getBoundaryDimension());
 }
}

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

if (geom.getDimension() == 2) {

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

/**
  * Label an isolated edge of a graph with its relationship to the target geometry.
  * If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
  * If the target has dim 0, the edge must be in the exterior
  */
 private void labelIsolatedEdge(Edge e, int targetIndex, Geometry target)
 {
  // this won't work for GeometryCollections with both dim 2 and 1 geoms
  if ( target.getDimension() > 0) {
  // since edge is not in boundary, may not need the full generality of PointLocator?
  // Possibly should use ptInArea locator instead?  We probably know here
  // that the edge does not touch the bdy of the target Geometry
   int loc = ptLocator.locate(e.getCoordinate(), target);
   e.getLabel().setAllLocations(targetIndex, loc);
  }
  else {
   e.getLabel().setAllLocations(targetIndex, Location.EXTERIOR);
  }
//System.out.println(e.getLabel());
 }

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

private Geometry reducePointwise(Geometry geom)
{
 GeometryEditor geomEdit;
 if (changePrecisionModel) {
   GeometryFactory newFactory = createFactory(geom.getFactory(), targetPM);
  geomEdit = new GeometryEditor(newFactory);
 }
 else
  // don't change geometry factory
  geomEdit = new GeometryEditor();
 /**
  * For polygonal geometries, collapses are always removed, in order
  * to produce correct topology
  */
 boolean finalRemoveCollapsed = removeCollapsed;
 if (geom.getDimension() >= 2)
   finalRemoveCollapsed = true;
 
 Geometry reduceGeom = geomEdit.edit(geom, 
     new PrecisionReducerCoordinateOperation(targetPM, finalRemoveCollapsed));
 
 return reduceGeom;
}

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

/**
 * Computes an interior point of this <code>Geometry</code>.
 * An interior point is guaranteed to lie in the interior of the Geometry,
 * if it possible to calculate such a point exactly. Otherwise,
 * the point may lie on the boundary of the geometry.
 * <p>
 * The interior point of an empty geometry is <code>POINT EMPTY</code>.
 *
 * @return a {@link Point} which is in the interior of this Geometry
 */
public Point getInteriorPoint()
{
 if (isEmpty()) 
  return factory.createPoint((Coordinate) null);
 Coordinate interiorPt = null;
 int dim = getDimension();
 if (dim == 0) {
  InteriorPointPoint intPt = new InteriorPointPoint(this);
  interiorPt = intPt.getInteriorPoint();
 }
 else if (dim == 1) {
  InteriorPointLine intPt = new InteriorPointLine(this);
  interiorPt = intPt.getInteriorPoint();
 }
 else {
  InteriorPointArea intPt = new InteriorPointArea(this);
  interiorPt = intPt.getInteriorPoint();
 }
 return createPointFromInternalCoord(interiorPt, this);
}

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

private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im)
 int dimA = arg[0].getGeometry().getDimension();
 int dimB = arg[1].getGeometry().getDimension();
 boolean hasProper         = intersector.hasProperIntersection();
 boolean hasProperInterior = intersector.hasProperInteriorIntersection();

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
   * @param geometry Geometry instance
   * @return Geometry dimension
   */
  public static Integer getDimension(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getDimension();
  }
}

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

return factory.createPoint((Coordinate) null);
Coordinate centPt = null;
int dim = getDimension();
if (dim == 0) {
 CentroidPoint cent = new CentroidPoint();

代码示例来源:origin: org.orbisgis/h2spatial

private void feedDim(Geometry geometry) {
  final int geomDim = geometry.getDimension();
  maxDim = Math.max(maxDim, geomDim);
  minDim = Math.min(minDim, geomDim);
}

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

&& geom.getDimension() == 0) {
boolean isAnyInTargetInterior = isAnyTestComponentInTargetInterior(geom);
return isAnyInTargetInterior;

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-gis

public int getDimension() {
 int dimension = Dimension.FALSE;
 final int n = getNumGeometries();
 for (int i = 0; i < n; i++) {
  dimension = Math.max(dimension, getGeometryN(i).getDimension());
 }
 return dimension;
}

相关文章