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


Java SLD类代码示例

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


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

示例1: createRGBStyle

import org.geotools.styling.SLD; //导入依赖的package包/类
/**
 * Creates the rgb style.
 *
 * @param reader the reader
 * @param raster the raster
 * @return the style
 */
private Style createRGBStyle(AbstractGridCoverage2DReader reader, WritableRaster raster) {
    RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();

    GridCoverage2D cov = null;
    try {
        cov = reader.read(null);
    } catch (IOException giveUp) {
        throw new RuntimeException(giveUp);
    }
    // We need at least three bands to create an RGB style
    int numBands = cov.getNumSampleDimensions();
    if (numBands < 3) {
        createRGBImageSymbol(sym, cov, raster);
    } else {
        createRGBChannelSymbol(sym, cov, numBands);
    }
    return SLD.wrapSymbolizers(sym);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:RasterReader.java

示例2: getStyle

import org.geotools.styling.SLD; //导入依赖的package包/类
public Style getStyle()
{
    Style style = null;

    if ( geometry instanceof Point )
    {
        style = SLD.createPointStyle( CIRCLE, strokeColor, fillColor,
            fillOpacity, radius );
    }
    else if ( geometry instanceof Polygon || geometry instanceof MultiPolygon )
    {
        if ( MapLayerType.BOUNDARY.equals( mapLayerType ) )
        {
            style = SLD.createLineStyle( strokeColor, LINE_STROKE_WIDTH );
        }
        else
        {
            style = SLD.createPolygonStyle( strokeColor, fillColor, fillOpacity );
        }
    }
    else
    {
        style = SLD.createSimpleStyle( getFeatureType() );
    }

    return style;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:28,代码来源:InternalMapObject.java

示例3: set

import org.geotools.styling.SLD; //导入依赖的package包/类
/**
 * Called to set up this "viewer" based on the provided symbolizer
 * @param sym
 */
public void set(final RasterSymbolizer sym2) {
	listen(false); // don't sync when setting up
	try {
		final RasterSymbolizer sym = sym2;

		if ( sym == null ) {
			this.opacity = 1.0;
		} else {
			this.opacity = SLD.rasterOpacity(sym);
		}
		final String text = MessageFormat.format("{0,number,#0%}", this.opacity); //$NON-NLS-1$
		this.percent.setText(text);
		this.percent.select(this.percent.indexOf(text));

	} finally {
		listen(true); // listen to user now
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:OpacityViewer.java

示例4: setMark

import org.geotools.styling.SLD; //导入依赖的package包/类
private void setMark(final Mark mark, final Mode mode) {
	listen(false);
	try {
		this.enabled = mode == Mode.POINT && mark != null;
		this.type = SLD.wellKnownName(mark);

		// Stroke is used in line, point and polygon
		this.on.setEnabled(mode == Mode.POINT || mode == Mode.ALL);

		if ( this.type != null ) {
			this.name.setText(this.type);
			this.name.select(this.name.indexOf(this.type));
		}

		this.on.setSelection(this.enabled);
		this.size.setEnabled(this.enabled);
		this.name.setEnabled(this.enabled);
	} finally {
		listen(true); // listen to user now
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:22,代码来源:GraphicViewer.java

示例5: run

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

示例6: createCoastlineLayer

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

示例7: createExtraFeatures

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

示例8: substituteExternalGraphics

import org.geotools.styling.SLD; //导入依赖的package包/类
/**
 * Change the external graphic in a rule.
 * 
 * @param rule the rule of which the external graphic has to be changed.
 * @param path the path of the image.
 */
public static void substituteExternalGraphics( Rule rule, URL externalGraphicsUrl ) {
    String urlString = externalGraphicsUrl.toString();
    String format = "";
    if (urlString.toLowerCase().endsWith(".png")) {
        format = "image/png";
    } else if (urlString.toLowerCase().endsWith(".jpg")) {
        format = "image/jpg";
    } else if (urlString.toLowerCase().endsWith(".svg")) {
        format = "image/svg+xml";
    } else {
        urlString = "";
        try {
            externalGraphicsUrl = new URL("file:");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    PointSymbolizer pointSymbolizer = Utilities.pointSymbolizerFromRule(rule);
    Graphic graphic = SLD.graphic(pointSymbolizer);
    graphic.graphicalSymbols().clear();
    ExternalGraphic exGraphic = sf.createExternalGraphic(externalGraphicsUrl, format);

    graphic.graphicalSymbols().add(exGraphic);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:32,代码来源:Utilities.java

示例9: getRenderer

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

示例10: getRenderer

import org.geotools.styling.SLD; //导入依赖的package包/类
private static GTRenderer getRenderer( File rasterFile ) {

        AbstractGridFormat format = GridFormatFinder.findFormat(rasterFile);
        AbstractGridCoverage2DReader coverageReader = format.getReader(rasterFile);

        MapContent mapContent = new MapContent();
        try {

            Style rasterStyle = SldUtilities.getStyleFromFile(rasterFile);
            if (rasterStyle == null) {
                RasterSymbolizer sym = SldUtilities.sf.getDefaultRasterSymbolizer();
                rasterStyle = SLD.wrapSymbolizers(sym);
            }

            GridReaderLayer layer = new GridReaderLayer(coverageReader, rasterStyle);
            mapContent.addLayer(layer);
            mapContent.getViewport().setCoordinateReferenceSystem(CrsUtilities.WGS84);
        } catch (Exception e) {
            e.printStackTrace();
        }
        GTRenderer renderer = new StreamingRenderer();
        renderer.setMapContent(mapContent);
        return renderer;
    }
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:25,代码来源:GridCoverageNwwLayer.java

示例11: main

import org.geotools.styling.SLD; //导入依赖的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.styling.SLD; //导入依赖的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: TwoAttributes

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

示例14: SaveMapAsImage

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

示例15: withTestModels

import org.geotools.styling.SLD; //导入依赖的package包/类
private static void withTestModels(String folder) throws Exception {
    	URL schemaURL = new File("/Users/markus/Documents/Projects/EMFFrag/02_workspace/citygml.git/de.hub.citygml.models/schemas/"+folder+"/TestFeature.xsd").toURL();    	
    	URL modelURL = new File("/Users/markus/Documents/Projects/EMFFrag/02_workspace/citygml.git/de.hub.citygml.models/schemas/"+folder+"/TestFeature.xml").toURL();

        GML gml = new GML(Version.WFS1_1);
        gml.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
        NameImpl typeName = new NameImpl("http://www.geotools.org/test", "TestFeature");
//        
		SimpleFeatureType featureType = gml.decodeSimpleFeatureType(schemaURL, typeName);        
        System.out.println("#1: " + (featureType == null ? "NULL" : featureType.toString()));
    
        SimpleFeatureCollection featureCollection = gml.decodeFeatureCollection(modelURL.openStream());        
        System.out.println("#2: " + featureCollection.size());
        
		MapContent map = new MapContent();
		map.setTitle("Quickstart");

		Style style = SLD.createSimpleStyle(featureCollection.getSchema());
		Layer layer = new FeatureLayer(featureCollection, style);
		map.addLayer(layer);

		// Now display the map
		JMapFrame.showMap(map);
    }
 
开发者ID:markus1978,项目名称:citygml4emf,代码行数:25,代码来源:Quickstart.java


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