mapbox/carto

Condense rules with 'or' filters

開放

#206 建立於 2012年10月24日

 (8 則留言) (0 個反應) (0 位負責人)JavaScript (132 個分叉)auto 404
enhancementhelp wantedperformance

倉庫指標

星標
 (658 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

The example style below will result in an XML file with 9 separate rules. But Mapnik XML supports 'or' in filters like ([type] = 'foo' or [type] = 'bar') and it really only needs to be one rule.

Ideally Carto could just condense these automatically, but alternatively there could be some kind of key in value1, value2, ... syntax. Thoughts?

#areas {
  [type='camp_site'],
  [type='common'],
  [type='national_park'],
  [type='nature_reserve'],
  [type='park'],
  [type='protected_area'],
  [type='recreation_ground'],
  [type='village_green'],
  [type='zoo'] {
    polygon-fill: green;
  }
}
<Style name="areas" filter-mode="first" >
  <Rule>
    <Filter>([type] = 'camp_site')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'common')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'national_park')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'nature_reserve')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'park')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'protected_area')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'recreation_ground')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'village_green')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
  <Rule>
    <Filter>([type] = 'zoo')</Filter>
    <PolygonSymbolizer fill="#008000" />
  </Rule>
</Style>

貢獻者指南