Hi,
I am having trouble with two methods, GetFeaturesWithinDistanceOf and GetFeaturesNearestTo. If no projection is applied to the layer these methods seem to work fine. However, if I project a layer in UTM83 Zone 16N into a geographic projection (NAD83) I receive an error every time I try to use them. Here is a code snippet:
Private Sub Map1_MapClick(ByVal sender As Object, ByVal e As ThinkGeo.MapSuite.DesktopEdition.MapClickWinformsMapEventArgs) Handles Map1.MapClick
Dim oFeatures As Collection(Of Feature)
Dim oClickPoint As New ScreenPointF(e.ScreenX, e.ScreenY)
Dim oDistancePoint As New ScreenPointF(e.ScreenY + 15, e.ScreenY)
Dim dDistance As Double = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(Map1.CurrentExtent, oClickPoint, oDistancePoint, Map1.Width, Map1.Height, Map1.MapUnit, DistanceUnit.Meter)
oFeatures = moTestUTMLayer.FeatureSource.GetFeaturesWithinDistanceOf(
New PointShape(e.WorldX, e.WorldY),
Map1.MapUnit,
DistanceUnit.Meter,
dDistance,
ReturningColumnsType.AllColumns)
oFeatures = moTestUTMLayer.FeatureSource.GetFeaturesNearestTo(New PointShape(e.WorldX, e.WorldY), Map1.MapUnit, 1, New String() {""}, dDistance, DistanceUnit.Meter)
End Sub
And here is the error I get:
System.ArgumentOutOfRangeException was unhandled
Message=The decimal degree latitude value you provided was out of range.
Parameter name: latitude
ParamName=latitude
Source=MapSuiteCore
StackTrace:
at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xcaea77dcf8ddb91c(Double x68af109c02c3871b, String x34decc57f0820440)
at ThinkGeo.MapSuite.Core.DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(Double distance, DistanceUnit distanceUnit, Double latitude)
at ThinkGeo.MapSuite.Core.BaseShape.BufferCore(Double distance, Int32 quadrantSegments, BufferCapType bufferCapType, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.BaseShape.Buffer(Double distance, GeographyUnit shapeUnit, DistanceUnit distanceUnit)
at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesWithinDistanceOfCore(BaseShape targetShape, GeographyUnit unitOfData, DistanceUnit distanceUnit, Double distance, IEnumerable`1 returningColumnNames)
at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesWithinDistanceOf(BaseShape targetShape, GeographyUnit unitOfData, DistanceUnit distanceUnit, Double distance, IEnumerable`1 returningColumnNames)
at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesWithinDistanceOf(BaseShape targetShape, GeographyUnit unitOfData, DistanceUnit distanceUnit, Double distance, ReturningColumnsType returningColumnNamesType)
at GetFeaturesWithinDistanceOf.Form1.Map1_MapClick(Object sender, MapClickWinformsMapEventArgs e) in C:\Users\steller\documents\visual studio 2010\Projects\ThinkGeo\GetFeaturesWithinDistanceOf\Form1.vb:line 44
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.OnMapClick(MapClickWinformsMapEventArgs e)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x1e882ae98c96da8b(InteractionArguments x195facd4ef5d753d)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xfeca3317d3c75bbb(Object xd9272088e65bd176, x6a8380ab1a7ebb4c xc2fd4c0ed406cdb7)
at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.OnMouseEvent(x6a8380ab1a7ebb4c e)
at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.x9726bb53ed7f1ead(Object xd9272088e65bd176, EventArgs xc2fd4c0ed406cdb7)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at GetFeaturesWithinDistanceOf.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
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 am not sure whether the problem is because I don't understand how to use these methods, or if it's a bug, or if they just don't work on projected data. I can provide a project that demonstrates this problem if necessary. Can you help me with this issue?
Thanks,
Steve