爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4789|回复: 7

[混合编程] KML之立体彩色多边形

[复制链接]

新浪微博达人勋

发表于 2019-1-14 14:11:44 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 15195775117 于 2019-1-14 16:29 编辑

飞鸽截图20190114140426.png
固定开头:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
文件名:
<name>ao</name>
文件状态:
<open>1</open>
新建样式,包括边线和内部的属性设置:
<Style id="DIYstyle">
1、设置线的属性:
<LineStyle>
1.1、设置线的宽度:
<width>7</width>
1.2、设置线的颜色(包括透明度):
<color>ff0000ff</color>
</LineStyle>
2、设置内部属性:
<PolyStyle>
2.1、设置填充色(包括透明度):
<color>7dff0000</color>
</PolyStyle>
</Style>
新建地标:
<Placemark>
地标名:
<name>例子</name>
地标可见:
<visibility>1</visibility>
引用样式:
<styleUrl>#DIYstyle</styleUrl>
新建连线:
<LineString>
垂到地面:
<extrude>1</extrude>
贴地模式:
<tessellate>1</tessellate>
使用相对地面的高度:
<altitudeMode>relativeToGround</altitudeMode>
坐标点:
<coordinates>
121.1,32.0,1000
121.2,32.0,2000
121.2,32.1,3000
121.1,32.1,4000
121.1,32.0,1000
</coordinates>
</LineString>
</Placemark>
固定收尾:
</Document>
</kml>




密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-14 14:26:22 | 显示全部楼层
以上只是通过LineString做连线,如果想做悬空的面、体,还需要Polygon、LinearRing等

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-15 14:50:09 | 显示全部楼层
案例2,制作填色多边形(不知为何我明明设置了高度,多边形却是贴地模式)
飞鸽截图20190115143805.png

固定开头:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
新建地标:
<Placemark>
<name>test1</name>
自有样式:
<Style>
<PolyStyle>
多边形内部颜色:
<color>7dff0000</color>
多边形内部是否填充:
<fill>1</fill>
是否显示边框:
<outline>1</outline>
</PolyStyle>


<LineStyle>
边框宽度:
<width>5</width>
边框颜色:
<color>ff0000ff</color>
</LineStyle>
</Style>


不知为何Polygon要套在MultiGeometry内:
<MultiGeometry>
新建多边形:
<Polygon>
这个也不懂:
<outerBoundaryIs>
LinearRing与LineString有什么区别?
<LinearRing>
<coordinates>
120.0,30.0,1000
120.1,30.0,2000
120.1,30.1,3000
120.0,30.1,4000
120.0,30.0,1000
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>


</Document>
</kml>


密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-15 15:13:52 | 显示全部楼层
本帖最后由 15195775117 于 2019-1-15 15:45 编辑

例3:空泡多边形

飞鸽截图20190115150625.png
固定开头:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
新建地标:
<Placemark>
<name>test1</name>
地标内部的自有样式:
<Style>
<PolyStyle>
填充色:
<color>7dff0000</color>
是否填充:
<fill>1</fill>
是否显示边框:
<outline>1</outline>
</PolyStyle>
<LineStyle>
线框宽:
<width>5</width>
线框色:
<color>ff0000ff</color>
</LineStyle>
</Style>


<MultiGeometry>
<Polygon>
多边形的外边框是一定要有的,
这也可以理解,多边形就是通过外边框定型的:
<outerBoundaryIs>
<LinearRing>
<coordinates>
120.0,30.0,1000
120.1,30.0,2000
120.1,30.1,3000
120.0,30.1,4000
120.0,30.0,1000
</coordinates>
</LinearRing>
</outerBoundaryIs>
设置内边框:
<innerBoundaryIs>
<LinearRing>
<coordinates>
120.03,30.03,1000
120.07,30.03,2000
120.07,30.07,3000
120.03,30.07,4000
120.03,30.03,1000
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>








</Document>
</kml>




密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-15 15:49:27 | 显示全部楼层
例4 立体多边形
飞鸽截图20190115154624.png


固定开头:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
设置样式:
<Style id="p1">
设置线型:
<LineStyle>
设置线粗:
<width>5</width>
设置线色:
<color>ff0000ff</color>
</LineStyle>
设置多边形:
<PolyStyle>
填充色:
<color>7f00ff00</color>
</PolyStyle>
</Style>
新建地标:
<Placemark>
<name>p1</name>
引用样式:
<styleUrl>#p1</styleUrl>
新建多边形:
<Polygon>
垂到地面:
<extrude>1</extrude>
相对地面高度:
<altitudeMode>relativeToGround</altitudeMode>
新建外边框:
<outerBoundaryIs>
<LinearRing>
<coordinates>
121.1,32.0,1000
121.2,32.0,2000
121.2,32.1,3000
121.1,32.1,4000
121.1,32.0,1000
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
收尾:
</Document>
</kml>

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-15 16:16:48 | 显示全部楼层
例5 彩色墙
飞鸽截图20190115161417.png


固定内容:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
样式1:
<Style id="p1">
<LineStyle>
<width>5</width>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<outline>1</outline>
<color>7f00ff00</color>
</PolyStyle>
</Style>
样式2:
<Style id="p2">
<LineStyle>
<width>5</width>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<outline>1</outline>
<color>7fff0000</color>
</PolyStyle>
</Style>
地标1:
<Placemark>
<name>p1</name>
引用样式1:
<styleUrl>#p1</styleUrl>
<Polygon>
<extrude>0</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
120,30,1000
120.05,30,1000
120.05,30,5000
120,30,5000
120,30,1000
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
地标2:
<Placemark>
<name>p2</name>
引用样式2:
<styleUrl>#p2</styleUrl>
<Polygon>
<extrude>0</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
120,30,5000
120.1,30,5000
120.1,30,10000
120,30,10000
120,30,5000
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-16 11:30:19 | 显示全部楼层
kml文件见附件
飞鸽截图20190116113010.png

out.kml

3.39 KB, 下载次数: 1, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-1-29 16:08:47 | 显示全部楼层
案例:利用<Polygon>的外边框和内边框绘制五角大楼


飞鸽截图20190129155324.png

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark>
<name>The Pentagon</name>
<Style>
<LineStyle>
                        <color>ff0000ff</color>
                        <width>1</width>
                </LineStyle>
                <PolyStyle>
                        <color>ffcdff32</color>
                        <outline>1</outline>
                </PolyStyle>
</Style>
<Polygon>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
118.05788457660967,38.87253259892824,100
118.05465973756702,38.87291016281703,100
118.05315536854791,38.87053267794386,100
118.05552622493516,38.868757801256,100
118.05844056290393,38.86996206506943,100
118.05788457660967,38.87253259892824,100
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
118.05668055019126,38.87154239798456,100
118.05542625960818,38.87167890344077,100
118.05485125901024,38.87076535397792,100
118.05577677433152,38.87008686581446,100
118.05691162017543,38.87054446963351,100
118.05668055019126,38.87154239798456,100
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
</Placemark> </kml>


密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表