views:

681

answers:

2

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

+1  A: 

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

geographika
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.
James Larkin
Did you use the <extrude>1</extrude> tag in your polygon to "join" the polygon from its altitude to the ground?
geographika
The extrude tag is only if you want to extend to the it will not work for objects in the air.
James Larkin
Yes you are right. Seems an oversight in the KML specs. There are examples of the 2d faces to create 3d polygons at http://www.skyfool.de/luftraeume/
geographika
+1  A: 

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"&gt;
<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>
Berwyn
Thanks Berwyn, This is what I was looking for.
James Larkin