本文整理汇总了Java中org.opengis.geometry.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于org.opengis.geometry包,在下文中一共展示了BoundingBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exampleReferencedEnvelopeStaticMethods
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
private void exampleReferencedEnvelopeStaticMethods() throws Exception {
// exampleReferencedEnvelopeStaticMethods start
ReferencedEnvelope env; // can hold both regular ReferencedEnvelope as well as ReferencedEnvelope3D
ReferencedEnvelope original = null; // can be instance of ReferencedEnvelope3D;
CoordinateReferenceSystem crs = null; //can be 2D or 3D
org.opengis.geometry.Envelope opengis_env = null; //can be instance of ReferencedEnvelope(3D)
com.vividsolutions.jts.geom.Envelope jts_env = null; //can be instance of ReferencedEnvelope(3D)
BoundingBox bbox = null; //can be instance of ReferencedEnvelope(3D)
//safely copy ReferencedEnvelope, uses type of original to determine type
env = ReferencedEnvelope.create( original );
//safely create ReferencedEnvelope from CRS, uses dimension to determine type
env = ReferencedEnvelope.create( crs );
//safely create ReferencedEnvelope from org.opengis.geometry.Envelope, uses dimension in Envelope to determine type
env = ReferencedEnvelope.create( opengis_env, crs );
//safely create ReferencedEnvelope from com.vividsolutions.jts.geom.Envelope, uses dimension in Envelope to determine type
env = ReferencedEnvelope.create( jts_env, crs );
//safely reference org.opengis.geometry.Envelope as ReferencedEnvelope
//--> if it is a ReferencedEnvelope(3D), simply cast it; if not, create a conversion
env = ReferencedEnvelope.reference ( opengis_env);
//safely reference com.vividsolutions.jts.geom.Envelope as ReferencedEnvelope
//--> if it is a ReferencedEnvelope(3D), simply cast it; if not, create a conversion
env = ReferencedEnvelope.reference ( jts_env);
//safely reference BoundingBox as ReferencedEnvelope
//--> if it is a ReferencedEnvelope(3D), simply cast it; if not, create a conversion
env = ReferencedEnvelope.reference ( bbox);
// exampleReferencedEnvelopeStaticMethods end
}
示例2: inBounds
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
private Matcher<SimpleFeature> inBounds(
BoundingBox bounds ) {
return new BaseMatcher<SimpleFeature>() {
@Override
public boolean matches(
Object item ) {
SimpleFeature feature = (SimpleFeature) item;
return feature.getBounds().intersects(
bounds);
}
@Override
public void describeTo(
Description description ) {
description.appendText("feature should be in bounds " + bounds);
}
};
}
示例3: reprojectBounds
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
public static Bounds reprojectBounds(Bounds inBounds, String fromCRS, String toCRS) {
if (fromCRS.equals(toCRS))
return inBounds;
try {
double ulx = inBounds.getLeft();
double uly = inBounds.getTop();
double lrx = inBounds.getRight();
double lry = inBounds.getBottom();
CoordinateReferenceSystem sourceCRS = CRS.decode(fromCRS);
CoordinateReferenceSystem targetCRS = CRS.decode(toCRS);
if (CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
return inBounds;
} else {
ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, sourceCRS);
BoundingBox b = re.toBounds(targetCRS);
return getBounds(b);
}
} catch (Exception e) {
}
return null;
}
示例4: getFilterConfiguration
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
/**
* Gets the filter configuration.
*
* @return the filter configuration
*/
@Override
public FilterName getFilterConfiguration() {
FilterName filterName = new FilterName("BBOX", Boolean.class);
filterName.addParameter(new FilterNameParameter("property", ExpressionTypeEnum.PROPERTY,
BoundingBox.class));
filterName.addParameter(new FilterNameParameter("boundingbox", ExpressionTypeEnum.LITERAL,
BoundingBox.class));
return filterName;
}
示例5: getBoundingBox
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
public BoundingBox getBoundingBox() {
try {
final BoundingBox bbox = featureSource.getBounds();
return bbox;
} catch (final IOException e) {
LOGGER.error("Error while getting the bounding box", e);
return null;
}
}
示例6: getBoundingBox
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
@Override
public BoundingBox getBoundingBox() {
try {
final BoundingBox bbox = featureSource.getBounds();
return bbox;
} catch (final IOException e) {
LOGGER.error("Error while getting the bounding box", e);
return null;
}
}
示例7: getRandomPoint
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
private static Point getRandomPoint(BoundingBox bb, Geometry geom) {
Random rand = new Random();
GeometryFactory gf = new GeometryFactory();
Point pt = null;
for(int i=0; i<1000; i++){
double x = randdouble(rand, bb.getMinX(),bb.getMaxX());
double y = randdouble(rand, bb.getMinY(),bb.getMaxY());
pt = gf.createPoint( new Coordinate(x,y) );
if(geom.contains(pt)){
return pt;
}
}
return null;
}
示例8: getBboxFilter
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
/**
* Create a bounding box filter from a bounding box.
*
* @param attribute the geometry attribute or null in the case of default "the_geom".
* @param bbox the {@link BoundingBox}.
* @return the filter.
* @throws CQLException
*/
public static Filter getBboxFilter( String attribute, BoundingBox bbox ) throws CQLException {
double w = bbox.getMinX();
double e = bbox.getMaxX();
double s = bbox.getMinY();
double n = bbox.getMaxY();
return getBboxFilter(attribute, w, e, s, n);
}
示例9: exampleBoundingBox
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
private void exampleBoundingBox() throws Exception {
// exampleBoundingBox start
CoordinateReferenceSystem wsg84 = CRS.decode("EPSG:4326");
org.opengis.geometry.BoundingBox bbox = new ReferencedEnvelope(0, 10, 0, 20, wsg84);
double xMin = bbox.getMinX();
double yMin = bbox.getMinY();
double xMax = bbox.getMaxX();
double yMax = bbox.getMaxY();
double width = bbox.getWidth();
double height = bbox.getHeight();
double xCenter = bbox.getMedian(0);
double yCenter = bbox.getMedian(1);
CoordinateReferenceSystem crs = bbox.getCoordinateReferenceSystem();
// Direct access to internal upper and lower positions
DirectPosition lower = bbox.getLowerCorner();
DirectPosition upper = bbox.getUpperCorner();
// expand to include 15, 30
bbox.include(15, 30);
// exampleBoundingBox end
}
示例10: getBoundsInternal
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected ReferencedEnvelope getBoundsInternal(
final Query query )
throws IOException {
double minx = -90.0, maxx = 90.0, miny = -180.0, maxy = 180.0;
DataStatistics<SimpleFeature> bboxStats = null;
if (query.getFilter().equals(
Filter.INCLUDE)) {
final Map<ByteArrayId, DataStatistics<SimpleFeature>> stats = new GeoWaveEmptyTransaction(
components).getDataStatistics();
bboxStats = stats.get(FeatureBoundingBoxStatistics.composeId(getFeatureType()
.getGeometryDescriptor()
.getLocalName()));
}
if (bboxStats != null) {
minx = ((BoundingBoxDataStatistics) bboxStats).getMinX();
maxx = ((BoundingBoxDataStatistics) bboxStats).getMaxX();
miny = ((BoundingBoxDataStatistics) bboxStats).getMinY();
maxy = ((BoundingBoxDataStatistics) bboxStats).getMaxY();
}
else {
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = new GeoWaveFeatureReader(
query,
new GeoWaveEmptyTransaction(
components),
components);
if (reader.hasNext()) {
minx = 90.0;
maxx = -90.0;
miny = 180.0;
maxy = -180.0;
while (reader.hasNext()) {
final BoundingBox bbox = reader.next().getBounds();
minx = Math.min(
bbox.getMinX(),
minx);
maxx = Math.max(
bbox.getMaxX(),
maxx);
miny = Math.min(
bbox.getMinY(),
miny);
maxy = Math.max(
bbox.getMaxY(),
maxy);
}
}
reader.close();
}
return new ReferencedEnvelope(
minx,
maxx,
miny,
maxy,
GeometryUtils.DEFAULT_CRS);
}
示例11: getBounds
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
public static Bounds getBounds(BoundingBox bb) {
Bounds bounds = new Bounds();
bounds.setTop(bb.getMaxY());
bounds.setBottom(bb.getMinY());
bounds.setLeft(bb.getMinX());
bounds.setRight(bb.getMaxX());
return bounds;
}
示例12: getBoundsForLayer
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
@Override
public Bounds getBoundsForLayer(String proj) {
BoundingBox env;
try {
env = nativeBounds.toBounds(CRS.decode(proj));
} catch (Exception e) {
return null;
}
Bounds b = new Bounds();
b.setBottom(env.getMinY());
b.setTop(env.getMaxY());
b.setLeft(env.getMinX());
b.setRight(env.getMaxX());
return b;
}
示例13: getFeatures
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
/** Get all the features in this collection that intersect or are contained
* by the passed {@link BoundingBox}.
*
* @param extent The bounding box to test against. This must be in the same
* CRS as the features in order to return the correct features.
* @return A new ArrayList<SimpleFeature> containing the relevant features
*/
public ArrayList<SimpleFeature> getFeatures(BoundingBox extent) {
ArrayList<SimpleFeature> tmp = new ArrayList<SimpleFeature>();
Iterator<SimpleFeature> iterator = iterator();
while (iterator.hasNext()) {
SimpleFeature f = iterator.next();
if (extent.contains( f.getBounds() ) ||
extent.intersects( f.getBounds() )) {
tmp.add(f);
}
}
return tmp;
}
示例14: getBounds
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
/** Get the bounding envelope for all features within this collection.
* If the bounds are not already set, this will build the spatialIndex and set the bounds
* from that.<p>
* Its assumed that all features in the collection have the same CoordinateReferenceSystem,
* therefore the BoundingBox has its SRSID set to the first feature's SRSID
*
* @return ReferencedEnvelope
*/
public final BoundingBox getBounds() {
if (bounds==null) {
int srsID =( (Geometry)this.get(0).getDefaultGeometry()).getSRID();
BoundingBox re = new BoundingBoxImpl(""+srsID);
for (SimpleFeature f : this) {
re.include(f.getBounds());
}
bounds = re;
}
return bounds;
}
示例15: getBounds
import org.opengis.geometry.BoundingBox; //导入依赖的package包/类
/**
* @return the BoundingBox from GpkgContents
*/
@Override
public BoundingBox getBounds() {
try {
super.getContents(geoPackage);
} catch (Exception e) {
e.printStackTrace();
}
return super.getBounds();
}