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

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

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

Geometry.apply介绍

[英]Performs an operation with or on this Geometry's coordinates. If this method modifies any coordinate values, #geometryChanged must be called to update the geometry state. Note that you cannot use this method to modify this Geometry if its underlying CoordinateSequence's #get method returns a copy of the Coordinate, rather than the actual Coordinate stored (if it even stores Coordinate objects at all).
[中]使用或在此Geometry的坐标上执行操作。如果此方法修改任何坐标值,则必须调用#geometryChanged来更新几何体状态。请注意,如果基础CoordinateSequence的#get方法返回坐标的副本,而不是存储的实际坐标(如果它甚至存储坐标对象),则无法使用此方法修改此几何体。

代码示例

代码示例来源:origin: com.h2database/h2

  1. private static int getDimensionCount(Geometry geometry) {
  2. ZVisitor finder = new ZVisitor();
  3. geometry.apply(finder);
  4. return finder.isFoundZ() ? 3 : 2;
  5. }

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

  1. private void collectLines(Geometry geometry, final List<LineString> lines) {
  2. geometry.apply(
  3. new GeometryComponentFilter() {
  4. @Override
  5. public void filter(Geometry geom) {
  6. if (geom instanceof LineString && !geom.isEmpty()) {
  7. lines.add((LineString) geom);
  8. }
  9. }
  10. });
  11. }
  12. };

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

  1. private static void shiftGeomByX(Geometry geom, final int xShift) {
  2. if (xShift == 0)
  3. return;
  4. geom.apply(new CoordinateSequenceFilter() {
  5. @Override
  6. public void filter(CoordinateSequence seq, int i) {
  7. seq.setOrdinate(i, CoordinateSequence.X, seq.getX(i) + xShift );
  8. }
  9. @Override public boolean isDone() { return false; }
  10. @Override public boolean isGeometryChanged() { return true; }
  11. });
  12. }

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

  1. public void apply(CoordinateFilter filter) {
  2. geometry.apply(filter);
  3. }

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

  1. public void apply(CoordinateSequenceFilter filter) {
  2. geometry.apply(filter);
  3. }

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

  1. public void apply(GeometryComponentFilter filter) {
  2. geometry.apply(filter);
  3. }

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

  1. public void apply(GeometryFilter filter) {
  2. geometry.apply(filter);
  3. }

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

  1. } else {
  2. final List<Polygon> accum = new ArrayList<Polygon>();
  3. intersection.apply(
  4. new GeometryComponentFilter() {
  5. public void filter(Geometry geom) {

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

  1. public LinearElevationInterpolator(Geometry original, CoordinateReferenceSystem crs) {
  2. originalLines = new ArrayList<LineString>();
  3. original.apply(
  4. new GeometryComponentFilter() {
  5. @Override
  6. public void filter(Geometry geom) {
  7. if (geom instanceof LineString) {
  8. originalLines.add((LineString) geom);
  9. }
  10. }
  11. });
  12. }

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

  1. private List<LinearRing> getRings(Geometry bounds) {
  2. final ArrayList<LinearRing> rings = new ArrayList<LinearRing>();
  3. bounds.apply(
  4. new GeometryComponentFilter() {
  5. @Override
  6. public void filter(Geometry geom) {
  7. if (geom instanceof LinearRing && !geom.isEmpty()) {
  8. rings.add((LinearRing) geom);
  9. }
  10. }
  11. });
  12. return rings;
  13. }

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

  1. @Override
  2. public void encodeGeometryValue(Geometry value, int dimension, int srid, StringBuffer sql)
  3. throws IOException {
  4. if (value == null) {
  5. sql.append("NULL");
  6. return;
  7. }
  8. GeometryDimensionFinder finder = new GeometryDimensionFinder();
  9. value.apply(finder);
  10. WKTWriter writer = new WKTWriter(finder.hasZ() ? 3 : 2);
  11. String wkt = writer.write(value);
  12. sql.append("geometry::STGeomFromText('").append(wkt).append("',").append(srid).append(")");
  13. }

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

  1. private static Polygon toPolygonInternal(Shape shape) {
  2. Geometry geomROI = null;
  3. if (shape != null) {
  4. geomROI = ShapeReader.read(shape, 0, new GeometryFactory());
  5. geomROI.apply(Y_INVERSION);
  6. }
  7. return (Polygon) geomROI;
  8. }
  9. }

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

  1. public static CoordinateSequence find(Geometry g) {
  2. CoordinateSequenceFinder finder = new CoordinateSequenceFinder();
  3. g.apply(finder);
  4. return finder.getSeq();
  5. }

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

  1. public static List<CoordinateSequence> find(Geometry g) {
  2. CoordinateSequenceCollector finder = new CoordinateSequenceCollector();
  3. g.apply(finder);
  4. return finder.getSequences();
  5. }

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

  1. /**
  2. * returns the coordinate dimension for a geometry
  3. *
  4. * @param Geometry g
  5. * @return if there is one z value != NaN, then 3 else 2
  6. */
  7. public static final int guessCoordinateDimension(Geometry g) {
  8. DimensionCoordFilter filter = new DimensionCoordFilter();
  9. g.apply(filter);
  10. return filter.getDimension();
  11. }

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

  1. /**
  2. * Looks up the geometry dimension by trying a number of heuristics. Returns 2 if all attempts
  3. * at guessing the dimension failed.
  4. */
  5. protected int getGeometryDimension(Geometry g, AttributeDescriptor descriptor)
  6. throws IOException {
  7. int dimension = getDescriptorDimension(descriptor);
  8. if (g == null || dimension > 0) {
  9. return dimension;
  10. }
  11. // check for dimension in the geometry coordinate sequences
  12. CoordinateSequenceDimensionExtractor dex = new CoordinateSequenceDimensionExtractor();
  13. g.apply(dex);
  14. return dex.getDimension();
  15. }

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

  1. public Object evaluate(Object feature, Class context) {
  2. Geometry g = getExpression(0).evaluate(feature, Geometry.class);
  3. if (g == null) return null;
  4. MultiPointExtractor filter = new MultiPointExtractor();
  5. g.apply(filter);
  6. return filter.getMultiPoint();
  7. }

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

  1. public static CoordinateSequence find(Geometry g) {
  2. CoordinateSequenceFinder finder = new CoordinateSequenceFinder();
  3. g.apply(finder);
  4. return finder.getSeq();
  5. }

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

  1. public static boolean check(Geometry g, Class coordSeqClass, int dimension) {
  2. CoordinateSequenceSchemaChecker checkCS =
  3. new CoordinateSequenceSchemaChecker(coordSeqClass, dimension);
  4. g.apply(checkCS);
  5. return checkCS.isSame();
  6. }

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

  1. public Object evaluate(Object feature) {
  2. Geometry geom = getExpression(0).evaluate(feature, Geometry.class);
  3. Double offsetX = getExpression(1).evaluate(feature, Double.class);
  4. if (offsetX == null) offsetX = 0d;
  5. Double offsetY = getExpression(2).evaluate(feature, Double.class);
  6. if (offsetY == null) offsetY = 0d;
  7. if (geom != null) {
  8. Geometry offseted = geom.copy();
  9. offseted.apply(new OffsetOrdinateFilter(offsetX, offsetY));
  10. return offseted;
  11. } else {
  12. return null;
  13. }
  14. }

相关文章