From 9a37d9bded37e195bc60e5fdd583900f68180ae1 Mon Sep 17 00:00:00 2001 From: Mikko Johansson Date: Tue, 12 Nov 2013 13:14:15 +0200 Subject: [PATCH] [AH-289] wfs custom style support --- .gitignore | 2 + .../sql/views/07-wfs-new-impl-view.sql | 3 + .../renderer/oskari/TTFMarkFactoryOskari.java | 2 +- .../{ => src/main/resources}/dot-markers.ttf | Bin service-OGC/pom.xml | 2 + .../map/mapwindow/util/MapLayerWorker.java | 6 +- transport/pom.xml | 22 + .../java/fi/nls/oskari/pojo/SessionStore.java | 2 +- .../nls/oskari/pojo/WFSCustomStyleStore.java | 407 +++++++++++++ .../oskari/transport/TransportService.java | 102 +++- .../main/java/fi/nls/oskari/wfs/WFSImage.java | 94 ++- .../fi/nls/oskari/work/WFSMapLayerJob.java | 42 +- .../fi/nls/oskari/wfs/sld_oskari_custom.xml | 548 ++++++++++++++++++ .../oskari/pojo/WFSCustomStyleStoreTest.java | 100 ++++ .../nls/oskari/wfs/WFSCommunicatorTest.java | 16 + .../java/fi/nls/oskari/wfs/WFSImageTest.java | 8 +- .../wfs/extension/AnalysisFilterTest.java | 1 + .../nls/oskari/pojo/custom_highlight_sld.xml | 548 ++++++++++++++++++ .../fi/nls/oskari/pojo/custom_sld.xml | 548 ++++++++++++++++++ 19 files changed, 2394 insertions(+), 59 deletions(-) rename geoserver-ext/OskariMarkFactory/{ => src/main/resources}/dot-markers.ttf (100%) create mode 100755 transport/src/main/java/fi/nls/oskari/pojo/WFSCustomStyleStore.java create mode 100755 transport/src/main/resources/fi/nls/oskari/wfs/sld_oskari_custom.xml create mode 100755 transport/src/test/java/fi/nls/oskari/pojo/WFSCustomStyleStoreTest.java create mode 100755 transport/src/test/resources/fi/nls/oskari/pojo/custom_highlight_sld.xml create mode 100755 transport/src/test/resources/fi/nls/oskari/pojo/custom_sld.xml diff --git a/.gitignore b/.gitignore index 659ded861f..1939ea2b81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ */target +*/*/target */.settings */.classpath */.project @@ -8,3 +9,4 @@ .project /data/ /servlet-map/src/main/webapp/WEB-INF/jetty-env.xml +transport.log \ No newline at end of file diff --git a/content-resources/src/main/resources/sql/views/07-wfs-new-impl-view.sql b/content-resources/src/main/resources/sql/views/07-wfs-new-impl-view.sql index f10c712a28..b485309384 100755 --- a/content-resources/src/main/resources/sql/views/07-wfs-new-impl-view.sql +++ b/content-resources/src/main/resources/sql/views/07-wfs-new-impl-view.sql @@ -163,6 +163,9 @@ UPDATE portti_view_bundle_seq set startup = '{ }, "mapfull" : { "bundlePath" : "/Oskari/packages/framework/bundle/" + }, + "ui-components" : { + "bundlePath" : "/Oskari/packages/framework/bundle/" } }, "Require-Bundle-Instance" : [] diff --git a/geoserver-ext/OskariMarkFactory/src/main/java/org/geotools/renderer/oskari/TTFMarkFactoryOskari.java b/geoserver-ext/OskariMarkFactory/src/main/java/org/geotools/renderer/oskari/TTFMarkFactoryOskari.java index 584d2e070b..30722d77f4 100755 --- a/geoserver-ext/OskariMarkFactory/src/main/java/org/geotools/renderer/oskari/TTFMarkFactoryOskari.java +++ b/geoserver-ext/OskariMarkFactory/src/main/java/org/geotools/renderer/oskari/TTFMarkFactoryOskari.java @@ -76,7 +76,7 @@ public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature String[] fontElements = markUrl.substring(9).split("#"); // look up the font - Font font = FontCache.getDefaultInsance().getFont(fontElements[0]); + Font font = Font.createFont(Font.TRUETYPE_FONT, this.getClass().getResourceAsStream("/dot-markers.ttf")); if (font == null) { throw new IllegalArgumentException("Unknown font " + fontElements[0]); diff --git a/geoserver-ext/OskariMarkFactory/dot-markers.ttf b/geoserver-ext/OskariMarkFactory/src/main/resources/dot-markers.ttf similarity index 100% rename from geoserver-ext/OskariMarkFactory/dot-markers.ttf rename to geoserver-ext/OskariMarkFactory/src/main/resources/dot-markers.ttf diff --git a/service-OGC/pom.xml b/service-OGC/pom.xml index 66f483f016..7755e5ebf1 100755 --- a/service-OGC/pom.xml +++ b/service-OGC/pom.xml @@ -32,11 +32,13 @@ flexjson 2.0 + org.geotools diff --git a/service-map/src/main/java/fi/mml/map/mapwindow/util/MapLayerWorker.java b/service-map/src/main/java/fi/mml/map/mapwindow/util/MapLayerWorker.java index ee9a6ca65f..bf3763f0b8 100755 --- a/service-map/src/main/java/fi/mml/map/mapwindow/util/MapLayerWorker.java +++ b/service-map/src/main/java/fi/mml/map/mapwindow/util/MapLayerWorker.java @@ -501,10 +501,12 @@ private static void populateLayerStylesOnJSONArray(JSONObject styleJSON, Layer l List styleList = wfsService.findWFSLayerStyles(layer.getId()); try{ if ( styleList.size() > 0) { + JSONArray arr = new JSONArray(); for (WFSSLDStyle style : styleList) { - JSONObject obj = createStylesJSON(style.getName(), style.getName(), style.getName()); - styleJSON.accumulate("styles", obj); + JSONObject obj = createStylesJSON(style.getName(), style.getName(), style.getName());; + arr.put(obj); } + styleJSON.put("styles", arr); } }catch (Exception e) { throw new RuntimeException(e); diff --git a/transport/pom.xml b/transport/pom.xml index bd1ebed22e..f7275e10bd 100755 --- a/transport/pom.xml +++ b/transport/pom.xml @@ -374,6 +374,28 @@ oskari-base 1.0-SNAPSHOT + + fi.nls.oskari + shared-test-resources + 1.0-SNAPSHOT + + + org.geoserver + OskariMarkFactory + 1.0 + + org.slf4j slf4j-api diff --git a/transport/src/main/java/fi/nls/oskari/pojo/SessionStore.java b/transport/src/main/java/fi/nls/oskari/pojo/SessionStore.java index 44e54f0807..5f96b4c092 100755 --- a/transport/src/main/java/fi/nls/oskari/pojo/SessionStore.java +++ b/transport/src/main/java/fi/nls/oskari/pojo/SessionStore.java @@ -375,7 +375,7 @@ public void setKeepPrevious(boolean keepPrevious) { * otherwise. */ public boolean save() { - JedisManager.setex(KEY + client, 86400, getAsJSON()); + JedisManager.setex(KEY + client, 86400, getAsJSON()); return this.isValid(); } diff --git a/transport/src/main/java/fi/nls/oskari/pojo/WFSCustomStyleStore.java b/transport/src/main/java/fi/nls/oskari/pojo/WFSCustomStyleStore.java new file mode 100755 index 0000000000..6ecbedec3f --- /dev/null +++ b/transport/src/main/java/fi/nls/oskari/pojo/WFSCustomStyleStore.java @@ -0,0 +1,407 @@ +package fi.nls.oskari.pojo; + +import fi.nls.oskari.cache.JedisManager; +import fi.nls.oskari.log.LogFactory; +import fi.nls.oskari.log.Logger; +import fi.nls.oskari.transport.TransportService; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.map.JsonMappingException; +import org.opengis.feature.simple.SimpleFeature; + +import java.io.IOException; + +public class WFSCustomStyleStore { + private static final Logger log = LogFactory.getLogger(WFSCustomStyleStore.class); + + public static final String KEY = "WFSCustomStyle_"; + + public static final String HIGHLIGHT_FILL_COLOR = "#FAEBD7"; + public static final String HIGHLIGHT_BORDER_COLOR = "#000000"; + public static final String HIGHLIGHT_STROKE_COLOR = "#FAEBD7"; + public static final String HIGHLIGHT_DOT_COLOR = "#FAEBD7"; + + public static final String GEOMETRY = "defaultGeometry"; + public static final String FILL_PATTERN_PARTIAL = "fill_pattern_partial"; + public static final String LINE_STYLE_PARTIAL = "line_style_partial"; + public static final String BORDER_STYLE_PARTIAL = "border_style_partial"; + + public static final String LINE_STYLE_PARTIAL_LINECAP = "stroke_linecap"; + public static final String LINE_STYLE_PARTIAL_DASHARRAY = "5 2"; + public static final String BORDER_STYLE_PARTIAL_DASHARRAY = "5 2"; + + public static final String FILL_PATTERN_PARTIAL_DEFAULT = "fill_color"; + public static final String FILL_PATTERN_PARTIAL_MARK = "\n" + + " \n" + + " \n" + + " shape://fill_mark\n" + + " \n" + + " fill_color\n" + + " fill_stroke_width\n" + + " \n" + + " \n" + + " fill_size\n" + + " \n" + + ""; + + + private String client; + private String layerId; + + private String fillColor; + private int fillPattern; + private String borderColor; + private String borderLinejoin; + private String borderDasharray; + private int borderWidth; + + private String strokeLinecap; + private String strokeColor; + private String strokeLinejoin; + private String strokeDasharray; + private int strokeWidth; + + private String dotColor; + private int dotShape; + private int dotSize; + + private String geometry; + private String sld; + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getLayerId() { + return layerId; + } + + public void setLayerId(String layerId) { + this.layerId = layerId; + } + + public String getFillColor() { + return fillColor; + } + + public void setFillColor(String fillColor) { + this.fillColor = addPrefixColor(fillColor); + } + + public int getFillPattern() { + return fillPattern; + } + + public void setFillPattern(int fillPattern) { + this.fillPattern = fillPattern; + } + + public String getBorderColor() { + return borderColor; + } + + public void setBorderColor(String borderColor) { + this.borderColor = addPrefixColor(borderColor); + } + + public String getBorderLinejoin() { + return borderLinejoin; + } + + public void setBorderLinejoin(String borderLinejoin) { + this.borderLinejoin = borderLinejoin; + } + + public String getBorderDasharray() { + return borderDasharray; + } + + public void setBorderDasharray(String borderDasharray) { + this.borderDasharray = borderDasharray; + } + + public int getBorderWidth() { + return borderWidth; + } + + public void setBorderWidth(int borderWidth) { + this.borderWidth = borderWidth; + } + + public String getStrokeLinecap() { + return strokeLinecap; + } + + public void setStrokeLinecap(String strokeLinecap) { + this.strokeLinecap = strokeLinecap; + } + + public String getStrokeColor() { + return strokeColor; + } + + public void setStrokeColor(String strokeColor) { + this.strokeColor = addPrefixColor(strokeColor); + } + + public String getStrokeLinejoin() { + return strokeLinejoin; + } + + public void setStrokeLinejoin(String strokeLinejoin) { + this.strokeLinejoin = strokeLinejoin; + } + + public String getStrokeDasharray() { + return strokeDasharray; + } + + public void setStrokeDasharray(String strokeDasharray) { + this.strokeDasharray = strokeDasharray; + } + + public int getStrokeWidth() { + return strokeWidth; + } + + public void setStrokeWidth(int strokeWidth) { + this.strokeWidth = strokeWidth; + } + + public String getDotColor() { + return dotColor; + } + + public void setDotColor(String dotColor) { + this.dotColor = addPrefixColor(dotColor); + } + + public int getDotShape() { + return dotShape; + } + + public void setDotShape(int dotShape) { + this.dotShape = dotShape; + } + + public int getDotSize() { + return dotSize; + } + + public void setDotSize(int dotSize) { + this.dotSize = dotSize; + } + + public String getGeometry() { + return geometry; + } + + public void setGeometry(String geometry) { + this.geometry = geometry; + } + + @JsonIgnore + public String getSld() { + return sld; + } + + /** + * Adds '#' in front of color codes for the back + * + * @param color + * @return color with '#' + */ + @JsonIgnore + public String addPrefixColor(String color) { + if(color.charAt(0) != '#') { + return '#' + color; + } + return color; + } + + /** + * Removes '#' in front of color codes for the front + * + * @param color + * @return color without '#' + */ + @JsonIgnore + public String removePrefixColor(String color) { + if(color.charAt(0) == '#') { + return color.substring(1); + } + return color; + } + + /** + * Sets sld by combining values with given template + * + * @param template + * @param isHighlight + */ + public void replaceValues(String template, boolean isHighlight) { + if(geometry == null) { + log.warn("No geometry set"); + return; + } + + // all point scales + for(int i = 18; i < 43; i+=2) { + template = template.replaceAll(TransportService.PARAM_DOT_SIZE + i, Integer.toString(dotSize*i)); + } + + // line styles + String lineStylePartial; + if(strokeDasharray.equals("")) { + lineStylePartial = LINE_STYLE_PARTIAL_LINECAP; + } else { + lineStylePartial = LINE_STYLE_PARTIAL_DASHARRAY; + } + template = template.replaceAll(LINE_STYLE_PARTIAL, lineStylePartial); + + // fill patterns + String fillPatternPartial; + if(fillPattern == -1) { + fillPatternPartial = FILL_PATTERN_PARTIAL_DEFAULT; + } else if(fillPattern == 0) { + fillPatternPartial = FILL_PATTERN_PARTIAL_MARK; + fillPatternPartial = fillPatternPartial.replaceAll("fill_mark", "slash"); + fillPatternPartial = fillPatternPartial.replaceAll("fill_stroke_width", Integer.toString(1)); + fillPatternPartial = fillPatternPartial.replaceAll("fill_size", Integer.toString(4)); + } else if(fillPattern == 1) { + fillPatternPartial = FILL_PATTERN_PARTIAL_MARK; + fillPatternPartial = fillPatternPartial.replaceAll("fill_mark", "slash"); + fillPatternPartial = fillPatternPartial.replaceAll("fill_stroke_width", Integer.toString(2)); + fillPatternPartial = fillPatternPartial.replaceAll("fill_size", Integer.toString(6)); + } else if(fillPattern == 2) { + fillPatternPartial = FILL_PATTERN_PARTIAL_MARK; + fillPatternPartial = fillPatternPartial.replaceAll("fill_mark", "horline"); + fillPatternPartial = fillPatternPartial.replaceAll("fill_stroke_width", Double.toString(0.4)); + fillPatternPartial = fillPatternPartial.replaceAll("fill_size", Double.toString(4.5)); + } else if(fillPattern == 3) { + fillPatternPartial = FILL_PATTERN_PARTIAL_MARK; + fillPatternPartial = fillPatternPartial.replaceAll("fill_mark", "horline"); + fillPatternPartial = fillPatternPartial.replaceAll("fill_stroke_width", Integer.toString(2)); + fillPatternPartial = fillPatternPartial.replaceAll("fill_size", Double.toString(5.5)); + } else { + log.warn("Undefined fill pattern value"); + fillPatternPartial = ""; + } + template = template.replaceAll(FILL_PATTERN_PARTIAL, fillPatternPartial); + + // border styles + String borderStylePartial; + if(borderDasharray.equals("")) { + borderStylePartial = ""; + } else { + borderStylePartial = BORDER_STYLE_PARTIAL_DASHARRAY; + } + template = template.replaceAll(BORDER_STYLE_PARTIAL, borderStylePartial); + + // colors + if(isHighlight) { + template = template.replaceAll(TransportService.PARAM_FILL_COLOR, HIGHLIGHT_FILL_COLOR); + template = template.replaceAll(TransportService.PARAM_BORDER_COLOR, HIGHLIGHT_BORDER_COLOR); + + template = template.replaceAll(TransportService.PARAM_STROKE_COLOR, HIGHLIGHT_STROKE_COLOR); + + template = template.replaceAll(TransportService.PARAM_DOT_COLOR, HIGHLIGHT_DOT_COLOR); + } else { + template = template.replaceAll(TransportService.PARAM_FILL_COLOR, fillColor); + template = template.replaceAll(TransportService.PARAM_BORDER_COLOR, borderColor); + + template = template.replaceAll(TransportService.PARAM_STROKE_COLOR, strokeColor); + + template = template.replaceAll(TransportService.PARAM_DOT_COLOR, dotColor); + } + + template = template.replaceAll(TransportService.PARAM_BORDER_LINEJOIN, borderLinejoin); + template = template.replaceAll(TransportService.PARAM_BORDER_WIDTH, Integer.toString(borderWidth)); + + template = template.replaceAll(TransportService.PARAM_STROKE_LINECAP, strokeLinecap); + template = template.replaceAll(TransportService.PARAM_STROKE_LINEJOIN, strokeLinejoin); + template = template.replaceAll(TransportService.PARAM_STROKE_WIDTH, Integer.toString(strokeWidth)); + + template = template.replaceAll(TransportService.PARAM_DOT_SHAPE, Integer.toString(dotShape)); + + template = template.replaceAll(GEOMETRY, geometry); + + this.sld = template; + } + + /** + * Saves into redis + * + * @return true if saved a valid session; false + * otherwise. + */ + public void save() { + JedisManager.setex(KEY + client + "_" + layerId, 86400, getAsJSON()); + } + + /** + * Transforms object to JSON String + * + * @return JSON String + */ + @JsonIgnore + public String getAsJSON() { + try { + return TransportService.mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + log.error(e, "JSON Generation failed"); + } catch (JsonMappingException e) { + log.error(e, "Mapping from Object to JSON String failed"); + } catch (IOException e) { + log.error(e, "IO failed"); + } + return null; + } + + /** + * Creates store from cache + * + * @param client + * @param layerId + * @return object + */ + @JsonIgnore + public static WFSCustomStyleStore create(String client, String layerId) + throws IOException { + String json = getCache(client, layerId); + if(json == null) { + return null; + } + + return setJSON(json); + } + + /** + * Transforms JSON String to object + * + * @param json + * @return object + */ + @JsonIgnore + public static WFSCustomStyleStore setJSON(String json) + throws IOException { + return TransportService.mapper.readValue(json, + WFSCustomStyleStore.class); + } + + /** + * Gets saved session from redis + * + * @param client + * @param layerId + * @return style as JSON String + */ + @JsonIgnore + public static String getCache(String client, String layerId) { + return JedisManager.get(KEY + client + "_" + layerId); + } +} diff --git a/transport/src/main/java/fi/nls/oskari/transport/TransportService.java b/transport/src/main/java/fi/nls/oskari/transport/TransportService.java index 7b09cc6889..0eed135fe3 100755 --- a/transport/src/main/java/fi/nls/oskari/transport/TransportService.java +++ b/transport/src/main/java/fi/nls/oskari/transport/TransportService.java @@ -9,8 +9,10 @@ import java.util.Properties; import fi.nls.oskari.cache.JedisManager; +import fi.nls.oskari.pojo.*; import fi.nls.oskari.util.ConversionHelper; import fi.nls.oskari.util.PropertyUtil; +import fi.nls.oskari.wfs.WFSImage; import org.codehaus.jackson.map.ObjectMapper; import org.cometd.bayeux.Message; import org.cometd.bayeux.server.BayeuxServer; @@ -21,13 +23,6 @@ import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; -import fi.nls.oskari.pojo.GeoJSONFilter; -import fi.nls.oskari.pojo.Grid; -import fi.nls.oskari.pojo.Layer; -import fi.nls.oskari.pojo.Location; -import fi.nls.oskari.pojo.Tile; -import fi.nls.oskari.pojo.SessionStore; -import fi.nls.oskari.pojo.WFSLayerPermissionsStore; import fi.nls.oskari.wfs.CachingSchemaLocator; import fi.nls.oskari.work.Job; import fi.nls.oskari.work.JobQueue; @@ -92,17 +87,36 @@ public class TransportService extends AbstractService { public static final String PARAM_FEATURE_IDS = "featureIds"; public static final String PARAM_KEEP_PREVIOUS = "keepPrevious"; + // custom style params + public static final String PARAM_FILL_COLOR = "fill_color"; + public static final String PARAM_FILL_PATTERN = "fill_pattern"; + public static final String PARAM_BORDER_COLOR = "border_color"; + public static final String PARAM_BORDER_LINEJOIN = "border_linejoin"; + public static final String PARAM_BORDER_DASHARRAY = "border_dasharray"; + public static final String PARAM_BORDER_WIDTH = "border_width"; + + public static final String PARAM_STROKE_LINECAP = "stroke_linecap"; + public static final String PARAM_STROKE_COLOR = "stroke_color"; + public static final String PARAM_STROKE_LINEJOIN = "stroke_linejoin"; + public static final String PARAM_STROKE_DASHARRAY = "stroke_dasharray"; + public static final String PARAM_STROKE_WIDTH = "stroke_width"; + + public static final String PARAM_DOT_COLOR = "dot_color"; + public static final String PARAM_DOT_SHAPE = "dot_shape"; + public static final String PARAM_DOT_SIZE = "dot_size"; + public static final String CHANNEL_INIT = "/service/wfs/init"; public static final String CHANNEL_ADD_MAP_LAYER = "/service/wfs/addMapLayer"; public static final String CHANNEL_REMOVE_MAP_LAYER = "/service/wfs/removeMapLayer"; public static final String CHANNEL_SET_LOCATION = "/service/wfs/setLocation"; public static final String CHANNEL_SET_MAP_SIZE = "/service/wfs/setMapSize"; public static final String CHANNEL_SET_MAP_LAYER_STYLE = "/service/wfs/setMapLayerStyle"; + public static final String CHANNEL_SET_MAP_LAYER_CUSTOM_STYLE = "/service/wfs/setMapLayerCustomStyle"; public static final String CHANNEL_SET_MAP_CLICK = "/service/wfs/setMapClick"; public static final String CHANNEL_SET_FILTER = "/service/wfs/setFilter"; public static final String CHANNEL_SET_MAP_LAYER_VISIBILITY = "/service/wfs/setMapLayerVisibility"; public static final String CHANNEL_HIGHLIGHT_FEATURES = "/service/wfs/highlightFeatures"; - + public static final String CHANNEL_DISCONNECT = "/meta/disconnect"; public static final String CHANNEL_ERROR = "/error"; @@ -166,6 +180,7 @@ public TransportService(BayeuxServer bayeux) addService(CHANNEL_SET_LOCATION, "processRequest"); addService(CHANNEL_SET_MAP_SIZE, "processRequest"); addService(CHANNEL_SET_MAP_LAYER_STYLE, "processRequest"); + addService(CHANNEL_SET_MAP_LAYER_CUSTOM_STYLE, "processRequest"); addService(CHANNEL_SET_MAP_CLICK, "processRequest"); addService(CHANNEL_SET_FILTER, "processRequest"); addService(CHANNEL_SET_MAP_LAYER_VISIBILITY, "processRequest"); @@ -179,7 +194,6 @@ public TransportService(BayeuxServer bayeux) */ @Override protected void finalize() throws Throwable { - // clear Sessions JedisManager.delAll(SessionStore.KEY); super.finalize(); @@ -215,8 +229,7 @@ public SessionStore getStore(String client) { try { store = SessionStore.setJSON(json); } catch (IOException e) { - log.error("JSON parsing failed for SessionStore \n" + json + "\n", - e); + log.error(e, "JSON parsing failed for SessionStore \n" + json); } if (store == null) { return new SessionStore(client); @@ -253,6 +266,9 @@ public void disconnect(ServerSession client, Message message) } } JedisManager.del(SessionStore.KEY + client.getId()); + JedisManager.delAll(WFSCustomStyleStore.KEY + client.getId()); + + // TODO: remove styles from map log.debug("Session & permission deleted: " + client); } @@ -299,6 +315,8 @@ public void processRequest(ServerSession client, Message message) setMapSize(store, params); } else if (channel.equals(CHANNEL_SET_MAP_LAYER_STYLE)) { setMapLayerStyle(store, params); + } else if (channel.equals(CHANNEL_SET_MAP_LAYER_CUSTOM_STYLE)) { + setMapLayerCustomStyle(store, params); } else if (channel.equals(CHANNEL_SET_MAP_CLICK)) { setMapClick(store, params); } else if (channel.equals(CHANNEL_SET_FILTER)) { @@ -488,7 +506,7 @@ private void setMapLayerStyle(SessionStore store, Map layer) { if(store.containsLayer(layerId)) { Layer tmpLayer = store.getLayers().get(layerId); - if(!tmpLayer.getStyleName().equals(layerStyle)) { + if(!tmpLayer.getStyleName().equals(layerStyle) || layerStyle.startsWith(WFSImage.PREFIX_CUSTOM_STYLE)) { tmpLayer.setStyleName(layerStyle); this.save(store); if(tmpLayer.isVisible()) { @@ -501,6 +519,61 @@ private void setMapLayerStyle(SessionStore store, Map layer) { } } + /** + * Sets layer style into session and starts job for the layer + * + * @param store + * @param style + */ + private void setMapLayerCustomStyle(SessionStore store, Map style) { + if(!style.containsKey(PARAM_LAYER_ID) || + !style.containsKey(PARAM_FILL_COLOR) || + !style.containsKey(PARAM_FILL_PATTERN) || + !style.containsKey(PARAM_BORDER_COLOR) || + !style.containsKey(PARAM_BORDER_LINEJOIN) || + !style.containsKey(PARAM_BORDER_DASHARRAY) || + !style.containsKey(PARAM_BORDER_WIDTH) || + + !style.containsKey(PARAM_STROKE_LINECAP) || + !style.containsKey(PARAM_STROKE_COLOR) || + !style.containsKey(PARAM_STROKE_LINEJOIN) || + !style.containsKey(PARAM_STROKE_DASHARRAY) || + !style.containsKey(PARAM_STROKE_WIDTH) || + + !style.containsKey(PARAM_DOT_COLOR) || + !style.containsKey(PARAM_DOT_SHAPE) || + !style.containsKey(PARAM_DOT_SIZE)) { + log.warn("Failed to set map layer custom style"); + return; + } + + String layerId = style.get(PARAM_LAYER_ID).toString(); + + WFSCustomStyleStore customStyle = new WFSCustomStyleStore(); + + customStyle.setLayerId(layerId); + customStyle.setClient(store.getClient()); + + customStyle.setFillColor(style.get(PARAM_FILL_COLOR).toString()); + customStyle.setFillPattern(((Long)style.get(PARAM_FILL_PATTERN)).intValue()); + customStyle.setBorderColor(style.get(PARAM_BORDER_COLOR).toString()); + customStyle.setBorderLinejoin(style.get(PARAM_BORDER_LINEJOIN).toString()); + customStyle.setBorderDasharray(style.get(PARAM_BORDER_DASHARRAY).toString()); + customStyle.setBorderWidth(((Long)style.get(PARAM_BORDER_WIDTH)).intValue()); + + customStyle.setStrokeLinecap(style.get(PARAM_STROKE_LINECAP).toString()); + customStyle.setStrokeColor(style.get(PARAM_STROKE_COLOR).toString()); + customStyle.setStrokeLinejoin(style.get(PARAM_STROKE_LINEJOIN).toString()); + customStyle.setStrokeDasharray(style.get(PARAM_STROKE_DASHARRAY).toString()); + customStyle.setStrokeWidth(((Long)style.get(PARAM_STROKE_WIDTH)).intValue()); + + customStyle.setDotColor(style.get(PARAM_DOT_COLOR).toString()); + customStyle.setDotShape(((Long)style.get(PARAM_DOT_SHAPE)).intValue()); + customStyle.setDotSize(((Long)style.get(PARAM_DOT_SIZE)).intValue()); + + customStyle.save(); + } + /** * Click isn't saved in session. Set click will be request just once. * @@ -585,7 +658,6 @@ private void setMapLayerVisibility(SessionStore store, if (!layer.containsKey(PARAM_LAYER_ID) || !layer.containsKey(PARAM_LAYER_VISIBLE)) { log.warn("Layer style not defined"); - return; } @@ -621,7 +693,6 @@ private void highlightMapLayerFeatures(SessionStore store, || !layer.containsKey(PARAM_FEATURE_IDS) || !layer.containsKey(PARAM_KEEP_PREVIOUS)) { log.warn("Layer features not defined"); - return; } @@ -669,8 +740,9 @@ private Grid parseGrid(Map params) { } private List> parseBounds(Object[] params) { - if(params == null) + if(params == null) { return null; + } List> bounds = new ArrayList>(); List tile = null; diff --git a/transport/src/main/java/fi/nls/oskari/wfs/WFSImage.java b/transport/src/main/java/fi/nls/oskari/wfs/WFSImage.java index b52e5649d9..68fec92c10 100755 --- a/transport/src/main/java/fi/nls/oskari/wfs/WFSImage.java +++ b/transport/src/main/java/fi/nls/oskari/wfs/WFSImage.java @@ -13,6 +13,8 @@ import fi.nls.oskari.cache.JedisManager; import fi.nls.oskari.log.LogFactory; +import fi.nls.oskari.pojo.WFSCustomStyleStore; +import fi.nls.oskari.util.IOHelper; import org.apache.commons.codec.binary.Base64; import org.geotools.feature.FeatureCollection; import org.geotools.geometry.jts.ReferencedEnvelope; @@ -20,7 +22,6 @@ import org.geotools.map.Layer; import org.geotools.map.MapContent; import org.geotools.map.MapViewport; -import org.geotools.referencing.CRS; import org.geotools.renderer.GTRenderer; import org.geotools.renderer.lite.StreamingRenderer; import org.geotools.sld.SLDConfiguration; @@ -33,8 +34,6 @@ import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import redis.clients.jedis.Jedis; - import fi.nls.oskari.log.Logger; import fi.nls.oskari.pojo.Location; import fi.nls.oskari.pojo.Tile; @@ -52,13 +51,15 @@ public class WFSImage { ImageIO.setUseCache(false); } - private static final String KEY = "WFSImage_"; + public static final String KEY = "WFSImage_"; + public static final String PREFIX_CUSTOM_STYLE = "oskari_custom"; - private static final String STYLE_DEFAULT = "default"; - private static final String STYLE_HIGHLIGHT = "highlight"; + public static final String STYLE_DEFAULT = "default"; + public static final String STYLE_HIGHLIGHT = "highlight"; - private static final String DEFAULT_SLD = "sld_default.xml"; - private static final String HIGHLIGHT_SLD = "sld_highlight.xml"; + public static final String DEFAULT_SLD = "sld_default.xml"; + public static final String HIGHLIGHT_SLD = "sld_highlight.xml"; + public static final String OSKARI_CUSTOM_SLD = "sld_oskari_custom.xml"; private Style style; @@ -67,21 +68,49 @@ public class WFSImage { private int imageWidth = 0; private int imageHeight = 0; + WFSCustomStyleStore customStyle; + private boolean isHighlight = false; + /** * Constructor for image of certain layer and style * * @param layer * @param styleName */ - public WFSImage(WFSLayerStore layer, String styleName) { + public WFSImage(WFSLayerStore layer, String client, String styleName, String highlightStyleName) { if(layer == null || styleName == null) { log.error("Failed to construct image (undefined params)"); return; } - this.style = getSLDStyle(layer, styleName); + if(styleName.startsWith(PREFIX_CUSTOM_STYLE)) { + try { + this.customStyle = WFSCustomStyleStore.create(client, layer.getLayerId()); + if(this.customStyle == null) { + this.style = null; + log.error("WFSCustomStyleStore not created", client, layer.getLayerId()); + return; + } + this.customStyle.setGeometry(layer.getGMLGeometryProperty()); // set the geometry name + if(highlightStyleName == null) { + this.style = createCustomSLDStyle(); + } else { + isHighlight = true; + this.style = createCustomSLDStyle(); + } + } catch(Exception e) { + this.style = null; + log.error(e, "JSON parsing failed for WFSCustomStyleStore"); + return; + } + } else if(highlightStyleName == null) { + this.style = getSLDStyle(layer, styleName); + } else { + isHighlight = true; + this.style = getSLDStyle(layer, highlightStyleName); + } } - + /** * Gets bufferedImage from cache (persistant) * @@ -91,7 +120,6 @@ public WFSImage(WFSLayerStore layer, String styleName) { * @param zoom * @return buffered image from cache */ - public static BufferedImage getCache(String layerId, String styleName, String srs, Double[] bbox, long zoom) { return getCache(layerId, styleName, srs, bbox, zoom, true); } @@ -106,7 +134,6 @@ public static BufferedImage getCache(String layerId, String styleName, String sr * @param persistent * @return buffered image from cache */ - public static BufferedImage getCache(String layerId, String styleName, String srs, @@ -120,6 +147,12 @@ public static BufferedImage getCache(String layerId, log.error("Cache key couldn't be created"); return null; } + + // no persistent cache for custom styles (only for image route) + if(styleName.startsWith(PREFIX_CUSTOM_STYLE)) { + return null; + } + String sBbox = bbox[0] + "-" + bbox[1] + "-" + bbox[2]+ "-" + bbox[3]; String sKey = KEY + layerId + "_" + styleName + "_" + srs + "_" + sBbox + "_" + zoom; if(!persistent) { @@ -142,7 +175,6 @@ public static BufferedImage getCache(String layerId, * @param persistent * @return buffered image from cache */ - public static void setCache(BufferedImage bufferedImage, String layerId, String styleName, @@ -158,6 +190,11 @@ public static void setCache(BufferedImage bufferedImage, return; } + // no persistent cache for custom styles + if(styleName.startsWith(PREFIX_CUSTOM_STYLE)) { + persistent = false; + } + byte[] byteImage = imageToBytes(bufferedImage); String sBbox = bbox[0] + "-" + bbox[1] + "-" + bbox[2]+ "-" + bbox[3]; String sKey = KEY + layerId + "_" + styleName + "_" + srs + "_" + sBbox + "_" + zoom; @@ -249,10 +286,10 @@ public BufferedImage draw(Tile tile, * * @return image */ - public BufferedImage draw(final Tile tile, - final Location location, - final List bounds, - final FeatureCollection features) { + public BufferedImage draw(Tile tile, + Location location, + List bounds, + FeatureCollection features) { if(bounds == null) { this.location = location; @@ -276,7 +313,7 @@ public BufferedImage draw(final Tile tile, log.warn(imageHeight); log.warn(location); log.warn(style); - log.warn(features); + log.warn(features.isEmpty()); return null; } @@ -396,4 +433,23 @@ private Style createSLDStyle(InputStream xml) { } return SLD.styles(sld)[0]; } + + /** + * Creates own sld style by replacing + * + * @return sld + */ + public Style createCustomSLDStyle() { + InputStream resource = WFSImage.class.getResourceAsStream(OSKARI_CUSTOM_SLD); + try { + String xml = IOHelper.readString(resource, "ISO-8859-1"); + customStyle.replaceValues(xml, isHighlight); + xml = customStyle.getSld(); + return createSLDStyle(xml); + } catch(Exception e) { + log.error(e, "Failed to get Own SLD Style"); + log.error(resource); + } + return null; + } } diff --git a/transport/src/main/java/fi/nls/oskari/work/WFSMapLayerJob.java b/transport/src/main/java/fi/nls/oskari/work/WFSMapLayerJob.java index 13fd69c245..35e2ca7a0b 100755 --- a/transport/src/main/java/fi/nls/oskari/work/WFSMapLayerJob.java +++ b/transport/src/main/java/fi/nls/oskari/work/WFSMapLayerJob.java @@ -268,7 +268,9 @@ public final void run() { if(!fromCache) { if(this.image == null) { this.image = new WFSImage(this.layer, - this.session.getLayers().get(this.layerId).getStyleName()); + this.session.getClient(), + this.session.getLayers().get(this.layerId).getStyleName(), + null); } bufferedImage = this.image.draw(this.session.getTileSize(), this.session.getLocation(), @@ -308,28 +310,30 @@ public final void run() { log.debug("highlight image handling", this.features.size()); // IMAGE HANDLING - log.debug("sending"); - Location location = this.session.getLocation(); - if(this.image == null) { - this.image = new WFSImage(this.layer, + log.debug("sending"); + Location location = this.session.getLocation(); + if(this.image == null) { + this.image = new WFSImage(this.layer, + this.session.getClient(), + this.session.getLayers().get(this.layerId).getStyleName(), Type.HIGHLIGHT.toString()); - } - BufferedImage bufferedImage = this.image.draw(this.session.getMapSize(), - this.session.getLocation(), - this.features); - if(bufferedImage == null) { - this.imageParsingFailed(); - return; - } + } + BufferedImage bufferedImage = this.image.draw(this.session.getMapSize(), + this.session.getLocation(), + this.features); + if(bufferedImage == null) { + this.imageParsingFailed(); + return; + } - Double[] bbox = location.getBboxArray(); + Double[] bbox = location.getBboxArray(); - // cache (non-persistant) - setImageCache(bufferedImage, Type.HIGHLIGHT.toString(), bbox, false); + // cache (non-persistant) + setImageCache(bufferedImage, Type.HIGHLIGHT.toString(), bbox, false); - String url = createImageURL(Type.HIGHLIGHT.toString(), bbox); - log.debug("url"); - this.sendWFSImage(url, bufferedImage, bbox, false, false); + String url = createImageURL(Type.HIGHLIGHT.toString(), bbox); + log.debug("url"); + this.sendWFSImage(url, bufferedImage, bbox, false, false); } } else if(this.type == Type.MAP_CLICK) { if(!this.requestHandler(null)) { diff --git a/transport/src/main/resources/fi/nls/oskari/wfs/sld_oskari_custom.xml b/transport/src/main/resources/fi/nls/oskari/wfs/sld_oskari_custom.xml new file mode 100755 index 0000000000..71312e7001 --- /dev/null +++ b/transport/src/main/resources/fi/nls/oskari/wfs/sld_oskari_custom.xml @@ -0,0 +1,548 @@ + + + + custom_style + + custom_style + + + PointScale1 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 1000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size42 + + + + + + PointScale2 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 1000 + 3000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size40 + + + + + + PointScale3 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 3000 + 6000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size38 + + + + + + PointScale4 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 6000 + 12000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size36 + + + + + + PointScale5 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 12000 + 25000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size34 + + + + + + PointScale6 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 25000 + 50000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size32 + + + + + + PointScale7 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 50000 + 100000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size30 + + + + + + PointScale8 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 100000 + 300000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size28 + + + + + + PointScale9 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 300000 + 600000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size26 + + + + + + PointScale10 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 600000 + 1200000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size24 + + + + + + PointScale11 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 1200000 + 2500000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size22 + + + + + + PointScale12 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 2500000 + 5000000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size20 + + + + + + PointScale13 + + + + + defaultGeometry + + Point + MultiPoint + + true + + + 5000000 + + + + oskari://dot-markers#0xe00dot_shape + + dot_color + + + #B4B4B4 + + + dot_size18 + + + + + + + + + + defaultGeometry + + LineString + MultiLineString + + true + + + + + stroke_color + stroke_width + stroke_linejoin + + line_style_partial + + + + + + + + + + + defaultGeometry + + Polygon + MultiPolygon + + true + + + + + fill_pattern_partial + 0.7 + + + + + border_color + border_width + border_linejoin + + border_style_partial + + + + + + + + \ No newline at end of file diff --git a/transport/src/test/java/fi/nls/oskari/pojo/WFSCustomStyleStoreTest.java b/transport/src/test/java/fi/nls/oskari/pojo/WFSCustomStyleStoreTest.java new file mode 100755 index 0000000000..46e5e08f2a --- /dev/null +++ b/transport/src/test/java/fi/nls/oskari/pojo/WFSCustomStyleStoreTest.java @@ -0,0 +1,100 @@ +package fi.nls.oskari.pojo; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; + +import fi.nls.oskari.util.IOHelper; +import fi.nls.oskari.wfs.WFSImage; +import fi.nls.test.util.ResourceHelper; +import org.junit.BeforeClass; +import org.junit.Test; + +public class WFSCustomStyleStoreTest { + private static WFSCustomStyleStore customStyle; + + String jsonResult = "{\"client\":\"test\",\"layerId\":\"216\",\"fillColor\":\"#ffde00\",\"fillPattern\":-1,\"borderColor\":\"#000000\",\"borderLinejoin\":\"mitre\",\"borderDasharray\":\"\",\"borderWidth\":1,\"strokeLinecap\":\"butt\",\"strokeColor\":\"#3233ff\",\"strokeLinejoin\":\"mitre\",\"strokeDasharray\":\"\",\"strokeWidth\":1,\"dotColor\":\"#000000\",\"dotShape\":1,\"dotSize\":3,\"geometry\":\"geom\"}"; + String jsonFail = "{\"client\"\"test\",\"layerId\":\"216\",\"fillColor\":\"#ffde00\",\"fillPattern\":-1,\"borderColor\":\"#000000\",\"borderLinejoin\":\"mitre\",\"borderDasharray\":\"\",\"borderWidth\":1,\"strokeLinecap\":\"butt\",\"strokeColor\":\"#3233ff\",\"strokeLinejoin\":\"mitre\",\"strokeDasharray\":\"\",\"strokeWidth\":1,\"dotColor\":\"#000000\",\"dotShape\":1,\"dotSize\":3}\n"; + + @BeforeClass + public static void setUp() { + customStyle = new WFSCustomStyleStore(); + + customStyle.setLayerId(Integer.toString(216)); + customStyle.setClient("test"); + + customStyle.setFillColor("#ffde00"); + customStyle.setFillPattern(-1); + customStyle.setBorderColor("#000000"); + customStyle.setBorderLinejoin("mitre"); + customStyle.setBorderDasharray(""); + customStyle.setBorderWidth(1); + + customStyle.setStrokeLinecap("butt"); + customStyle.setStrokeColor("#3233ff"); + customStyle.setStrokeLinejoin("mitre"); + customStyle.setStrokeDasharray(""); + customStyle.setStrokeWidth(1); + + customStyle.setDotColor("#000000"); + customStyle.setDotShape(1); + customStyle.setDotSize(3); + + customStyle.setGeometry("geom"); + } + + @Test + public void testJSON() throws IOException { + String json = customStyle.getAsJSON(); + assertEquals("should get right result", jsonResult, json); + } + + @Test + public void testSetJSON() throws IOException { + customStyle = WFSCustomStyleStore.setJSON(jsonResult); + String color = customStyle.getFillColor(); + assertTrue("should have same fill color", color.equals("#ffde00")); + } + + @Test + public void testXML() throws IOException { + InputStream resource = WFSImage.class.getResourceAsStream(WFSImage.OSKARI_CUSTOM_SLD); + if(resource == null) { + fail("Resource not found"); + } + + String xml = IOHelper.readString(resource, "ISO-8859-1"); + customStyle.replaceValues(xml, false); + xml = customStyle.getSld(); + if(xml == null) { + fail("sld not found"); + } + + String res = ResourceHelper.readStringResource("custom_sld.xml", this); + assertEquals("should have same result", res, xml); + } + + @Test + public void testHighlightXML() throws IOException { + InputStream resource = WFSImage.class.getResourceAsStream(WFSImage.OSKARI_CUSTOM_SLD); + if(resource == null) { + fail("Resource not found"); + } + + String xml = IOHelper.readString(resource, "ISO-8859-1"); + customStyle.replaceValues(xml, true); + xml = customStyle.getSld(); + if(xml == null) { + fail("sld not found"); + } + + String res = ResourceHelper.readStringResource("custom_highlight_sld.xml", this); + assertEquals("should have same result", res, xml); + } + + @Test(expected=IOException.class) + public void testJSONIOException() throws IOException { + WFSLayerPermissionsStore.setJSON(jsonFail); + } +} diff --git a/transport/src/test/java/fi/nls/oskari/wfs/WFSCommunicatorTest.java b/transport/src/test/java/fi/nls/oskari/wfs/WFSCommunicatorTest.java index d14a626a82..1ec418fd7c 100755 --- a/transport/src/test/java/fi/nls/oskari/wfs/WFSCommunicatorTest.java +++ b/transport/src/test/java/fi/nls/oskari/wfs/WFSCommunicatorTest.java @@ -102,4 +102,20 @@ public void testFailingFilterConstruct() throws NullPointerException { WFSFilter filter = WFSCommunicator.constructFilter(layerId); assertTrue("Should be null", filter == null); } + + + @Test + public void testRaHu() { + String payload = WFSCommunicator.createRequestPayload(type, layer, session, bounds, null); + assertTrue("Should get defined result with bounds", payload.equals(boundsResult)); + + // request (maplayer_id 216) + BufferedReader response = HttpHelper.postRequestReader(layer.getURL(), "text/xml", payload, layer.getUsername(), layer.getPassword()); + assertTrue("Should get valid response", response != null); + + // parse + FeatureCollection features = WFSCommunicator.parseSimpleFeatures(response, layer); + assertTrue("Should get valid features", features != null); + assertTrue("Should get features", features.size() > 0); + } } diff --git a/transport/src/test/java/fi/nls/oskari/wfs/WFSImageTest.java b/transport/src/test/java/fi/nls/oskari/wfs/WFSImageTest.java index eb012eecd7..befd9f52a8 100755 --- a/transport/src/test/java/fi/nls/oskari/wfs/WFSImageTest.java +++ b/transport/src/test/java/fi/nls/oskari/wfs/WFSImageTest.java @@ -85,7 +85,9 @@ public static void setUp() { @Test public void testMap() { WFSImage mapImage = new WFSImage(layer, - session.getLayers().get(layer.getLayerId()).getStyleName()); + "test", + session.getLayers().get(layer.getLayerId()).getStyleName(), + null); BufferedImage bufferedMapImage = mapImage.draw(session.getTileSize(), session.getLocation(), @@ -96,7 +98,9 @@ public void testMap() { @Test public void testTile() { WFSImage tileImage = new WFSImage(layer, - session.getLayers().get(layer.getLayerId()).getStyleName()); + "test", + session.getLayers().get(layer.getLayerId()).getStyleName(), + null); BufferedImage bufferedTileImage = tileImage.draw(session.getTileSize(), session.getLocation(), diff --git a/transport/src/test/java/fi/nls/oskari/wfs/extension/AnalysisFilterTest.java b/transport/src/test/java/fi/nls/oskari/wfs/extension/AnalysisFilterTest.java index 68211bb97d..064a5379b7 100755 --- a/transport/src/test/java/fi/nls/oskari/wfs/extension/AnalysisFilterTest.java +++ b/transport/src/test/java/fi/nls/oskari/wfs/extension/AnalysisFilterTest.java @@ -140,6 +140,7 @@ public void testHighlight() { StAXOMBuilder staxOMBuilder = XMLHelper.createBuilder(filterStr); filter = staxOMBuilder.getDocumentElement(); } + System.out.println(filter.toString()); assertTrue("Should get expected resultHighlightFeatures", filter.toString().equals(resultHighlightFeatures)); } diff --git a/transport/src/test/resources/fi/nls/oskari/pojo/custom_highlight_sld.xml b/transport/src/test/resources/fi/nls/oskari/pojo/custom_highlight_sld.xml new file mode 100755 index 0000000000..8b5e81ff4d --- /dev/null +++ b/transport/src/test/resources/fi/nls/oskari/pojo/custom_highlight_sld.xml @@ -0,0 +1,548 @@ + + + + custom_style + + custom_style + + + PointScale1 + + + + + geom + + Point + MultiPoint + + true + + + 1000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 126 + + + + + + PointScale2 + + + + + geom + + Point + MultiPoint + + true + + + 1000 + 3000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 120 + + + + + + PointScale3 + + + + + geom + + Point + MultiPoint + + true + + + 3000 + 6000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 114 + + + + + + PointScale4 + + + + + geom + + Point + MultiPoint + + true + + + 6000 + 12000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 108 + + + + + + PointScale5 + + + + + geom + + Point + MultiPoint + + true + + + 12000 + 25000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 102 + + + + + + PointScale6 + + + + + geom + + Point + MultiPoint + + true + + + 25000 + 50000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 96 + + + + + + PointScale7 + + + + + geom + + Point + MultiPoint + + true + + + 50000 + 100000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 90 + + + + + + PointScale8 + + + + + geom + + Point + MultiPoint + + true + + + 100000 + 300000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 84 + + + + + + PointScale9 + + + + + geom + + Point + MultiPoint + + true + + + 300000 + 600000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 78 + + + + + + PointScale10 + + + + + geom + + Point + MultiPoint + + true + + + 600000 + 1200000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 72 + + + + + + PointScale11 + + + + + geom + + Point + MultiPoint + + true + + + 1200000 + 2500000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 66 + + + + + + PointScale12 + + + + + geom + + Point + MultiPoint + + true + + + 2500000 + 5000000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 60 + + + + + + PointScale13 + + + + + geom + + Point + MultiPoint + + true + + + 5000000 + + + + oskari://dot-markers#0xe001 + + #FAEBD7 + + + #B4B4B4 + + + 54 + + + + + + + + + + geom + + LineString + MultiLineString + + true + + + + + #FAEBD7 + 1 + mitre + + butt + + + + + + + + + + + geom + + Polygon + MultiPolygon + + true + + + + + #FAEBD7 + 0.7 + + + + + #000000 + 1 + mitre + + + + + + + + + + \ No newline at end of file diff --git a/transport/src/test/resources/fi/nls/oskari/pojo/custom_sld.xml b/transport/src/test/resources/fi/nls/oskari/pojo/custom_sld.xml new file mode 100755 index 0000000000..feba1cbe27 --- /dev/null +++ b/transport/src/test/resources/fi/nls/oskari/pojo/custom_sld.xml @@ -0,0 +1,548 @@ + + + + custom_style + + custom_style + + + PointScale1 + + + + + geom + + Point + MultiPoint + + true + + + 1000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 126 + + + + + + PointScale2 + + + + + geom + + Point + MultiPoint + + true + + + 1000 + 3000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 120 + + + + + + PointScale3 + + + + + geom + + Point + MultiPoint + + true + + + 3000 + 6000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 114 + + + + + + PointScale4 + + + + + geom + + Point + MultiPoint + + true + + + 6000 + 12000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 108 + + + + + + PointScale5 + + + + + geom + + Point + MultiPoint + + true + + + 12000 + 25000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 102 + + + + + + PointScale6 + + + + + geom + + Point + MultiPoint + + true + + + 25000 + 50000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 96 + + + + + + PointScale7 + + + + + geom + + Point + MultiPoint + + true + + + 50000 + 100000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 90 + + + + + + PointScale8 + + + + + geom + + Point + MultiPoint + + true + + + 100000 + 300000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 84 + + + + + + PointScale9 + + + + + geom + + Point + MultiPoint + + true + + + 300000 + 600000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 78 + + + + + + PointScale10 + + + + + geom + + Point + MultiPoint + + true + + + 600000 + 1200000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 72 + + + + + + PointScale11 + + + + + geom + + Point + MultiPoint + + true + + + 1200000 + 2500000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 66 + + + + + + PointScale12 + + + + + geom + + Point + MultiPoint + + true + + + 2500000 + 5000000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 60 + + + + + + PointScale13 + + + + + geom + + Point + MultiPoint + + true + + + 5000000 + + + + oskari://dot-markers#0xe001 + + #000000 + + + #B4B4B4 + + + 54 + + + + + + + + + + geom + + LineString + MultiLineString + + true + + + + + #3233ff + 1 + mitre + + butt + + + + + + + + + + + geom + + Polygon + MultiPolygon + + true + + + + + #ffde00 + 0.7 + + + + + #000000 + 1 + mitre + + + + + + + + + + \ No newline at end of file