Hello Forum,
We’re generating some colour layers using GridFeatureLayer (similar to those used in your “Isolines With Kriging” code sample). To do this we need to call the static GridFeatureSource.GenerateGrid method using an appropriate interpolation model. We use a LinealKrigingGridInterpolationModel with 5 reference points (Desktop Edition 9).
Our data points are a scattering of values arranged basically in a grid formation but with patches often missing, and it generally causes no problems when generating the grid. However, on occasion, the method fails and does so in a manner from which we cannot seem to recover. In the debugger, we receive the following message:
System.InvalidOperationException was unhandled
Message: An unhandled exception of type ‘System.InvalidOperationException’ occurred in MapSuiteCore.dll
Additional information: The matrix cannot be inversed, please check if the input data is valid. For example 2 points with different values should not have the same coordination.
That’s fine and all, but the exception cannot be caught on our side, it seems, and instead brings down our service. We’d much rather skip the calculation and carry on. I’ll append the stacktrace below, as well as attach an x,y,z data set (in metre map units) which causes the issue for us when we try to generate a grid with 100 cells along the shortest side.
Are there any app domain considerations we should be making here which might prevent the exception from propagating from the ThinkGeo code? If you have any ideas on how we can get around this issue, I’d very much appreciate it.
Many thanks,
Scott D.
---------
> MapSuiteCore.dll!ThinkGeo.MapSuite.Core.KrigingGridInterpolationModel.ahw=(int nPn, double x, double y) Unknown
MapSuiteCore.dll!ThinkGeo.MapSuite.Core.KrigingGridInterpolationModel.InterpolateCore(ThinkGeo.MapSuite.Core.RectangleShape cellExtent, ThinkGeo.MapSuite.Core.GridDefinition gridDefinition) Unknown
MapSuiteCore.dll!ThinkGeo.MapSuite.Core.GridInterpolationModel.Interpolate(ThinkGeo.MapSuite.Core.RectangleShape cellExtent, ThinkGeo.MapSuite.Core.GridDefinition gridDefinition) Unknown
MapSuiteCore.dll!xRM=.Cjc=.DDc=(object objStateInfo) Unknown
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Unknown
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() Unknown
001_data.txt (16.4 KB)
GenerateGrid exception
Hi Scott,
If you visit our sample data in IsoLinesWithKriging sample, you can see the data is splited by “,” and in the project code please visit the function GetWellDepthPointDataFromCSV, it contains a line: string[] parts = line.Split(’,’);
You can modify it for your data or modify your data to separated by “,”.
I tried to modify the data to separated by “,” and hadn’t met the exception you mentioned.
Regards,
Don
Thanks for the reply.
The format of the data file is not relevant here, our application doesn’t actually read it in that way.
I have modified your Kriging sample application to reproduce the error and have attached it here. It just needed to account for the difference in projection when reading the data file, and to put a try/catch block around the GenerateGrid call. If you start the application and change the number of reference points to 4, the exception occurs as described above. This is what is happening for us under various conditions.
As I mentioned in my original post, while the exception is in itself a problem, the bigger issue is that the entire application crashes when the exception is raised down in the MapSuiteCore. We would like to be able to recover from the problem.
If you have any advice, we would be most grateful.
Regards,
Scott D.
001_IsoLinesWithKriging.zip (142 KB)
Hi Scott,
Thanks for the sample, it is very easy for us to recreate the issue. Currently, we are working on it and will give you a response asap.
Thanks,
Troy
Hello again,
Just wondering if there is any news on this, either a fix or a work-around? Any information much appreciated.
Regards,
Scott D.
Hi Scott,
That crash caused by exception is thrown in child thread, for now we cannot fix that in our end, as below is a workaround, please let us know whether that can work for you.
I think you can solve that like this:
public class MyLinealKrigingGridInterpolationModel : LinealKrigingGridInterpolationModel
{
double noDataValue = -9999; // You can modify this value equal the value in function CreateGridFile of sample.cs
public MyLinealKrigingGridInterpolationModel()
: base(new Dictionary<PointShape, double>(), 5)
{ }
public MyLinealKrigingGridInterpolationModel(IDictionary<PointShape, double> points)
: base(points, 5)
{ }
public MyLinealKrigingGridInterpolationModel(IDictionary<PointShape, double> points, int numberOfRefreancedPoints)
: base(points, numberOfRefreancedPoints)
{ }
protected override double InterpolateCore(RectangleShape cellExtent, GridDefinition gridDefinition)
{
double result;
try
{
result = base.InterpolateCore(cellExtent, gridDefinition);
}
catch (Exception)
{
result = noDataValue;
}
return result;
}
}
The use the new class: interpolationModel = new MyLinealKrigingGridInterpolationModel(wellDepthPointData, referencingPointCount);
That will solve your issue.
Regards,
Don
Thank you for the response, much appreciated.
I will give this a try now.
Regards,
Scott D.
Scott,
Please let us know if the issue still persists.
Thanks,
Troy
That fixed the problem, and didn’t stop us generating the contours either. This is great news.
Thanks again for the assistance.
Regards,
Scott D.
Great to hear Don’t suggestion works.
Thanks,
Troy