git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/gis-interface@115176 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7def713898
commit
568311e64b
|
@ -1,6 +1,13 @@
|
||||||
<ReleaseNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<ReleaseNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="xsd/changelog.xsd">
|
xsi:noNamespaceSchemaLocation="xsd/changelog.xsd">
|
||||||
<Changeset component="org.gcube.spatial-data.geonetowrk.1-0-0" date="2013-03-01">
|
<Changeset component="gis-interface.1-0-0" date="2013-03-01">
|
||||||
<Change>First Release</Change>
|
<Change>First Release</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="gis-interface.2-1-1" date="2014-10-12">
|
||||||
|
<Change>Added point style generation support</Change>
|
||||||
|
<Change>Style generation through different range / classes definitions</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="gis-interface.2-1-2" date="2015-06-25">
|
||||||
|
<Change>Integration fixes</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
41
pom.xml
41
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>gis-interface</artifactId>
|
<artifactId>gis-interface</artifactId>
|
||||||
<version>2.1.0-SNAPSHOT</version>
|
<version>2.1.2-SNAPSHOT</version>
|
||||||
<name>gis-interface</name>
|
<name>gis-interface</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -114,38 +114,16 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration>
|
|
||||||
<source>1.6</source> <target>1.6</target> </configuration> </plugin> -->
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<version>2.3.2</version>
|
||||||
<version>2.5</version>
|
<configuration>
|
||||||
<executions>
|
<source>1.7</source>
|
||||||
<execution>
|
<target>1.7</target>
|
||||||
<id>copy-profile</id>
|
</configuration>
|
||||||
<phase>install</phase>
|
</plugin>
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>target</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${distroDirectory}</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<includes>
|
|
||||||
<include>profile.xml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
@ -164,7 +142,6 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.gcube.spatial.data.gis.symbology;
|
||||||
|
|
||||||
|
public enum GeometryType {
|
||||||
|
|
||||||
|
POLYGON,POINT
|
||||||
|
|
||||||
|
}
|
|
@ -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_DESCRIPTION;
|
||||||
import static org.geotoolkit.style.StyleConstants.DEFAULT_DISPLACEMENT;
|
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_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.awt.Color;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.Collections;
|
||||||
|
|
||||||
import javax.measure.unit.NonSI;
|
import javax.measure.unit.NonSI;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -24,6 +27,9 @@ import org.geotoolkit.style.MutableRule;
|
||||||
import org.geotoolkit.style.MutableStyle;
|
import org.geotoolkit.style.MutableStyle;
|
||||||
import org.geotoolkit.style.MutableStyleFactory;
|
import org.geotoolkit.style.MutableStyleFactory;
|
||||||
import org.opengis.filter.FilterFactory;
|
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;
|
import org.opengis.style.Style;
|
||||||
|
|
||||||
public class StyleUtils {
|
public class StyleUtils {
|
||||||
|
@ -34,26 +40,55 @@ public class StyleUtils {
|
||||||
new Hints(Hints.STYLE_FACTORY, MutableStyleFactory.class));
|
new Hints(Hints.STYLE_FACTORY, MutableStyleFactory.class));
|
||||||
protected static XMLUtilities utils=new XMLUtilities();
|
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{
|
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{
|
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 {
|
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 {
|
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<ClassStyleDef> 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 createStyleScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue,GeometryType geometryType) throws Exception {
|
||||||
public static String createStyle(String nameStyle, String attributeName, List<ClassStyleDef> classes, Color c1, Color c2) 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<ClassStyleDef> classes, Color c1, Color c2,GeometryType geometryType) throws Exception {
|
||||||
if (classes.size() <= 0)
|
if (classes.size() <= 0)
|
||||||
throw new Exception("Invalid number of classes!!");
|
throw new Exception("Invalid number of classes!!");
|
||||||
|
|
||||||
|
@ -68,10 +103,10 @@ public class StyleUtils {
|
||||||
for(int i=0;i<classes.size();i++){
|
for(int i=0;i<classes.size();i++){
|
||||||
ClassStyleDef classStyle=classes.get(i);
|
ClassStyleDef classStyle=classes.get(i);
|
||||||
switch(classStyle.getType()){
|
switch(classStyle.getType()){
|
||||||
case RANGE : fts.rules().add(makeRule(new Range(attributeName, colors.get(i), classStyle.getFrom(), classStyle.getTo(), Condition.BETWEEN)));
|
case RANGE : fts.rules().add(makeRule(new Range(attributeName, colors.get(i), classStyle.getFrom(), classStyle.getTo(), Condition.BETWEEN),geometryType));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SINGLE_VALUE : fts.rules().add(makeRule(new Range(attributeName, colors.get(i), classStyle.getFrom(), null, Condition.EQUALS)));
|
case SINGLE_VALUE : fts.rules().add(makeRule(new Range(attributeName, colors.get(i), classStyle.getFrom(), null, Condition.EQUALS),geometryType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +117,7 @@ public class StyleUtils {
|
||||||
return marshall(style);
|
return marshall(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue,boolean linear)throws Exception{
|
private static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue,boolean linear,GeometryType geometryType)throws Exception{
|
||||||
if (maxClasses <= 0)
|
if (maxClasses <= 0)
|
||||||
throw new Exception("Invalid number of classes!!");
|
throw new Exception("Invalid number of classes!!");
|
||||||
|
|
||||||
|
@ -98,7 +133,7 @@ public class StyleUtils {
|
||||||
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
|
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
|
||||||
|
|
||||||
for(Range r:ranges){
|
for(Range r:ranges){
|
||||||
fts.rules().add(makeRule(r));
|
fts.rules().add(makeRule(r,geometryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
style.featureTypeStyles().add(fts);
|
style.featureTypeStyles().add(fts);
|
||||||
|
@ -108,7 +143,7 @@ public class StyleUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String createStyleScatterColors(String nameStyle, String attributeName, int maxClasses, Class typeValue, Object maxValue, Object minValue,boolean linear)throws Exception{
|
private static String createStyleScatterColors(String nameStyle, String attributeName, int maxClasses, Class typeValue, Object maxValue, Object minValue,boolean linear,GeometryType geometryType)throws Exception{
|
||||||
if (maxClasses <= 0)
|
if (maxClasses <= 0)
|
||||||
throw new Exception("Invalid number of classes!!");
|
throw new Exception("Invalid number of classes!!");
|
||||||
|
|
||||||
|
@ -124,7 +159,7 @@ public class StyleUtils {
|
||||||
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
|
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
|
||||||
|
|
||||||
for(Range r:ranges){
|
for(Range r:ranges){
|
||||||
fts.rules().add(makeRule(r));
|
fts.rules().add(makeRule(r,geometryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
style.featureTypeStyles().add(fts);
|
style.featureTypeStyles().add(fts);
|
||||||
|
@ -140,13 +175,13 @@ public class StyleUtils {
|
||||||
return writer.toString().replaceAll("<([a-zA-Z][a-zA-Z0-9:]*)[^>]*>\\s*</\\1>", ""); //Erase all empty tags
|
return writer.toString().replaceAll("<([a-zA-Z][a-zA-Z0-9:]*)[^>]*>\\s*</\\1>", ""); //Erase all empty tags
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MutableRule makeRule(Range r){
|
private static MutableRule makeRule(Range r,GeometryType geomType){
|
||||||
MutableRule toReturn=SF.rule();
|
MutableRule toReturn=SF.rule();
|
||||||
switch(r.getCondition()){
|
switch(r.getCondition()){
|
||||||
case BETWEEN : toReturn.setFilter(FF.and( // property => min AND property < max
|
case BETWEEN : toReturn.setFilter(FF.and( // property => min AND property < max
|
||||||
FF.greaterOrEqual(FF.property(r.getToFilterProperty()), FF.literal(r.getMin())),
|
FF.greaterOrEqual(FF.property(r.getToFilterProperty()), FF.literal(r.getMin())),
|
||||||
FF.less(FF.property(r.getToFilterProperty()), FF.literal(r.getMax()))));
|
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;
|
break;
|
||||||
|
|
||||||
case GREATER_THEN_MIN : toReturn.setFilter(// property => min
|
case GREATER_THEN_MIN : toReturn.setFilter(// property => min
|
||||||
|
@ -164,8 +199,16 @@ public class StyleUtils {
|
||||||
break;
|
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;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class PublishTable {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
String scope="/d4science.research-infrastructures.eu";
|
String scope="/gcube/devsec/devVRE";
|
||||||
String toPublishTable="mytable";
|
String toPublishTable="mytable";
|
||||||
String datastore="mydatastore";
|
String datastore="mydatastore";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue