Created
October 20, 2009 06:37
-
-
Save mikeyk/214070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableDictionary * hashedLocations = [NSMutableDictionary dictionaryWithCapacity:100]; | |
NSArray * lastResultList = [dataSource locations]; | |
for (InfoLocation * infoloc in lastResultList) { | |
InfoLocation * infoLocCopy = [[InfoLocation alloc] initWithInfoLocation:infoloc]; | |
CLLocationCoordinate2D coord = [infoloc coordinate]; | |
NSString * hash = [NSString stringWithFormat:@"%.5f-%.5f", coord.latitude, coord.longitude]; | |
if (![hashedLocations objectForKey:hash]) { | |
[hashedLocations setValue:[[NSNumber alloc] initWithInt:1] forKey:hash]; | |
} else { | |
// offset a bit so we don't have a bunch of clustered ones | |
int interval = [[infoLocCopy timestamp] timeIntervalSince1970]; | |
float latoffset = ((interval % 128) / 64.0) - 1; | |
float lonoffset = ((interval % 142) / 71.0) - 1; | |
coord.latitude += latoffset / 1300.0; | |
coord.longitude += lonoffset / 1300.0; | |
[infoLocCopy setCoordinate:coord]; | |
} | |
[mainMapView addAnnotation:infoLocCopy]; | |
[infoLocCopy release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment