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

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

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

Geometry.getInteriorPoint介绍

[英]Computes an interior point of this Geometry. 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.

The interior point of an empty geometry is POINT EMPTY.
[中]计算此Geometry的内部点。如果可以精确计算内点,则保证内点位于几何体的内部。否则,该点可能位于几何体的边界上。
空几何体的内部点为POINT EMPTY

代码示例

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

public static Geometry interiorPoint(Geometry arg0) {
  if (arg0 == null) return null;
  Geometry _this = arg0;
  return _this.getInteriorPoint();
}

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

public Point getInteriorPoint() {
  return geometry.getInteriorPoint();
}

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

/**
 * @param geometry the JTS {@link Geometry} object
 * @return the interior point of the given geometry
 */
public static LatLong computeInteriorPoint(Geometry geometry) {
  Point interiorPoint = geometry.getInteriorPoint();
  if (interiorPoint != null) {
    return new LatLong(interiorPoint.getCoordinate().y, interiorPoint.getCoordinate().x);
  }
  return null;
}

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

@DescribeProcess(
  title = "Interior Point",
  description =
      "Returns a point that lies inside a geometry if possible, or that lies on its boundary."
)
@DescribeResult(description = "Interior point")
public static Geometry interiorPoint(
    @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
  return geom.getInteriorPoint();
}

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

private static Geometry pointInGeometry(Geometry g) {
  Point p = g.getCentroid();
  if (g instanceof Polygon) {
    // if the geometry is heavily generalized centroid computation may fail and return NaN
    if (Double.isNaN(p.getX()) || Double.isNaN(p.getY()))
      return g.getFactory().createPoint(g.getCoordinate());
    // otherwise let's check if the point is inside. Again, this check and
    // "getInteriorPoint"
    // will work only if the geometry is valid
    if (g.isValid() && !g.contains(p)) {
      try {
        p = g.getInteriorPoint();
      } catch (Exception e) {
        // generalized geometries might make interior point go bye bye
        return p;
      }
    } else {
      return p;
    }
  }
  return p;
}

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

/**
   * @param geometry Valid Geometry instance
   * @return A Point that lie on the surface or null if input geometry is not a surface.
   */
  public static Geometry getInteriorPoint(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getInteriorPoint();
  }
}

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

public static Geometry interiorPoint(Geometry g) {      return g.getInteriorPoint();  }

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

public boolean isTrue(Geometry g) {
  return g.getInteriorPoint().within(mask);
 }
});

代码示例来源:origin: Geomatys/geotoolkit

/**
 * Returns a point interior to the geometry.
 */
@Override
public final DirectPosition getRepresentativePoint() {
  org.locationtech.jts.geom.Geometry jtsGeom = getJTSGeometry();
  org.locationtech.jts.geom.Point p = jtsGeom.getInteriorPoint();
  return JTSUtils.pointToDirectPosition(p, getCoordinateReferenceSystem());
}

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

public void paint(Geometry geom, Viewport viewport, Graphics2D g2d)
{
 if (geom.getUserData() == null) return;
 
 Coordinate p = null;
 if (geom instanceof Polygon) {
  p = ConstrainedInteriorPoint.getCoordinate((Polygon) geom, viewport.getModelEnv());
 }
 else {
  p = geom.getInteriorPoint().getCoordinate();
 }
 
 Point2D vp = viewport.toView(new Point2D.Double(p.x, p.y));
 
 g2d.setColor(color);
 g2d.setFont(AppConstants.FONT_LABEL);
 
 String label = geom.getUserData().toString();
 //int stringLen = (int) g2d.getFontMetrics().getStringBounds(label, g2d).getWidth();
 GraphicsUtil.drawStringAlignCenter(g2d, label, (int) vp.getX(), (int) vp.getY()); 
}

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

private void checkInteriorPoint(Geometry g)
{
 Point ip = g.getInteriorPoint();
 assertTrue(g.contains(ip));
}

代码示例来源:origin: org.n52.arctic-sea/shetland

/**
 * Get the point from samplingGeometry or featureOfInterest
 *
 * @return The {@link Point}
 */
private Point getPoint() {
  Point point = null;
  if (isSetSpatialFilteringProfileParameter()) {
    Geometry geometry = getSpatialFilteringProfileParameter().getValue().getValue();
    point = geometry.getInteriorPoint();
    point.setSRID(geometry.getSRID());
  } else {
    if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature
        && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest())
            .isSetGeometry()) {
      Geometry geometry =
          ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
      point = geometry.getInteriorPoint();
      point.setSRID(geometry.getSRID());
    }
  }
  return point;
}

相关文章