Hello, all
I'd like to input lon/lat and search information about county and road.
In v2.x, I used spatialQuery and QueryByDistance to search where lon/lat in.
But, in v3.x RC2, it is many different.
could someone help me?
In v3.x :
value = instance.SpatialQuery(targetShape, queryType, returningColumnNamesType)
instance is a feacureSource...I don't know what's it mean. How could I use it?
the follows code is error:
Dim county_layer As ShapeFileFeatureLayer = DirectCast(WinformsMap1.FindFeatureLayer("county"), ShapeFileFeatureLayer)
results = town_layer.QueryTools.GetFeaturesWithin(testpoint, ReturningColumnsType.AllColumns)
in v2.x, I write as belows:
'(county search)
Dim testpoint = New PointShape(longitude, latitude)
intRecID = Map1.Layers(2).SpatialQuery(testpoint, SpatialQueryContainment.Contained) 'county
If intRecID.Length > 0 Then
str_county = Map1.Layers(2).DataQuery(intRecID(0), "COUNTYNAME")
End If
'(road search)
intRecID2 = Map1.Layers(13).QueryByDistance(testpoint, 10, MapLengthUnits.metres, Map1.MapUnit) 'road
Dim mPointShape = New PointShape(longitude, latitude)
Dim items As New Dictionary(Of Integer, Double)()
Dim distances As New List(Of Double)()
Dim diss(intRecID2.Length - 1) As Double
If intRecID2.Length > 0 Then
For j As Integer = 0 To intRecID2.Length - 1
diss(j) = mPointShape.DistanceTo(Map1.Layers(13).GetShape(intRecID2(j)), Map1.MapUnit, MapLengthUnits.miles, DistanceTypes.Shortest)
items.Add(intRecID2(j), diss(j))
distances.Add(diss(j))
Next
End If
Dim firstRecord As Integer = 0
Dim firstvalue As Double
If (intRecID2.Length > 0) Then
distances.Sort()
firstvalue = distances(0)
For j As Integer = 0 To intRecID2.Length - 1
If items(intRecID2(j)) = firstvalue Then
firstRecord = intRecID2(j)
End If
Next
str_road = Map1.Layers(13).DataQuery(firstRecord, "roadname")
End If