How do you create a polygon shape in a KML that is positioned in the air?
Asked Answered
T

2

13

I need to be able to place a polygon object with a given height into a KML that will be located above the ground. I'm looking to display airspace information into a KML and each airspace has a low altitude and and high altitude value.

The closest thing I have been able to do so far is to create two polygons with different altitudes to show the airspace but I have no way of connecting the polygons to show the middle area.

Thanks for your help

Tattered answered 4/2, 2010 at 13:35 Comment(1)
Did you ever find an answer to this question? I'm interested in doing something similar myself and would like to 'float' a polygon in mid airInapposite
D
8

Your have two options, you can create a collada model of the air space, or a series of polygon objects defining each face,

verticly oriented polygons can be defined, be take note of the direction of your (clockwise or counter clockwise) as this will effect the style, viewing a polygon from the bottom makes it slightly darker

for a simple rectancular shape you will need 6 faces

the following kml is a modified version of the pentagon example with one of the verticle faces filled in, the other 4 verticle faces need to be complete, but you'll get the idea.

    <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
    <name>pm1.kml</name>
    <Style id="poly">
        <LineStyle>
            <color>f0ffed42</color>
        </LineStyle>
        <PolyStyle>
            <color>e8ff9257</color>
        </PolyStyle>
    </Style>



<Placemark>
    <styleUrl>#poly</styleUrl>
        <Polygon>
            <altitudeMode>relativeToGround</altitudeMode>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
-77.05844056290393,38.86996206506943,500 -77.05552622493516,38.868757801256,500 
-77.05315536854791,38.87053267794386,500 -77.05465973756702,38.87291016281703,500 -77.05788457660967,38.87253259892824,500 -77.05844056290393,38.86996206506943,500 </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
</Placemark>
<Placemark>
    <styleUrl>#poly</styleUrl>
        <Polygon>
            <altitudeMode>relativeToGround</altitudeMode>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
-77.05844056290393,38.86996206506943,400 -77.05552622493516,38.868757801256,400 
-77.05315536854791,38.87053267794386,400 -77.05465973756702,38.87291016281703,400 -77.05788457660967,38.87253259892824,400 -77.05844056290393,38.86996206506943,400 </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
</Placemark>

<Placemark>
    <styleUrl>#poly</styleUrl>
        <Polygon>
            <altitudeMode>relativeToGround</altitudeMode>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
 -77.05844056290393,38.86996206506943,500 -77.05844056290393,38.86996206506943,400 -77.05552622493516,38.868757801256,400  -77.05552622493516,38.868757801256,500  -77.05844056290393,38.86996206506943,500
</coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
</Placemark>

</Document>
</kml>
Dissimulation answered 16/2, 2010 at 19:30 Comment(0)
G
1

It sounds like you are creating 2 2d polygons rather than a 3d one? You could create a regular 3d polygon:

http://code.google.com/apis/kml/documentation/kml_tut.html#polygons

Then check out the altitudemode tag in KML to "float it" above the surface:

http://code.google.com/apis/kml/documentation/altitudemode.html

Getaway answered 6/2, 2010 at 15:59 Comment(4)
Thanks for the answer geographika. You are correct the polygons have a altitude mode but all of them are based from the ground up except absolute which will only float the polygon up but will not give it a depth.Tattered
Did you use the <extrude>1</extrude> tag in your polygon to "join" the polygon from its altitude to the ground?Getaway
The extrude tag is only if you want to extend to the it will not work for objects in the air.Tattered
Yes you are right. Seems an oversight in the KML specs. There are examples of the 2d faces to create 3d polygons at skyfool.de/luftraeumeGetaway

© 2022 - 2024 — McMap. All rights reserved.