Announcement

Collapse
No announcement yet.

Develop Branch + KML Polygons

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Develop Branch + KML Polygons

    Hi there,

    Similar to another poster a few months ago (whose issues were fixed in develop supposedly), I'm having some trouble with polygon rendering from KML files. The attached shows a very simple example, but the rendering seems to just get worse the more polygons are added.

    It doesn't seem to matter if I use clampToGround, no altitudeMode, with or without adding altitudes, the overlay just isn't solid... Frequently as I move my mouse around the window or zoom in or out, different chunks of the polygon's overlay will disappear or reappear. If I move my mouse enough or zoom in at juuuust the right point, the white part will become solid.

    The screenshot attached is generated from a KML with this Placemark.

    Code:
     
                 <Placemark>
                    <name>Polygon</name>
                    <visibility>1</visibility>
                    <description>Polygon</description>
                    <MultiGeometry>
                        <Polygon>
                            <outerBoundaryIs>
                                <LinearRing>
                                    <coordinates>-86.59971,34.74294,1000 -86.60211,34.71793,1000 -86.56463,34.71486,1000 -86.57285,34.75236,1000</coordinates>
                                    <altitudeMode>clampToGround</altitudeMode>
                                </LinearRing>
                            </outerBoundaryIs>
                        </Polygon>
                    </MultiGeometry>
                </Placemark>

  • #2
    I'll answer my own question here. There is a bug in the KML parsing - it only reads altitudeMode from the <Polygon> element and not from LinearRing. Without that it just creates a WorldWind.Polygon instead of a WorldWind.SurfacePolygon.

    Comment


    • #3
      It certainly is a bug as the LinearRing inside of the Polygon can have altitude mode clampToGround. This option shouldn't produce SurfacePolygon as far as I understand the documentation of the format though:

      From KML Documentation:
      Note: In Google Earth, a Polygon with an &lt;altitudeMode&gt; of clampToGround follows lines of constant bearing; however, a LinearRing (by itself) with an &lt;altitudeMode&gt; of clampToGround follows great circle lines.

      The documentation doesn't state how should we handle situations where the altitudeMode of the Polygon and boundary differs or when the inner and outer boundary differs such as absolute inner and clampToGround outer. I am not therefore sure what should be part of the default implementation.

      To support what you are asking for, it is possible to use following code after loading Web World Wind. The code will provide different implementation of the KmlPolygon which will behave in a way you are asking for. I hope that this will help you. In this way you can modify the behaviour of any Kml element.


      var KmlPolygonRespectsBoundaries = function(options) {
      WorldWind.KmlPolygon.apply(this, options):
      };

      KmlPolygonRespectsBoundaries.prototype.c reatePolygon = function(styles) { if(this.kmlAltitudeMode == WorldWind.CLAMP_TO_GROUND || this.kmlOuterBoundary.kmlAltitudeMode == WorldWind.CLAMP_TO_GROUND) { this._renderable = new SurfacePolygon(this.prepareLocations(), this.prepareAttributes(styles.normal)); } else { this._renderable = new Polygon(this.prepareLocations(), this.prepareAttributes(styles.normal)); } if(styles.highlight) { this._renderable.highlightAttributes = this.prepareAttributes(styles.highlight) ; } this.moveValidProperties(); };
      WorldWind.KmlElements.addKey('Polygon', KmlPolygonRespectsBoundaries);

      Comment


      • #4
        Thanks for the explanation and code - very useful! I will give it a try.

        Comment

        Working...
        X