Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#3879 closed enhancement (fixed)

Introduction of INITIALGAP as a new parameter to STYLE

Reported by: havatv Owned by: havatv
Priority: normal Milestone: 6.2 release
Component: Documentation - MapServer Version: 6.0
Severity: normal Keywords: initial, gap, symbol, line
Cc: havatv

Description

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
      }

Change History (7)

comment:1 by tbonfort, 13 years ago

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 ?

comment:2 by havatv, 13 years ago

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

comment:3 by tbonfort, 13 years ago

Status: newassigned

comment:4 by tbonfort, 13 years ago

support for initialgap added to dashed line pattern in r12708 and r12709.

autotest added in r12710

comment:5 by tbonfort, 13 years ago

Component: Renderer APIMapServer Documentation
Owner: changed from tbonfort to havatv
Status: assignednew

Support for INITIALGAP added for line markers in r12711

autotest added/updated in r12712

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

comment:6 by havatv, 12 years ago

Resolution: fixed
Status: newclosed

Thanks! The style document has been updated with the new parameter in trunk (r12720). Closing.

comment:7 by havatv, 12 years ago

The trunk symbol construction document has been updated with examples of INITALGAP usage (r12724).

Note: See TracTickets for help on using tickets.