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

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

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

  1. public static Geometry interiorPoint(Geometry arg0) {
  2. if (arg0 == null) return null;
  3. Geometry _this = arg0;
  4. return _this.getInteriorPoint();
  5. }

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

  1. public Point getInteriorPoint() {
  2. return geometry.getInteriorPoint();
  3. }

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

  1. /**
  2. * @param geometry the JTS {@link Geometry} object
  3. * @return the interior point of the given geometry
  4. */
  5. public static LatLong computeInteriorPoint(Geometry geometry) {
  6. Point interiorPoint = geometry.getInteriorPoint();
  7. if (interiorPoint != null) {
  8. return new LatLong(interiorPoint.getCoordinate().y, interiorPoint.getCoordinate().x);
  9. }
  10. return null;
  11. }

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

  1. @DescribeProcess(
  2. title = "Interior Point",
  3. description =
  4. "Returns a point that lies inside a geometry if possible, or that lies on its boundary."
  5. )
  6. @DescribeResult(description = "Interior point")
  7. public static Geometry interiorPoint(
  8. @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
  9. return geom.getInteriorPoint();
  10. }

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

  1. private static Geometry pointInGeometry(Geometry g) {
  2. Point p = g.getCentroid();
  3. if (g instanceof Polygon) {
  4. // if the geometry is heavily generalized centroid computation may fail and return NaN
  5. if (Double.isNaN(p.getX()) || Double.isNaN(p.getY()))
  6. return g.getFactory().createPoint(g.getCoordinate());
  7. // otherwise let's check if the point is inside. Again, this check and
  8. // "getInteriorPoint"
  9. // will work only if the geometry is valid
  10. if (g.isValid() && !g.contains(p)) {
  11. try {
  12. p = g.getInteriorPoint();
  13. } catch (Exception e) {
  14. // generalized geometries might make interior point go bye bye
  15. return p;
  16. }
  17. } else {
  18. return p;
  19. }
  20. }
  21. return p;
  22. }

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

  1. /**
  2. * @param geometry Valid Geometry instance
  3. * @return A Point that lie on the surface or null if input geometry is not a surface.
  4. */
  5. public static Geometry getInteriorPoint(Geometry geometry) {
  6. if(geometry==null) {
  7. return null;
  8. }
  9. return geometry.getInteriorPoint();
  10. }
  11. }

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

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

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

  1. public boolean isTrue(Geometry g) {
  2. return g.getInteriorPoint().within(mask);
  3. }
  4. });

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

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

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

  1. public void paint(Geometry geom, Viewport viewport, Graphics2D g2d)
  2. {
  3. if (geom.getUserData() == null) return;
  4. Coordinate p = null;
  5. if (geom instanceof Polygon) {
  6. p = ConstrainedInteriorPoint.getCoordinate((Polygon) geom, viewport.getModelEnv());
  7. }
  8. else {
  9. p = geom.getInteriorPoint().getCoordinate();
  10. }
  11. Point2D vp = viewport.toView(new Point2D.Double(p.x, p.y));
  12. g2d.setColor(color);
  13. g2d.setFont(AppConstants.FONT_LABEL);
  14. String label = geom.getUserData().toString();
  15. //int stringLen = (int) g2d.getFontMetrics().getStringBounds(label, g2d).getWidth();
  16. GraphicsUtil.drawStringAlignCenter(g2d, label, (int) vp.getX(), (int) vp.getY());
  17. }

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

  1. private void checkInteriorPoint(Geometry g)
  2. {
  3. Point ip = g.getInteriorPoint();
  4. assertTrue(g.contains(ip));
  5. }

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

  1. /**
  2. * Get the point from samplingGeometry or featureOfInterest
  3. *
  4. * @return The {@link Point}
  5. */
  6. private Point getPoint() {
  7. Point point = null;
  8. if (isSetSpatialFilteringProfileParameter()) {
  9. Geometry geometry = getSpatialFilteringProfileParameter().getValue().getValue();
  10. point = geometry.getInteriorPoint();
  11. point.setSRID(geometry.getSRID());
  12. } else {
  13. if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature
  14. && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest())
  15. .isSetGeometry()) {
  16. Geometry geometry =
  17. ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
  18. point = geometry.getInteriorPoint();
  19. point.setSRID(geometry.getSRID());
  20. }
  21. }
  22. return point;
  23. }

相关文章