Skip to content

Commit

Permalink
mapserver: support for text-min-path-length (numeric and auto)
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Aug 22, 2017
1 parent ac53585 commit 62fa58d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 13 additions & 1 deletion builder/mapserver/mapfile.go
Expand Up @@ -487,6 +487,16 @@ func (m *Map) addTextSymbolizer(b *Block, r mss.Rule, isLine bool) (styled bool)
style.AddNonNil("Font", fontNames) style.AddNonNil("Font", fontNames)
} }


var minFeatureSizeSet bool
if _, ok := r.Properties.GetString("text-min-path-length"); ok {
minFeatureSizeSet = true
style.Add("MinFeatureSize", "AUTO")
}
if minLength, ok := r.Properties.GetFloat("text-min-path-length"); ok {
minFeatureSizeSet = true
style.Add("MinFeatureSize", minLength)
}

style.Add("Type", "truetype") style.Add("Type", "truetype")
if isLine { if isLine {
angle, ok := r.Properties.GetString("text-placement") angle, ok := r.Properties.GetString("text-placement")
Expand All @@ -497,7 +507,9 @@ func (m *Map) addTextSymbolizer(b *Block, r mss.Rule, isLine bool) (styled bool)
style.Add("Angle", "FOLLOW") style.Add("Angle", "FOLLOW")
} }


style.Add("MinFeatureSize", "AUTO") if !minFeatureSizeSet {
style.Add("MinFeatureSize", "AUTO")
}
} }
if wrapWidth, ok := r.Properties.GetFloat("text-wrap-width"); ok { if wrapWidth, ok := r.Properties.GetFloat("text-wrap-width"); ok {
maxLength := wrapWidth / textSize maxLength := wrapWidth / textSize
Expand Down
11 changes: 10 additions & 1 deletion mss/spec.go
Expand Up @@ -83,6 +83,15 @@ func isKeyword(keywords ...string) isValid {
} }
} }


func isKeywordOr(other isValid, keywords ...string) isValid {
return func(val interface{}) bool {
if other(val) {
return true
}
return isKeyword(keywords...)(val)
}
}

func isStops(val interface{}) bool { func isStops(val interface{}) bool {
vals, ok := val.([]Value) vals, ok := val.([]Value)
if !ok { if !ok {
Expand Down Expand Up @@ -376,7 +385,7 @@ func init() {
"text-justify-alignment": isJustifyAlignment, "text-justify-alignment": isJustifyAlignment,
"text-margin": isNumber, "text-margin": isNumber,
"text-repeat-distance": isNumber, "text-repeat-distance": isNumber,
"text-min-path-length": isNumber, "text-min-path-length": isKeywordOr(isNumber, "auto"),
"text-rotate-displacement": isBool, "text-rotate-displacement": isBool,
"text-upgright": isKeyword("auto", "auto-down", "left", "right", "left-only", "right-only"), "text-upgright": isKeyword("auto", "auto-down", "left", "right", "left-only", "right-only"),
"text-simplify": isNumber, "text-simplify": isNumber,
Expand Down

0 comments on commit 62fa58d

Please sign in to comment.