none
Blog post: Vertex Reduction - Support tons of data in Bing Maps Silverlight

All replies

  • I haven't tested this out, but won't your implementations of BMSLExtenstions.Join() and BMSLExtensions.GetBoundingBox() in your library fail when a polygon/polyline/LocationRect spans the international dateline?  Seems you need to use a more robust definition like:

    https://deepearth.svn.codeplex.com/svn/branch/DeepEarth_2011/SILVERLIGHT/Core/DeepEarth.Core/LocationRectangle.cs

    Monday, December 12, 2011 9:56 PM
  • This looks cool, and I'll try it out.  Might want to change the #usings to:

     

    #if !WINDOWS_PHONE
    using Microsoft.Maps.MapControl;
    using Microsoft.Maps.MapControl.Core;
    #else
    using Microsoft.Phone.Controls.Maps;
    using Microsoft.Phone.Controls.Maps.Core;
    using Microsoft.Phone.Controls.Maps.Platform;
    #endif
    

     


    • Edited by jaybo_nomad Tuesday, December 13, 2011 12:08 AM typo
    Monday, December 12, 2011 11:58 PM
  • And some warnings:  #1 seems bad!

    Warning 1 Field 'BingMapsSL.MultiShape.MultiMapShapeBase.verticesHashCode' is never assigned to, and will always have its default value 0 E:\devDeepZoom\DeepZoom3\BingMaps.MultiShape.WP7\MultiMapShapeBase.cs 35 21 BingMaps.MultiShape.WP7

    Warning 2 'BingMapsSL.MultiShape.MultiMapShapeBase.Opacity' hides inherited member 'System.Windows.UIElement.Opacity'. Use the new keyword if hiding was intended. E:\devDeepZoom\DeepZoom3\BingMaps.MultiShape.WP7\MultiMapShapeBase.cs 245 23 BingMaps.MultiShape.WP7

    Warning 3 'BingMapsSL.MultiShape.MultiMapShapeBase.OpacityMask' hides inherited member 'System.Windows.UIElement.OpacityMask'. Use the new keyword if hiding was intended. E:\devDeepZoom\DeepZoom3\BingMaps.MultiShape.WP7\MultiMapShapeBase.cs 257 22 BingMaps.MultiShape.WP7

    Tuesday, December 13, 2011 12:05 AM
  • To be honest I have a more complex version of that extension in some newer code. That said, it will still render shapes that cross the international date line. I've used this with hundreds of shapefiles worth of data in the past without any issues.
    http://rbrundritt.wordpress.com
    Tuesday, December 13, 2011 12:57 AM
  • Here's a few additional problems I encountered trying to use this code. If the following rules are not followed, various exceptions arise in BMSLExtensions.cs. All of the following limitations are from AddMultiPolyline():

    1. "List<LocationCollection> points" cannot be empty (or null).

    2. "LocationCollection p" (or p2) cannot be empty (or null).

    These limitations make use difficult for a logging type application. You can't just initialize everything to empty Lists and then add points as they come in.

    Tuesday, December 13, 2011 6:03 AM
  • So it seems that the visibility logic also needs improvement.  If I create a track (consisting of multiple segments), and if the first point in the first segment isn't visible the entire track disappears.  Here's a video:

    https://skydrive.live.com/?cid=c65543daf04f23c4#cid=C65543DAF04F23C4&id=C65543DAF04F23C4%211050


    Update: With the code changes outlined below, this visibility problem no longer occurs.

    • Edited by jaybo_nomad Friday, December 30, 2011 12:00 AM Update:
    Tuesday, December 13, 2011 7:07 AM
  • Here is a code delta showing the changes needed to support empty "List<LocationCollection> points", which is useful in tracking applications:

    Index: E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/BMSLExtensions.cs
    ===================================================================
    --- E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/BMSLExtensions.cs	(revision 347)
    +++ E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/BMSLExtensions.cs	(revision 348)
    @@ -120,7 +120,7 @@
             {
                 LocationRect boundingBox = new LocationRect();
     
    -            if (locations.Count > 0)
    +            if (locations.Count > 0 && locations[0].Count > 0)
                 {
                     boundingBox = locations[0].GetBoundingBox();
                 }
    Index: E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/MultiMapShapeBase.cs
    ===================================================================
    --- E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/MultiMapShapeBase.cs	(revision 347)
    +++ E:/devDeepZoom/DeepZoom3/BingMaps.MultiShape.WP7/MultiMapShapeBase.cs	(revision 348)
    @@ -1,6 +1,7 @@
     using System;
     using System.Collections.Generic;
     using System.Collections.Specialized;
    +using System.Diagnostics;
     using System.Windows;
     using System.Windows.Automation.Peers;
     using System.Windows.Controls;
    @@ -31,7 +32,7 @@
             private ProjectionUpdateLevel pendingUpdate = ProjectionUpdateLevel.Full;
             private Shape shape;
             private Point topLeftViewportPoint = new Point();
    -        private LocationRect boundingBox;
    +        public LocationRect boundingBox;
             private int verticesHashCode;
             private bool enableOptimizations = true;
     
    @@ -89,11 +90,13 @@
                     if (this.Vertices != null)
                     {
                         //check to see if the Verticies object has changed since the last time we rendered the shape
    -                    if (boundingBox == null || verticesHashCode != Vertices.GetHashCode())
    +                    int hashCode = Vertices.GetHashCode();
    +                    if (boundingBox == null || verticesHashCode != hashCode)
                         {
                             //calculate bounding box of shape. Do this every time the vertices change.
                             boundingBox = this.Vertices.GetBoundingBox();
    -                        verticesHashCode = Vertices.GetHashCode(); // jaybo added
    +                        // Debug.WriteLine("BoundingBox: {0} {1} {2} {3}", boundingBox.West, boundingBox.North, boundingBox.East, boundingBox.South);
    +                        verticesHashCode = hashCode; // jaybo added
                         }
     
                         //Check to see if the bounding boxes intersect
    @@ -159,7 +162,7 @@
                             }
                             this.pendingUpdate = ProjectionUpdateLevel.Full;
                         }
    -                    else if (((this.ProjectedPoints.Count > 0) && (this.ProjectedPoints[0].Count > 0) && (this.Vertices.Count > 0) && (this.Vertices[0].Count > 0)) && parentMap.TryLocationToViewportPoint(this.Vertices[0][0], out point3))
    +                    else if ((this.ProjectedPoints != null) && ((this.ProjectedPoints.Count > 0) && (this.ProjectedPoints[0].Count > 0) && (this.Vertices.Count > 0) && (this.Vertices[0].Count > 0)) && parentMap.TryLocationToViewportPoint(this.Vertices[0][0], out point3))
                         {
                             System.Windows.Point point5 = this.ProjectedPoints[0][0];
                             this.topLeftViewportPoint = new System.Windows.Point(point3.X - point5.X, point3.Y - point5.Y);
    
    


    Other changes of note:

    1. the hashCode was never being set, so the boundingBox was always being calculated unnecessarily.

    2. as a total hack, I made "boundingBox" public so I can just set it to null in my client code to force the bounding box to be recalculated as new points are added (without reassigning the point collection).

    Thursday, December 29, 2011 11:58 PM