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

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

本文整理了Java中org.locationtech.jts.geom.Geometry.getDimension()方法的一些代码示例,展示了Geometry.getDimension()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getDimension()方法的具体详情如下:
包路径:org.locationtech.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).
[中]返回此几何图形的尺寸。几何体的维数是其嵌入二维欧氏平面的拓扑维数。在JTS空间模型中,维度值位于集合{0,1,2}中。
请注意,这与顶点坐标的尺寸是不同的概念。几何图形尺寸永远不能大于坐标尺寸。例如,0维几何图形(例如点)的坐标尺寸可能为3(X、Y、Z)。

代码示例

代码示例来源:origin: geotools/geotools

public static int dimension(Geometry arg0) {
  if (arg0 == null) return -1;
  Geometry _this = arg0;
  return _this.getDimension();
}

代码示例来源:origin: geotools/geotools

public int getDimension() {
  return geometry.getDimension();
}

代码示例来源:origin: geotools/geotools

@Override
public void filter(Geometry geom) {
  if (!(geom instanceof GeometryCollection)
      && geom.getDimension() == targetDimension
      && !geom.isEmpty()) {
    geometries.add(geom);
  }
}

代码示例来源:origin: geotools/geotools

private boolean polygonOverlap(Geometry g1, Geometry g2) {
  // TODO: try to use relate instead
  Geometry intersection = g1.intersection(g2);
  return intersection != null && intersection.getDimension() == 2;
}

代码示例来源:origin: geotools/geotools

@DescribeProcess(
  title = "Dimension",
  description =
      "Returns the largest dimension of a geometry or geometry collection: 0 for point, 1 for line, 2 for polygon."
)
@DescribeResult(description = "Dimension of the input geometry")
public static int dimension(
    @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
  return geom.getDimension();
}

代码示例来源:origin: geotools/geotools

new GeometryDimensionCollector(geom.getDimension());
clipped.apply(collector);
Geometry result = collector.collect();
  if (result.getDimension() == 2 || result.getDimension() == 0) {
    result.apply(new IDWElevationInterpolator(geom, crs));
  } else if (result.getDimension() == 1) {
    result.apply(new LinearElevationInterpolator(geom, crs));

代码示例来源:origin: locationtech/jts

private boolean isEmptyBufferExpected(Geometry geom)
{
  boolean isNegativeBufferOfNonAreal = geom.getDimension() < 2 && distance <= 0.0;
  return isNegativeBufferOfNonAreal;
}

代码示例来源:origin: locationtech/jts

private static boolean hasArea(Geometry geom) {
   if (geom.getDimension() >= 2) return true;
   if (geom instanceof LinearRing) return true;
   return false;
  }

代码示例来源:origin: orbisgis/h2gis

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

代码示例来源:origin: locationtech/jts

private static boolean hasLength(Geometry geom) {
   if (geom.getDimension() >= 1) return true;
   return false;
  }

代码示例来源:origin: geotools/geotools

new GeometryDimensionCollector(geometry.getDimension());
result.apply(collector);
result = collector.collect();

代码示例来源:origin: locationtech/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: orbisgis/h2gis

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

代码示例来源:origin: org.opengeo/geodb

public static Integer ST_Dimension(byte[] wkb) {
  Geometry geometry = gFromWKB(wkb);
  if (geometry != null) {
    return geometry.getDimension();
  }
  return null;
}

代码示例来源:origin: jdeolive/geodb

public static Integer ST_Dimension(byte[] wkb) {
  Geometry geometry = gFromWKB(wkb);
  if (geometry != null) {
    return geometry.getDimension();
  }
  return null;
}

代码示例来源:origin: orbisgis/h2gis

private int getMinDimension(GeometryCollection geometries) {
  int dimension = Integer.MAX_VALUE;
  for (int i = 0; i < geometries.getNumGeometries(); i++) {
    dimension = Math.min(dimension, geometries.getGeometryN(i).getDimension());
  }
  if(dimension == Integer.MAX_VALUE) {
    dimension = -1;
  }
  return dimension;
}
/**

代码示例来源:origin: locationtech/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: orbisgis/h2gis

private void removeLowerDimension(Geometry geometry, List<Geometry> result, int dimension) {
  for (int i = 0; i < geometry.getNumGeometries(); i++) {
    Geometry g = geometry.getGeometryN(i);
    if (g instanceof GeometryCollection) {
      removeLowerDimension(g, result, dimension);
    } else if (g.getDimension() >= dimension) {
      result.add(g);
    }
  }
}

代码示例来源:origin: locationtech/jts

private static double area(Geometry geom) {
 double area = 0;
 if (geom.getDimension() >= 2) {
  area = geom.getArea();
 }
 else if (geom instanceof LinearRing) {
  area = Area.ofRing(geom.getCoordinates());
 }
 return area;
}

代码示例来源:origin: locationtech/jts

public void doPredicates(Geometry a, Geometry b) throws Exception
{
 assertTrue( a.contains(b) == a.relate(b).isContains() );
 assertTrue( a.crosses(b) == a.relate(b).isCrosses(a.getDimension(), b.getDimension()) );
 assertTrue( a.disjoint(b) == a.relate(b).isDisjoint() );
 assertTrue( a.equals(b) == a.relate(b).isEquals(a.getDimension(), b.getDimension()) );
 assertTrue( a.intersects(b) == a.relate(b).isIntersects() );
 assertTrue( a.overlaps(b) == a.relate(b).isOverlaps(a.getDimension(), b.getDimension()) );
 assertTrue( a.touches(b) == a.relate(b).isTouches(a.getDimension(), b.getDimension()) );
 assertTrue( a.within(b) == a.relate(b).isWithin() );
}

相关文章