Hello,
I would like to understand how to use the GetFeaturesWithinDistanceOf properly. I am now either getting no features or the whole dataset. I am using the 4.0 version.
I have a map using the OpenStreetMapOverlay and I am loading some shapefiles (defined in WGS:84 / Esri 4326) on it.
I am trying to allow the user to select the shapes and I am using the GetFeaturesWithinDistanceOf method.
wgsToMercator = new ManagedProj4Projection(ManagedProj4Projection.GetEsriParameters(4326),
ManagedProj4Projection.GetSphericalMercatorParameter());
mercatorToWgs = new ManagedProj4Projection(ManagedProj4Projection.GetSphericalMercatorParameter(),
ManagedProj4Projection.GetEsriParameters(4326));
roadLayer.Open();
mercatorToWgs.Open();
var shape = mercatorToWgs.ConvertToExternalProjection(clickWorldPosition);
mercatorToWgs.Close();
var featuresWithinDistance = roadLayer.QueryTools.GetFeaturesWithinDistanceOf(shape,GeographyUnit.DecimalDegree, DistanceUnit.Meter, 300, ReturningColumnsType.AllColumns);
The shape point is coming out as a sensible lat/long value that is actually on spot to where I click.
If I set the Geographic unit to meter I get all the shapes in the feature source. If I set the Geographic unit to degrees I get none. The shape file itself is in decimal degrees. What am I doing wrong ? Am I wrong in the assumption (and since it isn't documented) that the distance parameter of the method relates to distance unit ? What unit should the distance be ?
Thanks for any pointers.
EDIT
I decided to fiddle with the distance parameter, and I am finding the results rather odd.
Selecting the same point:
With GeographyUnit.Meter, DistanceUnit.Meter
Distance vs features found
1
0
10
0
50
0
50.5
0
51
230
52
51207
53
89497
56
121143 (complete dataset)
62
121143
75
121143
With GeographyUnit.DecimalDegreer, DistanceUnit.Meter
100
0
1000
0
5 000 000
0
5 100 000
0
5 300 000
0
5 500 000
0 (long search)
5 550 000
0
5 600 000
4134
5 750 000
78741
6 000 000
121143
I cannot make of these values. All I want is to get the feature I clicked on, I undesrtand that lines and so on make this bit more complex and that distance comes in play, but it seems the distance parameter is waay to sensitive and I do not know to what real units can I relate the distance to. The searches take very very long as well. I must be doing something wrong.