diff --git a/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.gml b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.gml new file mode 100644 index 0000000000..2df16aae77 --- /dev/null +++ b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.gml @@ -0,0 +1,23 @@ + + + + 0.0 0.0 + 100.0 100.0 + + + + + 1 + dummy + + + 50.000000 50.000000 + + + + + diff --git a/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.png b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.png new file mode 100644 index 0000000000..0570d49237 Binary files /dev/null and b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.png differ diff --git a/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.xml b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.xml new file mode 100644 index 0000000000..a6c984d16a --- /dev/null +++ b/deegree-core/deegree-core-rendering-2d/src/test/resources/org/deegree/rendering/r2d/similaritytests/point_wellknownname_svgpath.xml @@ -0,0 +1,12 @@ + + + + + svgpath://m 8,14 0,-6 h -4.5 c 0,0 0,-7.5 6.6,-7.5 6,0 6.5,7.5 6.6,7.5 l -4.5,0 0,6 z m -4,0 v -2 h 2 v 2 z#FF00000.4#000000140 + 00 + + diff --git a/deegree-core/deegree-core-style/src/main/java/org/deegree/style/styling/wkn/SvgPathLoader.java b/deegree-core/deegree-core-style/src/main/java/org/deegree/style/styling/wkn/SvgPathLoader.java new file mode 100644 index 0000000000..01703134ad --- /dev/null +++ b/deegree-core/deegree-core-style/src/main/java/org/deegree/style/styling/wkn/SvgPathLoader.java @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------- + This file is part of deegree, http://deegree.org/ + Copyright (C) 2022 by: + - grit graphische Informationstechnik Beratungsgesellschaft mbH - + + This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation; either version 2.1 of the License, or (at your option) + any later version. + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact information: + + grit graphische Informationstechnik Beratungsgesellschaft mbH + Landwehrstr. 143, 59368 Werne + Germany + http://www.grit.de/ + + lat/lon GmbH + Aennchenstr. 19, 53177 Bonn + Germany + http://lat-lon.de/ + + Department of Geography, University of Bonn + Prof. Dr. Klaus Greve + Postfach 1147, 53001 Bonn + Germany + http://www.geographie.uni-bonn.de/deegree/ + + e-mail: info@deegree.org + ----------------------------------------------------------------------------*/ +package org.deegree.style.styling.wkn; + +import java.awt.Shape; +import java.net.URL; +import java.util.function.Function; + +import org.apache.batik.parser.AWTPathProducer; +import org.apache.batik.parser.ParseException; +import org.apache.batik.parser.PathParser; +import org.deegree.style.styling.mark.WellKnownNameLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvgPathLoader implements WellKnownNameLoader { + + private static final Logger LOG = LoggerFactory.getLogger( SvgPathLoader.class ); + + public static final String PREFIX = "svgpath://"; + + @Override + public Shape parse( String wellKnownName, Function resolver ) { + if ( wellKnownName == null || !wellKnownName.startsWith( PREFIX ) ) + return null; + + String wkn = wellKnownName.substring( PREFIX.length() ); + + Shape s = null; + AWTPathProducer pathProducer = new AWTPathProducer(); + PathParser pp = new PathParser(); + pp.setPathHandler( pathProducer ); + try { + pp.parse( wkn ); + s = pathProducer.getShape(); + } catch ( ParseException ex ) { + LOG.warn( "Could not Parse SVGPath {}: {}", wkn, ex.getMessage() ); + LOG.trace( "Exception", ex ); + } + + return s; + } +} \ No newline at end of file diff --git a/deegree-core/deegree-core-style/src/main/resources/META-INF/services/org.deegree.style.styling.mark.WellKnownNameLoader b/deegree-core/deegree-core-style/src/main/resources/META-INF/services/org.deegree.style.styling.mark.WellKnownNameLoader index edb1f28d7d..b0e8ce0f00 100644 --- a/deegree-core/deegree-core-style/src/main/resources/META-INF/services/org.deegree.style.styling.mark.WellKnownNameLoader +++ b/deegree-core/deegree-core-style/src/main/resources/META-INF/services/org.deegree.style.styling.mark.WellKnownNameLoader @@ -2,6 +2,6 @@ org.deegree.style.styling.wkn.ShapeLoader org.deegree.style.styling.wkn.ExtShapeLoader org.deegree.style.styling.wkn.TrueTypeFontLoader org.deegree.style.styling.wkn.QGisShapeLoader -#org.deegree.style.styling.wkn.SvgPathLoader +org.deegree.style.styling.wkn.SvgPathLoader #org.deegree.style.styling.wkn.WKTLoader #org.deegree.style.styling.wkn.WKTLinearizeLoader \ No newline at end of file diff --git a/deegree-services/deegree-webservices-handbook/src/main/asciidoc/images/se_wkn_example/svgpath_example.png b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/images/se_wkn_example/svgpath_example.png new file mode 100644 index 0000000000..d9b6cd38bb Binary files /dev/null and b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/images/se_wkn_example/svgpath_example.png differ diff --git a/deegree-services/deegree-webservices-handbook/src/main/asciidoc/renderstyles.adoc b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/renderstyles.adoc index 4414e2e965..fbeeb531e4 100644 --- a/deegree-services/deegree-webservices-handbook/src/main/asciidoc/renderstyles.adoc +++ b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/renderstyles.adoc @@ -771,6 +771,18 @@ image::se_wkn_example/extshape_arrow_t_00_10.png[] extshape://arrow?t=0.2&hr=2&ab=0.5 ---- +====== Custom Symbol from SVG path svgpath:// + +It is also possible to define a symbol from a SVG path data. +The syntax of SVG path data is described at https://www.w3.org/TR/SVG/paths.html#PathData + +.Example of custom symbol with \`svgpath://` +[cols="10,90"] +|=== +a|image::se_wkn_example/svgpath_example.png[] +a|`svgpath://m 8,14 0,-6 h -4.5 c 0,0 0,-7.5 6.6,-7.5 6,0 6.5,7.5 6.6,7.5 l -4.5,0 0,6 z m -4,0 v -2 h 2 v 2 z` +|=== + ====== Use Symbol from character code ttf:// Also TrueType font files can be used as source for symbols.