FastDrawn states out of sync (I guess?)

Developer
Apr 6, 2011 at 6:57 PM

I am getting this error...

"Index was outside the bounds of the array." on this line of code.

 

DotSpatial.Control.MapPointLayer

 

private void DrawFeatures(MapArgs e, IEnumerable indices)
{
...
    foreach (int index in indices)�
    {
        FastDrawnState state = states[index];}   // <= error is here
...
}

My Offending code is as follows
FeatureSet fs = (_labelLayer.DataSet as FeatureSet);
 
IFeature labelPoint = fs.AddFeature( _dropTarget.Centroid());
fs.Save();


FYI, the new point is saved in the file just fine. After crashing and restarting the point is there where it should be.

I often face this error when modifying a feature set.  Usually I can use some combination of InvalidateVertices or UpdateExents and it goes away.  However, this time nothing help.

What is the write way to ensure that the "FastDrawn" states are not corrupted by DataSet edits?


Thanks,

Garth

 

Jun 28, 2011 at 2:04 PM

I'm getting a similar issue...

After I call the function below, my application will crash immediately after I change the extents of the map (by panning,zooming,etc.). The function call works fine, it's only after I do something with the map when my application crashes.

 

 /// <summary>
        /// Adds a feature... uses dummy data 
        /// ID =1
        /// Type = TESTPOINT
        /// </summary>
        /// <param name="geo"></param>
        /// <returns></returns>
        public bool AddFeature(DotSpatial.Topology.IPoint geo)
        {
            bool result = false;
            try
            {
                DotSpatial.Data.IFeature feat = attributeFeatureSet.AddFeature(geo);
               // DotSpatial.Data.IFeature feat = new DotSpatial.Data.Feature(geo);
                feat.DataRow.BeginEdit();
                feat.DataRow["ID"] = 1;
                feat.DataRow["Type"] = "TESTPOINT";
                feat.DataRow.EndEdit();
                //attributeFeatureSet.AddFeature(feat.FeatureType )
                attributeFeatureSet.SaveAs(@"C:\Projects\MHD\\GISData\Shapes\TestCreatePoints.shp",true);
                result = true;
            }
            catch (Exception Exc)
            {
                //TODO: Add error handling to addFeature Method
                System.Diagnostics.Debug.Print(Exc.Message + "," + Exc.StackTrace);
                result = false;
            }
            return result;    
        }

The function call works fine, it's only after I do something with the map when my application crashes and I get the following error:
[System.IndexOutOfRangeException]

{"Index was outside the bounds of the array."}

Source: DotSpatial.Controls

StackTrace:   at DotSpatial.Controls.MapPointLayer.DrawFeatures(MapArgs e, IEnumerable`1 indices)   at DotSpatial.Controls.MapPointLayer.DrawFeatures(MapArgs args, List`1 indices, List`1 clipRectangles, Boolean useChunks)   at DotSpatial.Controls.MapPointLayer.DrawRegions(MapArgs args, List`1 regions)   at DotSpatial.Controls.MapFrame.Initialize(List`1 regions)   at DotSpatial.Controls.MapFrame.Initialize()   at DotSpatial.Controls.MapFrame.ResetBuffer()   at DotSpatial.Controls.MapFrame.set_ViewExtents(Extent value)   at DotSpatial.Controls.Map.set_ViewExtents(Extent value)   at DotSpatial.Controls.MapFunctionClickZoom.OnMouseUp(GeoMouseArgs e)   at DotSpatial.Controls.MapFunction.DoMouseUp(GeoMouseArgs e)   at DotSpatial.Controls.Map.OnMouseUp(MouseEventArgs e)   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)   at System.Windows.Forms.Control.WndProc(Message& m)   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)   at System.Windows.Forms.UserControl.WndProc(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)   at System.Windows.Threading.Dispatcher.Run()   at System.Windows.Application.RunDispatcher(Object ignore)   at System.Windows.Application.RunInternal(Window window)   at System.Windows.Application.Run(Window window)   at System.Windows.Application.Run()   at WpfApplication1.App.Main() in C:\Tools\Applications\TestMapWindow\WpfApplication1\WpfApplication1\obj\x86\Debug\App.g.cs:line 0   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   at System.Threading.ThreadHelper.ThreadStart()

I'm hosting the map control through a WPF host control. I'm using an existing point layer rather than creating a new one.

Any ideas?

Did you have get any resolution to your error Garth?

 

Developer
Jun 28, 2011 at 4:47 PM
Sorry, I never did find a resolution. I moved on to a commercial spatial library.

It looks like kellison is doing work in that area though. You might get fixes or advice from them.



Garth Tissington


On Tue, Jun 28, 2011 at 6:04 AM, michael_rut <notifications@codeplex.com> wrote:

From: michael_rut

I'm getting a similar issue...

After I call the function below, my application will crash immediately after I change the extents of the map (by panning,zooming,etc.). The function call works fine, it's only after I do something with the map when my application crashes.

 /// <summary>
/// Adds a feature... uses dummy data
/// ID =1
/// Type = TESTPOINT
/// </summary>
/// <param name="geo"></param>
/// <returns></returns>
public bool AddFeature(DotSpatial.Topology.IPoint geo)
{
bool result = false;
try
{
DotSpatial.Data.IFeature feat = attributeFeatureSet.AddFeature(geo);
// DotSpatial.Data.IFeature feat = new DotSpatial.Data.Feature(geo);
feat.DataRow.BeginEdit();
feat.DataRow["ID"] = 1;
feat.DataRow["Type"] = "TESTPOINT";
feat.DataRow.EndEdit();
//attributeFeatureSet.AddFeature(feat.FeatureType )
attributeFeatureSet.SaveAs(@"C:\Projects\MHD\\GISData\Shapes\TestCreatePoints.shp",true);
result = true;
}
catch (Exception Exc)
{
//TODO: Add error handling to addFeature Method
System.Diagnostics.Debug.Print(Exc.Message + "," + Exc.StackTrace);
result = false;
}
return result;
}

The function call works fine, it's only after I do something with the map when my application crashes and I get the following error:
[System.IndexOutOfRangeException]

{"Index was outside the bounds of the array."}

Source: DotSpatial.Controls

StackTrace: at DotSpatial.Controls.MapPointLayer.DrawFeatures(MapArgs e, IEnumerable`1 indices) at DotSpatial.Controls.MapPointLayer.DrawFeatures(MapArgs args, List`1 indices, List`1 clipRectangles, Boolean useChunks) at DotSpatial.Controls.MapPointLayer.DrawRegions(MapArgs args, List`1 regions) at DotSpatial.Controls.MapFrame.Initialize(List`1 regions) at DotSpatial.Controls.MapFrame.Initialize() at DotSpatial.Controls.MapFrame.ResetBuffer() at DotSpatial.Controls.MapFrame.set_ViewExtents(Extent value) at DotSpatial.Controls.Map.set_ViewExtents(Extent value) at DotSpatial.Controls.MapFunctionClickZoom.OnMouseUp(GeoMouseArgs e) at DotSpatial.Controls.MapFunction.DoMouseUp(GeoMouseArgs e) at DotSpatial.Controls.Map.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at WpfApplication1.App.Main() in C:\Tools\Applications\TestMapWindow\WpfApplication1\WpfApplication1\obj\x86\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

I'm hosting the map control through a WPF host control. I'm using an existing point layer rather than creating a new one.

Any ideas?

Did you have get any resolution to your error Garth?

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Developer
Jun 28, 2011 at 9:45 PM

Hi,

I'm not using the canned DotSpatial MapLayers.  My heavy shapefiles overloaded the RAM based MapLayers based on FeatureSets.  I'm using the file-based version IFeatureSource/IShapeSource and implemented my own MapLayers.  I could give you some pointers on how to do that if you wanted to go that route.  The hardest part was the drawing code; I was able to make some simplifying assumptions so I did not have to honor complete DotSpatial symbology.  Using the file-based approach gets you completely out of the FastDrawn States synchronization problems that seem to crop up a lot.

Kyle

Developer
Jun 28, 2011 at 10:51 PM
Thanks for feedback, I looked at that route myself but found the drawing logic just way over my head. Very impressive that you manged to work around it that way.

Perhaps I'll come back to this on another project but for now I've abandoned DotSpatial in favor of a commercial framework.

Good luck.

Garth Tissington


On Tue, Jun 28, 2011 at 1:45 PM, kellison <notifications@codeplex.com> wrote:

From: kellison

Hi,

I'm not using the canned DotSpatial MapLayers. My heavy shapefiles overloaded the RAM based MapLayers based on FeatureSets. I'm using the file-based version IFeatureSource/IShapeSource and implemented my own MapLayers. I could give you some pointers on how to do that if you wanted to go that route. The hardest part was the drawing code; I was able to make some simplifying assumptions so I did not have to honor complete DotSpatial symbology. Using the file-based approach gets you completely out of the FastDrawn States synchronization problems that seem to crop up a lot.

Kyle

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Jul 24, 2014 at 1:32 AM
I'm finding the same problem with the latest version.
Weird thing is that if I put a break point just before the error and then play around with the object, most of time everything fixes up.
The FeatureLayer is out of sync with the DataSet, especially the DrawnStates property.

Found that doing a
                layer.DataSet.InitializeVertices();
                layer.AssignFastDrawnStates();
seems to make problem go away.