I have alread asked this question on SO, so I apologize if duplicating this is bad form. I will link to each of the sites if I get the right answer.
I have a collection of my own PointOfInterest
classes (approx. 1500) each having their own Latitude
and Longitude
double properties.
Im trying to draw them on my screen, but at a certain logical zoom level, there is no point showing some of them because they are so close together.
How can I very efficiently group POI's by their lat lon properties?
I have this type of thing:
var pointOfInterests = (from p in PointsOfInterest select p).Distinct(new EqualityComparer()).ToList();
where the EqualityComparer
is:
public class EqualityComparer : IEqualityComparer<PointOfInterest>
{
public bool Equals(PointOfInterest x, PointOfInterest y)
{
return Math.Round(x.Latitude.Value, PointOfInterest.DecimalPlaceFilterLevel) == Math.Round(y.Latitude.Value, PointOfInterest.DecimalPlaceFilterLevel) &&
Math.Round(x.Longitude.Value, PointOfInterest.DecimalPlaceFilterLevel) == Math.Round(y.Longitude.Value, PointOfInterest.DecimalPlaceFilterLevel);
}
public int GetHashCode(PointOfInterest obj)
{
return Math.Round(obj.Latitude.Value, PointOfInterest.DecimalPlaceFilterLevel).GetHashCode() ^ Math.Round(obj.Longitude.Value, PointOfInterest.DecimalPlaceFilterLevel).GetHashCode();
}
}
and the PointOfInterest.DecimalPlaceFilterLevel
is a static int property that I set when the user is at a certian zoom level.
But this isnt working, I keep getting overlapping POI's and its not very fast... since I am on the phone, I need it to perform very well.