SENSOREN MOBILER DEVICES Universität zu Köln Historisch-Kulturwissenschaftliche Informationsverarbeitung AM1 Hauptseminar: Re-usable Content in 3D und Simulationssystemen SS 2013 Prof. Manfred Thaller Referent: Nicolas Frings
Inhalt Warum Sensoren? Sensortypen GPS-Tutorial
Warum Sensoren? Technischer Fortschritt der Smartphones Vereinfachung der Handhabung (Touch) Gerade bei Apps essenziell (Navigation/Ortung) Problemstellung: Apps sollen schnell und effizient qualitativ hochwertige Informationen liefern! Map-Apps Sensoren sind Grundvoraussetzung!
Warum Sensoren? Map-Apps Basic Knowledge in ios: 3 Typen: Web Apps Nutzen bereits vorhandene Geo-Referenzierungen (Google Maps) Lediglich Ortung des mobilen devices nötig (Google Maps JavaScript API)
Warum Sensoren? Hybrid Apps Smartphone-Apps welche auf Google Maps im Browser zurückgreifen Copy-Paste bestehender SDK s, Frameworks, etc. Ebenfalls Ortung des mobilen devices nötig Native Apps Smartphone-Apps welche auf Apple Maps zurückgreifen Ortung und Ausrichtung vonnöten (Map Kit API & Core Framework)
Sensortypen Kamera Optischer Sensor Schnittstelle: UIImagePickerViewController
Sensortypen Magnetometer Sensor erfasst magnetische Ausrichtung und ermöglicht so die präzise Ausrichtung des devices Kombination mit dem Beschleunigungssensor Ermöglicht Echtzeit-Ausrichtung Kompass Schnittstelle: CLLocationManager & CoreLocation
Sensortypen Mikrofon Audiosensor Spracheingabe automatische Lautstärkeregelung Schnittstelle: AV Foundation & Media Player frameworks
Sensortypen Beschleunigungssensor / Accelerometer Erfasst 3-achsige Bewegung Rotation (X-Achse) Weite (Y-Achse) Höhe (Z-Achse) Beispiel: Iphone senkrecht auf dem Tisch stehend: x = 0, y = 0, z = 1 Schnittstelle: Keine API im SDK vorhanden!
Sensortypen Gyroskop / Kreiselsensor Erweiterung zum Beschleunigungssensor Erfasst präzise das device in sämtlichen Lagen und Positionen Grundlage für die device-ortung Core Framework Schnittstelle Schnittstelle: Core Location Framework
GPS-Tutorial Neues Projekt mit der CoreLocation Framework verknüpfen und eine CoreLocationDelegateClass als Objective-C class anlegen.
GPS-Tutorial In der.h wird die Klasse definiert. #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> @protocol CoreLocationControllerDelegate @required @end - (void)locationupdate:(cllocation *)location; - (void)locationerror:(nserror *)error; @interface CoreLocationController : NSObject <CLLocationManagerDelegate> { CLLocationManager *locmgr; id delegate; @property (nonatomic, retain) CLLocationManager *locmgr; @property (nonatomic, assign) id delegate; @end
GPS-Tutorial In der.m werden die eigentlichen core-updates festgelegt #import "CoreLocationController.h @implementation CoreLocationController @synthesize locmgr, delegate; - (id)init { self = [super init]; if(self!= nil) { self.locmgr = [[[CLLocationManager alloc] init] autorelease]; self.locmgr.delegate = self; return self; - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { if([self.delegate conformstoprotocol:@protocol(corelocationcontrollerdelegate)]) { [self.delegate locationupdate:newlocation]; - (void)locationmanager:(cllocationmanager *)manager didfailwitherror:(nserror *)error { if([self.delegate conformstoprotocol:@protocol(corelocationcontrollerdelegate)]) { [self.delegate locationerror:error]; - (void)dealloc { [self.locmgr release]; [super dealloc]; @end
GPS-Tutorial Nun noch ein geeignetes UI, welches auf Objekte unserer Klasse zurückgreift. #import <UIKit/UIKit.h> #import "CoreLocationController.h" @interface CoreLocationDemoViewController : UIViewController <CoreLocationControllerDelegate> { CoreLocationController *CLController; IBOutlet UILabel *loclabel; @property (nonatomic, retain) CoreLocationController *CLController; @end
GPS-Tutorial Und dann noch das rekursive Update implementieren - (void)viewdidload { [super viewdidload]; CLController = [[CoreLocationController alloc] init]; CLController.delegate = self; [CLController.locMgr startupdatinglocation]; - (void)locationupdate:(cllocation *)location { loclabel.text = [location description]; - (void)locationerror:(nserror *)error { loclabel.text = [error description]; - (void)didreceivememorywarning { [super didreceivememorywarning];
Vielen Dank!
Quellen Andreucci, Pro ios Geo Allan, Basic Sensors in ios http://www.vellios.com/2010/08/16/core-location-gpstutorial/