Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2011, 10:14 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: TP Minnesota
Posts: 24
elias130 is on a distinguished road
Send a message via Skype™ to elias130
Question Help with getting location information

Ok so i am just starting out on writing code and i am having problems due to my lack of programming knowledge. I have gotten this code from the book,"Beginning iphone Development" so this code is not my work but Dave Mark, and Jeff LaMarche work.

my question is now that i have gotten the location data i want to create a method which can access the method which contains locationManager.



Code:
-(void)locationManager:(CLLocationManager *)manager 
didUpdateToLocation:(CLLocation *)newLocation 
fromLocation:(CLLocation *)oldLocation{

	if(startingPoint == nil)
		self.startingPoint = newLocation;
	
	
	NSString *latString = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.latitude];
	latLabel.text = latString;
	[latString release];
	
	NSString *lonString = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.longitude];
	lonLabel.text = lonString;
	[lonString release];
	
	NSString *horizontalAccuracyString = [[NSString alloc] initWithFormat:@"%gm", newLocation.horizontalAccuracy];
	horizontalAccuracyLabel.text = horizontalAccuracyString;
	[horizontalAccuracyString release];
	
	NSString *altitudeString = [[NSString alloc] initWithFormat:@"%gm", newLocation.altitude];
	altitudeLabel.text = altitudeString;
	[altitudeString release];
	
	NSString *verticalAccuracyString = [[NSString alloc] initWithFormat:@"%gm", newLocation.verticalAccuracy];
	verticalAccuracyLabel.text = verticalAccuracyString;
	[verticalAccuracyString release];
	
	CLLocationDistance distance = [newLocation getDistanceFrom:startingPoint];
	NSString *distanceString = [[NSString alloc] initWithFormat:@"%gm", distance];
	distanceTraveledLabel.text = distanceString;
	[distanceString release];
}
for example my new method wants to get the current altitude then wait 10 seconds and get the altitude again, with this data i would then take the change in altitude/time(10 secs) to get how many m/s i am moving up.


//sudo code
Code:
-(IBAction)getSpeed{
getAltitude;
wait 10 seconds;
getAltitudeDelayed;

AltitudeDelayed-Altitude = changeInAltitude;
chageInAltitdue/10 = rateOfChange;

label.text = rateOfChange; 
}
any help would be awesome!!
elias130 is offline   Reply With Quote
Old 02-13-2011, 02:43 AM   #2 (permalink)
Registered Member
 
Chobie's Avatar
 
Join Date: Feb 2011
Location: UK
Posts: 115
Chobie is on a distinguished road
Default

You need to understand how core location services work.

The method locationManager:didUpdateToLocation:fromLocation: is a delegate method and will be called everytime the location manager gets the latest location information.

Within the CLLocation objects you can get a whole load of information, altitude included but this requires GPS so you should configure the CLLocationManager accordingly.
__________________
Chobie is offline   Reply With Quote
Reply

Bookmarks

Tags
altimeter, gps, location, methods, speed

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 385
14 members and 371 guests
blasterbr, buggen, Clouds, EvilElf, jeroenkeij, jimmyon122, LEARN2MAKE, Mah6447, n00b, nyoe, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:52 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0