ThinkGeo.com    |     Documentation    |     Premium Support

FormatException with InMemoryGridFeatureSource.GetAllFeatures()

 Hi,


I am attempting to get all the features from the interpolated grid as polygons using InMemoryGridFeatureSource as below but when I'm trying to retrieve the features, I get this exception:



// Input data in WGS84
var boundary = new Feature("POLYGON ((-90.282488000113517 33.580227999947965, -90.282328000059351 33.5802599999588, -90.2821919999551 33.5802599999588, -90.282016000011936 33.58027600008063, -90.2818879999686 33.580328000010923, -90.281815999886021 33.580456000054255, -90.281752000097185 33.580612000077963, -90.28170399996452 33.580739999888465, -90.281607999932021 33.5808679999318, -90.281560000032187 33.581055999966338, -90.281615999992937 33.581220000050962, -90.2817760000471 33.581336000002921, -90.281864000018686 33.581464000046253, -90.281840000068769 33.581607999978587, -90.281832000007853 33.581744000082836, -90.281752000097185 33.5818080001045, -90.2816800000146 33.581920000026, -90.281656000064686 33.582063999958336, -90.28164800000377 33.5822240000125, -90.28164800000377 33.582395999925211, -90.281639999942854 33.582575999898836, -90.281632000114769 33.58273999998346, -90.281624000053853 33.582891999976709, -90.281607999932021 33.583067999919876, -90.28159200004302 33.583227999974042, -90.281543999910355 33.58338399999775, -90.2814720000606 33.583559999940917, -90.2813919999171 33.583739999914542, -90.281327999895439 33.583931999979541, -90.2812640001066 33.584120000014082, -90.281224000034854 33.584304000018165, -90.281215999973938 33.584488000022247, -90.281200000084937 33.58467200002633, -90.2811680000741 33.584856000030413, -90.2810879999306 33.584971999982372, -90.280967999948189 33.584939999971539, -90.280967999948189 33.584772000089288, -90.281008000019938 33.584543999983, -90.281055999919772 33.584319999907166, -90.281104000052437 33.584111999953166, -90.281160000013188 33.583908000029624, -90.281215999973938 33.583692000014707, -90.2812959998846 33.583480000030249, -90.281327999895439 33.583347999956459, -90.2813760000281 33.583172000013292, -90.2813919999171 33.582951999967918, -90.281408000038937 33.582727999892086, -90.281408000038937 33.582515999907628, -90.281399999978021 33.582316000014544, -90.281416000099853 33.582123999949545, -90.281423999927938 33.58192400005646, -90.281479999888688 33.581748000113294, -90.2814879999496 33.581644000019878, -90.2813760000281 33.5816160000395, -90.2812799999956 33.581712000072, -90.281200000084937 33.581903999904171, -90.281112000113353 33.582159999990836, -90.281048000091687 33.582412000047043, -90.280959999887273 33.582660000072792, -90.2808640000876 33.582911999896169, -90.2807839999441 33.583167999982834, -90.280712000094354 33.583431999897584, -90.280608000000939 33.583696000045165, -90.280543999979272 33.583951999899, -90.280439999885857 33.584192000096664, -90.28035999997519 33.584439999889582, -90.280248000053689 33.584687999915332, -90.280224000103772 33.584911999991164, -90.280199999921024 33.585063999984413, -90.280128000071272 33.585147999925539, -90.280040000099689 33.585327999899164, -90.279944000067189 33.585547999944538, -90.279880000045523 33.585787999909371, -90.27979200007394 33.586024000076577, -90.279728000052273 33.58626400004141, -90.279655999969691 33.58651200006716, -90.279600000008941 33.586756000062451, -90.279576000059024 33.5870040000882, -90.279559999937192 33.587248000083491, -90.279567999998108 33.587492000078782, -90.279567999998108 33.587743999902159, -90.279583999887109 33.588004000019282, -90.279591999948025 33.588243999984115, -90.279600000008941 33.588479999918491, -90.279600000008941 33.588723999913782, -90.279608000069857 33.588952000020072, -90.279608000069857 33.589187999954447, -90.279600000008941 33.589440000010654, -90.279623999958858 33.589679999975488, -90.279632000019774 33.58990400005132, -90.279632000019774 33.590120000066236, -90.279687999980524 33.590328000020236, -90.279743999941275 33.590456000063568, -90.279728000052273 33.590572000015527, -90.279679999919608 33.590715999947861, -90.279679999919608 33.590916000073776, -90.279704000102356 33.591143999947235, -90.279704000102356 33.591391999972984, -90.279719999991357 33.591627999907359, -90.279719999991357 33.591860000044107, -90.279728000052273 33.592100000008941, -90.279728000052273 33.592324000084773, -90.27975200000219 33.592543999897316, -90.279880000045523 33.592671999940649, -90.280167999910191 33.592667999910191, -90.280520000029355 33.592643999960274, -90.280871999915689 33.592607999918982, -90.281239999923855 33.592568000080064, -90.28159200004302 33.592543999897316, -90.281960000051185 33.592495999997482, -90.282335999887437 33.592431999975815, -90.2826880000066 33.592384000075981, -90.28303200006485 33.592339999973774, -90.283383999951184 33.5923119999934, -90.2837119998876 33.592352000065148, -90.284008000046015 33.592491999967024, -90.284295999910682 33.592620000010356, -90.284560000058264 33.592731999931857, -90.284847999922931 33.592851999914274, -90.285112000070512 33.592964000068605, -90.285279999952763 33.593039999948815, -90.2853119999636 33.593056000070646, -90.285895999986678 33.593003999907523, -90.28591200010851 33.592956000007689, -90.285983999958262 33.592787999892607, -90.286071999929845 33.592560000019148, -90.286176000023261 33.592307999962941, -90.286279999883845 33.592027999926358, -90.286360000027344 33.591751999920234, -90.286432000109926 33.591468000086024, -90.286616000114009 33.591216000029817, -90.286888000089675 33.590991999953985, -90.287184000015259 33.590779999969527, -90.287472000112757 33.590563999954611, -90.287815999938175 33.590272000059485, -90.288127999985591 33.590071999933571, -90.288495999993756 33.589964000042528, -90.2887599999085 33.589791999896988, -90.288823999930173 33.589495999971405, -90.288928000023589 33.588823999976739, -90.288968000095338 33.588487999979407, -90.289031999884173 33.588136000093073, -90.28909599990584 33.587768000084907, -90.2891599999275 33.58736400003545, -90.289223999949172 33.586991999996826, -90.289360000053421 33.586251999950036, -90.289431999903172 33.585864000022411, -90.289551999885589 33.585483999922872, -90.28976000007242 33.585143999895081, -90.290015999926254 33.584836000110954, -90.290263999952 33.584531999891624, -90.290456000017 33.584263999946415, -90.2905520000495 33.584092000033706, -90.290608000010252 33.583916000090539, -90.290631999960169 33.583704000106081, -90.290648000082 33.583467999938875, -90.290672000031918 33.5832320000045, -90.290672000031918 33.583000000100583, -90.290672000031918 33.582759999902919, -90.290680000092834 33.582543999888, -90.29068799992092 33.582316000014544, -90.29068799992092 33.582084000110626, -90.290680000092834 33.58184799994342, -90.290695999981835 33.5816160000395, -90.290704000042751 33.581387999933213, -90.290695999981835 33.581167999887839, -90.290608000010252 33.581000000005588, -90.290424000006169 33.580935999983922, -90.290199999930337 33.580916000064462, -90.29002399998717 33.580871999962255, -90.289888000115752 33.580824000062421, -90.2897679999005 33.580768000101671, -90.289591999957338 33.580739999888465, -90.289416000014171 33.580708000110462, -90.289199999999255 33.580676000099629, -90.289015999995172 33.580651999916881, -90.288831999991089 33.580644000088796, -90.288647999987 33.58063600002788, -90.288472000043839 33.580612000077963, -90.288423999911174 33.580612000077963, -90.288416000083089 33.580644000088796, -90.28827999997884 33.580623999936506, -90.288119999924675 33.580631999997422, -90.28801600006409 33.58063600002788, -90.287896000081673 33.580627999966964, -90.287768000038341 33.580612000077963, -90.287639999995008 33.58063600002788, -90.287552000023425 33.580687999958172, -90.287511999951676 33.580700000049546, -90.287464000051841 33.580672000069171, -90.287376000080258 33.580599999986589, -90.287248000036925 33.5805480000563, -90.287087999982759 33.580527999904007, -90.286912000039592 33.580527999904007, -90.286768000107259 33.580524000106379, -90.286608000053093 33.58048400003463, -90.28648000000976 33.580456000054255, -90.286351999966428 33.580435999901965, -90.28621600009501 33.580432000104338, -90.28606400010176 33.5804520000238, -90.2859040000476 33.580464000115171, -90.285743999993429 33.580460000084713, -90.28560799988918 33.580456000054255, -90.28545599989593 33.5804520000238, -90.285303999902681 33.580435999901965, -90.285159999970347 33.58042800007388, -90.2849920000881 33.580415999982506, -90.2848159999121 33.580400000093505, -90.284639999968931 33.580388000002131, -90.284440000075847 33.580375999910757, -90.284231999889016 33.58037200011313, -90.284008000046015 33.580347999930382, -90.283815999981016 33.580328000010923, -90.283616000087932 33.580315999919549, -90.2833920000121 33.580291999969631, -90.2831840000581 33.580263999989256, -90.2829919999931 33.580240000039339, -90.282848000060767 33.5802440000698, -90.282696000067517 33.580236000008881, -90.282488000113517 33.580227999947965))");

var dataPoints = new Dictionary<PointShape, double>();
dataPoints.Add(new PointShape(){ X = -90.5176819052947, Y = 33.3351474890471 }, 214);
dataPoints.Add(new PointShape(){ X = -90.5166210650288, Y = 33.3360337851921 }, 290);
dataPoints.Add(new PointShape(){ X = -90.5166210650288, Y = 33.3342611838843 }, 264);
dataPoints.Add(new PointShape(){ X = -90.5166212448932, Y = 33.3333748697038 }, 236);

// Projections
var directProjection = new Proj4Projection(Proj4Projection.GetWgs84ParametersString(),                                                   Proj4Projection.GetGoogleMapParametersString());
var inverseProjection = new Proj4Projection(Proj4Projection.GetGoogleMapParametersString(),                                                 Proj4Projection.GetWgs84ParametersString());

// Reproject to GoogleMap the boundary and data points
var reprojectedDataPoints = new Dictionary<PointShape, double>();
directProjection.Open();
Feature reprojectedBoundary = directProjection.ConvertToExternalProjection(boundary);
foreach (var dataPoint in dataPoints)
{              reprojectedDataPoints.Add((PointShape)directProjection.ConvertToExternalProjection(dataPoint.Key), dataPoint.Value);
}
directProjection.Close();

// Create the feature source and attempt to get features
var interpolationExtent = reprojectedBoundary.GetBoundingBox();

var gridDefinition = new GridDefinition(interpolationExtent, 10, 0,reprojectedDataPoints);
var interpolationModel = new InverseDistanceWeightedGridInterpolationModel();

var featureSource = new InMemoryGridFeatureSource();
featureSource.GridMatrix = InMemoryGridFeatureLayer.GenerateGridMatrix(gridDefinition, interpolationModel);
featureSource.Open();
var features = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
featureSource.Close();


[FormatException: 24141: A number is expected at position 31 of the input. The input has -1.79769313486232E+308.]


   Microsoft.SqlServer.Types.WellKnownTextReader.RecognizeDouble() +642


   Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText() +82


   Microsoft.SqlServer.Types.WellKnownTextReader.ParsePolygonText() +267


   Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type) +209


   Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid) +61


   Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid) +223


   Microsoft.SqlServer.Types.SqlGeometry.STGeomFromText(SqlChars geometryTaggedText, Int32 srid) +59


   ThinkGeo.MapSuite.Core.BaseShape.IntersectsCore(BaseShape targetShape) +330


   ThinkGeo.MapSuite.Core.BaseShape.Intersects(BaseShape targetShape) +124


   ThinkGeo.MapSuite.Core.InMemoryGridFeatureSource.GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable`1 returningColumnNames) +233


   ThinkGeo.MapSuite.Core.InMemoryGridFeatureSource.GetAllFeaturesCore(IEnumerable`1 returningColumnNames) +138


   ThinkGeo.MapSuite.Core.FeatureSource.GetAllFeatures(IEnumerable`1 returningColumnNames) +187


   ThinkGeo.MapSuite.Core.FeatureSource.GetAllFeatures(ReturningColumnsType returningColumnNamesType) +133


   TestingThinkGeo.Controllers.ThinkGeoController.GridFeatureSourceIssue() in C:\Users\Marius\Documents\Visual Studio 2010\Projects\TestingThinkGeo\TestingThinkGeo\Controllers\ThinkGeoController.cs:95


   lambda_method(Closure , ControllerBase , Object[] ) +101


   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14


   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211


   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27


   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28


   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57


   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48


   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57


   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223


   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57


   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48


   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24


   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57


   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43


   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14


   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62


   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57


   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62


   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47


   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10


   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25


   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23


   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62


   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47


   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9


   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629296


   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


Regards, 


Marius




Hi  Marius 
  
 We have fix this issue, please get the latest version 6.0.0.263 or 6.0.263.0. 
  
 Hope it helps. 
  
 Edgar 


 Thanks Edgar,


the fix works.



Hello Marius, 
  
 I’m glad it’s working , please feel free to let us know your problems. 
  
 Regards, 
  
 Gary