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

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

本文整理了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

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

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

  1. public int getDimension() {
  2. return geometry.getDimension();
  3. }

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

  1. @Override
  2. public void filter(Geometry geom) {
  3. if (!(geom instanceof GeometryCollection)
  4. && geom.getDimension() == targetDimension
  5. && !geom.isEmpty()) {
  6. geometries.add(geom);
  7. }
  8. }

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * @param geometry Geometry instance
  3. * @return Geometry dimension
  4. */
  5. public static Integer getDimension(Geometry geometry) {
  6. if(geometry==null) {
  7. return null;
  8. }
  9. return geometry.getDimension();
  10. }
  11. }

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

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

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

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

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

  1. public int getDimension() {
  2. int dimension = Dimension.FALSE;
  3. for (int i = 0; i < geometries.length; i++) {
  4. dimension = Math.max(dimension, geometries[i].getDimension());
  5. }
  6. return dimension;
  7. }

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

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

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

  1. public static Integer ST_Dimension(byte[] wkb) {
  2. Geometry geometry = gFromWKB(wkb);
  3. if (geometry != null) {
  4. return geometry.getDimension();
  5. }
  6. return null;
  7. }

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

  1. public static Integer ST_Dimension(byte[] wkb) {
  2. Geometry geometry = gFromWKB(wkb);
  3. if (geometry != null) {
  4. return geometry.getDimension();
  5. }
  6. return null;
  7. }

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

  1. private int getMinDimension(GeometryCollection geometries) {
  2. int dimension = Integer.MAX_VALUE;
  3. for (int i = 0; i < geometries.getNumGeometries(); i++) {
  4. dimension = Math.min(dimension, geometries.getGeometryN(i).getDimension());
  5. }
  6. if(dimension == Integer.MAX_VALUE) {
  7. dimension = -1;
  8. }
  9. return dimension;
  10. }
  11. /**

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

  1. private void checkExpectedEmpty()
  2. {
  3. // can't check areal features
  4. if (input.getDimension() >= 2) return;
  5. // can't check positive distances
  6. if (distance > 0.0) return;
  7. // at this point can expect an empty result
  8. if (! result.isEmpty()) {
  9. isValid = false;
  10. errorMsg = "Result is non-empty";
  11. errorIndicator = result;
  12. }
  13. report("ExpectedEmpty");
  14. }

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

  1. private void removeLowerDimension(Geometry geometry, List<Geometry> result, int dimension) {
  2. for (int i = 0; i < geometry.getNumGeometries(); i++) {
  3. Geometry g = geometry.getGeometryN(i);
  4. if (g instanceof GeometryCollection) {
  5. removeLowerDimension(g, result, dimension);
  6. } else if (g.getDimension() >= dimension) {
  7. result.add(g);
  8. }
  9. }
  10. }

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

  1. private static double area(Geometry geom) {
  2. double area = 0;
  3. if (geom.getDimension() >= 2) {
  4. area = geom.getArea();
  5. }
  6. else if (geom instanceof LinearRing) {
  7. area = Area.ofRing(geom.getCoordinates());
  8. }
  9. return area;
  10. }

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

  1. public void doPredicates(Geometry a, Geometry b) throws Exception
  2. {
  3. assertTrue( a.contains(b) == a.relate(b).isContains() );
  4. assertTrue( a.crosses(b) == a.relate(b).isCrosses(a.getDimension(), b.getDimension()) );
  5. assertTrue( a.disjoint(b) == a.relate(b).isDisjoint() );
  6. assertTrue( a.equals(b) == a.relate(b).isEquals(a.getDimension(), b.getDimension()) );
  7. assertTrue( a.intersects(b) == a.relate(b).isIntersects() );
  8. assertTrue( a.overlaps(b) == a.relate(b).isOverlaps(a.getDimension(), b.getDimension()) );
  9. assertTrue( a.touches(b) == a.relate(b).isTouches(a.getDimension(), b.getDimension()) );
  10. assertTrue( a.within(b) == a.relate(b).isWithin() );
  11. }

相关文章