本文整理匯總了Java中com.vividsolutions.jts.geom.GeometryFactory.toGeometry方法的典型用法代碼示例。如果您正苦於以下問題:Java GeometryFactory.toGeometry方法的具體用法?Java GeometryFactory.toGeometry怎麽用?Java GeometryFactory.toGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.toGeometry方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTileGeom
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的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);
}
示例2: initBox
import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
private void initBox() {
if (this.box == null) {
GeometryFactory factory = new GeometryFactory();
this.box = factory.toGeometry(new Envelope(this.minX, this.maxX, this.minY, this.maxY));
}
}