[mapserver-commits] r12711 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Oct 27 08:40:19 EDT 2011
Author: tbonfort
Date: 2011-10-27 05:40:19 -0700 (Thu, 27 Oct 2011)
New Revision: 12711
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapagg.cpp
trunk/mapserver/mapfile.c
trunk/mapserver/maprendering.c
Log:
- Add initial gap support for line marker symbols (#3879)
- Fix center to center computation of gaps for line marker symbols
and polygon tile patterns (#3867)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-10-27 10:25:17 UTC (rev 12710)
+++ trunk/mapserver/HISTORY.TXT 2011-10-27 12:40:19 UTC (rev 12711)
@@ -15,8 +15,13 @@
Current Version (SVN trunk, 6.1-dev, future 6.2):
-------------------------------------------------
-- Add intial gap support for line patterns (#3879)
+- Add initial gap support for line marker symbols (#3879)
+- Fix center to center computation of gaps for line marker symbols
+ and polygon tile patterns (#3867)
+
+- Add initial gap support for line patterns (#3879)
+
- Fixed grid of thin lines in polygon symbol fills (#3868)
- Fixed cannot add a style to a label in PHP/SWIG Mapscript (#4038)
Modified: trunk/mapserver/mapagg.cpp
===================================================================
--- trunk/mapserver/mapagg.cpp 2011-10-27 10:25:17 UTC (rev 12710)
+++ trunk/mapserver/mapagg.cpp 2011-10-27 12:40:19 UTC (rev 12711)
@@ -208,15 +208,18 @@
mapserver::conv_stroke<mapserver::conv_dash<line_adaptor> > stroke_dash(dash);
int patt_length = 0;
for (int i = 0; i < style->patternlength; i += 2) {
-
if (i < style->patternlength - 1) {
dash.add_dash(MS_MAX(1,MS_NINT(style->pattern[i])),
MS_MAX(1,MS_NINT(style->pattern[i + 1])));
- patt_length = MS_MAX(1,MS_NINT(style->pattern[i])) +
+ if(style->patternoffset) {
+ patt_length = MS_MAX(1,MS_NINT(style->pattern[i])) +
MS_MAX(1,MS_NINT(style->pattern[i + 1]));
+ }
}
}
- dash.dash_start(patt_length - style->patternoffset);
+ if(style->patternoffset > 0) {
+ dash.dash_start(patt_length - style->patternoffset);
+ }
stroke_dash.width(style->width);
if(style->width>1)
applyCJC(stroke_dash, style->linecap, style->linejoin);
Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c 2011-10-27 10:25:17 UTC (rev 12710)
+++ trunk/mapserver/mapfile.c 2011-10-27 12:40:19 UTC (rev 12711)
@@ -2399,7 +2399,7 @@
style->patternlength = 0; /* solid line */
style->gap = 0;
- style->initialgap = 0;
+ style->initialgap = -1;
style->position = MS_CC;
style->linecap = MS_CJC_DEFAULT_CAPS;
style->linejoin = MS_CJC_DEFAULT_JOINS;
@@ -2486,6 +2486,10 @@
break;
case(INITIALGAP):
if((getDouble(&style->initialgap)) == -1) return(MS_FAILURE);
+ if(style->initialgap < 0) {
+ msSetError(MS_MISCERR, "INITIALGAP requires a positive values", "loadStyle()");
+ return(MS_FAILURE);
+ }
break;
case(MAXSCALEDENOM):
if(getDouble(&(style->maxscaledenom)) == -1) return(MS_FAILURE);
@@ -2554,7 +2558,7 @@
case(END):
if(style->patternlength < 2) {
msSetError(MS_SYMERR, "Not enough pattern elements. A minimum of 2 are required", "loadStyle()");
- return(-1);
+ return(MS_FAILURE);
}
done = MS_TRUE;
break;
@@ -2711,7 +2715,7 @@
else writeColor(stream, indent, "COLOR", NULL, &(style->color));
writeNumber(stream, indent, "GAP", 0, style->gap);
- writeNumber(stream, indent, "INITIALGAP", 0, style->initialgap);
+ writeNumber(stream, indent, "INITIALGAP", -1, style->initialgap);
if(style->_geomtransform.type != MS_GEOMTRANSFORM_NONE) {
writeKeyword(stream, indent, "GEOMTRANSFORM", style->_geomtransform.type, 6,
Modified: trunk/mapserver/maprendering.c
===================================================================
--- trunk/mapserver/maprendering.c 2011-10-27 10:25:17 UTC (rev 12710)
+++ trunk/mapserver/maprendering.c 2011-10-27 12:40:19 UTC (rev 12711)
@@ -263,7 +263,8 @@
}
int msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol,
- symbolStyleObj *style, double spacing, int auto_angle) {
+ symbolStyleObj *style, double spacing,
+ double initialgap, int auto_angle) {
rendererVTableObj *renderer = MS_IMAGE_RENDERER(image);
int i,j;
pointObj point;
@@ -282,7 +283,12 @@
for(i=0; i<p->numlines; i++)
{
int line_in = 0;
- double current_length = (spacing+symbol_width)/2.0; /* initial padding for each line */
+ double current_length;
+ if(initialgap < 0) {
+ current_length = spacing/2.0; /* initial padding for each line */
+ } else {
+ current_length = initialgap; /* initial padding for each line */
+ }
double line_length=0;
for(j=1; j<p->line[i].numpoints; j++)
{
@@ -323,22 +329,24 @@
}
if( ret != MS_SUCCESS)
return ret;
- current_length += symbol_width + spacing;
+ current_length += spacing;
in = 1;
line_in=1;
}
if (in)
{
- current_length -= length + symbol_width/2.0;
+ current_length -= length;
}
else current_length -= length;
}
- /* if we couldn't place a symbol on the line, add one now
- we don't add the symbol if the line is shorter than the
- length of the symbol itself */
- if(!line_in && line_length>symbol_width) {
+ /*
+ * if we couldn't place a symbol on the line and no initialgap was
+ * specified, add one now we don't add the symbol if the line is shorter
+ * than the length of the symbol itself
+ */
+ if(initialgap < 0 && !line_in && line_length>symbol_width) {
/* total lengths of beginnning and end of current segment */
double before_length=0,after_length=0;
@@ -440,7 +448,7 @@
s.patternlength = style->patternlength;
for(i=0; i<s.patternlength; i++)
s.pattern[i] = style->pattern[i] * finalscalefactor;
- s.patternoffset = style->initialgap * finalscalefactor;
+ s.patternoffset = (style->initialgap<=0) ? 0 : (style->initialgap * finalscalefactor);
if(MS_VALID_COLOR(style->color))
s.color = &style->color;
@@ -488,10 +496,12 @@
/* compute a markerStyle and use it on the line */
if(style->gap<0) {
/* special function that treats any other symbol used as a marker, not a brush */
- msImagePolylineMarkers(image,offsetLine,symbol,&s,-s.gap,1);
+ msImagePolylineMarkers(image,offsetLine,symbol,&s,-s.gap,
+ style->initialgap * finalscalefactor, 1);
}
else if(style->gap>0) {
- msImagePolylineMarkers(image,offsetLine,symbol,&s,s.gap,0);
+ msImagePolylineMarkers(image,offsetLine,symbol,&s,s.gap,
+ style->initialgap * finalscalefactor,0);
} else {
if(renderer->renderLineTiled != NULL) {
int pw,ph;
@@ -667,11 +677,21 @@
}
if(s.scale != 1) {
- pw = MS_NINT(symbol->sizex * s.scale + s.gap);
- ph = MS_NINT(symbol->sizey * s.scale + s.gap);
+ if (s.gap > 0) {
+ pw = MS_MAX(MS_NINT(s.gap),symbol->sizex * s.scale);
+ ph = MS_MAX(MS_NINT(s.gap),symbol->sizey * s.scale);
+ } else {
+ pw = MS_NINT(symbol->sizex * s.scale);
+ ph = MS_NINT(symbol->sizey * s.scale);
+ }
} else {
- pw = symbol->sizex + s.gap;
- ph = symbol->sizey + s.gap;
+ if (s.gap > 0) {
+ pw = MS_MAX(s.gap,symbol->sizex);
+ ph = MS_MAX(s.gap,symbol->sizey);
+ } else {
+ pw = symbol->sizex;
+ ph = symbol->sizey;
+ }
}
if(pw<1) pw=1;
if(ph<1) ph=1;
More information about the mapserver-commits
mailing list