Search in sources :

Example 21 with UserLayerImpl

use of org.geotools.styling.UserLayerImpl in project sldeditor by robward-scisys.

the class CreateInternalDataSource method internal_determineGeometryType.

/**
 * Internal determine geometry type.
 *
 * @param sld the sld
 * @return the geometry type enum
 */
protected GeometryTypeEnum internal_determineGeometryType(StyledLayerDescriptor sld) {
    GeometryTypeEnum geometryType = GeometryTypeEnum.UNKNOWN;
    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();
        int pointCount = 0;
        int lineCount = 0;
        int polygonCount = 0;
        int rasterCount = 0;
        for (StyledLayer styledLayer : styledLayerList) {
            List<Style> styleList = null;
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                styleList = namedLayerImpl.styles();
            } else if (styledLayer instanceof UserLayerImpl) {
                UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                styleList = userLayerImpl.userStyles();
            }
            if (styleList != null) {
                for (Style style : styleList) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer instanceof PointSymbolizer) {
                                    pointCount++;
                                } else if (symbolizer instanceof LineSymbolizer) {
                                    lineCount++;
                                } else if (symbolizer instanceof PolygonSymbolizer) {
                                    polygonCount++;
                                } else if (symbolizer instanceof RasterSymbolizer) {
                                    rasterCount++;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (polygonCount > 0) {
            geometryType = GeometryTypeEnum.POLYGON;
        } else if (lineCount > 0) {
            geometryType = GeometryTypeEnum.LINE;
        } else if (pointCount > 0) {
            geometryType = GeometryTypeEnum.POINT;
        } else if (rasterCount > 0) {
            geometryType = GeometryTypeEnum.RASTER;
        }
    }
    return geometryType;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Point(com.vividsolutions.jts.geom.Point) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) UserLayerImpl(org.geotools.styling.UserLayerImpl) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Aggregations

UserLayerImpl (org.geotools.styling.UserLayerImpl)21 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)18 Style (org.geotools.styling.Style)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 StyledLayer (org.geotools.styling.StyledLayer)16 Rule (org.geotools.styling.Rule)10 Symbolizer (org.geotools.styling.Symbolizer)5 LineSymbolizer (org.geotools.styling.LineSymbolizer)3 PointSymbolizer (org.geotools.styling.PointSymbolizer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)3 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)3 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 UserLayer (org.geotools.styling.UserLayer)2 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)1 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)1