[Schmitzm-commits] r1258 - in trunk: src/schmitzm/geotools/styling src_junit/schmitzm/geotools/styling
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Nov 10 13:31:14 CET 2010
Author: alfonx
Date: 2010-11-10 13:31:14 +0100 (Wed, 10 Nov 2010)
New Revision: 1258
Modified:
trunk/src/schmitzm/geotools/styling/StylingUtil.java
trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
Log:
Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java 2010-11-10 12:07:48 UTC (rev 1257)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java 2010-11-10 12:31:14 UTC (rev 1258)
@@ -862,32 +862,37 @@
* FeatureUtil.getGeometryForm
*/
public static Style createDefaultStyle(Object object) {
- Style style = STYLE_BUILDER.createStyle(); // SK.. nicer default than
// null !
+ if (object instanceof GeometryForm) {
+ return FeatureUtil.createDefaultStyle((GeometryForm) object);
+ }
+
if (object instanceof StyledFeaturesInterface)
- style = FeatureUtil
+ return FeatureUtil
.createDefaultStyle(((StyledFeaturesInterface<?>) object)
.getSchema().getGeometryDescriptor());
if (object instanceof GridCoverage2D
|| object instanceof AbstractGridCoverage2DReader
|| object instanceof StyledRasterInterface)
- style = GridUtil.createDefaultStyle();
+ return GridUtil.createDefaultStyle();
if (object instanceof FeatureCollection)
- style = FeatureUtil
+ return FeatureUtil
.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
if (object instanceof FeatureSource)
- style = FeatureUtil.createDefaultStyle(((FeatureSource) object)
+ return FeatureUtil.createDefaultStyle(((FeatureSource) object)
.getSchema().getGeometryDescriptor());
if (object instanceof GeometryAttributeType)
- style = FeatureUtil
+ return FeatureUtil
.createDefaultStyle((GeometryAttributeType) object);
- return style;
+ LOGGER.warn("createDefaultStyle could not handle " + object
+ + " and returned an empty (invalid) Style");
+ return STYLE_BUILDER.createStyle();
}
/**
@@ -3134,13 +3139,14 @@
return validates(new FileInputStream(tempFile));
}
- public static boolean isStyleDifferent(FeatureTypeStyle fts1,FeatureTypeStyle fts2) {
+ public static boolean isStyleDifferent(FeatureTypeStyle fts1,
+ FeatureTypeStyle fts2) {
Style style1 = STYLE_BUILDER.createStyle();
style1.featureTypeStyles().add(fts1);
-
+
Style style2 = STYLE_BUILDER.createStyle();
style2.featureTypeStyles().add(fts2);
-
+
return isStyleDifferent(style1, style2);
}
}
Modified: trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java 2010-11-10 12:07:48 UTC (rev 1257)
+++ trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java 2010-11-10 12:31:14 UTC (rev 1258)
@@ -135,6 +135,8 @@
Style style = StylingUtil.createDefaultStyle(GeometryForm.POLYGON);
+ assertTrue(StylingUtil.validates(style));
+
File tf = File.createTempFile("junit", ".sld");
StylingUtil.saveStyleToSld(style, tf);
assertTrue(tf.exists());
More information about the Schmitzm-commits
mailing list