mapbox/carto

Condense rules with 'or' filters

オープン

#206 opened on 2012/10/24

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (132 件のフォーク)auto 404
enhancementhelp wantedperformance

Repository metrics

Stars
 (658 個のスター)
PR merge metrics
 (30d に merged 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>

コントリビューターガイド