Java 类com.vividsolutions.jts.geom.CoordinateFilter 实例源码

项目:elasticgeo    文件:FilterToElasticHelper.java   
protected Literal clipToWorld(Literal geometry) {
    if(geometry != null) {
        Geometry g = geometry.evaluate(null, Geometry.class);
        if(g != null) {
            g.apply(new GeometryComponentFilter() {
                @Override
                public void filter(Geometry geom) {
                    geom.apply(new CoordinateFilter() {
                        @Override
                        public void filter(Coordinate coord) {
                            coord.setCoordinate(new Coordinate(clipLon(coord.x),clipLat(coord.y)));
                        }
                    });
                }
            });
            geometry = CommonFactoryFinder.getFilterFactory(null).literal(g);

        }
    }

    return geometry;
}
项目:geomajas-project-client-gwt2    文件:DefaultCriterionFilterConverter.java   
private Geometry check(Geometry geometry) {
    if (maxCoordinatesInGeometry > 0) {
        int distanceTolerance = 10;
        while (geometry.getNumPoints() > maxCoordinatesInGeometry) {
            geometry = DouglasPeuckerSimplifier.simplify(geometry, distanceTolerance);
            distanceTolerance *= 2;
        }
    }
    if (roundCoordinates) {
        final double factor = Math.pow(10, roundNumberOfDecimals);
        geometry.apply(new CoordinateFilter() {

            @Override
            public void filter(Coordinate coord) {
                coord.x = Math.round(coord.x * factor) / factor;
                coord.y = Math.round(coord.y * factor) / factor;
            }
        });
    }
    return geometry;
}
项目:geopackager    文件:AbstractFeatureHarvester.java   
protected Geometry transformJTSGeometry(Geometry geom, final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem crs) throws Exception {
    final MathTransform transform = CRS.findMathTransform(sourceCRS, crs, true);
    final Mutable<Boolean> anyChanged = new Mutable<Boolean>(false);

    geom = (Geometry) geom.clone();
    geom.apply(new CoordinateFilter() {
        @Override
        public void filter(Coordinate c) {
            DirectPosition dpFrom = new DirectPosition2D(sourceCRS, c.x, c.y);
            DirectPosition dpTo = new DirectPosition2D();
            try {
                transform.transform(dpFrom, dpTo);
                c.x = dpTo.getOrdinate(0);
                c.y = dpTo.getOrdinate(1);
                anyChanged.set(true);
            } catch (TransformException e) {
                LOG.warn("Failed to transform point " + c, e);
            }
        }
    });
    if (anyChanged.get()) {
        geom.geometryChanged();
    }
    return geom;
}
项目:gtfs2json    文件:GeoUtils.java   
/**
 * Finds a UTM projection and applies it to all coordinates of the given geom.
 * 
 * @param orig
 * @return
 */

public static Geometry projectLonLatGeom(Geometry orig) {
  // TODO FIXME XXX: what about when the geoms cross zones?
  final Geometry geom = (Geometry) orig.clone();
  geom.apply(new CoordinateFilter() {
    public void filter(Coordinate coord) {
      final ProjectedCoordinate converted =
          GeoUtils.convertLonLatToEuclidean(coord);
      coord.setCoordinate(converted);
    }
  });

  geom.geometryChanged();
  return geom;
}
项目:vt-support    文件:Fragmenter.java   
public static Geometry toMercator(Geometry geometry) {
  Geometry clone = (Geometry) geometry.clone();
  clone.apply(new CoordinateFilter() {
    @Override
    public void filter(Coordinate coord) {
      coord.setCoordinate(new Coordinate(lon2x(coord.x), lat2y(coord.y), coord.z));
    }
  });
  clone.geometryChanged();
  return clone;
}
项目:geoxygene    文件:PolynomialTransformation.java   
/**
 * @return a coordinate filter that applies the transformation to all coordinates it is given.
 */
public CoordinateFilter getCoordinateFilter() {
  return new CoordinateFilter() {
    @Override
    public void filter(Coordinate coord) {
      coord.setCoordinate(PolynomialTransformation.this.transform(coord));
    }
  };
}
项目:geoxygene    文件:JtsAlgorithms.java   
public IGeometry translate(IGeometry geom, final double tx, final double ty,
    final double tz) {
  try {
    Geometry jtsGeom = JtsGeOxygene.makeJtsGeom(geom);
    CoordinateFilter translateCoord = new CoordinateFilter() {
      @Override
      public void filter(Coordinate coord) {
        coord.x += tx;
        coord.y += ty;
        coord.z += tz;
      }
    };
    jtsGeom.apply(translateCoord);
    IGeometry result = JtsGeOxygene.makeGeOxygeneGeom(jtsGeom);
    return result;
  } catch (Exception e) {
    JtsAlgorithms.logger
        .error(I18N.getString("JtsAlgorithms.TranslateError")); //$NON-NLS-1$
    if (JtsAlgorithms.logger.isDebugEnabled()) {
      JtsAlgorithms.logger
          .debug(I18N.getString("JtsAlgorithms.Geometry") + ((geom != null) ? geom.toString() : I18N.getString("JtsAlgorithms.NullGeometry"))); //$NON-NLS-1$ //$NON-NLS-2$
      JtsAlgorithms.logger.debug(e.getMessage());
    }
    e.printStackTrace();
    return null;
  }
}
项目:modelingcommons    文件:AbstractProjection.java   
public ForwardTransformer (AbstractProjection proj) {
    _proj = proj;
    _filter = new CoordinateFilter() {
            private Coordinate temp = new Coordinate();
            public void filter (Coordinate coord) {
                temp = _proj.forwardPoint(coord.x, coord.y, temp);
                coord.setCoordinate(temp);
            }
        };
}
项目:jeql    文件:CentroidAligner.java   
/**
 * Moves g so that c is at (0,0).
 * @param g the Geometry to modify
 * @param c the point to move to the origin
 */
public void translate(Geometry g, final Coordinate delta) {
  g.apply(new CoordinateFilter() {
    public void filter(Coordinate coordinate) {
      coordinate.x += delta.x;
      coordinate.y += delta.y;
    }
  });
}
项目:jeql    文件:Reprojector.java   
public void reproject(Geometry geometry, final CoordinateSystem source,
    final CoordinateSystem destination) {
    if (!wouldChangeValues(source, destination)) {
        return;
    }

    geometry.apply(new CoordinateFilter() {
            public void filter(Coordinate coord) {
                reproject(coord, source, destination);
            }
        });
    geometry.setSRID(destination.getEPSGCode());
    geometry.geometryChanged();
}
项目:gama    文件:DynamicLineString.java   
@Override
public void apply(final CoordinateFilter filter) {
    filter.filter(getCoordinate());
    filter.filter(GeometryUtils.toCoordinate(target.getLocation()));
}
项目:GeoSpark    文件:Circle.java   
@Override
public void apply(CoordinateFilter filter) {
    // Do nothing. This circle is not expected to be a complete geometry.
}