[Schmitzm-commits] r1049 - branches/2.2.x/src/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 22 14:36:06 CEST 2010


Author: mojays
Date: 2010-09-22 14:36:06 +0200 (Wed, 22 Sep 2010)
New Revision: 1049

Modified:
   branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java
Log:
StylingUtil: correctRasterStyle(.) integrated in correctPropertyNames(.)
StylingUtil: correctPropertyNames(.) integrated in createStyleFromSLD(.), so it is used in SDSS

Modified: branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java	2010-09-22 12:15:12 UTC (rev 1048)
+++ branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java	2010-09-22 12:36:06 UTC (rev 1049)
@@ -898,17 +898,17 @@
 	 */
 	public static Style createStyleFromSLD(Element element) {
 		String xmlDefinition = new XMLOutputter().outputString(element);
-		// TODO: Workaround, because gt2-2.6.x has problems when the
-        //       ColorMapEntries are not in the ascending order according to
-        //       their values
-		// --> maybe we can bring the XML-Elements to an ascending order
-		//     prior to interprete the XML
-		
 		ByteArrayInputStream inputStream = null;
 		try {
 			inputStream = new ByteArrayInputStream(xmlDefinition.getBytes());
 			Style[] style = loadSLD(inputStream);
-			return style == null || style.length == 0 ? null : style[0];
+			if (style == null || style.length == 0)
+			  return null;
+			// etwaige Korrekturen vornehmen, insb.
+			// - Sortierung ColorMapEntrys
+			// - PropertyName null (fuer RasterSymbolizer)
+			// ...
+			return correctPropertyNames(style[0], null);
 		} finally {
 			IOUtils.closeQuietly(inputStream);
 		}
@@ -2519,33 +2519,33 @@
 		return filterSLDVisibleOnly(fc, style, scaleDenominator);
 	}
 	
-	/**
-	 * Note: This method is merged into
-	 * {@link #correctPropertyNames(Style, SimpleFeatureType)} in trunk. Note
-	 * further, that on trunk correctPropertyNames is renamed to correctStyle
-	 * Correct RasterStyle specific pitfalls.<br/>
-	 * 1. setGeometryPropertyName(null); 2. check colormaps are in correct order
-	 */
-	public static Style correctRasterStyle(Style style) {
-		DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor() {
-			@Override
-			public void visit(ColorMap cm) {
-				super.visit(sortColorMap(cm));
-			};
+//	/**
+//	 * Note: This method is merged into
+//	 * {@link #correctPropertyNames(Style, SimpleFeatureType)} in trunk. Note
+//	 * further, that on trunk correctPropertyNames is renamed to correctStyle
+//	 * Correct RasterStyle specific pitfalls.<br/>
+//	 * 1. setGeometryPropertyName(null); 2. check colormaps are in correct order
+//	 */
+//	public static Style correctRasterStyle(Style style) {
+//		DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor() {
+//			@Override
+//			public void visit(ColorMap cm) {
+//				super.visit(sortColorMap(cm));
+//			};
+//
+//			@Override
+//			public void visit(RasterSymbolizer sym) {
+//				sym.setGeometryPropertyName(null);
+//				super.visit(sym);
+//			};
+//		};
+//
+//		dsv.visit(style);
+//
+//		Style copiedCleanStyle = (Style) dsv.getCopy();
+//		return copiedCleanStyle;
+//	}
 
-			@Override
-			public void visit(RasterSymbolizer sym) {
-				sym.setGeometryPropertyName(null);
-				super.visit(sym);
-			};
-		};
-
-		dsv.visit(style);
-
-		Style copiedCleanStyle = (Style) dsv.getCopy();
-		return copiedCleanStyle;
-	}
-
 	/**
 	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster
 	 * Styles need GeometryProperty set to "geom" to work. This method checks
@@ -2558,17 +2558,28 @@
 			final SimpleFeatureType schema) {
 
 		DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor() {
-			public void visit(RasterSymbolizer sym) {
-				if (!sym.getGeometryPropertyName().equals("geom")) {
-					LOGGER
-							.debug("Corrected one RasterSymbolizer with GeometryPropertyName '"
-									+ sym.getGeometryPropertyName()
-									+ "' to 'geom'.");
-					sym.setGeometryPropertyName("geom");
-				}
-				super.visit(sym);
-			};
+//			public void visit(RasterSymbolizer sym) {
+//				if (!sym.getGeometryPropertyName().equals("geom")) {
+//					LOGGER
+//							.debug("Corrected one RasterSymbolizer with GeometryPropertyName '"
+//									+ sym.getGeometryPropertyName()
+//									+ "' to 'geom'.");
+//					sym.setGeometryPropertyName("geom");
+//				}
+//				super.visit(sym);
+//			};
 
+            @Override
+            public void visit(ColorMap cm) {
+                super.visit(sortColorMap(cm));
+            };
+  
+            @Override
+            public void visit(RasterSymbolizer sym) {
+                sym.setGeometryPropertyName(null);
+                super.visit(sym);
+            };
+
 			@Override
 			public void visit(LineSymbolizer sym) {
 				sym.setGeometryPropertyName(FeatureUtil



More information about the Schmitzm-commits mailing list