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


Java SLD.wrapSymbolizers方法代码示例

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


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

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

示例4: createRGBStyle

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * This method examines the names of the sample dimensions in the provided coverage looking for "red...", "green..."
 * and "blue..." (case insensitive match). If these names are not found it uses bands 1, 2, and 3 for the red, green
 * and blue channels. It then sets up a raster symbolizer and returns this wrapped in a Style.
 * 
 * @param reader
 *
 * @return a new Style object containing a raster symbolizer set up for RGB image
 */
public static Style createRGBStyle(final GridCoverage2DReader reader) {
	GridCoverage2D cov = null;
	try {
		cov = reader.read(null);
	} catch (final IOException giveUp) {
		throw new RuntimeException(giveUp);
	}
	// We need at least three bands to create an RGB style
	final int numBands = cov.getNumSampleDimensions();
	if (numBands < 3) { return null; }
	// Get the names of the bands
	final String[] sampleDimensionNames = new String[numBands];
	for (int i = 0; i < numBands; i++) {
		final GridSampleDimension dim = cov.getSampleDimension(i);
		sampleDimensionNames[i] = dim.getDescription().toString();
	}
	final int RED = 0, GREEN = 1, BLUE = 2;
	final int[] channelNum = { -1, -1, -1 };
	// We examine the band names looking for "red...", "green...",
	// "blue...".
	// Note that the channel numbers we record are indexed from 1, not 0.
	for (int i = 0; i < numBands; i++) {
		final String name = sampleDimensionNames[i].toLowerCase();
		if (name != null) {
			if (name.matches("red.*")) {
				channelNum[RED] = i + 1;
			} else if (name.matches("green.*")) {
				channelNum[GREEN] = i + 1;
			} else if (name.matches("blue.*")) {
				channelNum[BLUE] = i + 1;
			}
		}
	}
	// If we didn't find named bands "red...", "green...", "blue..."
	// we fall back to using the first three bands in order
	if (channelNum[RED] < 0 || channelNum[GREEN] < 0 || channelNum[BLUE] < 0) {
		channelNum[RED] = 1;
		channelNum[GREEN] = 2;
		channelNum[BLUE] = 3;
	}
	// Now we create a RasterSymbolizer using the selected channels
	final SelectedChannelType[] sct = new SelectedChannelType[cov.getNumSampleDimensions()];
	final ContrastEnhancement ce =
			styleFactory.contrastEnhancement(filterFactory.literal(1.0), ContrastMethod.NORMALIZE);
	for (int i = 0; i < 3; i++) {
		sct[i] = styleFactory.createSelectedChannelType(String.valueOf(channelNum[i]), ce);
	}
	final RasterSymbolizer sym = styleFactory.getDefaultRasterSymbolizer();
	final ChannelSelection sel = styleFactory.channelSelection(sct[RED], sct[GREEN], sct[BLUE]);
	sym.setChannelSelection(sel);

	return SLD.wrapSymbolizers(sym);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:63,代码来源:Utils.java

示例5: viewCoverage

import org.geotools.styling.SLD; //导入方法依赖的package包/类
@Execute
public void viewCoverage() throws Exception {
    StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
    // RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
    // Style rasterStyle = SLD.wrapSymbolizers(sym);

    StyleBuilder sB = new StyleBuilder(sf);
    RasterSymbolizer rasterSym = sf.createRasterSymbolizer();

    ColorMap colorMap = sf.createColorMap();

    RenderedImage renderedImage = raster.getRenderedImage();
    double max = Double.NEGATIVE_INFINITY;
    double min = Double.POSITIVE_INFINITY;
    RectIter iter = RectIterFactory.create(renderedImage, null);
    do {
        do {
            double value = iter.getSampleDouble();
            if (value > max) {
                max = value;
            }
            if (value < min) {
                min = value;
            }
        } while( !iter.nextPixelDone() );
        iter.startPixels();
    } while( !iter.nextLineDone() );

    // red to blue
    Color fromColor = Color.blue;
    Color toColor = Color.red;
    Expression fromColorExpr = sB.colorExpression(new java.awt.Color(fromColor.getRed(), fromColor.getGreen(), fromColor
            .getBlue(), 255));
    Expression toColorExpr = sB.colorExpression(new java.awt.Color(toColor.getRed(), toColor.getGreen(), toColor.getBlue(),
            255));
    Expression fromExpr = sB.literalExpression(min);
    Expression toExpr = sB.literalExpression(max);

    ColorMapEntry entry = sf.createColorMapEntry();
    entry.setQuantity(fromExpr);
    entry.setColor(fromColorExpr);
    colorMap.addColorMapEntry(entry);

    entry = sf.createColorMapEntry();
    entry.setQuantity(toExpr);
    entry.setColor(toColorExpr);
    colorMap.addColorMapEntry(entry);

    rasterSym.setColorMap(colorMap);

    Style rasterStyle = SLD.wrapSymbolizers(rasterSym);

    // Set up a MapContext with the two layers
    final MapContext map = new DefaultMapContext();
    map.setTitle("Coverage Viewer");
    map.addLayer(raster, rasterStyle);

    // Create a JMapFrame with a menu to choose the display style for the
    final JMapFrame frame = new JMapFrame(map);
    frame.setSize(800, 600);
    frame.enableStatusBar(true);
    frame.enableTool(JMapFrame.Tool.ZOOM, JMapFrame.Tool.PAN, JMapFrame.Tool.RESET);
    frame.enableToolBar(true);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
        public void windowClosing( WindowEvent e ) {
            frame.setVisible(false);
        }
    });

    while( frame.isVisible() ) {
        Thread.sleep(300);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:75,代码来源:OmsCoverageViewer.java

示例6: addImageMosaic

import org.geotools.styling.SLD; //导入方法依赖的package包/类
private void addImageMosaic( MapContent map ) throws Exception {
    if (inImageMosaics != null) {
        RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
        Style style = SLD.wrapSymbolizers(sym);

        final ParameterValue<Color> inTransp = AbstractGridFormat.INPUT_TRANSPARENT_COLOR.createValue();
        inTransp.setValue(Color.white);

        final ParameterValue<Color> outTransp = ImageMosaicFormat.OUTPUT_TRANSPARENT_COLOR.createValue();
        outTransp.setValue(Color.white);
        final ParameterValue<Color> backColor = ImageMosaicFormat.BACKGROUND_COLOR.createValue();
        backColor.setValue(Color.RED);
        final ParameterValue<Boolean> fading = ImageMosaicFormat.FADING.createValue();
        fading.setValue(true);

        final ParameterValue<Interpolation> interpol = ImageMosaicFormat.INTERPOLATION.createValue();
        interpol.setValue(new javax.media.jai.InterpolationBilinear());

        final ParameterValue<Boolean> resol = ImageMosaicFormat.ACCURATE_RESOLUTION.createValue();
        resol.setValue(true);

        
        final ParameterValue<Boolean> multiThread= ImageMosaicFormat.ALLOW_MULTITHREADING.createValue();
        multiThread.setValue(true);

        final ParameterValue<Boolean> usejai = ImageMosaicFormat.USE_JAI_IMAGEREAD.createValue();
        usejai.setValue(false);

        final ParameterValue<double[]> bkg = ImageMosaicFormat.BACKGROUND_VALUES.createValue();
        bkg.setValue(new double[]{0});

        GeneralParameterValue[] gp = new GeneralParameterValue[]{inTransp, multiThread};

        for( String imageMosaicPath : inImageMosaics ) {
            ImageMosaicReader imr = new ImageMosaicReader(new File(imageMosaicPath));
            GridReaderLayer layer = new GridReaderLayer(imr, style, gp);
            map.addLayer(layer);
        }
    }

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:42,代码来源:OmsMapsViewer.java

示例7: addCoverages

import org.geotools.styling.SLD; //导入方法依赖的package包/类
private void addCoverages( final MapContent map ) throws Exception {
    if (inRasters == null) {
        return;
    }
    RasterSymbolizer rasterSym = sf.createRasterSymbolizer();
    ColorMap colorMap = sf.createColorMap();

    for( String rasterPath : inRasters ) {
        GridCoverage2D readRaster = OmsRasterReader.readRaster(rasterPath);
        RenderedImage renderedImage = readRaster.getRenderedImage();
        double max = Double.NEGATIVE_INFINITY;
        double min = Double.POSITIVE_INFINITY;
        RectIter iter = RectIterFactory.create(renderedImage, null);
        do {
            do {
                double value = iter.getSampleDouble();
                if (value > max) {
                    max = value;
                }
                if (value < min) {
                    min = value;
                }
            } while( !iter.nextPixelDone() );
            iter.startPixels();
        } while( !iter.nextLineDone() );

        // red to blue
        Color fromColor = Color.blue;
        Color midColor = Color.green;
        Color toColor = Color.red;
        Expression fromColorExpr = sb
                .colorExpression(new java.awt.Color(fromColor.getRed(), fromColor.getGreen(), fromColor.getBlue(), 255));
        Expression midColorExpr = sb
                .colorExpression(new java.awt.Color(midColor.getRed(), midColor.getGreen(), midColor.getBlue(), 255));
        Expression toColorExpr = sb
                .colorExpression(new java.awt.Color(toColor.getRed(), toColor.getGreen(), toColor.getBlue(), 255));
        Expression fromExpr = sb.literalExpression(min);
        Expression midExpr = sb.literalExpression(min + (max - min) / 2);
        Expression toExpr = sb.literalExpression(max);

        ColorMapEntry entry = sf.createColorMapEntry();
        entry.setQuantity(fromExpr);
        entry.setColor(fromColorExpr);
        colorMap.addColorMapEntry(entry);

        entry = sf.createColorMapEntry();
        entry.setQuantity(midExpr);
        entry.setColor(midColorExpr);
        colorMap.addColorMapEntry(entry);

        entry = sf.createColorMapEntry();
        entry.setQuantity(toExpr);
        entry.setColor(toColorExpr);
        colorMap.addColorMapEntry(entry);

        rasterSym.setColorMap(colorMap);

        Style rasterStyle = SLD.wrapSymbolizers(rasterSym);

        GridCoverageLayer layer = new GridCoverageLayer(readRaster, rasterStyle);

        map.addLayer(layer);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:65,代码来源:OmsMapsViewer.java

示例8: createRGBStyle

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * This method examines the names of the sample dimensions in the provided coverage looking for
 * "red...", "green..." and "blue..." (case insensitive match). If these names are not found
 * it uses bands 1, 2, and 3 for the red, green and blue channels. It then sets up a raster
 * symbolizer and returns this wrapped in a Style.
 *
 * @return a new Style object containing a raster symbolizer set up for RGB image
 */
private Style createRGBStyle() {
    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) {
        return null;
    }
    // Get the names of the bands
    String[] sampleDimensionNames = new String[numBands];
    for (int i = 0; i < numBands; i++) {
        GridSampleDimension dim = cov.getSampleDimension(i);
        sampleDimensionNames[i] = dim.getDescription().toString();
    }
    final int RED = 0, GREEN = 1, BLUE = 2;
    int[] channelNum = { -1, -1, -1 };
    // We examine the band names looking for "red...", "green...", "blue...".
    // Note that the channel numbers we record are indexed from 1, not 0.
    for (int i = 0; i < numBands; i++) {
        String name = sampleDimensionNames[i].toLowerCase();
        if (name != null) {
            if (name.matches("red.*")) {
                channelNum[RED] = i + 1;
            } else if (name.matches("green.*")) {
                channelNum[GREEN] = i + 1;
            } else if (name.matches("blue.*")) {
                channelNum[BLUE] = i + 1;
            }
        }
    }
    // If we didn't find named bands "red...", "green...", "blue..."
    // we fall back to using the first three bands in order
    if (channelNum[RED] < 0 || channelNum[GREEN] < 0 || channelNum[BLUE] < 0) {
        channelNum[RED] = 1;
        channelNum[GREEN] = 2;
        channelNum[BLUE] = 3;
    }
    // Now we create a RasterSymbolizer using the selected channels
    SelectedChannelType[] sct = new SelectedChannelType[cov.getNumSampleDimensions()];
    ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
    for (int i = 0; i < 3; i++) {
        sct[i] = sf.createSelectedChannelType(String.valueOf(channelNum[i]), ce);
    }
    RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
    ChannelSelection sel = sf.channelSelection(sct[RED], sct[GREEN], sct[BLUE]);
    sym.setChannelSelection(sel);

    return SLD.wrapSymbolizers(sym);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:62,代码来源:ImageLab.java

示例9: createRGBStyle

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * This method examines the names of the sample dimensions in the provided
 * coverage looking for "red...", "green..." and "blue..." (case insensitive
 * match). If these names are not found it uses bands 1, 2, and 3 for the red,
 * green and blue channels. It then sets up a raster symbolizer and returns
 * this wrapped in a Style.
 *
 * @return a new Style object containing a raster symbolizer set up for RGB
 *         image
 */
private Style createRGBStyle(GridCoverage2D cov) {
	// We need at least three bands to create an RGB style
	int numBands = cov.getNumSampleDimensions();
	if (numBands < 3) {
		return null;
	}
	// Get the names of the bands
	String[] sampleDimensionNames = new String[numBands];
	for (int i = 0; i < numBands; i++) {
		GridSampleDimension dim = cov.getSampleDimension(i);
		sampleDimensionNames[i] = dim.getDescription().toString();
	}
	final int RED = 0, GREEN = 1, BLUE = 2;
	int[] channelNum = { -1, -1, -1 };
	// We examine the band names looking for "red...", "green...", "blue...".
	// Note that the channel numbers we record are indexed from 1, not 0.
	for (int i = 0; i < numBands; i++) {
		String name = sampleDimensionNames[i].toLowerCase();
		if (name != null) {
			if (name.matches("red.*")) {
				channelNum[RED] = i + 1;
			} else if (name.matches("green.*")) {
				channelNum[GREEN] = i + 1;
			} else if (name.matches("blue.*")) {
				channelNum[BLUE] = i + 1;
			}
		}
	}
	// If we didn't find named bands "red...", "green...", "blue..."
	// we fall back to using the first three bands in order
	if (channelNum[RED] < 0 || channelNum[GREEN] < 0 || channelNum[BLUE] < 0) {
		channelNum[RED] = 1;
		channelNum[GREEN] = 2;
		channelNum[BLUE] = 3;
	}

	// Now we create a RasterSymbolizer using the selected channels
	SelectedChannelType[] sct = new SelectedChannelType[cov
	                                                    .getNumSampleDimensions()];
	ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0),
			ContrastMethod.NORMALIZE);
	for (int i = 0; i < 3; i++) {
		sct[i] = sf.createSelectedChannelType(String.valueOf(channelNum[i]), ce);
	}
	RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
	ChannelSelection sel = sf.channelSelection(sct[RED], sct[GREEN], sct[BLUE]);
	sym.setChannelSelection(sel);

	return SLD.wrapSymbolizers(sym);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:61,代码来源:SaveMapAsImage.java

示例10: createGreyscaleStyle

import org.geotools.styling.SLD; //导入方法依赖的package包/类
/**
 * Create a Style to display the specified band of the GeoTIFF image
 * as a greyscale layer.
 * <p>
 * This method is a helper for createGreyScale() and is also called directly
 * by the displayLayers() method when the application first starts.
 *
 * @param band the image band to use for the greyscale display
 *
 * @return a new Style instance to render the image in greyscale
 */
private Style createGreyscaleStyle(int band) {
    ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE);
    SelectedChannelType sct = sf.createSelectedChannelType(String.valueOf(band), ce);

    RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();
    ChannelSelection sel = sf.channelSelection(sct);
    sym.setChannelSelection(sel);

    return SLD.wrapSymbolizers(sym);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:22,代码来源:ImageLab.java


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