Skip to content

Commit 26d7125

Browse files
committed
Lay some groundwork for outputting transformation expressions
1 parent 6de30b6 commit 26d7125

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

geocss/src/main/scala/Translator.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,24 @@ class Translator(val baseURL: Option[java.net.URL]) {
607607
for (name <- typenames) yield (name, rules filter isForTypename(name) map stripTypenames)
608608

609609
for ((typename, overlays) <- styleRules) {
610-
val zGroups: Seq[(Double, (Rule, Seq[gt.Symbolizer]))] =
610+
val zGroups: Seq[((Double, Option[OGCExpression]), (Rule, Seq[gt.Symbolizer]))] =
611611
for {
612612
rule <- cascading2exclusive(overlays)
613613
(z, syms) <- groupByZ(symbolize(rule))
614-
} yield (z, (rule, syms))
615-
616-
for ((_, group) <- orderedRuns(zGroups)) {
614+
} yield ((z, None), (rule, syms))
615+
616+
// In order to ensure minimal output, the conversion requires that like
617+
// transforms be sorted together. However, there is no natural ordering
618+
// over OGC Expressions. Instead, we synthesize one by generating a list
619+
// of all transform expressions used in this stylesheet and indexing into
620+
// it to get a sort key.
621+
val allTransforms = zGroups.map { case ((_, tx), _) => tx }.distinct
622+
implicit val transformOrdering: Ordering[OGCExpression] =
623+
Ordering.by { x => allTransforms.indexOf(x) }
624+
625+
for (((_, transform), group) <- orderedRuns(zGroups)) {
617626
val fts = styles.createFeatureTypeStyle
627+
transform.foreach { fts.setTransformation }
618628
typename.foreach { t => fts.featureTypeNames.add(new NameImpl(t)) }
619629
for ((rule, syms) <- group if !syms.isEmpty) {
620630
val sldRule = styles.createRule()

0 commit comments

Comments
 (0)