本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.getEnvelopeInternal方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.getEnvelopeInternal方法的具體用法?Java Geometry.getEnvelopeInternal怎麽用?Java Geometry.getEnvelopeInternal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Geometry
的用法示例。
在下文中一共展示了Geometry.getEnvelopeInternal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
@DescribeResult(name = "result", description = "Clipped feature collection")
public SimpleFeatureCollection execute(
@DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features,
@DescribeParameter(name = "clip", description = "Geometry to use for clipping (in same CRS as input features)") Geometry clip,
@DescribeParameter(name = "preserveZ", min=0,description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)") Boolean preserveZ)
throws ProcessException {
// only get the geometries in the bbox of the clip
Envelope box = clip.getEnvelopeInternal();
String srs = null;
if(features.getSchema().getCoordinateReferenceSystem() != null) {
srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem());
}
BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs);
// default value for preserve Z
if(preserveZ == null) {
preserveZ = false;
}
// return dynamic collection clipping geometries on the fly
return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ);
}
示例2: fastGetSharedAreaRatio
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* This is ten times faster than the absolutely correct
* version above, and it's only off by an average of 1%.
* Note that the first argument MUST be rectangular, or
* your results will be meaningless.
*/
public static double fastGetSharedAreaRatio (Geometry geom1, Geometry geom2) {
Envelope env1 = geom1.getEnvelopeInternal();
if ((SimplePointInAreaLocator.locate(new Coordinate(env1.getMinX(),env1.getMinY()), geom2) == Location.INTERIOR) &&
(SimplePointInAreaLocator.locate(new Coordinate(env1.getMaxX(),env1.getMaxY()), geom2) == Location.INTERIOR) &&
(SimplePointInAreaLocator.locate(new Coordinate(env1.getMaxX(),env1.getMinY()), geom2) == Location.INTERIOR) &&
(SimplePointInAreaLocator.locate(new Coordinate(env1.getMinX(),env1.getMaxY()), geom2) == Location.INTERIOR)) {
// I suppose it is possible for a valid polygon geometry
// to contain all four corners and share considerably less
// than 100% of its area with the envelope in question.
// But if you're that worried about correctness you
// shouldn't be using this method in the first place.
return 1.0;
}
double xInc = env1.getWidth() / 9.0;
double yInc = env1.getHeight() / 9.0;
double x = env1.getMinX();
double y = env1.getMinY();
double ct = 0;
for (int i = 0; i < 10; i += 1) {
y = env1.getMinY();
for (int j = 0; j < 10; j += 1) {
if (SimplePointInAreaLocator.locate(new Coordinate(x,y), geom2) == Location.INTERIOR) {
ct += 1;
}
y += yInc;
}
x += xInc;
}
return (ct / 100.0);
}
示例3: ClippingFeatureIterator
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public ClippingFeatureIterator(SimpleFeatureIterator delegate, Geometry clip,
SimpleFeatureType schema, boolean preserveZ) {
this.delegate = delegate;
// can we use the fast clipper?
if(clip.getEnvelope().equals(clip)) {
this.clipper = new GeometryClipper(clip.getEnvelopeInternal());
} else {
this.clip = clip;
}
fb = new SimpleFeatureBuilder(schema);
this.preserveZ = preserveZ;
}