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


Java Layer类代码示例

本文整理汇总了Java中org.geotools.map.Layer的典型用法代码示例。如果您正苦于以下问题:Java Layer类的具体用法?Java Layer怎么用?Java Layer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createSearchEnv

import org.geotools.map.Layer; //导入依赖的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

示例2: renderVectorMap

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * Render vector map.
 *
 * @param features the results
 * @param imageSize the image size
 * @param style the style
 * @param dpi the dpi
 */
private void renderVectorMap(FeatureSource<SimpleFeatureType, SimpleFeature> features,
        Rectangle imageSize, Style style, int dpi) {
    List<Layer> layerList = new ArrayList<Layer>();
    if (style != null) {
        FeatureLayer featureLayer = new FeatureLayer(features, style);
        layerList.add(featureLayer);
    }

    boolean hasGeometry = false;
    ReferencedEnvelope bounds = null;

    if (features != null) {
        bounds = calculateBounds();

        wmsEnvVarValues.setMapBounds(bounds);

        EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVarValues);

        if (features.getSchema() != null) {
            hasGeometry = (features.getSchema().getGeometryDescriptor() != null);
        }
    }

    internal_renderMap(layerList, bounds, imageSize, hasGeometry, dpi);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:34,代码来源:RenderPanelImpl.java

示例3: getHelper

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * gets the helper for the given layer.
 * @param layer the layer
 * @return the helper
 */
public static InfoToolHelper getHelper(Layer layer) {
    loadProviders();

    for (InfoToolHelper helper : cachedInstances) {
        try {
            if (helper.isSupportedLayer(layer)) {
                return helper.getClass().newInstance();
            }

        } catch (Exception ex) {
            throw new InfoToolHelperException(ex);
        }
    }

    return null;
}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:22,代码来源:InfoToolHelperLookup.java

示例4: createFeatureLayerFromMapObject

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * Creates a feature layer based on a map object.
 */
public static Layer createFeatureLayerFromMapObject( InternalMapObject mapObject )
{
    Style style = mapObject.getStyle();
    
    SimpleFeatureType featureType = mapObject.getFeatureType();
    SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    
    featureBuilder.add( mapObject.getGeometry() );
    SimpleFeature feature = featureBuilder.buildFeature( null );

    featureCollection.add( feature );

    return new FeatureLayer( featureCollection, style );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:19,代码来源:MapUtils.java

示例5: layerAdded

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * Called when a new map layer has been added. Sets the layer as selected
 * (for queries) and, if the layer table is being used, adds the new layer
 * to the table.
 */
@Override
public void layerAdded(final MapLayerListEvent event) {
	final Layer layer = event.getElement();
	if (layerTable != null) {
		layerTable.onAddLayer(layer);
	}
	layer.setSelected(true);
	redrawBaseImage = true;

	final boolean atFullExtent = equalsFullExtent(getDisplayArea());
	final boolean firstLayer = content.layers().size() == 1;
	if (firstLayer || atFullExtent) {
		reset();
		if (firstLayer) {
			setCrs(layer.getBounds().getCoordinateReferenceSystem());
			return;
		}
	}
	if (!isDisposed())
		redraw();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:SwtMapPane.java

示例6: layerRemoved

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * Called when a map layer has been removed
 */
@Override
public void layerRemoved(final MapLayerListEvent event) {
	final Layer layer = event.getElement();
	if (layerTable != null) {
		layerTable.onRemoveLayer(layer);
	}
	redrawBaseImage = true;

	if (content.layers().size() == 0) {
		clearFields();
	} else {
		setFullExtent();
	}
	if (!isDisposed())
		redraw();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:20,代码来源:SwtMapPane.java

示例7: run

import org.geotools.map.Layer; //导入依赖的package包/类
@Override
public void run() {
	final Display display = WorkbenchHelper.getDisplay();
	final Shell shell = new Shell(display);
	final File openFile = JFileImageChooser.showOpenFile(shell);

	if (openFile != null && openFile.exists()) {
		final AbstractGridFormat format = GridFormatFinder.findFormat(openFile);
		final AbstractGridCoverage2DReader tiffReader = format.getReader(openFile);
		final StyleFactoryImpl sf = new StyleFactoryImpl();
		final RasterSymbolizer symbolizer = sf.getDefaultRasterSymbolizer();
		final Style defaultStyle = SLD.wrapSymbolizers(symbolizer);

		final MapContent mapContent = mapPane.getMapContent();
		final Layer layer = new GridReaderLayer(tiffReader, defaultStyle);
		layer.setTitle(openFile.getName());
		mapContent.addLayer(layer);
		mapPane.redraw();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:OpenGeotiffAction.java

示例8: saveAsCSV

import org.geotools.map.Layer; //导入依赖的package包/类
@Override
public void saveAsCSV() {

	final Layer layer = mapLayerTable.getMapLayerTableViewer().getSelectedMapLayer();
	if (layer == null)
		return;
	final HashSet<String> atts = new HashSet<String>();

	final String layerName = layer.getFeatureSource().getName().toString();
	for (final String at : attributes.keySet()) {
		final String[] dec = at.split(";");

		if (layerName.equals(dec[0])) {
			atts.add(dec[1]);

		}
	}
	final List<IShape> geoms = osmfile.getLayers().get(layerName);
	final List<String> attsOrd = new ArrayList<String>(atts);
	Collections.sort(attsOrd);
	saveAsCSV(attsOrd, geoms, layerName);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:OSMFileViewer.java

示例9: createCoastlineLayer

import org.geotools.map.Layer; //导入依赖的package包/类
private static Layer createCoastlineLayer() {
    try {
        // File file = new File(
        // "/home/dxm/Downloads/shapefile-australia-coastline-polygon/cstauscd_r.shp");
        File file = new File("src/main/resources/shapes/countries.shp");
        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();

        // Style style = SLD.createSimpleStyle(featureSource.getSchema());
        Style style = SLD.createPolygonStyle(Color.black, new Color(242, 237, 206), 1);
        Layer layer = new FeatureLayer(featureSource, style);
        return layer;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:17,代码来源:Map.java

示例10: createExtraFeatures

import org.geotools.map.Layer; //导入依赖的package包/类
private static Layer createExtraFeatures() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("Location");
    b.setCRS(DefaultGeographicCRS.WGS84);
    // picture location
    b.add("geom", Point.class);
    final SimpleFeatureType TYPE = b.buildFeatureType();

    GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
    Point point = gf.createPoint(new Coordinate(CANBERRA_LONG, CANBERRA_LAT));

    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(TYPE);
    builder.add(point);
    SimpleFeature feature = builder.buildFeature("Canberra");
    DefaultFeatureCollection features = new DefaultFeatureCollection(null, null);
    features.add(feature);

    Style style = SLD.createPointStyle("Star", Color.BLUE, Color.BLUE, 0.3f, 10);

    return new FeatureLayer(features, style);
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:22,代码来源:Map.java

示例11: main

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * This method demonstrates using a memory-based cache to speed up the display (e.g. when
 * zooming in and out).
 * 
 * There is just one line extra compared to the main method, where we create an instance of
 * CachingFeatureStore.
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    CachingFeatureSource cache = new CachingFeatureSource(featureSource);

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Using cached features");
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(cache, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:QuickstartCache.java

示例12: main

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
 * contents on the screen in a map frame
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Quickstart");
    
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:26,代码来源:Quickstart.java

示例13: displayShapefile

import org.geotools.map.Layer; //导入依赖的package包/类
/**
 * Prompts the user for a shapefile (unless a filename is provided
 * on the command line; then creates a simple Style and displays
 * the shapefile on screen
 */
private void displayShapefile() throws Exception {
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    FeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("StyleLab");

    // Create a basic Style to render the features
    Style style = createStyle(file, featureSource);

    // Add the features and the associated Style object to
    // the MapContent as a new Layer
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:StyleLab.java

示例14: TwoAttributes

import org.geotools.map.Layer; //导入依赖的package包/类
public TwoAttributes(String[] args) throws IOException {
	File file = new File(args[0]);
	FileDataStore store = FileDataStoreFinder.getDataStore(file);
	SimpleFeatureSource featureSource = store.getFeatureSource();
	SimpleFeatureType schema = featureSource.getSchema();
	System.out.println(schema);
	// Create a map content and add our shapefile to it
	MapContent mapContent = new MapContent();
	mapContent.setTitle("GeoTools Mapping");
	Style style = SLD.createSimpleStyle(featureSource.getSchema());
	Layer layer = new FeatureLayer(featureSource, style);
	mapContent.addLayer(layer);
	frame = new JMapFrame(mapContent);
	frame.enableStatusBar(true);
	frame.enableToolBar(true);
	JToolBar toolBar = frame.getToolBar();
	toolBar.addSeparator();
	SaveAction save = new SaveAction("Save");
	toolBar.add(save);
	frame.initComponents();
	frame.setSize(1000, 500);
	frame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:24,代码来源:TwoAttributes.java

示例15: SaveMapAsImage

import org.geotools.map.Layer; //导入依赖的package包/类
public SaveMapAsImage(File file) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:SaveMapAsImage.java


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