當前位置: 首頁>>代碼示例>>Java>>正文


Java ReferencedEnvelope類代碼示例

本文整理匯總了Java中org.geotools.geometry.jts.ReferencedEnvelope的典型用法代碼示例。如果您正苦於以下問題:Java ReferencedEnvelope類的具體用法?Java ReferencedEnvelope怎麽用?Java ReferencedEnvelope使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReferencedEnvelope類屬於org.geotools.geometry.jts包,在下文中一共展示了ReferencedEnvelope類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setExtend

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
/**
 * sets the viewport of the map to the given extend.
 *
 * @param envelope the extend
 */
public void setExtend(ReferencedEnvelope envelope) {
    try {
        envelope = envelope.transform(this.mapContent.getViewport()
                .getCoordinateReferenceSystem(), true);
        double xLength = envelope.getSpan(0);
        xLength = xLength * TEN_PERCENT;
        double yLength = envelope.getSpan(1);
        yLength = yLength * TEN_PERCENT;
        envelope.expandBy(xLength, yLength);
        bboxAction.resetCoordinates();
        mapPane.deleteGraphics();
        mapPane.setDisplayArea(envelope);
    } catch (FactoryException | TransformException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
    }
}
 
開發者ID:gdi-by,項目名稱:downloadclient,代碼行數:22,代碼來源:WMSMapSwing.java

示例2: expandBounds

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
/**
 * Expands inBounds by multiplying min of inBounds.getWidth and inBounds.getHeight times percent
 * 
 * @param inBounds
 * @param percent
 * @return
 */
public static Bounds expandBounds(Bounds inBounds, String inCRS, double percent) {

	try {
		double ulx = inBounds.getLeft();
		double uly = inBounds.getTop();
		double lrx = inBounds.getRight();
		double lry = inBounds.getBottom();

		CoordinateReferenceSystem theCRS = CRS.decode(inCRS);
		ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, theCRS);
		double expandBy = Math.min(re.getHeight(), re.getWidth()) * percent;
		re.expandBy(expandBy);
		return getBounds(re.toBounds(theCRS));

	} catch (Exception e) {
	}

	return null;
}
 
開發者ID:lizardtechblog,項目名稱:ExpressZip,代碼行數:27,代碼來源:MapModel.java

示例3: read

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public void read(URL file) throws IOException {
    Map<String, Object> map = new HashMap<>();
    map.put("url", file);


    DataStore dataStore = DataStoreFinder.getDataStore(map);
    String typeName = dataStore.getTypeNames()[0];

    FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);

    FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();

    FeatureIterator<SimpleFeature> features = collection.features();
    int count = 0;
    LOGGER.info("reading world time zones ...");
    while (features.hasNext()) {
        count++;
        SimpleFeature feature = features.next();
        ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(feature.getBounds());
        quadtree.insert(referencedEnvelope,feature);
    }
    LOGGER.info(count + " features read");

}
 
開發者ID:graphhopper,項目名稱:timezone,代碼行數:25,代碼來源:TZShapeReader.java

示例4: parse

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
@Override
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    Envelope envelope = (Envelope) super.parse(instance, node, value);

    // handle the box CRS
    CoordinateReferenceSystem crs = this.crs;
    if (node.hasAttribute("srsName")) {
        URI srs = (URI) node.getAttributeValue("srsName");
        crs = CRS.decode(srs.toString());
    }
    
    if(crs != null) {
        return ReferencedEnvelope.create(envelope, crs);
    } else {
        return envelope;
    }
}
 
開發者ID:STEMLab,項目名稱:geoserver-3d-extension,代碼行數:18,代碼來源:GMLBoxTypeBinding_ISO.java

示例5: resizeSwingContent

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
/**
  * Resizes swing content and centers map.
  * @param width The new content width.
  */
public void resizeSwingContent(double width) {
    try {
        if (width >= mapWidth) {
            double oldWidth = mapPane.getWidth();

            this.mapNode.resize(width - MAP_NODE_MARGIN, mapHeight);
            double scale = mapPane.getWorldToScreenTransform().getScaleX();
            ReferencedEnvelope bounds = mapPane.getDisplayArea();

            double dXScreenCoord = (width - MAP_NODE_MARGIN - oldWidth) / 2;
            double dXWorldCoord = dXScreenCoord / scale;

            bounds.translate(-1 * dXWorldCoord , 0);
            mapPane.setDisplayArea(bounds);
            mapPane.deleteGraphics();
            clearCoordinateDisplay();
        }
    } catch (NullPointerException e) { }
}
 
開發者ID:gdi-by,項目名稱:downloadclient,代碼行數:24,代碼來源:WMSMapSwing.java

示例6: createSearchEnv

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
private ReferencedEnvelope createSearchEnv(final DirectPosition2D pos, final double radius) {
	final CoordinateReferenceSystem contextCRS = getMapContent().getCoordinateReferenceSystem();
	ReferencedEnvelope env = new ReferencedEnvelope(pos.x - radius, pos.x + radius, pos.y - radius, pos.y + radius,
			contextCRS);
	if (isTransformRequired()) {
		final Layer layer = layerRef.get();
		if (layer != null) {
			final CoordinateReferenceSystem layerCRS = layer.getFeatureSource().getSchema()
					.getCoordinateReferenceSystem();
			try {
				env = env.transform(layerCRS, true);
			} catch (final Exception ex) {
				throw new IllegalStateException(ex);
			}
		}
	}

	return env;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:20,代碼來源:VectorLayerHelper.java

示例7: calcAoi

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
private void calcAoi() throws NoninvertibleTransformException {
    Point2D.Double[] pts = new Point2D.Double[4];
    pts[0] = new Point2D.Double(tileCenter.x - tileHalf, tileCenter.y - tileHalf);
    pts[1] = new Point2D.Double(tileCenter.x + tileHalf, tileCenter.y - tileHalf);
    pts[2] = new Point2D.Double(tileCenter.x - tileHalf, tileCenter.y + tileHalf);
    pts[3] = new Point2D.Double(tileCenter.x + tileHalf, tileCenter.y + tileHalf);
    cartesian2ScreenTransform.inverseTransform(pts[0], pts[0]);
    cartesian2ScreenTransform.inverseTransform(pts[1], pts[1]);
    cartesian2ScreenTransform.inverseTransform(pts[2], pts[2]);
    cartesian2ScreenTransform.inverseTransform(pts[3], pts[3]);
    double x1 = Double.MAX_VALUE;
    double x2 = -Double.MAX_VALUE;
    double y1 = Double.MAX_VALUE;
    double y2 = -Double.MAX_VALUE;
    for (Point2D.Double pt : pts) {
        x1 = Math.min(x1, pt.x);
        y1 = Math.min(y1, pt.y);
        x2 = Math.max(x2, pt.x);
        y2 = Math.max(y2, pt.y);
    }
    tileAoi = new ReferencedEnvelope(x1, x2, y1, y2, mapDisplayContextCrs);
}
 
開發者ID:marat-gainullin,項目名稱:platypus-js,代碼行數:23,代碼來源:MapTilesCache.java

示例8: getEnvelope

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
/**
 * Get the current data envelope.
 * 
 * @param connection the db connection.
 * @return the envelope.
 * @throws Exception
 */
public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception {
    String query = "SELECT min(" + //
            ImageTableFields.COLUMN_LON.getFieldName() + "), max(" + //
            ImageTableFields.COLUMN_LON.getFieldName() + "), min(" + //
            ImageTableFields.COLUMN_LAT.getFieldName() + "), max(" + //
            ImageTableFields.COLUMN_LAT.getFieldName() + ") " + //
            " FROM " + TABLE_IMAGES;
    try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) {
        if (rs.next()) {
            double minX = rs.getDouble(1);
            double maxX = rs.getDouble(2);
            double minY = rs.getDouble(3);
            double maxY = rs.getDouble(4);

            ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84);
            return env;
        }
    }

    return null;
}
 
開發者ID:TheHortonMachine,項目名稱:hortonmachine,代碼行數:29,代碼來源:DaoImages.java

示例9: RasterizedSpatialiteLasLayer

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public RasterizedSpatialiteLasLayer( String title, ASpatialDb db, Integer tileSize, boolean transparentBackground,
        boolean doIntensity ) throws Exception {
    super(makeLevels(title, tileSize, transparentBackground, db, doIntensity));
    String plus = doIntensity ? INTENSITY : ELEVATION;
    this.layerName = title + " " + plus;
    this.setUseTransparentTextures(true);

    try {
        Envelope tableBounds = db.getTableBounds(LasSourcesTable.TABLENAME);
        GeometryColumn spatialiteGeometryColumns = db.getGeometryColumnsForTable(LasCellsTable.TABLENAME);
        CoordinateReferenceSystem dataCrs = CRS.decode("EPSG:" + spatialiteGeometryColumns.srid);
        CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
        ReferencedEnvelope env = new ReferencedEnvelope(tableBounds, dataCrs);
        ReferencedEnvelope envLL = env.transform(targetCRS, true);

        centre = envLL.centre();
    } catch (Exception e) {
        e.printStackTrace();
        centre = CrsUtilities.WORLD.centre();
    }
}
 
開發者ID:TheHortonMachine,項目名稱:hortonmachine,代碼行數:22,代碼來源:RasterizedSpatialiteLasLayer.java

示例10: getBoundaryProduct

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public Product getBoundaryProduct() throws FactoryException, TransformException {
    final CoordinateReferenceSystem mapCRS = getTargetCRS();
    if (mapCRS != null) {
        final ReferencedEnvelope envelope = getTargetEnvelope();
        final Envelope mapEnvelope = envelope.transform(mapCRS, true);

        final double pixelSizeX = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_X);
        final double pixelSizeY = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_Y);
        final int w = MathUtils.floorInt(mapEnvelope.getSpan(0) / pixelSizeX);
        final int h = MathUtils.floorInt(mapEnvelope.getSpan(1) / pixelSizeY);

        final Product product = new Product("mosaic", "MosaicBounds", w, h);
        final GeoCoding geoCoding = new CrsGeoCoding(mapCRS,
                                                     w, h,
                                                     mapEnvelope.getMinimum(0),
                                                     mapEnvelope.getMaximum(1),
                                                     pixelSizeX, pixelSizeY);
        product.setSceneGeoCoding(geoCoding);

        return product;
    }
    return null;
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:24,代碼來源:MosaicFormModel.java

示例11: FeatureLayer

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
                    PropertySet configuration) {
    super(layerType, configuration);
    crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
    if (crs == null) {
        // todo - check me! Why can this happen??? (nf)
        crs = DefaultGeographicCRS.WGS84;
    }
    final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs);
    modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
                                         envelope.getWidth(), envelope.getHeight());
    mapContext = new DefaultMapContext(crs);
    final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE);
    mapContext.addLayer(fc, style);
    renderer = new StreamingRenderer();
    workaroundLabelCacheBug();
    style.accept(new RetrievingStyleVisitor());
    renderer.setContext(mapContext);

}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:21,代碼來源:FeatureLayer.java

示例12: getWorldtoScreen

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public static Point2D getWorldtoScreen(double x, double y){
    
    Rectangle imageBounds=null;
    ReferencedEnvelope mapBounds=null;
    try{
//        mapBounds=map.getLayerBounds();
        imageBounds = mapFrame.getBounds();
        int width = (int)imageBounds.getWidth();
        int height = (int)imageBounds.getHeight();
    }catch(Exception e){
        
    } 
    
    
    AffineTransform world2screen =
    RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
    Point2D pointScreenAbsolute = new Point2D.Double(x, y);
    Point2D pointScreen = world2screen.transform(pointScreenAbsolute, null);
    return pointScreen;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:21,代碼來源:WorldScreen.java

示例13: getScreentoWorld

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
public static Point2D getScreentoWorld(double x, double y) throws Exception {
    Rectangle imageBounds=null;
    ReferencedEnvelope mapBounds=null;
    try{
//        mapBounds=map.getLayerBounds();
        imageBounds = mapFrame.getBounds();
        int width = (int)imageBounds.getWidth();
        int height = (int)imageBounds.getHeight();
    }catch(Exception e){
        
    } 
    
    AffineTransform world2screen =
    RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
    
    AffineTransform screen2world = world2screen.createInverse();
    Point2D pointScreenAbsolute = new Point2D.Double(x, y);
    Point2D pointScreen = screen2world.transform(pointScreenAbsolute, null); 
    return pointScreen;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:21,代碼來源:WorldScreen.java

示例14: afterTransactionInternal

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
private void afterTransactionInternal(final TransactionType transaction, boolean committed) {
    log.fine("Detected change to data, updating bounds of affected featuer types and layer groups");
    
    final Map<Name, Collection<ReferencedEnvelope>> byLayerDirtyRegions = getByLayerDirtyRegions(transaction);
    if (byLayerDirtyRegions.isEmpty()) {
        return;
    }
    byLayerDirtyRegions.entrySet().stream().forEach(e->{
        FeatureTypeInfo fti = catalog.getFeatureTypeByName(e.getKey());
        try{
            merge(fti.getNativeBoundingBox(), e.getValue()).ifPresent(dirtyRegion->{
                // Update the feature type
                updateFeatureType(fti, dirtyRegion);
                // Update all the layer groups that use it, directly or indirectly
                StreamSupport.stream(getLayerGroupsFor(fti).spliterator(), false)
                    .forEach(lgi->updateLayerGroup(lgi, dirtyRegion));
            });
        } catch (Exception ex) {
            log.log(Level.WARNING, ex.getMessage(), ex);
            return;
        }
    });
 
}
 
開發者ID:MapStory,項目名稱:ms-gs-plugins,代碼行數:25,代碼來源:BoundsUpdateTransactionListener.java

示例15: merge

import org.geotools.geometry.jts.ReferencedEnvelope; //導入依賴的package包/類
private Optional<ReferencedEnvelope> merge(final ReferencedEnvelope oldEnv,
        final Collection<ReferencedEnvelope> dirtyList) {
    final CoordinateReferenceSystem declaredCrs = oldEnv.getCoordinateReferenceSystem();
    return dirtyList.stream()
        .map(env->{
            if(env instanceof ReferencedEnvelope3D) {
                return new ReferencedEnvelope(env, CRS.getHorizontalCRS(env.getCoordinateReferenceSystem()));
            } else  {
                return env;
            }
        })
        .map(env->{
            try {
                return env.transform(declaredCrs, true, 1000);
            } catch (TransformException | FactoryException e) {
                throw new RuntimeException("Error while merging bounding boxes",e);
            }
        })
        .reduce((env1, env2)->{ReferencedEnvelope x = new ReferencedEnvelope(env1); x.expandToInclude(env2); return x;});
}
 
開發者ID:MapStory,項目名稱:ms-gs-plugins,代碼行數:21,代碼來源:BoundsUpdateTransactionListener.java


注:本文中的org.geotools.geometry.jts.ReferencedEnvelope類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。