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


Java SLD.createSimpleStyle方法代码示例

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


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

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

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

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

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

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

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

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

示例8: getLinesStyle

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * Create style for a lines layer. 
 * 
 * @param schema
 * @return a line style.
 */
public static Style getLinesStyle( SimpleFeatureType schema ) {
    Style style = SLD.createSimpleStyle(schema);

    Rule origRule = style.featureTypeStyles().get(0).rules().get(0);

    Symbolizer symbolizer = origRule.symbolizers().get(0);
    LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer;

    Stroke stroke = lineSymbolizer.getStroke();
    if (stroke == null) {
        stroke = sf.createStroke(ff.literal("#0000FF"), ff.literal("2"), ff.literal("1"));
    } else {
        stroke.setColor(ff.literal("#0000FF"));
        stroke.setWidth(ff.literal("2"));
        stroke.setOpacity(ff.literal("1"));
    }
    lineSymbolizer.setStroke(stroke);
    return style;
}
 
开发者ID:debrief,项目名称:deelite,代码行数:26,代码来源:StyleGenerator.java

示例9: initMap

import org.geotools.styling.SLD; //导入方法依赖的package包/类
private void initMap() {
	try {
		FileDataStore store = FileDataStoreFinder
				.getDataStore(this.getClass().getClassLoader().getResource("maps/countries.shp"));
		SimpleFeatureSource featureSource = store.getFeatureSource();
		map = new MapContent();
		map.setTitle("Quickstart");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		FeatureLayer layer = new FeatureLayer(featureSource, style);
		map.addLayer(layer);
		map.getViewport().setScreenArea(new Rectangle((int) canvas.getWidth(), (int) canvas.getHeight()));
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:gnoubi,项目名称:MarrakAir,代码行数:16,代码来源:MapCanvas.java

示例10: getRenderer

import org.geotools.styling.SLD; //导入方法依赖的package包/类
private static GTRenderer getRenderer( ASpatialDb db, String tableName, int featureLimit, Style style ) {
    MapContent mapContent = new MapContent();

    // read data and convert it to featurecollection
    try {
        long t1 = System.currentTimeMillis();
        System.out.println("STARTED READING: " + tableName);

        String databasePath = db.getDatabasePath();
        File dbFile = new File(databasePath);
        File parentFolder = dbFile.getParentFile();
        if (style == null) {
            File sldFile = new File(parentFolder, tableName + ".sld");
            if (sldFile.exists()) {
                style = SldUtilities.getStyleFromFile(sldFile);
            }
        }

        DefaultFeatureCollection fc = SpatialDbsImportUtils.tableToFeatureFCollection(db, tableName, featureLimit,
                NwwUtilities.GPS_CRS_SRID);
        long t2 = System.currentTimeMillis();
        System.out.println("FINISHED READING: " + tableName + " -> " + ((t2 - t1) / 1000) + "sec");
        if (style == null) {
            style = SLD.createSimpleStyle(fc.getSchema());
        }
        FeatureLayer layer = new FeatureLayer(fc, style);

        long t3 = System.currentTimeMillis();
        System.out.println("FINISHED BUILDING: " + tableName + " -> " + ((t3 - t2) / 1000) + "sec");

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

示例11: 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 {
	File file = null;
	if (args.length >= 1) {
		file = new File(args[0]);
	}
	if (file == null) {
		// display a data store file chooser dialog for shapefiles
		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,代码行数:31,代码来源:Quickstart.java

示例12: displayShapefile

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * This method:
 * <ol type="1">
 * <li>Prompts the user for a shapefile to display
 * <li>Creates a JMapFrame with custom toolbar buttons
 * <li>Displays the shapefile
 * </ol>
 */
// docs start display
private void displayShapefile() throws Exception {
    sourceFile = JFileDataStoreChooser.showOpenFile("shp", null);
    if (sourceFile == null) {
        return;
    }
    FileDataStore store = FileDataStoreFinder.getDataStore(sourceFile);
    featureSource = store.getFeatureSource();

    // Create a map context and add our shapefile to it
    map = new MapContent();
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(featureSource, style);
    map.layers().add(layer);

    // Create a JMapFrame with custom toolbar buttons
    JMapFrame mapFrame = new JMapFrame(map);
    mapFrame.enableToolBar(true);
    mapFrame.enableStatusBar(true);

    JToolBar toolbar = mapFrame.getToolBar();
    toolbar.addSeparator();
    toolbar.add(new JButton(new ValidateGeometryAction()));
    toolbar.add(new JButton(new ExportShapefileAction()));

    // Display the map frame. When it is closed the application will exit
    mapFrame.setSize(800, 600);
    mapFrame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:38,代码来源:CRSLab.java

示例13: Tissot

import org.geotools.styling.SLD; //导入方法依赖的package包/类
public Tissot(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);
		ReferencedEnvelope gridBounds = layer.getBounds();
		Layer gridLayer = createGridLayer(style, gridBounds);
		mapContent.addLayer(gridLayer);
		Style pstyle = SLD.createPointStyle("circle", Color.red, Color.red, 1.0f,
				5.0f);
		Layer tissotLayer = createTissotLayer(pstyle, gridBounds);
		mapContent.addLayer(tissotLayer);
		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,代码行数:30,代码来源:Tissot.java

示例14: MapWithGrid

import org.geotools.styling.SLD; //导入方法依赖的package包/类
public MapWithGrid(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 = SLD.createSimpleStyle(featureSource.getSchema());
		layer = new FeatureLayer(featureSource, style);

		ReferencedEnvelope gridBounds = layer.getBounds();
		gridLayer = createGridLayer(style, gridBounds);
		mapContent.addLayer(layer);
		mapContent.addLayer(gridLayer);
		mapContent.addMapBoundsListener(this);
		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,代码行数:29,代码来源:MapWithGrid.java

示例15: SaveMapAsImage

import org.geotools.styling.SLD; //导入方法依赖的package包/类
public SaveMapAsImage(File file, File raster) 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");
		AbstractGridFormat format = GridFormatFinder.findFormat(raster);
		AbstractGridCoverage2DReader reader = format.getReader(raster);
		GridCoverage2D cov;
		try {
			cov = reader.read(null);
		} catch (IOException giveUp) {
			throw new RuntimeException(giveUp);
		}
		Style rasterStyle = createRGBStyle(cov);
		Layer rasterLayer = new GridReaderLayer(reader, rasterStyle);
		mapContent.addLayer(rasterLayer);

		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		mapContent.getViewport().setCoordinateReferenceSystem(
				DefaultGeographicCRS.WGS84);
		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,代码行数:37,代码来源:SaveMapAsImage.java


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