[iOS]GPSとGPX(その1) | Cocoa練習帳

[iOS]GPSとGPX(その1)

GPSの情報を扱う形式に、GPX(GPS eXchange Format)というものがある。これを扱う為のフレームワークがMITライセンスで後悔されていたので、使ってみた。




iOS GPX Framework

http://gpxframework.com/




GitHubでの説明は、これをフレームワーク化して組み込み手順となっていたが、あまり、Xcodeに知らないものを組み込みたくないので、ソース一式をプロジェクトに追加した。




folder




ヘッダーファイルの検索パスに、このフレームワークのソースを追加する。




project




これで以下のようなサンプル・コードのビルドが通るようになったと思う。




#import <GPX/GPX.h>
...
GPXRoot *root = [GPXRoot rootWithCreator:@"Sample Application"];
    
GPXWaypoint *waypoint = [root newWaypointWithLatitude:35.658609f longitude:139.745447f];
waypoint.name = @"Tokyo Tower";
waypoint.comment = @"The old TV tower in Tokyo.";
    
GPXTrack *track = [root newTrack];
track.name = @"My New Track";
    
[track newTrackpointWithLatitude:35.658609f longitude:139.745447f];
[track newTrackpointWithLatitude:35.758609f longitude:139.745447f];
[track newTrackpointWithLatitude:35.828609f longitude:139.745447f];



ソースコード

GitHubからどうぞ。

https://github.com/murakami/workbook/tree/master/ios/WayPoints - GitHub




関連情報

iOS GPX Framework

GitHub

This is a iOS framework for parsing/generating GPX files. This Framework parses the GPX from a URL or Strings and create Objective-C Instances of GPX structure.