MapServer / MapServer-import

3 stars 2 forks source link

Introduction of INITIALGAP as a new parameter to STYLE #2247

Closed mapserver-bot closed 12 years ago

mapserver-bot commented 12 years ago

Reporter: havatv Date: 2011/05/18 - 12:38 Mapserver should have mechanisms that allow nice styling of dashed lines with point symbols. This is currently not possible with only the GAP parameter in combination with PATTERN. Current behaviour is to use half of the sum of the GAP length and the symbol size as the initial gap length.

From maprendering.c, in the function msImagePolylineMarkers(image,offsetLine,symbol,&s,-s.gap,1);

      double current_length = (spacing+symbol_width)/2.0; // initial padding for each line

A new parameter that specifies the initial gap has to be introduced in the STYLE element. A possible name for this parameter is "INITIALGAP". INITIALGAP should specify the distance from the start of the line to the point at which the symbol is to be drawn.

The OGC "Symbology Encoding Implementation Specification" (used for SLD) includes this mechanism and calls it

InitialGap .

When INTITALGAP is available in the style, the change to the code to implement the mechanism in maprendering.c should be minimal. One could for instance add something like the following after the initialisation of current_length (shown in the code above):

if (style->initialgap != 0 { double current_length = style->intialgap; // initial padding for each line }

mapserver-bot commented 12 years ago

Author: tbonfort Date: 2011/05/18 - 12:42 The current code places the symbol at the middle of the line segment if the line segment was too short for the specified gap. How would this behavior be kept/adapted if the user has specified INITIALGAP ?

mapserver-bot commented 12 years ago

Author: havatv Date: 2011/05/18 - 13:57 I had not looked at this part of the code.

This is an interesting question! ;-)

Current behaviour (to place the symbol at the center of the line) for too short lines seems reasonable, as it is often what the user would want. We are then "adding intelligence", and that kind of takes away some control from the user. We could add more intelligence by stretching / shortening all the gaps of a line (within some limits) to make the rendering symmetrical (start and end gap should have the same length).

If we wanted users to have more control over how symbols are placed on lines, we could add a parameter ("ADAPTGAPS"?) for the purpose.

If we want to have current behaviour for short lines, the key is to define "too short line". "Too short line" could be defined as line length less than GAP, or it could be defines as line length less than INITIALGAP. If INITIALGAP is used, I guess that the code would not have to change. If GAP is to be used, the test for short line would probably have to be moved before the j-loop, giving an extra traversal of the points of the line.

It should be possible to specify INITIALGAP = 0, so I guess that style->initialgap != 0 is not a useful test for the presence of the INITIALGAP parameter. That is, if not style->initialgap could be set to GAP/2 (or something that is recognizable as a missing value) by default in mapfile.c

mapserver-bot commented 12 years ago

Author: tbonfort Date: 2011/10/27 - 12:26 support for initialgap added to dashed line pattern in (r12708) and (r12709).

autotest added in (r12710)

mapserver-bot commented 12 years ago

Author: tbonfort Date: 2011/10/27 - 14:45 Support for INITIALGAP added for line markers in (r12711)

autotest added/updated in (r12712)

Havard, it's all yours to document now :)

mapserver-bot commented 12 years ago

Author: havatv Date: 2011/10/29 - 14:51 Thanks! The style document has been updated with the new parameter in trunk ( (r12720)). Closing.

mapserver-bot commented 12 years ago

Author: havatv Date: 2011/10/30 - 23:22 The trunk symbol construction document has been updated with examples of INITALGAP usage ( (r12724)).