Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 401
James Larkin Avatar asked Feb 04 '10 13:02

James Larkin


1 Answers

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>
like image 103
Berwyn Avatar answered Oct 01 '22 18:10

Berwyn