使用uDig制作geoserver中需要的style

作者:lizongbo 发表于:2:27 下午. 星期日, 1月 13th, 2008
版权声明:可以任意转载,转载时请务必以超链接形式标明文章和作者信息及本版权声明

手工编写SLD是非常麻烦的,因此可以用uDig来帮助生成。

1.下载uDig:

http://udig.refractions.net/downloads/udig-1.1-RC13.exe

来源: http://udig.refractions.net/

2.安装uDig,新建工程,添加图层.

3.选中图层,主菜单– > Layer — > Change Style ,编辑样式,然后选择左下角的Export,导出SLD文件,

对于导出的文件中,如果存在字体描述,容易出现乱码,删除

<sld:CssParameter name=”font-family”>
<ogc:Literal>Arial</ogc:Literal>
</sld:CssParameter>

关于 Openlayers,geoserver,uDig,网上有一组很有价值的文章:

链接如下:

http://hi.baidu.com/znn1980/blog/category/--escaped_anchor:51dbcafc1fa18a9e8b98a56b065a7fdb--

http://hi.baidu.com/znn1980/blog/item/0140c3f8c55f980cd9f9fd78.html
http://hi.baidu.com/znn1980/blog/item/66fab1259126956334a80f7b.html
http://hi.baidu.com/znn1980/blog/item/8c42da1f6614a260f624e442.html
http://hi.baidu.com/znn1980/blog/item/2b6af5c43afa48c839db494c.html
http://hi.baidu.com/znn1980/blog/item/89b7272439841030c895594f.html
http://hi.baidu.com/znn1980/blog/item/761b122907d129fd99250a48.html
http://hi.baidu.com/znn1980/blog/item/761b122921a807fd99250a01.html

http://hi.baidu.com/znn1980/blog/item/f6cb13c7904cf6d8d100601d.html

一个Openlayser的marker例子:

http://geoinformatics.nju.edu.cn/whereyougo/

一个 style 样本:

<?xml version=”1.0″ encoding=”UTF-8″?>
<sld:StyledLayerDescriptor xmlns:sld=”http://www.opengis.net/sld” xmlns:ogc=”http://www.opengis.net/ogc” xmlns:gml=”http://www.opengis.net/gml” version=”1.0.0″>
<sld:UserLayer>
<sld:LayerFeatureConstraints>
<sld:FeatureTypeConstraint/>
</sld:LayerFeatureConstraints>
<sld:UserStyle>
<sld:Name>Default Styler</sld:Name>
<sld:Title>Default Styler</sld:Title>
<sld:Abstract/>
<sld:FeatureTypeStyle>
<sld:Name>simple</sld:Name>
<sld:Title>title</sld:Title>
<sld:Abstract>abstract</sld:Abstract>
<sld:FeatureTypeName>Dguangdong_region</sld:FeatureTypeName>
<sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier>
<sld:SemanticTypeIdentifier>simple</sld:SemanticTypeIdentifier>
<sld:Rule>
<sld:Name>name</sld:Name>
<sld:Title>title</sld:Title>
<sld:Abstract>Abstract</sld:Abstract>
<sld:MaxScaleDenominator>1.7976931348623157E308</sld:MaxScaleDenominator>
<sld:PolygonSymbolizer>
<sld:Fill>
<sld:CssParameter name=”fill”>
<ogc:Literal>#C0C0C0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”fill-opacity”>
<ogc:Literal>0.5</ogc:Literal>
</sld:CssParameter>
</sld:Fill>
<sld:Stroke>
<sld:CssParameter name=”stroke”>
<ogc:Literal>#1B9E77</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”stroke-linecap”>
<ogc:Literal>butt</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”stroke-linejoin”>
<ogc:Literal>miter</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”stroke-opacity”>
<ogc:Literal>1.0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”stroke-width”>
<ogc:Literal>1.0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”stroke-dashoffset”>
<ogc:Literal>0.0</ogc:Literal>
</sld:CssParameter>
</sld:Stroke>
</sld:PolygonSymbolizer>
<sld:TextSymbolizer>
<sld:Label>
<ogc:PropertyName>ADMINNAME</ogc:PropertyName>
</sld:Label>
<sld:Font>
<sld:CssParameter name=”font-size”>
<ogc:Literal>14.0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”font-style”>
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”font-weight”>
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
</sld:Font>
<sld:LabelPlacement>
<sld:PointPlacement>
<sld:AnchorPoint>
<sld:AnchorPointX>
<ogc:Literal>0.5</ogc:Literal>
</sld:AnchorPointX>
<sld:AnchorPointY>
<ogc:Literal>0.5</ogc:Literal>
</sld:AnchorPointY>
</sld:AnchorPoint>
<sld:Displacement>
<sld:DisplacementX>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementX>
<sld:DisplacementY>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementY>
</sld:Displacement>
<sld:Rotation>
<ogc:Literal>0.0</ogc:Literal>
</sld:Rotation>
</sld:PointPlacement>
</sld:LabelPlacement>
<sld:Fill>
<sld:CssParameter name=”fill”>
<ogc:Literal>#000000</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”fill-opacity”>
<ogc:Literal>1.0</ogc:Literal>
</sld:CssParameter>
</sld:Fill>
<sld:VendorOption name=”spaceAround”>2</sld:VendorOption>
</sld:TextSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:UserLayer>
</sld:StyledLayerDescriptor>

四色地图效果的Style
在Change Style的时候,选择Theme,然后选择条件字段,再选择主题。 就可以得到不同区域不同颜色的地图了。

Tags: geoserver, gis, OpenLayers, uDig

Related posts

Tags: , , ,

recent related 12 searches :

This entry was posted on 星期日, 1月 13th, 2008 at 2:27 下午 and is filed under Java. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

Comments are closed.