Archive for January, 2010

29
Jan

decode google maps PolyLines objective C

If you are working on Google maps API and using routes/directions
this will help you decode route polylines
works on MAC OS X and iPhone SDK

-(NSMutableArray *)decodePolyLine: (NSMutableString *)encoded {
[encoded replaceOccurrencesOfString:@"\\\\" withString:@"\\"
options:NSLiteralSearch
range:NSMakeRange(0, [encoded length])];
NSInteger len = [encoded length];
NSInteger index = 0;
NSMutableArray *array = [[NSMutableArray alloc] init];
NSInteger lat=0;
NSInteger lng=0;
while (index < len) {
NSInteger b;
NSInteger shift = 0;
NSInteger result = 0;
do {
b = [encoded characterAtIndex:index++] - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
NSInteger dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = [encoded characterAtIndex:index++] - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
NSInteger dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
lng += dlng;
NSNumber *latitude = [[NSNumber alloc] initWithFloat:lat * 1e-5];
NSNumber *longitude = [[NSNumber alloc] initWithFloat:lng * 1e-5];
CLLocation *loc = [[CLLocation alloc] initWithLatitude:[latitude floatValue] longitude:[longitude floatValue]];
[polyLines addObject:loc];
NSLog(@"%f,%f",[latitude floatValue],[longitude floatValue]);
[loc release];
[latitude release];
[longitude release];
}
return array;
}

25
Jan

failed to upload *.app

Developing with Xcode is not all gold, sometimes you get diarrhea.
Like “failed to upload *.app” to your iPhone device for debug.
Solution is to restart your Xcode.
dont bother disconnecting and reconnecting your iPhone.
If still same error
then check if you are misusing .plist file, just try bringing it back to stock.
Delete app manually and try clean and build.




January 2010
M T W T F S S
« Nov   Feb »
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

No categories

Xbox360

PS3

Hasnat's PSN

Flickr

www.flickr.com