hi
Im working on getting points that are within a distanc that i specify when i click on the map, the issue is that points are not in a layer they are in an oracle db can you help me with the code.
Thanks
hi
Im working on getting points that are within a distanc that i specify when i click on the map, the issue is that points are not in a layer they are in an oracle db can you help me with the code.
Thanks
Hi Saddam,
Here is the code,
string connectString = "....";
OracleFeatureLayer oracleLayer = new OracleFeatureLayer(connectString, "", "");
oracleLayer.Open();
Collection<Feature> allFeaturesFromOrcl = oracleLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
InMemoryFeatureLayer inm = new InMemoryFeatureLayer();
foreach (var feature in allFeaturesFromOrcl)
{
if (feature.GetShape() is PointShape)
{
inm.InternalFeatures.Add(feature);
}
}
PointShape clickingPoint = e.Position;
//200 meter
Collection<Feature> expectedFeatures = inm.QueryTools.GetFeaturesWithinDistanceOf(clickingPoint, yourUnit, DistanceUnit.Meter, 200, ReturningColumnsType.AllColumns);
Hope it helps,
Edgar
hi Edgar
I have a large number of points in the db and i think that it will present a load on the system is there any way to get the distance using only lat and long without converting them into features and then use the getFeaturesWithinDistance?
THanks
Saddam,
I added the features into an InMemoryFeaturelayer is to make sure the features type are Point, the code could be simplified to,
string connectString = "....";
OracleFeatureLayer oracleLayer = new OracleFeatureLayer(connectString, "", "");
oracleLayer.Open();
PointShape clickingPoint = e.Position;
Collection<Feature> selectedFeatures = oracleLayer.QueryTools.GetFeaturesWithinDistanceOf(clickingPoint, yourUnit, DistanceUnit.Meter, 200, ReturningColumnsType.AllColumns);
The distance which I hard-coded is 200 meters, you can change it to your value.
If you can dissolve the points from db by yourself, you can use the following code the get the Distance.
DecimalDegreesHelper.GetDistanceFromDecimalDegrees(fromLongitude,fromLatitude,toLongitude,toLatitude);
Regards,
Edgar