【2】线

197 阅读17分钟

简单线条

本示例指定线条为黑色,粗细为 3 像素。

../../../_images/line_simpleline.png

简单线条

法典

View and download the full "Simple line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#000000</CssParameter>
 6            <CssParameter name="stroke-width">3</CssParameter>
 7          </Stroke>
 8        </LineSymbolizer>
 9      </Rule>
10    </FeatureTypeStyle>

这个SLD有一个合一,这是最简单的情况。(全部 除非另有说明,否则后续示例将包含一个和一个。造型 行通过(第 3-8 行)完成。第 5 行指定要用于的线条的颜色 黑色 (),而第 6 行将线条的宽度指定为 3 像素。<Rule>``<FeatureTypeStyle>``<Rule>``<FeatureTypeStyle>``<LineSymbolizer>``#000000

带边框的线

此示例演示如何绘制带边框的线条(有时称为“大小写线”)。 在这种情况下,线条绘制有 3 像素的蓝色中心和 1 像素宽的灰色边框。

../../../_images/line_linewithborder.png

带边框的线

法典

View and download the full "Line with border" SLD

 1    <FeatureTypeStyle>
 2       <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#333333</CssParameter>
 6            <CssParameter name="stroke-width">5</CssParameter>
 7            <CssParameter name="stroke-linecap">round</CssParameter>
 8          </Stroke>
 9        </LineSymbolizer>
10      </Rule>
11    </FeatureTypeStyle>
12    <FeatureTypeStyle>
13       <Rule>
14        <LineSymbolizer>
15        <Stroke>
16            <CssParameter name="stroke">#6699FF</CssParameter>
17            <CssParameter name="stroke-width">3</CssParameter>
18            <CssParameter name="stroke-linecap">round</CssParameter>
19          </Stroke>
20        </LineSymbolizer>
21       </Rule>
22    </FeatureTypeStyle>

SLD中的线条没有“填充”的概念,只有“描边”。因此,与点或面不同,无法设置 线几何图形的“边”。但是,可以通过绘制每条线两次来实现此效果:一次使用 一定的宽度,再次以略小的宽度。这通过掩盖 除较小线条的边缘外,所有位置都有较大的线条。

由于每条线都绘制两次,因此渲染的顺序非常重要。 地理服务器按照它们在 SLD 中的显示顺序进行渲染。 在此样式中,灰色边框线 首先通过第一个绘制,然后通过第二个绘制蓝色中心线。这可确保蓝线不会被灰线遮挡, 并确保在十字路口正确渲染,以便蓝线“连接”。<FeatureTypeStyle>``<FeatureTypeStyle>``<FeatureTypeStyle>

在此示例中,第 1-11 行包含第一行,即外线(或“笔划”)。第 5 行指定线条的颜色为深灰色 (),第 6 行指定此行的宽度 为 5 像素,在第 7 行中,参数 of 将线条的末端呈现为圆角而不是平坦。 (使用圆形线帽处理边框线时,可确保边框在线条的末端正确连接。<FeatureTypeStyle>``#333333``stroke-linecap``round

第12-22行包括第二条线,即内线(或“填充”)。第 16 行将线条的颜色指定为中蓝色 (),第 17 行将此行的宽度指定为 3 像素,第 18 行再次将线条的边缘呈现为圆角而不是平整。<FeatureTypeStyle>``#6699FF

结果是一条带有 3 像素灰色边框的 1 像素蓝线,因为 5 像素灰线将在每个像素上显示 1 个像素 3 像素蓝线的一侧。

虚线

本示例更改“简单”线,创建一条由 5 个像素组成的虚线 与 2 个像素的空白区域交替的线条。

../../../_images/line_dashedline.png

虚线

法典

View and download the full "Dashed line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#0000FF</CssParameter>
 6            <CssParameter name="stroke-width">3</CssParameter>
 7            <CssParameter name="stroke-dasharray">5 2</CssParameter>
 8          </Stroke>
 9        </LineSymbolizer>
10      </Rule>
11    </FeatureTypeStyle>

在此示例中,第 5 行将线条的颜色设置为蓝色 (),第 6 行设置 行为 3 像素。第 7 行确定线条虚线的组成。的值创建一个 重复绘制线的 5 个像素,然后是省略线的 2 个像素。#0000FF``5 2

偏移线

本示例修改“简单”线,在左侧添加一条垂直偏移线 的线,距离为 5 个像素。

../../../_images/line_offset.png

偏移线

法典

View and download the full "Dashed line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#000000</CssParameter>
 6          </Stroke>
 7        </LineSymbolizer>
 8        <LineSymbolizer>
 9          <Stroke>
10            <CssParameter name="stroke">#FF0000</CssParameter>
11            <CssParameter name="stroke-dasharray">5 2</CssParameter>
12          </Stroke>
13          <PerpendicularOffset>5</PerpendicularOffset>
14        </LineSymbolizer>
15      </Rule>
16    </FeatureTypeStyle>

在此示例中,第一个线符号化器只是将线涂成黑色。第 8 行开始第二个线符号化器,将第 10 行的线颜色设置为红色 (),然后 确定第 11 行处虚线的组成。第 13 行最后指定 5 个像素的垂直偏移量(正,因此在左侧)。#FF0000

铁路(孵化)

此示例使用剖面线创建铁路样式。线和图案填充均为黑色,具有 2 像素 主线的厚度和垂直图案填充的 1 像素宽度。

注意

 

此示例利用 GeoServer 中的 SLD 扩展。剖面线不是标准 SLD 1.0 规范的一部分。

../../../_images/line_railroad.png

铁路(孵化)

法典

View and download the full "Railroad (hatching)" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#333333</CssParameter>
 6            <CssParameter name="stroke-width">3</CssParameter>
 7          </Stroke>
 8        </LineSymbolizer>
 9        <LineSymbolizer>
10          <Stroke>
11            <GraphicStroke>
12              <Graphic>
13                <Mark>
14                  <WellKnownName>shape://vertline</WellKnownName>
15                  <Stroke>
16                    <CssParameter name="stroke">#333333</CssParameter>
17                    <CssParameter name="stroke-width">1</CssParameter>
18                  </Stroke>
19                </Mark>
20                <Size>12</Size>
21              </Graphic>
22            </GraphicStroke>
23          </Stroke>
24        </LineSymbolizer>
25      </Rule>
26    </FeatureTypeStyle>

在此示例中,有两个 s。 第一个符号化器位于第 3-8 行,绘制一条标准线,第 5 行将线绘制为深灰色 () 和第 6 行将行的宽度设置为 2 像素。<LineSymbolizer>``#333333

剖面线在第 9-24 行的第二个符号化器中调用。第 14 行指定符号化器绘制垂直线 垂直于线几何图形的填充 ()。第 16-17 行将填充颜色设置为深灰色 () 和宽度为 1 像素。最后,第 20 行指定了填充的长度和距离 每个影线之间均为 12 像素。shape://vertline``#333333

间隔图形符号

本示例使用图形描边和虚线数组来创建“点和空格”线型。 添加破折号数组规范可以控制一个符号和下一个符号之间的间距量。 不使用破折号 排列行将密集填充点,每个点都接触前一个点。

注意:

此示例可能不适用于使用 SLD 的其他系统,因为它们可能不支持组合使用笔划虚线数组图形笔画。 虽然 SLD 符合规范,但 SLD 规范并未说明此组合应该产生什么。

../../../_images/line_dashspace.png

沿线间隔的符号

法典

View and download the full "Spaced symbols" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <GraphicStroke>
 6              <Graphic>
 7                <Mark>
 8                  <WellKnownName>circle</WellKnownName>
 9                  <Fill>
10                    <CssParameter name="fill">#666666</CssParameter>
11                  </Fill>
12                  <Stroke>
13                    <CssParameter name="stroke">#333333</CssParameter>
14                    <CssParameter name="stroke-width">1</CssParameter>
15                  </Stroke>
16                </Mark>
17                <Size>4</Size>
18              </Graphic>
19            </GraphicStroke>
20            <CssParameter name="stroke-dasharray">4 6</CssParameter>
21          </Stroke>
22        </LineSymbolizer>
23      </Rule>
24    </FeatureTypeStyle>

与前面的其他示例一样,此示例使用 a 沿线条放置图形符号。符号, 定义 在第 7-16 行处是一个 4 像素的灰色圆圈,具有深灰色轮廓。符号之间的间距由 at 第 20 行,指定 4 个像素的笔下(刚好足以画圆)和 6 个像素的笔向上, 以提供间距。GraphicStroke``stroke-dasharray

带短划线偏移的交替符号

此示例演示如何创建交替使用虚线和图形符号的复杂线条样式。 该代码基于前面示例中所示的功能构建:

  • stroke-dasharray控制向下/向下笔行为以生成虚线
  • GraphicStroke沿线放置符号
  • 将两者结合起来可以控制符号间距

这也显示了破折号偏移的用法,它控制渲染的开始位置 在破折号数组中。 例如,破折号数组为 和破折号偏移量为 渲染器从头开始绘制 7 像素的图案。它跳过了 5 像素笔下 部分和笔向上部分的 2 个像素,然后绘制笔向上的剩余 8 个像素,然后绘制 5 个向下,10 个向上,依此类推。5 10``7

该示例演示如何使用这些功能创建两个同步的破折号数组序列, 一个绘制线段和其他符号。

注意:

此示例可能不适用于使用 SLD 的其他系统,因为它们可能不支持组合使用笔划虚线数组图形笔画。 虽然 SLD 符合规范,但 SLD 规范并未说明此组合应该产生什么。

../../../_images/line_dashdot.png

交替使用破折号和符号

法典

View and download the full "Spaced symbols" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#0000FF</CssParameter>
 6            <CssParameter name="stroke-width">1</CssParameter>
 7            <CssParameter name="stroke-dasharray">10 10</CssParameter>
 8          </Stroke>
 9        </LineSymbolizer>
10        <LineSymbolizer>
11          <Stroke>
12            <GraphicStroke>
13              <Graphic>
14                <Mark>
15                  <WellKnownName>circle</WellKnownName>
16                  <Stroke>
17                    <CssParameter name="stroke">#000033</CssParameter>
18                    <CssParameter name="stroke-width">1</CssParameter>
19                  </Stroke>
20                </Mark>
21                <Size>5</Size>
22              </Graphic>
23            </GraphicStroke>
24            <CssParameter name="stroke-dasharray">5 15</CssParameter>
25            <CssParameter name="stroke-dashoffset">7.5</CssParameter>
26          </Stroke>
27        </LineSymbolizer>
28      </Rule>
29    </FeatureTypeStyle>

在此示例中,两个 s 使用和不同的符号系统 以生成一系列交替的破折号和符号。第一个符号化器 (第 3-9 行)是一条简单的虚线,交替使用 10 个像素的笔下和 10 个像素的笔向上。 第二个符号化器(第 10-27 行)将 5 像素的空圆圈与 15 像素的空白区域交替使用。 圆形符号由元素生成,并指定其符号系统 按参数(第 17-18 行)。 符号之间的间距由 (第 24 行),指定 5 个向下笔像素(刚好足以绘制圆圈)和 15 个像素的笔向上。 为了使两个序列正确定位,第二个序列使用7.5(第25行)。 这使得序列从 12.5 开始 像素,然后是一个圆(然后在另一个图案的两个线段之间居中), 然后是 15 像素的空白,依此类推。LineSymbolizer``stroke-dasharray``Mark``stroke``stroke-dasharray``stroke-dashoffset

带有默认标签的行

此示例显示简单行上的文本标签。这是在没有任何其他标签的情况下显示标签的方式 定制。

../../../_images/line_linewithdefaultlabel.png

带有默认标签的行

法典

View and download the full "Line with default label" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#FF0000</CssParameter>
 6          </Stroke>
 7        </LineSymbolizer>
 8        <TextSymbolizer>
 9          <Label>
10            <ogc:PropertyName>name</ogc:PropertyName>
11          </Label>
12          <LabelPlacement>
13            <LinePlacement />
14          </LabelPlacement>
15          <Fill>
16            <CssParameter name="fill">#000000</CssParameter>
17          </Fill>
18        </TextSymbolizer>
19      </Rule>
20    </FeatureTypeStyle>

Details

In this example, there is one rule with a and a . The (lines 3-7) draws red lines (). Since no width is specified, the default is set to 1 pixel. The (lines 8-15) determines the labeling of the lines. Lines 9-11 specify that the text of the label will be determined by the value of the “name” attribute for each line. (Refer to the attribute table in the Example lines layer section if necessary.) Line 13 sets the text color to black. All other details about the label are set to the renderer default, which here is Times New Roman font, font color black, and font size of 10 pixels.<LineSymbolizer>``<TextSymbolizer>``<LineSymbolizer>``#FF0000``<TextSymbolizer>

Label following line

This example renders the text label to follow the contour of the lines.

Note

 

Labels following lines is an SLD extension specific to GeoServer. It is not part of the SLD 1.0 specification.

../../../_images/line_labelfollowingline.png

Label following line

Code

View and download the full "Label following line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#FF0000</CssParameter>
 6          </Stroke>
 7        </LineSymbolizer>
 8        <TextSymbolizer>
 9          <Label>
10            <ogc:PropertyName>name</ogc:PropertyName>
11          </Label>
12          <LabelPlacement>
13            <LinePlacement />
14          </LabelPlacement>
15          <Fill>
16            <CssParameter name="fill">#000000</CssParameter>
17          </Fill>
18          <VendorOption name="followLine">true</VendorOption>
19        </TextSymbolizer>
20      </Rule>
21    </FeatureTypeStyle>

Details

As the Alternating symbols with dash offsets example showed, the default label behavior isn’t optimal. The label is displayed at a tangent to the line itself, leading to uncertainty as to which label corresponds to which line.

This example is similar to the Alternating symbols with dash offsets example with the exception of lines 12-18Line 18 sets the option to have the label follow the line, while lines 12-14 specify that the label is placed along a line. If is not specified in an SLD, then is assumed, which isn’t compatible with line-specific rendering options.<LinePlacement />``<PointPlacement />

Note

 

Not all labels are shown due to label conflict resolution. See the next section on Optimized label placement for an example of how to maximize label display.

Optimized label placement

This example optimizes label placement for lines such that the maximum number of labels are displayed.

注意

 

此示例使用特定于 GeoServer 的选项,这些选项不属于 SLD 1.0 规范。

../../../_images/line_optimizedlabel.png

优化标签

法典

View and download the full "Optimized label" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#FF0000</CssParameter>
 6          </Stroke>
 7        </LineSymbolizer>
 8        <TextSymbolizer>
 9          <Label>
10            <ogc:PropertyName>name</ogc:PropertyName>
11          </Label>
12          <LabelPlacement>
13             <LinePlacement />
14          </LabelPlacement>
15          <Fill>
16            <CssParameter name="fill">#000000</CssParameter>
17          </Fill>
18          <VendorOption name="followLine">true</VendorOption>
19          <VendorOption name="maxAngleDelta">90</VendorOption>
20          <VendorOption name="maxDisplacement">400</VendorOption>
21          <VendorOption name="repeat">150</VendorOption>
22        </TextSymbolizer>
23      </Rule>
24    </FeatureTypeStyle>

GeoServer 使用“冲突解决”来确保标注不会绘制在其他标注之上,从而掩盖两者。 这解释了为什么在上一示例“标签后行”中许多行没有标签的原因。虽然可以切换此设置,但通常最好将其保留 ,并使用其他标签放置选项,以确保根据需要在正确的位置绘制标签。 这个例子就是这样做的。

此示例类似于上一个示例“标签”行。唯一的区别包含在第 18-21 行中。第 19 行设置标签将遵循的最大角度。这会将标签设置为永远不会弯曲超过 90 度,以防止标签因明显的曲线或角度而变得难以辨认。第 20 行将标签的最大位移设置为 400 像素。为了解决与重叠标注的冲突,GeoServer 将尝试移动标注,使其不再重叠。此值设置标签相对于其原始位置可以移动的距离。最后,第 21 行将标签设置为每 150 像素重复一次。一个要素通常只会接收一个标注,但这可能会导致长线混淆。将标签设置为重复可确保始终在本地标记该行。

优化和样式化的标签

本示例改进了“优化标签放置”示例中标签的样式。

../../../_images/line_optimizedstyledlabel.png

优化和样式化的标签

法典

View and download the full "Optimized and styled label" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <LineSymbolizer>
 4          <Stroke>
 5            <CssParameter name="stroke">#FF0000</CssParameter>
 6          </Stroke>
 7        </LineSymbolizer>
 8        <TextSymbolizer>
 9          <Label>
10            <ogc:PropertyName>name</ogc:PropertyName>
11          </Label>
12          <LabelPlacement>
13            <LinePlacement />
14          </LabelPlacement>
15          <Fill>
16            <CssParameter name="fill">#000000</CssParameter>
17          </Fill>
18          <Font>
19            <CssParameter name="font-family">Arial</CssParameter>
20            <CssParameter name="font-size">10</CssParameter>
21            <CssParameter name="font-style">normal</CssParameter>
22            <CssParameter name="font-weight">bold</CssParameter>
23          </Font>
24          <VendorOption name="followLine">true</VendorOption>
25          <VendorOption name="maxAngleDelta">90</VendorOption>
26          <VendorOption name="maxDisplacement">400</VendorOption>
27          <VendorOption name="repeat">150</VendorOption>
28        </TextSymbolizer>
29      </Rule>
30    </FeatureTypeStyle>

此示例类似于优化的标签放置。唯一的区别是字体信息,它包含在第 18-23 行中。第 19 行将字体系列设置为“Arial”,第 20 行将字体大小设置为 10,第 21 行将字体样式设置为“正常”(与“斜体”或“倾斜”相对), 22 行将字体粗细设置为“粗体”(而不是“正常”)。****

基于属性的线

本示例根据“type”(Road 类)属性以不同的方式设置线条样式。

../../../_images/line_attributebasedline.png

基于属性的线

法典

View and download the full "Attribute-based line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <Name>local-road</Name>
 4        <ogc:Filter>
 5          <ogc:PropertyIsEqualTo>
 6            <ogc:PropertyName>type</ogc:PropertyName>
 7            <ogc:Literal>local-road</ogc:Literal>
 8          </ogc:PropertyIsEqualTo>
 9        </ogc:Filter>
10        <LineSymbolizer>
11          <Stroke>
12            <CssParameter name="stroke">#009933</CssParameter>
13            <CssParameter name="stroke-width">2</CssParameter>
14          </Stroke>
15        </LineSymbolizer>
16      </Rule>
17    </FeatureTypeStyle>
18    <FeatureTypeStyle>
19      <Rule>
20        <Name>secondary</Name>
21        <ogc:Filter>
22          <ogc:PropertyIsEqualTo>
23            <ogc:PropertyName>type</ogc:PropertyName>
24            <ogc:Literal>secondary</ogc:Literal>
25          </ogc:PropertyIsEqualTo>
26        </ogc:Filter>
27        <LineSymbolizer>
28          <Stroke>
29            <CssParameter name="stroke">#0055CC</CssParameter>
30            <CssParameter name="stroke-width">3</CssParameter>
31          </Stroke>
32        </LineSymbolizer>
33      </Rule>
34    </FeatureTypeStyle>
35    <FeatureTypeStyle>
36      <Rule>
37      <Name>highway</Name>
38        <ogc:Filter>
39          <ogc:PropertyIsEqualTo>
40            <ogc:PropertyName>type</ogc:PropertyName>
41            <ogc:Literal>highway</ogc:Literal>
42          </ogc:PropertyIsEqualTo>
43        </ogc:Filter>
44        <LineSymbolizer>
45          <Stroke>
46            <CssParameter name="stroke">#FF0000</CssParameter>
47            <CssParameter name="stroke-width">6</CssParameter>
48          </Stroke>
49        </LineSymbolizer>
50      </Rule>
51    </FeatureTypeStyle>

注意

 

请参阅示例线图层以查看图层的属性。此示例避免了标签以简化样式,但您可以参考示例优化和样式标签以查看哪些属性对应于哪些点。

在我们虚构的国家有三种类型的道路类别,从小路到高速高速公路: “高速公路”、“二级公路”和“地方公路”。为了分别处理每种情况,有多个,每个都包含一个规则。这可确保按顺序渲染每种道路类型,因为每种道路类型都是根据其在 SLD 中的显示顺序绘制的。<FeatureTypeStyle>``<FeatureTypeStyle>

这三条规则的设计如下:

规则顺序规则名称/类型颜色大小
1地方道路#009933(绿色)2
2二 次#0055CC(蓝色)3
3公路#FF0000(红色)6

第 2-16 行构成第一个 .第 4-9 行为此规则设置过滤器,以便“类型” 属性的值为“本地道路”。如果此条件适用于特定行,则根据 到第 10-15 行第 12-13 行将线条的颜色设置为深绿色 () 和宽度为 2 像素。<Rule>``<LineSymbolizer>``#009933

第 19-33 行包括第二个 .第 21-26 行为此规则设置过滤器,以便“类型” 属性的值为“次要”。如果此条件适用于特定行,则根据 在第 27-32 行第 29-30 行将线条的颜色设置为深蓝色 () 和宽度为 3 像素,使线条比“本地道路”线略粗,并且 不同的颜色。<Rule>``<LineSymbolizer>``#0055CC

第 36-50 行包括第三个也是最后一个。第 38-43 行为此规则设置筛选器,以便 “type”属性的值为“primary”。如果此条件适用于特定行,则呈现规则 根据第 44-49 行第 46-47 行将线条的颜色设置为 亮红色 () 和宽度为 6 像素,以便这些线条呈现在 另外两个道路类别。这样,“主要”道路在地图渲染中被优先考虑。<Rule>``<LineSymbolizer>``#FF0000

基于缩放的线条

本示例更改不同缩放级别的“简单线条”样式。

../../../_images/line_zoombasedlinelarge.png

基于缩放的线条:放大

../../../_images/line_zoombasedlinemedium.png

Zoom-based line: Partially zoomed

../../../_images/line_zoombasedlinesmall.png

基于缩放的线条:缩小

法典

View and download the full "Zoom-based line" SLD

 1    <FeatureTypeStyle>
 2      <Rule>
 3        <Name>Large</Name>
 4        <MaxScaleDenominator>180000000</MaxScaleDenominator>
 5        <LineSymbolizer>
 6          <Stroke>
 7            <CssParameter name="stroke">#009933</CssParameter>
 8            <CssParameter name="stroke-width">6</CssParameter>
 9          </Stroke>
10        </LineSymbolizer>
11      </Rule>
12      <Rule>
13        <Name>Medium</Name>
14        <MinScaleDenominator>180000000</MinScaleDenominator>
15        <MaxScaleDenominator>360000000</MaxScaleDenominator>
16        <LineSymbolizer>
17          <Stroke>
18            <CssParameter name="stroke">#009933</CssParameter>
19            <CssParameter name="stroke-width">4</CssParameter>
20          </Stroke>
21        </LineSymbolizer>
22      </Rule>
23      <Rule>
24        <Name>Small</Name>
25        <MinScaleDenominator>360000000</MinScaleDenominator>
26        <LineSymbolizer>
27          <Stroke>
28            <CssParameter name="stroke">#009933</CssParameter>
29            <CssParameter name="stroke-width">2</CssParameter>
30          </Stroke>
31        </LineSymbolizer>
32      </Rule>
33    </FeatureTypeStyle>

创建外观自然的地图时,通常需要在较高的缩放级别下使形状变大。这个例子 根据缩放级别(或更准确地说,比例分母)改变线条的粗细。规模 分母是指地图的比例。比例分母为 10,000 表示地图的比例尺为 1:10,000 地图投影的单位。

注意

 

确定要使用的适当比例分母(缩放级别)超出了此示例的范围。

此样式包含三个规则。这三条规则的设计如下:

规则顺序规则名称刻度分母线宽
11:180,000,000以下6
2中等1:180,000,000 至 1:360,000,0004
3大于 1:360,000,0002

这些规则的顺序无关紧要,因为每个规则中计价的刻度不重叠。

第一条规则(第 2-11 行)是最小比例分母,对应于视图“放大”的时间。这 比例规则设置在第 4 行,以便该规则将应用于比例分母为 180,000,000 的任何地图,或 少。第 7-8 行将线条绘制为深绿色 (),宽度为 6 像素。#009933

第二条规则(第 12-22 行)是中间比例分母,对应于视图“部分”时 放大”。第 14-15 行设置比例,以便规则将应用于比例分母介于 180,000,000 和 360,000,000。(包含的和 独占,因此正好 360,000,000 的缩放级别在这里适用。除了规模,唯一的区别 此规则与前一条规则之间是行的宽度,在第 4 行上设置为 19 像素。<MinScaleDenominator>``<MaxScaleDenominator>

第三条规则(第 23-32 行)是最大比例分母,对应于地图“缩小”的时间。这 比例规则设置在第 25 行,以便该规则将应用于比例分母为 360,000,000 的任何地图,或者 大。同样,此规则与其他规则之间的唯一其他区别是行的宽度,设置为 第 2 行为 29 像素。

这种样式的结果是,在放大时以较大的宽度绘制线条,在缩小时以较小的宽度绘制线条。