@@ -607,14 +607,24 @@ class Translator(val baseURL: Option[java.net.URL]) {
607
607
for (name <- typenames) yield (name, rules filter isForTypename(name) map stripTypenames)
608
608
609
609
for ((typename, overlays) <- styleRules) {
610
- val zGroups : Seq [(Double , (Rule , Seq [gt.Symbolizer ]))] =
610
+ val zGroups : Seq [(( Double , Option [ OGCExpression ]), (Rule , Seq [gt.Symbolizer ]))] =
611
611
for {
612
612
rule <- cascading2exclusive(overlays)
613
613
(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)) {
617
626
val fts = styles.createFeatureTypeStyle
627
+ transform.foreach { fts.setTransformation }
618
628
typename.foreach { t => fts.featureTypeNames.add(new NameImpl (t)) }
619
629
for ((rule, syms) <- group if ! syms.isEmpty) {
620
630
val sldRule = styles.createRule()
0 commit comments