I put a vector symbol on an annotation layer to decorate a map, and
drew it in SVG format. At that time, I found the vector symbol
couldn't be drawn. When verifying if a MapServer can create a
correct SVG file, the following line was found in the produced SVG
file:
<polygon fill="#ff0000" stroke-width="1" (null) points="190,10 230,10 230,30
190,30 190,10"/>
A strange element, "(null)" is included in this polygon tag. I believe
several SVG viewers can't deal with a strange tag like this.
A vector symbol is converted into several SVG-format tags in mapsvg.c.
In the function "msDrawMarkerSymbolSVG", I found several bugs in the
portion of dealing with a vector symbol and writing SVG tags that
correspond to it. Here is the patch for simply fixing the problem mentioned
above:
--- mapsvg.c.orig
+++ mapsvg.c
@@ -1576,14 +1576,13 @@
k = 0; /* point counter */
for(j=0;j < symbol->numpoints;j++)
{
- if((symbol->points[j].x < 0) && (symbol->points[j].x < 0))
+ if((symbol->points[j].x < 0) && (symbol->points[j].y < 0))
{ /* new polygon (PENUP) */
if(k>2)
{
-
msIO_fprintfgz(image->img.svg->stream,
image->img.svg->compressed,
- "<polygon %s %s stroke-width=\"%d\"
%s points=\"",
+ "<polygon %s %s stroke-width=\"%d\"
points=\"",
pszFill, pszStroke, width);
for (i=0; i<k;i++)
@@ -1610,7 +1609,7 @@
msIO_fprintfgz(image->img.svg->stream,
image->img.svg->compressed,
- "<polygon %s %s stroke-width=\"%d\" %s points=\"",
+ "<polygon %s %s stroke-width=\"%d\" points=\"",
pszFill, pszStroke, width);
for (i=0; i<k;i++)
@@ -1632,7 +1631,7 @@
oldpnt.y = MS_NINT(d*symbol->points[0].y + offset_y);
for(j=1;j < symbol->numpoints;j++) { /* step through the marker
s */
- if((symbol->points[j].x < 0) && (symbol->points[j].x < 0)) {
+ if((symbol->points[j].x < 0) && (symbol->points[j].y < 0)) {
oldpnt.x = MS_NINT(d*symbol->points[j].x + offset_x);
oldpnt.y = MS_NINT(d*symbol->points[j].y + offset_y);
} else {
I don't know which element should be placed as the fourth variable of
msIO_fprintfgz,
so there would be any better way than simply erasing it.