当前位置: 首页>>代码示例>>Java>>正文


Java BoundingBox类代码示例

本文整理汇总了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
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:36,代码来源:APIExamples.java

示例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);
		}
	};
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:19,代码来源:SceneFeatureIteratorTest.java

示例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;
}
 
开发者ID:lizardtechblog,项目名称:ExpressZip,代码行数:25,代码来源:MapModel.java

示例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;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:16,代码来源:BBox.java

示例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;
  }
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:10,代码来源:GeospatialDatasetImpl.java

示例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;
  }
}
 
开发者ID:AURIN,项目名称:workbenchauth,代码行数:11,代码来源:GeospatialDatasetImpl.java

示例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;
}
 
开发者ID:conveyal,项目名称:aggregate-disser,代码行数:16,代码来源:Disser.java

示例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);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:FilterUtilities.java

示例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
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:29,代码来源:APIExamples.java

示例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);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:61,代码来源:GeoWaveFeatureSource.java

示例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;
}
 
开发者ID:lizardtechblog,项目名称:ExpressZip,代码行数:9,代码来源:MapModel.java

示例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;
}
 
开发者ID:lizardtechblog,项目名称:ExpressZip,代码行数:16,代码来源:VectorLayer.java

示例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;
}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:21,代码来源:FeatureCollection.java

示例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;
}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:20,代码来源:FeatureCollection.java

示例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();
}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:15,代码来源:TilesTable.java


注:本文中的org.opengis.geometry.BoundingBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。