Geoserver 上的动态 SLD

Dynamic SLD on Geoserver

有人可以帮我解决地理服务器上的 CSS sld 问题吗?

如果有人有更好的选择而不是我的方法,请提出建议。

[activity_group_id = 20] [application_status = 'PreSanction-Pending']{
  mark:symbol('ttf://ESRI Business#39');
  :symbol {
    fill:#FF0000;
    }
}

[activity_group_id = 20] [application_status = 'Payment-Done']{
  mark:symbol('ttf://ESRI Business#39');
  :symbol {
    fill:#00FF00;
    }
}

[activity_group_id = 20] [application_status = 'Work-Completed']{
  mark:symbol('ttf://ESRI Business#39');
  :symbol {
    fill:#0000FF;
    }
}

[activity_group_id = 20] [application_status = 'PreSanction-Received']{
  mark:symbol('ttf://ESRI Business#39');
  :symbol {
    fill:#00FFFF;
    }
}

这工作正常 但我想使用 if-then-else 来简化这个 我坚持这个

因为那里有 30 多个独特的 'activity_group_id'

我有点数据,其中每一行都有两个变量 'activity_group_id' 和 'activity_status', 我正在使用 ttf 符号显示为图层,但条件是, 每个点都需要根据其状态分配颜色(填充) 它总共有 4 个独特的价值,因为我是 sld 参考文档的新手,但没有找到任何解决方案。

编辑:- 为点定位图层添加一些测试数据

activity_group_id application_status desk4_longitude desk4_latitude
20  "Work-Completed"    77.8912643252645    20.7848792063826
20  "PreSanction-Pending"   77.8912791454753    20.7796634062134
20  "Payment-Done"  77.874307404545 20.7786504284761
20  "PreSanction-Pending"   77.8748653559629    20.7777572907007
20  "Payment-Done"  77.8935239518168    20.7742195299066
20  "PreSanction-Pending"   77.8887775696933    20.7848194877974
20  "PreSanction-Received"  77.8829004567405    20.7622202218188

使用recode function简化样式。 我无法测试它,但应该是这样的:

[activity_group_id = 20] {
  mark:symbol('ttf://ESRI Business#39');
  :symbol {
     fill: recode(application_status, 
           'Payment-Done', #00FF00,
           'Work-Completed', #0000FF,
           'PreSanction-Received', #00FFFF);
  }
}

如果根据application_status颜色相同,但形状根据组id改变,则使用级联并设置单独的规则:

[activity_group_id = 20] {
  mark:symbol('ttf://ESRI Business#39');
}

[activity_group_id = anotherId] {
  mark:symbol('ttf://anotherSymbol');
}

* {
  :symbol {
     fill: recode(application_status, 
           'Payment-Done', #00FF00,
           'Work-Completed', #0000FF,
           'PreSanction-Received', #00FFFF);
  }
}

@Andrea Aime

根据你的参考,我检查了文档,并对你的答案的语法做了一些修改 分享我的答案以帮助其他人

check geoserver css doc

/* @title Apiculture */
[activity_group_id = 20] {
  mark:symbol('ttf://ESRI Business#39');
  mark-size:15;
  :symbol {
     fill: [recode(application_status,
            'PreSanction-Pending','#FF0000',
           'Payment-Done', '#00FF00',
           'Work-Completed', '#0000FF',
           'PreSanction-Received', '#00FFFF')];
  }
}

/* @title Sprinkler Irrigation */
[activity_group_id = 19] {
  mark:symbol('ttf://ESRI Business#40');
  mark-size:15;
  :symbol {
     fill: [recode(application_status,
            'PreSanction-Pending','#FF0000',
           'Payment-Done', '#00FF00',
           'Work-Completed', '#0000FF',
           'PreSanction-Received', '#00FFFF')];
  }
}