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


Java ReferencedEnvelope.getWidth方法代码示例

本文整理汇总了Java中org.geotools.geometry.jts.ReferencedEnvelope.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ReferencedEnvelope.getWidth方法的具体用法?Java ReferencedEnvelope.getWidth怎么用?Java ReferencedEnvelope.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.geometry.jts.ReferencedEnvelope的用法示例。


在下文中一共展示了ReferencedEnvelope.getWidth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawImage

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public void drawImage( Graphics2D g2d, ReferencedEnvelope ref, int imageWidth, int imageHeight, double buffer ) {
    checkMapContent();

    if (buffer > 0.0)
        ref.expandBy(buffer, buffer);

    Rectangle2D refRect = new Rectangle2D.Double(ref.getMinX(), ref.getMinY(), ref.getWidth(), ref.getHeight());
    Rectangle2D imageRect = new Rectangle2D.Double(0, 0, imageWidth, imageHeight);

    GeometryUtilities.scaleToRatio(imageRect, refRect, false);

    ReferencedEnvelope newRef = new ReferencedEnvelope(refRect, ref.getCoordinateReferenceSystem());

    Rectangle imageBounds = new Rectangle(0, 0, imageWidth, imageHeight);
    Color white = Color.white;
    g2d.setColor(new Color(white.getRed(), white.getGreen(), white.getBlue(), 0));
    g2d.fillRect(0, 0, imageWidth, imageHeight);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    synchronized (renderer) {
        content.getViewport().setBounds(newRef);
        renderer.paint(g2d, imageBounds, newRef);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:25,代码来源:ImageGenerator.java

示例2: 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

示例3: OSMInfo

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public OSMInfo(final URL url, final long modificationStamp) {
	super(modificationStamp);
	CoordinateReferenceSystem crs = null;
	ReferencedEnvelope env2 = new ReferencedEnvelope();

	int number = 0;
	try {
		final File f = new File(url.toURI());
		final GamaOsmFile osmfile = new GamaOsmFile(null, f.getAbsolutePath());
		attributes.putAll(osmfile.getOSMAttributes(GAMA.getRuntimeScope()));

		final SimpleFeatureType TYPE = DataUtilities.createType("geometries", "geom:LineString");
		final ArrayList<SimpleFeature> list = new ArrayList<SimpleFeature>();
		for (final IShape shape : osmfile.iterable(null)) {
			list.add(SimpleFeatureBuilder.build(TYPE, new Object[] { shape.getInnerGeometry() }, null));
		}
		final SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, list);
		final SimpleFeatureSource featureSource = DataUtilities.source(collection);

		env2 = featureSource.getBounds();
		number = osmfile.nbObjects;
		crs = osmfile.getOwnCRS(null);
	} catch (final Exception e) {
		System.out.println("Error in reading metadata of " + url);
		hasFailed = true;

	} finally {

		// approximation of the width and height in meters.
		width = env2 != null ? env2.getWidth() * (FastMath.PI / 180) * 6378137 : 0;
		height = env2 != null ? env2.getHeight() * (FastMath.PI / 180) * 6378137 : 0;
		itemNumber = number;
		this.crs = crs;
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:37,代码来源:GamaOsmFile.java

示例4: getRenderer

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private static GTRenderer getRenderer(File shapeFilesFolder) {
    File[] shpFiles = shapeFilesFolder.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".shp");
        }
    });

    MapContent mapContent = new MapContent();
    for (File shpFile : shpFiles) {
        try {
            SimpleFeatureCollection readFC = NwwUtilities.readAndReproject(shpFile.getAbsolutePath());
            ReferencedEnvelope tmpBounds = readFC.getBounds();
            if (tmpBounds.getWidth() == 0 || tmpBounds.getHeight() == 0) {
                System.err.println("Ignoring: " + shpFile);
                continue;
            }
            // if (bounds == null) {
            // bounds = new ReferencedEnvelope(tmpBounds);
            // } else {
            // bounds.expandToInclude(tmpBounds);
            // }
            Style style = SldUtilities.getStyleFromFile(shpFile);
            if (style == null)
                style = SLD.createSimpleStyle(readFC.getSchema());

            FeatureLayer layer = new FeatureLayer(readFC, style);
            mapContent.addLayer(layer);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    GTRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mapContent);
    return renderer;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:37,代码来源:RasterizedShapefilesFolderNwwLayer.java

示例5: pixelDistanceToMapUnits

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
/**
 * 
 * @param bbox	Envelope of the requested image
 * @param imageWidth Width of the ReferencedEnvelope
 * @param imageHeight  Height of the requested image
 * @param pixelToConvert The number of pixel to convert to map units
 * @return
 */
public static double pixelDistanceToMapUnits(final ReferencedEnvelope bbox, final int imageWidth, final int imageHeight, final double pixelToConvert) {
	
	final double pixelPerMuX =  bbox.getWidth() / (double) imageWidth;
	final double pixelPerMuY =  bbox.getHeight() / (double) imageHeight;
	
	// use the average of the two ratios in case a skewed WMS image is requested
	return ((pixelPerMuX + pixelPerMuY) / 2.0) * pixelToConvert;
}
 
开发者ID:geops,项目名称:trafimage-geoserver-transformations,代码行数:17,代码来源:MapUnits.java

示例6: lockAspectRatio

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public ReferencedEnvelope lockAspectRatio(ReferencedEnvelope env){
	double ratioX  = env.getWidth() / canvasWidth;
	double ratioY   = env.getHeight() / canvasHeight;
	double diff, width, height;
	if (ratioY > ratioX){
		width = ratioY*canvasWidth;
		diff = (width-env.getWidth())/2;
		env.init(env.getMinX()-diff, env.getMaxX()+diff, env.getMinY(), env.getMaxY());
	}else{
		height = ratioX*canvasHeight;
		diff = (height-env.getHeight())/2;
		env.init(env.getMinX(), env.getMaxX(), env.getMinY()-diff, env.getMaxY()+diff);		
	}
	return env;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:16,代码来源:GeoFeaturesManager.java

示例7: handleVectorMask

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private static Rectangle2D handleVectorMask(Mask mask) {
    VectorDataNode vectorData = Mask.VectorDataType.getVectorData(mask);
    ReferencedEnvelope envelope = vectorData.getEnvelope();
    if (!envelope.isEmpty()) {
        return new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
                                      envelope.getWidth(), envelope.getHeight());
    }
    return null;
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:10,代码来源:MaskFormActions.java

示例8: exampleCustomFeatureType

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private void exampleCustomFeatureType() {
    // exampleCustomFeatureType start
    SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
    typeBuilder.setName("hextype");
    typeBuilder.add("hexagon", Polygon.class, (CoordinateReferenceSystem)null);
    typeBuilder.add("color", Color.class);
    SimpleFeatureType TYPE = typeBuilder.buildFeatureType();

    final ReferencedEnvelope bounds = new ReferencedEnvelope(0, 100, 0, 100, null);

    GridFeatureBuilder builder = new GridFeatureBuilder(TYPE) {
        @Override
        public void setAttributes(GridElement element, Map<String, Object> attributes) {
            PolygonElement polyEl = (PolygonElement) element;
            int g = (int) (255 * polyEl.getCenter().x / bounds.getWidth());
            int b = (int) (255 * polyEl.getCenter().y / bounds.getHeight());
            attributes.put("color", new Color(0, g, b));
        }
    };
    
    // Pass the GridFeatureBuilder object to the createHexagonalGrid method
    // (the -1 value here indicates that we don't need densified polygons)
    final double sideLen = 5.0;
    SimpleFeatureSource grid = Grids.createHexagonalGrid(bounds, sideLen, -1, builder);

    // exampleCustomFeatureType end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:28,代码来源:GridExamples.java

示例9: exampleReferencedEnvelope

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private void exampleReferencedEnvelope() throws Exception {
    // exampleReferencedEnvelope start
    ReferencedEnvelope envelope = new ReferencedEnvelope(0, 10, 0, 20, DefaultGeographicCRS.WGS84);
    
    double xMin = envelope.getMinX();
    double yMin = envelope.getMinY();
    
    double xMax = envelope.getMaxX();
    double yMax = envelope.getMaxY();
    
    double width = envelope.getWidth();
    double height = envelope.getHeight();
    
    double xCenter = envelope.getMedian(0);
    double yCenter = envelope.getMedian(1);
    
    CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
    int dimension = envelope.getDimension();
    
    // Direct access to internal upper and lower positions
    DirectPosition lower = envelope.getLowerCorner();
    DirectPosition upper = envelope.getUpperCorner();
    
    // expand to include 15, 30
    envelope.include(15, 30);
    
    envelope.isEmpty(); // check if storing width and height are 0
    
    envelope.isNull(); // check if "null" (not storing anything)
    envelope.setToNull();
    
    // exampleReferencedEnvelope end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:34,代码来源:APIExamples.java

示例10: calculateBounds

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
/**
 * Calculate bounds.
 *
 * @return the referenced envelope
 */
private ReferencedEnvelope calculateBounds() {
    ReferencedEnvelope bounds = null;

    try {
        bounds = featureList.getBounds();

        if (bounds == null) {
            // It could be that the above call was too costly!
            bounds = featureList.getFeatures().getBounds();
        }

        if (bounds.getCoordinateReferenceSystem() == null) {
            // We need a coordinate reference system set otherwise
            // transformations fail to render
            bounds = ReferencedEnvelope.create(bounds, DefaultGeographicCRS.WGS84);
        }

        if (bounds != null) {
            Unit<?> unit = CRSUtilities
                    .getUnit(bounds.getCoordinateReferenceSystem().getCoordinateSystem());

            double width;
            double height;
            if (unit == NonSI.DEGREE_ANGLE) {
                width = (bounds.getWidth() < BOUNDINGBOX_BUFFER_THRESHOLD_ANGLE)
                        ? BOUNDINGBOX_BUFFER_MIN_ANGLE
                        : (bounds.getWidth() * BOUNDINGBOX_BUFFER_ANGLE);
                height = (bounds.getHeight() < BOUNDINGBOX_BUFFER_THRESHOLD_ANGLE)
                        ? BOUNDINGBOX_BUFFER_MIN_ANGLE
                        : (bounds.getHeight() * BOUNDINGBOX_BUFFER_ANGLE);
            } else {
                width = (bounds.getWidth() < BOUNDINGBOX_BUFFER_THRESHOLD_LINEAR)
                        ? BOUNDINGBOX_BUFFER_MIN_LINEAR
                        : (bounds.getWidth() * BOUNDINGBOX_BUFFER_LINEAR);
                height = (bounds.getHeight() < BOUNDINGBOX_BUFFER_THRESHOLD_LINEAR)
                        ? BOUNDINGBOX_BUFFER_MIN_LINEAR
                        : (bounds.getHeight() * BOUNDINGBOX_BUFFER_LINEAR);
            }

            bounds.expandBy(width, height);
        }
    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }
    return bounds;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:52,代码来源:RenderPanelImpl.java

示例11: createTissotLayer

import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
/**
 * A method to create Tissot Indicatrices based on Whuber's answer to
 * http://gis
 * .stackexchange.com/questions/5068/how-to-create-an-accurate-tissot
 * -indicatrix
 *
 * @param style
 *          - the style to draw the circles with
 * @param gridBounds
 *          - the bounds of the map (may be increased in the method)
 * @return a layer of Tissot Indicatrices (scaled for visibility).
 */
private Layer createTissotLayer(Style style, ReferencedEnvelope gridBounds) {
	FeatureType type = createFeatureType(null,
			gridBounds.getCoordinateReferenceSystem());
	SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(
			(SimpleFeatureType) type);
	double step = 20.0;
	GeometryFactory geomFac = new GeometryFactory();
	double width = gridBounds.getWidth();
	double height = gridBounds.getHeight();
	int id = 0;
	final ListFeatureCollection fc = new ListFeatureCollection(
			(SimpleFeatureType) type);
	double y = gridBounds.getMinY();

	for (int iy = 0; iy < (height / step); iy++) {
		double x = gridBounds.getMinX();
		for (int ix = 0; ix < (width / step); ix++) {
			Point p = geomFac.createPoint(new Coordinate(x, y));

			sfb.set("the_geom", p);
			SimpleFeature f = sfb.buildFeature("tissot2" + id);
			fc.add(f);
			x += step;
		}
		y += step;
	}

	Layer layer = new FeatureLayer(fc, style);
	return layer;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:43,代码来源:Tissot.java


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