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"
|
||||
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>
|
||||
</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>
|
||||
</ReleaseNotes>
|
35
pom.xml
35
pom.xml
|
@ -8,7 +8,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>gis-interface</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>2.1.2-SNAPSHOT</version>
|
||||
<name>gis-interface</name>
|
||||
|
||||
<properties>
|
||||
|
@ -114,38 +114,16 @@
|
|||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<finalName>${artifactId}</finalName>
|
||||
<plugins>
|
||||
|
||||
<!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration>
|
||||
<source>1.6</source> <target>1.6</target> </configuration> </plugin> -->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
|
@ -164,7 +142,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</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_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<ClassStyleDef> classes, Color c1, Color c2) throws Exception{
|
||||
return createStyle(nameStyle, attributeName, classes, c1,c2,GeometryType.POLYGON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String createStyle(String nameStyle, String attributeName, List<ClassStyleDef> classes, Color c1, Color c2) throws Exception {
|
||||
|
||||
// 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 {
|
||||
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)
|
||||
throw new Exception("Invalid number of classes!!");
|
||||
|
||||
|
@ -68,10 +103,10 @@ public class StyleUtils {
|
|||
for(int i=0;i<classes.size();i++){
|
||||
ClassStyleDef classStyle=classes.get(i);
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +117,7 @@ public class StyleUtils {
|
|||
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)
|
||||
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(Range r:ranges){
|
||||
fts.rules().add(makeRule(r));
|
||||
fts.rules().add(makeRule(r,geometryType));
|
||||
}
|
||||
|
||||
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)
|
||||
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(Range r:ranges){
|
||||
fts.rules().add(makeRule(r));
|
||||
fts.rules().add(makeRule(r,geometryType));
|
||||
}
|
||||
|
||||
style.featureTypeStyles().add(fts);
|
||||
|
@ -140,7 +175,7 @@ public class StyleUtils {
|
|||
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();
|
||||
switch(r.getCondition()){
|
||||
case BETWEEN : toReturn.setFilter(FF.and( // property => min AND property < max
|
||||
|
@ -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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue