From 568311e64bcc75f50debae6643fcdef863f1f82f Mon Sep 17 00:00:00 2001 From: "fabio.sinibaldi" Date: Wed, 3 Jun 2015 10:40:32 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/gis-interface@115176 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 9 ++- pom.xml | 41 +++------- .../data/gis/symbology/GeometryType.java | 7 ++ .../data/gis/symbology/StyleUtils.java | 81 ++++++++++++++----- .../gcube/spatial/data/gis/PublishTable.java | 2 +- 5 files changed, 87 insertions(+), 53 deletions(-) create mode 100644 src/main/java/org/gcube/spatial/data/gis/symbology/GeometryType.java diff --git a/distro/changelog.xml b/distro/changelog.xml index 10dc79e..c16c5bb 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,6 +1,13 @@ - + First Release + + + Added point style generation support + Style generation through different range / classes definitions + + + Integration fixes \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3630ca8..85a73a8 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.gcube.spatial.data gis-interface - 2.1.0-SNAPSHOT + 2.1.2-SNAPSHOT gis-interface @@ -114,38 +114,16 @@ + ${artifactId} - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - copy-profile - install - - copy-resources - - - target - - - ${distroDirectory} - true - - profile.xml - - - - - - - - + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + org.apache.maven.plugins maven-assembly-plugin @@ -164,7 +142,6 @@ - \ No newline at end of file diff --git a/src/main/java/org/gcube/spatial/data/gis/symbology/GeometryType.java b/src/main/java/org/gcube/spatial/data/gis/symbology/GeometryType.java new file mode 100644 index 0000000..0332079 --- /dev/null +++ b/src/main/java/org/gcube/spatial/data/gis/symbology/GeometryType.java @@ -0,0 +1,7 @@ +package org.gcube.spatial.data.gis.symbology; + +public enum GeometryType { + + POLYGON,POINT + +} diff --git a/src/main/java/org/gcube/spatial/data/gis/symbology/StyleUtils.java b/src/main/java/org/gcube/spatial/data/gis/symbology/StyleUtils.java index ca768aa..7e5e374 100644 --- a/src/main/java/org/gcube/spatial/data/gis/symbology/StyleUtils.java +++ b/src/main/java/org/gcube/spatial/data/gis/symbology/StyleUtils.java @@ -2,12 +2,15 @@ package org.gcube.spatial.data.gis.symbology; import static org.geotoolkit.style.StyleConstants.DEFAULT_DESCRIPTION; import static org.geotoolkit.style.StyleConstants.DEFAULT_DISPLACEMENT; +import static org.geotoolkit.style.StyleConstants.DEFAULT_ANCHOR_POINT; import static org.geotoolkit.style.StyleConstants.LITERAL_ZERO_FLOAT; +import static org.geotoolkit.style.StyleConstants.LITERAL_ONE_FLOAT; +import static org.geotoolkit.style.StyleConstants.MARK_SQUARE; import java.awt.Color; import java.io.StringWriter; import java.util.ArrayList; -import java.util.List; +import java.util.Collections; import javax.measure.unit.NonSI; import javax.xml.bind.JAXBException; @@ -24,6 +27,9 @@ import org.geotoolkit.style.MutableRule; import org.geotoolkit.style.MutableStyle; import org.geotoolkit.style.MutableStyleFactory; import org.opengis.filter.FilterFactory; +import org.opengis.style.Graphic; +import org.opengis.style.GraphicalSymbol; +import org.opengis.style.Mark; import org.opengis.style.Style; public class StyleUtils { @@ -34,26 +40,55 @@ public class StyleUtils { new Hints(Hints.STYLE_FACTORY, MutableStyleFactory.class)); protected static XMLUtilities utils=new XMLUtilities(); - + // OLD METHODs WITH ASSUMED POLYGON + + @Deprecated public static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue) throws Exception{ - return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, true); + return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, true,GeometryType.POLYGON); } - + @Deprecated public static String createStyleLog(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue) throws Exception{ - return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, false); + return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, false,GeometryType.POLYGON); } - + @Deprecated public static String createStyleScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue) throws Exception { - return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, true); + return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, true,GeometryType.POLYGON); } + @Deprecated public static String createStyleLogScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue) throws Exception { - return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, false); + return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, false,GeometryType.POLYGON); + } + + @Deprecated + public static String createStyle(String nameStyle, String attributeName, ArrayList classes, Color c1, Color c2) throws Exception{ + return createStyle(nameStyle, attributeName, classes, c1,c2,GeometryType.POLYGON); + } + + + + + // NEW METHODS + + + public static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue, GeometryType geometryType) throws Exception{ + return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, true,geometryType); + } + + public static String createStyleLog(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue,GeometryType geometryType) throws Exception{ + return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, false,geometryType); } - - public static String createStyle(String nameStyle, String attributeName, List classes, Color c1, Color c2) throws Exception { + public static String createStyleScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue,GeometryType geometryType) throws Exception { + return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, true,geometryType); + } + public static String createStyleLogScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue,GeometryType geometryType) throws Exception { + return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, false,geometryType); + } + + + public static String createStyle(String nameStyle, String attributeName, ArrayList classes, Color c1, Color c2,GeometryType geometryType) throws Exception { if (classes.size() <= 0) throw new Exception("Invalid number of classes!!"); @@ -68,10 +103,10 @@ public class StyleUtils { for(int i=0;i]*>\\s*", ""); //Erase all empty tags } - private static MutableRule makeRule(Range r){ + private static MutableRule makeRule(Range r,GeometryType geomType){ MutableRule toReturn=SF.rule(); switch(r.getCondition()){ case BETWEEN : toReturn.setFilter(FF.and( // property => min AND property < max FF.greaterOrEqual(FF.property(r.getToFilterProperty()), FF.literal(r.getMin())), FF.less(FF.property(r.getToFilterProperty()), FF.literal(r.getMax())))); - toReturn.setName(r.getToFilterProperty()+" in ["+r.getMin()+" , "+r.getMax()+")"); + toReturn.setName(r.getToFilterProperty()+" in ["+r.getMin()+" , "+r.getMax()+")"); break; case GREATER_THEN_MIN : toReturn.setFilter(// property => min @@ -164,8 +199,16 @@ public class StyleUtils { break; } + switch (geomType) { + case POINT: + Mark mark = SF.mark(MARK_SQUARE, SF.fill(r.getToAssignColor()), null); + Graphic graphic = SF.graphic(Collections.singletonList((GraphicalSymbol)mark), LITERAL_ONE_FLOAT,FF.literal(5), LITERAL_ZERO_FLOAT, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT); + toReturn.symbolizers().add(SF.pointSymbolizer(toReturn.getName(), "the_geom", DEFAULT_DESCRIPTION, NonSI.PIXEL, graphic)); + break; - toReturn.symbolizers().add(SF.polygonSymbolizer(toReturn.getName(),"the_geom",DEFAULT_DESCRIPTION,NonSI.PIXEL,null,SF.fill(r.getToAssignColor()),DEFAULT_DISPLACEMENT,LITERAL_ZERO_FLOAT)); + default: + toReturn.symbolizers().add(SF.polygonSymbolizer(toReturn.getName(),"the_geom",DEFAULT_DESCRIPTION,NonSI.PIXEL,null,SF.fill(r.getToAssignColor()),DEFAULT_DISPLACEMENT,LITERAL_ZERO_FLOAT)); + } return toReturn; } diff --git a/src/test/java/org/gcube/spatial/data/gis/PublishTable.java b/src/test/java/org/gcube/spatial/data/gis/PublishTable.java index 79a9575..5aaf80b 100644 --- a/src/test/java/org/gcube/spatial/data/gis/PublishTable.java +++ b/src/test/java/org/gcube/spatial/data/gis/PublishTable.java @@ -34,7 +34,7 @@ public class PublishTable { public static void main(String[] args) throws Exception { - String scope="/d4science.research-infrastructures.eu"; + String scope="/gcube/devsec/devVRE"; String toPublishTable="mytable"; String datastore="mydatastore";