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.


The ArcGIS WP7 api has clustering capabilities.

enter image description here

| improve this answer | |
  • isnt that a server side thing? I have all my POI's locally – Mark Mar 30 '11 at 4:21
  • The way I read it, you should be able to create a graphics layer at run time, assign it a clusterer, then add graphics to it (one graphic for each POI). As the graphics are added, the clusterer builds clusters for you. – Kirk Kuykendall Mar 30 '11 at 13:13

I am working on a similar problem with iOS. I have come across this answer How do I cluster XY point data? (ArcGIS 9.3) which I am trying to incorporate into the iOS app. I've not yet figured out how best to apply it (server or client), but the theory seems sound. Essentially, create a grid and then map each point to the closest corner. I'll follow this post and update with anything I find as I work through this one...

| improve this answer | |
  • thanks, sounds like a good theory im just worried about performance as all my content is local, no server side data – Mark Mar 30 '11 at 4:22
  • 1
    This type of algorithm is computationally efficient: all it takes to identify a point's cluster is to to shift, rescale, and round each coordinate. For 1500 points, then, we're talking about tens of microseconds, maybe a few milliseconds in interpreted environments on slow CPUs. – whuber Mar 30 '11 at 4:33
  • I agree with whuber. I had the same high performance needs, in my case pulling ~15000 points from ArcGIS server and then clustering in iOS (and in javascript for a web implementation). – Steve Mar 31 '11 at 0:25
  • 1
    I don't have anything to copy and paste but I'll try and throw something together later today. As a comment on the other suggestion, it is not server side. If you have a graphics layer that you are using in WP7 to display your points, you should be able to add the clusterer to the layer and have it do this automatically. The "Extending the GraphicsClusterer" section has a decent example on how to subclass it for custom appearance. – Steve Mar 31 '11 at 15:15
  • 1
    that would be fantastic, I will also have a go, I have read over the theory a few times now and am getting understanding a lot better. But if you do happen to have some spare time to throw something together, that would be greatly appreciated – Mark Mar 31 '11 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.