本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.apply方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.apply方法的具體用法?Java Geometry.apply怎麽用?Java Geometry.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Geometry
的用法示例。
在下文中一共展示了Geometry.apply方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: LinearElevationInterpolator
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public LinearElevationInterpolator(Geometry original, CoordinateReferenceSystem crs) {
originalLines = new ArrayList<LineString>();
original.apply(new GeometryComponentFilter() {
@Override
public void filter(Geometry geom) {
if(geom instanceof LineString) {
originalLines.add((LineString) geom);
}
}
});
}
示例2: getLines
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private Collection<Geometry> getLines(final Geometry geom) {
final List<Geometry> linesList = new ArrayList<Geometry>();
final LinearComponentExtracter lineFilter = new LinearComponentExtracter(
linesList);
geom.apply(lineFilter);
return linesList;
}
示例3: getLines
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private Collection<Geometry> getLines(final Geometry geom1, final Geometry geom2) {
final List<Geometry> linesList = new ArrayList<Geometry>();
final LinearComponentExtracter lineFilter = new LinearComponentExtracter(
linesList);
geom1.apply(lineFilter);
geom2.apply(lineFilter);
return linesList;
}
示例4: toMercator
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
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;
}
示例5: transformIntoPointGeometryCollection
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* Transform into GeometryCollection.
*
* @param geom input geometry
* @return a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[]{coord[i]};
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, geom.getFactory());
}
return new GeometryCollection(geometries, geom.getFactory());
}
示例6: gatherElevationPointCloud
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
List<PointDistance> gatherElevationPointCloud(Geometry geom) {
final List<PointDistance> results = new ArrayList<PointDistance>();
geom.apply(new CoordinateSequenceFilter() {
@Override
public boolean isGeometryChanged() {
return false;
}
@Override
public boolean isDone() {
return false;
}
@Override
public void filter(CoordinateSequence seq, int i) {
// we do all the collecting when called for the first ordinate
if(i > 0) {
return;
}
// collects only points with a Z
if(hasElevations(seq)) {
Coordinate[] coords = seq.toCoordinateArray();
for (int j = 0; j < coords.length; j++) {
Coordinate c = coords[j];
// avoid adding the last element of a ring to avoid un-balancing the
// weights (the fist/last coordinate would be counted twice)
if((j < coords.length - 1 || !c.equals(coords[0])) && !Double.isNaN(c.z)) {
results.add(new PointDistance(c));
}
}
}
}
});
if(results.size() == 0) {
return null;
} else {
return results;
}
}
示例7: createTileGeom
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* <p>Create geometry clipped and then converted to MVT 'extent' coordinates. Result
* contains both clipped geometry (intersection) and transformed geometry for encoding to
* MVT.</p>
* <p>Allows specifying separate tile and clipping coordinates. {@code clipEnvelope} can be bigger
* than {@code tileEnvelope} to have geometry exist outside the MVT tile extent.</p>
*
* @param geometryList original 'source' geometry, passed through
* {@link #flatFeatureList(Geometry)}
* @param tileEnvelope world coordinate bounds for tile, used for transforms
* @param clipEnvelope world coordinates to clip tile by
* @param geomFactory creates a geometry for the tile envelope
* @param mvtLayerParams specifies vector tile properties
* @param filter geometry values that fail filter after transforms are removed
* @return tile geometry result
* @see TileGeomResult
*/
public static TileGeomResult createTileGeom(List<Geometry> geometryList,
Envelope tileEnvelope,
Envelope clipEnvelope,
GeometryFactory geomFactory,
MvtLayerParams mvtLayerParams,
IGeometryFilter filter) {
final Geometry tileClipGeom = geomFactory.toGeometry(clipEnvelope);
final AffineTransformation t = new AffineTransformation();
final double xDiff = tileEnvelope.getWidth();
final double yDiff = tileEnvelope.getHeight();
final double xOffset = -tileEnvelope.getMinX();
final double yOffset = -tileEnvelope.getMinY();
// Transform Setup: Shift to 0 as minimum value
t.translate(xOffset, yOffset);
// Transform Setup: Scale X and Y to tile extent values, flip Y values
t.scale(1d / (xDiff / (double) mvtLayerParams.extent),
-1d / (yDiff / (double) mvtLayerParams.extent));
// Transform Setup: Bump Y values to positive quadrant
t.translate(0d, (double) mvtLayerParams.extent);
// The area contained in BOTH the 'original geometry', g, AND the 'clip envelope geometry' is
// the 'tile geometry'
final List<Geometry> intersectedGeoms = flatIntersection(tileClipGeom, geometryList);
final List<Geometry> transformedGeoms = new ArrayList<>(intersectedGeoms.size());
// Transform intersected geometry
Geometry nextTransformGeom;
Object nextUserData;
for (Geometry nextInterGeom : intersectedGeoms) {
nextUserData = nextInterGeom.getUserData();
nextTransformGeom = t.transform(nextInterGeom);
// Floating --> Integer, still contained within doubles
nextTransformGeom.apply(RoundingFilter.INSTANCE);
// TODO: Refactor line simplification
// Can't use 0d, specify value < .5d
nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d);
nextTransformGeom.setUserData(nextUserData);
// Apply filter on transformed geometry
if (filter.accept(nextTransformGeom)) {
transformedGeoms.add(nextTransformGeom);
}
}
return new TileGeomResult(intersectedGeoms, transformedGeoms);
}