Примеры картостилей Mapserver

Полигональный слой с ограничением по масштабу и подписями

<map>
  <layer>
    <labelitem>a_hsnmbr</labelitem>
    <class>
      <style>
        <color red="255" green="170" blue="127"/>
        <outlinecolor red="106" green="106" blue="106"/>
        <width>0.425196850394</width>
        <maxscaledenom>10000</maxscaledenom> <!-- Ограничение по масштабу -->
      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>10000</maxscaledenom>
      </label>
    </class>
  </layer>
</map>

Точечный белый кружок

<style>
  <color red="255" green="255" blue="255"/>
  <outlinecolor red="0" green="0" blue="0"/>
  <size>8.50393700787</size>
  <symbol>std:circle</symbol>
</style>

Линия из маленьких чёрных кружков

<style>
  <angle>auto</angle>
  <gap>-10</gap>
  <color red="255" green="255" blue="255"/>
  <outlinecolor red="0" green="0" blue="0"/>
  <size>2</size>
  <symbol>std:circle</symbol>
</style>

Выборка

<map>
  <layer>
    <labelitem>NAME</labelitem>
    <classitem>PLACE</classitem>
    <class>
      <expression>"city"</expression>
      <style>
        <color red="255" green="170" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>11.3385826772</size>
        <symbol>std:circle</symbol>

      </style>
      <style>
        <color red="255" green="170" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>5.66929133858</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>18</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
         <position>ur</position>
      </label>
    </class>
    <class>
      <expression>"town"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>11.3385826772</size>
        <symbol>std:circle</symbol>

      </style>
      <style>
        <color red="0" green="0" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>5.66929133858</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>14</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
         <position>ur</position>
      </label>
    </class>
    <class>
      <expression>"village"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>6.8031496063</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
      </label>
    </class>
    <class>
      <expression>"hamlet"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>4.25196850394</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
      </label>
    </class>
    <class>
      <expression>"locality"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>2.83464566929</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>6.5</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
      </label>
    </class>
    <class>
      <expression>''</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>2.83464566929</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
      </label>
    </class>
  </layer>
</map>

Площадной слой с классификацией по значению поля и подписями

<map>
<layer>
  <labelitem>NAME</labelitem>
    <class>
      <expression>(([num] gt 18) and ([num] le 26.1))</expression>
      <style>
        <color red="255" green="255" blue="212"/>
        <outlinecolor blue="64" green="64" red="64"/>

      </style>
       <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>7000000</maxscaledenom>
      </label>
    </class>

      <class>
      <expression>(([num] gt 26.1) and ([num] le 28.1))</expression>
      <style>
       <color red="254" green="217" blue="142"/>
        <outlinecolor blue="64" green="64" red="64"/>

      </style>
         <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>7000000</maxscaledenom>
      </label>
    </class>


    <class>
      <expression>(([num] gt 28.1) and ([num] le 30))</expression>
      <style>
       <color red="254" green="153" blue="41"/>
        <outlinecolor blue="64" green="64" red="64"/>

      </style>
       <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>7000000</maxscaledenom>
      </label>
    </class>

  </layer>
</map>

Кластеризация точек на сервере

<map>
  <symbol>
    <type>ellipse</type>
    <name>shop</name>
    <anchorpoint x="0.5" y="0.5" />
    <points>1 1</points>
    <filled>true</filled>
  </symbol>
  <layer>
    <labelitem>Cluster_FeatureCount</labelitem>
    <classitem>Cluster_FeatureCount</classitem>
    <cluster>
      <maxdistance>20</maxdistance>
      <region>"ellipse"</region>
    </cluster>
    <class>
      <expression>("[Cluster_FeatureCount]" != "1")</expression>
      <style>
        <symbol>shop</symbol>
        <size>20</size>
        <color blue="0" green="0" red="180"/>
        <outlinecolor blue="64" green="64" red="64"/>
      </style>
      <label>
        <type>truetype</type>
        <font>bold-italic</font>
        <size>10</size>
        <color blue="255" green="255" red="255"/>
        <outlinewidth>1</outlinewidth>
        <outlinecolor blue="0" green="0" red="0"/>
        <position>cc</position>
        <offset x="10" y="0" />
      </label>
    </class>
    <class>
      <expression>"1"</expression>
      <style>
        <symbol>shop</symbol>
        <size>10</size>
        <color blue="0" green="0" red="180"/>
        <outlinecolor blue="64" green="64" red="64"/>
      </style>
    </class>

  </layer>
</map>

OSM settlement-point

<!-- Стиль с разделением по масштабам-->
<!-- Версия 2015-07-24 -->
<map>
  <layer>
    <labelitem>NAME</labelitem>
    <classitem>PLACE</classitem>
    <class>
      <expression>"city"</expression> <!-- Большой город -->
      <style>
        <color red="255" green="170" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>11.3385826772</size>
        <symbol>std:circle</symbol>

      </style>
      <style>
        <color red="255" green="170" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>5.66929133858</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>18</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
         <position>ur</position>
      </label>
    </class>
    <class>
      <expression>"town"</expression> <!-- Средний или малый город -->
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>11.3385826772</size>
        <symbol>std:circle</symbol>
        <maxscaledenom>6000000</maxscaledenom>

      </style>
      <style>
        <color red="0" green="0" blue="0"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>5.66929133858</size>
        <symbol>std:circle</symbol>
        <maxscaledenom>6000000</maxscaledenom>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>14</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
         <position>ur</position>
        <maxscaledenom>6000000</maxscaledenom>
      </label>
    </class>
    <class>
      <expression>"village"</expression> <!-- Посёлок  -->
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>6.8031496063</size>
        <symbol>std:circle</symbol>
        <maxscaledenom>1000000</maxscaledenom>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>1000000</maxscaledenom>
      </label>
    </class>
    <class>
      <expression>"hamlet"</expression> <!-- Деревня -->
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>4.25196850394</size>
        <symbol>std:circle</symbol>
        <maxscaledenom>500000</maxscaledenom>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>500000</maxscaledenom>
      </label>
    </class>
    <class>
      <expression>"locality"</expression> <!-- Необитаемая местность -->
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>2.83464566929</size>
        <symbol>std:circle</symbol>
        <maxscaledenom>500000</maxscaledenom>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>6.5</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
        <maxscaledenom>500000</maxscaledenom>
      </label>
    </class>
    <class>
      <expression>''</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>2.83464566929</size>
        <symbol>std:circle</symbol>

      </style>
      <label>
        <type>truetype</type>
        <font>regular</font>
        <size>8.25</size>
        <color blue="0" green="0" red="0"/>
        <outlinewidth>3</outlinewidth>
        <outlinecolor blue="255" green="255" red="255"/>
        <position>ur</position>
      </label>
    </class>
  </layer>
</map>

OSM highway-lowzoom

Дороги общего пользования (мелкие вынесены в отдельный стиль дальше, чтобы можно было отдельно включать-выключать). Цветовая схема - с openstreetmap.de

../../_images/mastyles_osm-highway-lowzoom.png

Рис. 7.145. Фрагмент цветовой схемы дорог общего пользования

<map>
<!-- Highways for low-zoom from openstreetmap (from motorway to residential) version 2015-11-06 -->
    <layer>
        <classitem>Highway</classitem>
        <labelitem>Name</labelitem>
        <class>
            <expression>"motorway"</expression>
            <style>
                <color red="185" green="49" blue="49" />
                <linejoin>round</linejoin>
                <width>8</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="255" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"motorway_link"</expression>
            <style>
                <color red="185" green="49" blue="49" />
                <linejoin>round</linejoin>
                <width>8</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="255" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"trunk"</expression>
            <style>
                <color red="185" green="49" blue="49" />
                <linejoin>round</linejoin>
                <width>8</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="255" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"trunk_link"</expression>
            <style>
                <color red="185" green="49" blue="49" />
                <linejoin>round</linejoin>
                <width>8</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="255" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"primary"</expression>
            <style>
                <color red="141" green="67" blue="70" />
                <linejoin>round</linejoin>
                <width>6.4062992126</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>3.57165354331</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"primary_link"</expression>
            <style>
                <color red="141" green="67" blue="70" />
                <linejoin>round</linejoin>
                <width>6.4062992126</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="226" green="114" blue="114" />
                <linejoin>round</linejoin>
                <width>3.57165354331</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"secondary"</expression>
            <style>
                <color red="163" green="123" blue="72" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="246" green="232" blue="86" />
                <linejoin>round</linejoin>
                <width>3</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"secondary_link"</expression>
            <style>
                <color red="163" green="123" blue="72" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="246" green="232" blue="86" />
                <linejoin>round</linejoin>
                <width>3</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"tertiary"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="179" />
                <linejoin>round</linejoin>
                <width>3</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"tertiary_link"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="179" />
                <linejoin>round</linejoin>
                <width>3</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"unclassified"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>4</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="179" />
                <linejoin>round</linejoin>
                <width>3</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
                <minscaledenom>1</minscaledenom>
                        <maxscaledenom>40000</maxscaledenom>
            </label>
        </class>
        <class>
            <expression>"residential"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>2</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="179" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
                <minscaledenom>1</minscaledenom>
                        <maxscaledenom>40000</maxscaledenom>
            </label>
        </class>
        <class>
            <expression>"living_street"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>2</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="179" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
                <minscaledenom>1</minscaledenom>
                        <maxscaledenom>40000</maxscaledenom>
            </label>
        </class>
    </layer>
</map>

OSM highway-maxzoom

Дороги подъездные, технологические, грунтовые, пешеходные

../../_images/mastyles_osm-highway-highzoom.png

Рис. 7.146. Фрагмент изображения карты дорог

<map>
 <!-- Highways for high-zoom from openstreetmap (from service to track) version 2015-11-06 -->
    <layer>
        <classitem>Highway</classitem>
        <labelitem>Name</labelitem>
        <class>
            <expression>"service"</expression>
            <style>
                <color red="187" green="187" blue="187" />
                <linejoin>round</linejoin>
                <width>2</width>
                <linecap>round</linecap>
            </style>
            <style>
                <color red="255" green="255" blue="255" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"footway"</expression>
            <style>
                <color red="255" green="0" blue="0" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
            </style>
            <label>
                <type>truetype</type>
                <font>regular</font>
                <size>7</size>
                <color blue="0" green="0" red="0" />
                <outlinewidth>1</outlinewidth>
                <outlinecolor blue="255" green="255" red="255" />
                <angle>follow</angle>
                <antialias>true</antialias>
                <repeatdistance>300</repeatdistance>
                <maxoverlapangle>20.0</maxoverlapangle>
            </label>
        </class>
        <class>
            <expression>"pedestrian"</expression>
            <style>
                <color red="255" green="0" blue="0" />
                <linejoin>round</linejoin>
                <width>2</width>
                <linecap>round</linecap>
            </style>
        </class>
        <class>
            <expression>"path"</expression>
            <style>
                <color red="255" green="0" blue="0" />
                <linejoin>round</linejoin>
                <width>1</width>
                <linecap>round</linecap>
                <pattern>5 5</pattern>
            </style>
        </class>
        <class>
            <expression>"track"</expression>
            <style>
                <color red="153" green="116" blue="43" />
                <linejoin>round</linejoin>
                <width>2</width>
                <pattern>16 8</pattern>
                <linecap>round</linecap>
            </style>
        </class>
    </layer>
</map>

OSM railway-line

<!-- Стиль railway-line с разделением по масштабам
version 2015-07-24 -->
<map>
  <layer>
    <classitem>RAILWAY</classitem>
    <class>
      <expression>"abandoned"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <linejoin>round</linejoin>
        <width>2.83464566929</width>
        <linecap>round</linecap>
      </style>
      <style>
        <pattern>2.35275590551 4.70551181102</pattern>
        <color red="165" green="165" blue="165"/>
        <linejoin>round</linejoin>
        <width>2.35275590551</width>
        <linecap>round</linecap>
      </style>
    </class>
        <class>
      <expression>"razed"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <linejoin>round</linejoin>
        <width>2.83464566929</width>
        <linecap>round</linecap>
      </style>
      <style>
        <pattern>2.35275590551 4.70551181102</pattern>
        <color red="255" green="165" blue="210"/>
        <linejoin>round</linejoin>
        <width>2.35275590551</width>
        <linecap>round</linecap>
      </style>
    </class>
    <class>
      <expression>"construction"</expression>
      <style>
        <color red="255" green="255" blue="255"/>
        <linejoin>round</linejoin>
        <width>2.83464566929</width>
        <linecap>round</linecap>
      </style>
      <style>
        <pattern>2.35275590551 4.70551181102</pattern>
        <color red="255" green="0" blue="127"/>
        <linejoin>round</linejoin>
        <width>2.35275590551</width>
        <linecap>round</linecap>
      </style>
    </class>
    <class>
      <expression>"crossing"</expression>
      <style>
        <color red="37" green="37" blue="255"/>
        <linejoin>bevel</linejoin>
        <width>0.737007874016</width>
        <linecap>square</linecap>
      </style>
    </class>
    <class>
      <expression>"light_rail"</expression>
      <style>
        <color red="0" green="0" blue="0"/>
        <linejoin>bevel</linejoin>
        <width>1.41732283465</width>
        <linecap>square</linecap>
      </style>
    </class>
    <class>
      <expression>"narrow_gauge"</expression>
      <style>
        <color red="150" green="150" blue="150"/>
        <linejoin>bevel</linejoin>
        <width>1.41732283465</width>
        <linecap>square</linecap>
      </style>
    </class>
    <class>
      <expression>"platform"</expression>
      <style>
        <color red="0" green="0" blue="0"/>
        <linejoin>bevel</linejoin>
        <width>4.25196850394</width>
        <linecap>square</linecap>
      </style>
    </class>
    <class>
      <expression>"rail"</expression>
      <style>
        <color red="0" green="0" blue="0"/>
        <linejoin>bevel</linejoin>
        <width>2.83464566929</width>
        <linecap>square</linecap>
        <maxscaledenom>25000</maxscaledenom> <!-- Чёрно-белая линия на крупном масштабе -->
      </style>
      <style>
        <pattern>9.41102362205 14.1165354331</pattern>
        <color red="255" green="255" blue="255"/>
        <linejoin>bevel</linejoin>
        <width>2.35275590551</width>
        <linecap>square</linecap>
        <maxscaledenom>25000</maxscaledenom> <!-- Чёрно-белая линия на крупном масштабе -->
      </style>
       <style>

        <color red="0" green="0" blue="0"/>
        <linejoin>bevel</linejoin>
        <width>2</width>
        <linecap>square</linecap>
        <minscaledenom>25000</minscaledenom> <!-- Чёрная линия на среднем масштабе -->
      </style>
    </class>
    <class>
      <expression>"siding"</expression>
      <style>
        <color red="145" green="145" blue="145"/>
        <linejoin>bevel</linejoin>
        <width>1.41732283465</width>
        <linecap>square</linecap>
      </style>
    </class>
    <class>
      <expression>"subway"</expression>
      <style>
        <pattern>1.41732283465 2.83464566929</pattern>
        <color red="155" green="155" blue="155"/>
        <linejoin>round</linejoin>
        <width>1.41732283465</width>
        <linecap>round</linecap>
      </style>
    </class>
    <class>
      <expression>"tram"</expression>
      <style>
        <color red="0" green="0" blue="0"/>
        <linejoin>bevel</linejoin>
        <width>1.41732283465</width>
        <linecap>square</linecap>
      </style>
    </class>
  </layer>
</map>

OSM water-line

<!-- Стиль water-line с разделением по масштабам-->
<!-- Версия 2015-07-24 -->
<map>
  <layer>
    <classitem>Waterway</classitem>
    <labelitem>name</labelitem>
    <class>
      <expression>"river"</expression>
      <style>
        <color red="102" green="153" blue="204"/>
        <linejoin>round</linejoin>
        <width>3</width>
        <linecap>round</linecap>
        <!-- Остались необработанные атрибуты: width_unit, offset_unit, customdash_unit -->
      </style>
      <label>
        <type>truetype</type> <!-- Подпись -->
        <font>bold</font>
        <size>7</size>
        <color blue="255" green="255" red="255"/>
        <outlinewidth>1</outlinewidth>
        <outlinecolor red="102" green="153" blue="204"/>
        <angle>auto</angle>
        <repeatdistance>300</repeatdistance>
        <maxoverlapangle>90.0</maxoverlapangle>
        <maxscaledenom>500000</maxscaledenom>
      </label>
      </class>

      <class>
      <expression>"canal"</expression>
      <style><!-- вертикальные линии -->
        <angle>auto</angle>
        <gap>-8.50393700787</gap>
        <!-- Остались необработанные атрибуты: interval_unit, placement, offset_unit, offset -->
        <color red="102" green="153" blue="204"/>
        <outlinecolor red="0" green="0" blue="0"/>
        <size>15.66929133858</size>
        <symbol>std:line</symbol>
        <!-- Остались необработанные атрибуты: outline_width, offset_unit, outline_width_unit, size_unit -->
      </style>
      <style>
        <color red="102" green="153" blue="204"/>
        <linejoin>round</linejoin>
        <width>3</width>
        <linecap>round</linecap>
        <!-- Остались необработанные атрибуты: width_unit, offset_unit, customdash_unit -->
      </style>
      <label>
        <type>truetype</type> <!-- Подпись -->
        <font>bold</font>
        <size>7</size>
        <color blue="255" green="255" red="255"/>
        <outlinewidth>1</outlinewidth>
        <outlinecolor red="102" green="153" blue="204"/>
        <angle>auto</angle>
        <repeatdistance>300</repeatdistance>
        <maxoverlapangle>90.0</maxoverlapangle>
        <maxscaledenom>500000</maxscaledenom>
      </label>
      </class>

      <class>
      <expression>"stream"</expression>
      <style>
        <color red="102" green="153" blue="204"/>
        <linejoin>round</linejoin>
        <width>1.5</width>
        <linecap>round</linecap>
        <maxscaledenom>250000</maxscaledenom>
        <!-- Остались необработанные атрибуты: width_unit, offset_unit, customdash_unit -->
      </style>
      </class>

      <class>
      <expression>"drain"</expression>
      <style>
        <color red="102" green="153" blue="204"/>
        <linejoin>round</linejoin>
        <width>1</width>
        <linecap>round</linecap>
        <maxscaledenom>250000</maxscaledenom>
        <!-- Остались необработанные атрибуты: width_unit, offset_unit, customdash_unit -->
      </style>
      </class>
  </layer>
</map>

OSM water-polygon

<!-- стиль water-polygon
Версия 2015-07-24
Нужно добавить
-водохранилища
-штриховку для болот
-->
<map>
  <layer>
    <labelitem>NAME</labelitem>
    <classitem>NATURAL</classitem>
    <class>
      <expression>"water"</expression> <!-- Вода -->
      <style>
        <color red="102" green="153" blue="204"/>
        <outlinecolor red="102" green="153" blue="204"/>
      </style>
         <label>
        <type>truetype</type>
        <font>regular</font>
        <size>7</size>
        <color red="102" green="153" blue="204"/>
        <outlinewidth>2</outlinewidth>
        <outlinecolor red="255" green="255" blue="222"/>
        <!-- Ограничение подписи по масштабу -->
        <minscaledenom>1</minscaledenom>
        <maxscaledenom>100000</maxscaledenom>
      </label>
    </class>
    <class>
      <expression>"wetland"</expression> <!-- Болото -->
          <style>
        <color red="102" green="153" blue="204"/>
        <outlinecolor red="102" green="153" blue="204"/>
      </style>
         <label>
        <type>truetype</type>
        <font>regular</font>
        <size>7</size>
        <color red="102" green="153" blue="204"/>
        <outlinewidth>2</outlinewidth>
        <outlinecolor red="255" green="255" blue="222"/>
        <!-- Ограничение подписи по масштабу -->
        <minscaledenom>1</minscaledenom>
        <maxscaledenom>100000</maxscaledenom>
      </label>
    </class>
  </layer>
</map>

OSM landuse-polygon

Стили NextGIS Web поддерживают различные штриховки (см. Рис. 7.147.).

<map> <!-- Демонстрация штриховок, предполагается что под этим слоем будет чёрный фон-->
    <layer>
        <labelitem>OSM_ID</labelitem>
        <classitem>LANDUSE</classitem>
        <class>
            <expression>"residential"</expression>
            <!-- Жилые зоны -->
            <style>
                <!-- штриховка направо -->
                <color red="255" green="185" blue="33"/>
                <width>1.4</width>
                <symbol>std:line</symbol>
                <gap>3</gap>
                <size>1</size>
                <angle>90</angle>
            </style>
            <style>
                <!-- Обводка -->
                <outlinecolor red="255" green="185" blue="33"/>
                <width>0.5</width>
            </style>
        </class>
        <class>
            <expression>"grass"</expression>
            <!-- Газоны зоны -->
            <style>
                <!-- Линии -->
                <color red="20" green="255" blue="33"/>
                <width>1</width>
                <symbol>std:line</symbol>
                <gap>6</gap>
                <size>4</size>
                <angle>0</angle>
                <pattern>2.5 4.5</pattern>
            </style>
            <style>
                <!-- Обводка -->
                <outlinecolor red="20" green="255" blue="33"/>
                <width>0.5</width>
            </style>
        </class>
        <class>
            <expression>"commercial"</expression>
            <!-- Жилые зоны -->
            <style>
                <!-- штриховка направо -->
                <color red="133" green="33" blue="25"/>
                <width>1.4</width>
                <symbol>std:line</symbol>
                <gap>10</gap>
                <size>5</size>
                <angle>45</angle>
            </style>
            <style>
                <!-- Обводка -->
                <outlinecolor red="133" green="33" blue="25"/>
                <width>0.5</width>
            </style>
        </class>
        <class>
            <expression>"industrial"</expression>
            <!-- Промзоны -->
            <style>
                <!-- штриховка направо -->
                <color red="255" green="50" blue="50"/>
                <width>0.4</width>
                <symbol>std:hatch</symbol>
                <gap>10</gap>
                <size>5</size>
                <angle>45</angle>
            </style>
            <style>
                <!-- штриховка налево-->
                <color red="255" green="50" blue="50"/>
                <width>0.4</width>
                <symbol>std:hatch</symbol>
                <gap>10</gap>
                <size>5</size>
                <angle>-45</angle>
            </style>
            <style>
                <!-- Обводка -->
                <outlinecolor red="255" green="50" blue="50"/>
                <width>0.5</width>
            </style>
        </class>
        <class>
            <expression>"cemetery"</expression>
            <!-- Кладбоны -->
            <style>
                <!-- оградки -->
                <color red="14" green="166" blue="0"/>
                <width>1.4</width>
                <symbol>std:rectangle</symbol>
                <gap>20</gap>
                <size>11</size>
                <angle>0</angle>
            </style>
            <style>
                <!-- оградки -->
                <color red="0" green="0" blue="0"/>
                <width>1.2</width>
                <symbol>std:rectangle</symbol>
                <gap>20</gap>
                <size>10</size>
                <angle>0</angle>
            </style>
            <style>
                <!-- кресты -->
                <color red="14" green="166" blue="0"/>
                <width>1.4</width>
                <symbol>std:cross</symbol>
                <gap>20</gap>
                <size>9</size>
                <angle>0</angle>
            </style>
            <style>
                <!-- Обводка -->
                <outlinecolor red="14" green="166" blue="0"/>
                <width>0.5</width>
            </style>
        </class>
    </layer>
</map>

Использование стиля из поля векторного слоя

Имеется возможность настройки стиля отрисовки векторных данных для каждой записи индивидуально. Для этого необходимо завести поле с описание стиля в формате ORG Style. Например,

ogr2ogr -f GeoJSON -sql "select *, OGR_STYLE from Australia" australia.geojson Australia.TAB

Описание формата ORG Style можно изучить по странице Feature Style Specification.

Для векторного слоя с полем OGR_STYLE которое содержит стиль записи необходимо выставить следующий стиль NextGIS Web Mapserver:

<map>
  <layer>
    <styleitem>OGR_STYLE</styleitem>
    <class>
      <name>default</name>
    </class>
  </layer>
</map>

Теги языка картостилей Mapserver

Для правки стиля или написания нового рекомендуется взять код какого-нибудь существующего стиля из примера, и потом дополнять его, а не писать с нуля.

Общие теги

  • <color red=»255» green=»170» blue=»127»/> - цвет заливки или линии

  • <outlinecolor red=»106» green=»106» blue=»106»/> - цвет обводки

  • <width>0.5</width> - толщина линии или границы полигона в пикселях.

  • <outlinewidth>3</outlinewidth> - ширина обводки

  • <minscaledenom>1</minscaledenom> - не рисовать объект на масштабе больше указанного (когда карта крупнее чем)

  • <maxscaledenom>100000</maxscaledenom> - не рисовать объект на масштабе меньше указанного (когда карта мельче чем)

Значки

../../_images/mapstyle_hatch_demo.png

Рис. 7.147. Демонстрация различных видов штриховок

  • <symbol>std:circle</symbol> - тип значка

    • std:rectangle - квадратик

    • std:circle - кружок

    • std:diamond - ромбик

    • std:triangle - треугольник острием вверх

    • std:triangle-equilateral - треугольник острием вниз

    • std:star - пятиконечная звёздочка

    • std:pentagon - пятиугольник

    • std:arrow - стрелка (по умолчанию вверх, можно поворачивать тегом <angle>45</angle>)

    • std:cross - +

    • std:xcross - x

    • std:line - коротенькая линия

    • std:hatch - длинная линия, стыкующаяся в текстуру

Эти значки можно использовать для рисования линии, заливки полигонов, или обозначения точек. Так же их можно комбинировать в такую конструкцию:

       <class>
           <expression>"industrial"</expression>
           <!-- Промзоны -->
           <style> <!-- штриховка направо -->
               <color red="255" green="50" blue="50"/>
               <width>1.4</width>
               <symbol>std:hatch</symbol>
               <gap>10</gap>
               <size>5</size>
               <angle>45</angle>
           </style>
           <style> <!-- штриховка налево-->
               <color red="255" green="50" blue="50"/>
               <width>1.4</width>
               <symbol>std:hatch</symbol>
               <gap>10</gap>
               <size>5</size>
               <angle>-45</angle>
           </style>
           <style> <!-- Обводка -->
               <outlinecolor red="255" green="50" blue="50"/>
               <width>0.5</width>
           </style>
</class>
  • <size>2</size> - размер значка в пикселях

Линейные объекты

  • <gap>10</gap> - шаг пунктира (используется вместе с <symbol>std:circle</symbol>)

  • <width>8</width> - ширина линии в пикселах

  • <classitem>PLACE</classitem> - выборка по атрибуту с названием PLACE. Так же смотрите пример в #Выборка. Поддерживаются следующие операторы

    • имя атрибута

    • !=

    • >=

    • <=

    • <

    • >

    • =* - сравнение строк без учёта раскладки.

    • =

    • lt - меньше

    • gt - больше

    • ge - больше или равно

    • le - меньше или равно

    • eq - равно

    • ne - не равно

    • and - И

    • && - И

    • or - ИЛИ

    • || - ИЛИ

  • <linejoin>round</linejoin> - рисование линии в углах поворота

  • <linecap>round</linecap> - рисование начала и конца линии

../../_images/admin_mapstyles_linecap.png

Рис. 7.148. Пример <linecap>butt</linecap> / <linecap>round</linecap> / <linecap>square</linecap>.

  • <pattern>2.5 4.5</pattern> - шаблон пунктира

  • <angle> - угол поворота значка. Так же можно поворачивать штриховку.

Подписи

  • <labelitem>a_hsnmbr</labelitem> - название атрибута, из которого берётся подпись.

  • <minscaledenom>100</minscaledenom> - не выводить подпись на масштабе крупнее 1:1000

  • <maxscaledenom>100000</maxscaledenom> - не выводить подпись на масштабе мельче 1:100000

  • <position>ur</position> - направление сдвига подписи.

    • ur - ↗ вверх вправо (в книгах по картографии рекомендуют так делать по умолчанию)

    • ul - ↖

    • uc - ↑

    • cl - ←

    • cc - строго по центру

    • cr - →

    • ll - ↙

    • lc - ↓

    • lr - ↘

    • auto

Другие полезные тэги

  • MAXGEOWIDTH - Максимальная ширина, в единицах измерения карты, при которой задействуется LAYER. Если также указан параметр MAXSCALEDENOM, он имеет приоритет и будет использован именно MAXSCALEDENOM.

  • MINGEOWIDTH - Минимальная ширина, в единицах карты, при которой задействуется LAYER. Если также указан параметр MINSCALEDENOM, он имеет приоритет и будет использован именно MINSCALEDENOM.

  • OFFSITE - Задает индекс цветов, которые будут обрабатываться как прозрачные (для растровых слоев).

  • OPACITY [integer|alpha] - непрозрачность слоя

  • SIZEUNITS [feet|inches|kilometers|meters|miles|nauticalmiles|pixels] - Задает единицу измерения значения SIZE объектов, включенных в CLASS (по умолчанию - в пикселях).

  • SYMBOLSCALEDENOM [double] - Масштаб, при котором символы и/или текст показываются в полном размере. Это делает возможным динамическое масштабирование объектов в соответствии с масштабом карты. Если этот параметр не задан, слой всегда будет отображаться в одном и том же размере. Масштабирование происходит только в рамках, заданных тэгами MINSIZE и MAXSIZE (см выше). Вводится значение знаменателя масштаба, например для карты с масштабом 1:24000 введите 24000.

  • TYPE [chart|circle|line|point|polygon|raster|query] - Указывает, как должны выводиться данные. Не обязательно должен совпадать с типом геометрии объектов. Например, полигоны или полилинии могут выводиться как точечный слой.

С помощью этих тэгов можно модифицировать шаблоны стилей Mapserver.