Skip to content

Commit c3416d9

Browse files
committed
Add playground as better example
1 parent 61786d2 commit c3416d9

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Example/CoreGPX.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
B1FA67C144CC465C6B228AB8 /* GPXKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GPXKit.podspec; path = ../GPXKit.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
5151
BF67E9292217F2EE008B6202 /* GPXTest-TrackPointOnly.gpx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "GPXTest-TrackPointOnly.gpx"; sourceTree = "<group>"; };
5252
BF693E5022C8A69A00CBCE5A /* CoreGPX.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; name = CoreGPX.podspec; path = ../CoreGPX.podspec; sourceTree = "<group>"; };
53+
BF693E5422C8E71B00CBCE5A /* CoreGPX Playground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = "CoreGPX Playground.playground"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
5354
BF7F905C21F7501800359484 /* CreationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreationViewController.swift; sourceTree = "<group>"; };
5455
BFD4523C21E9F17A002ECA3A /* ParseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseViewController.swift; sourceTree = "<group>"; };
5556
E4C0F7E2E749B02F23048D43 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
@@ -100,6 +101,7 @@
100101
607FACD21AFB9204008FA782 /* Example for CoreGPX */ = {
101102
isa = PBXGroup;
102103
children = (
104+
BF693E5422C8E71B00CBCE5A /* CoreGPX Playground.playground */,
103105
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
104106
607FACD71AFB9204008FA782 /* ViewController.swift */,
105107
BF7F905C21F7501800359484 /* CreationViewController.swift */,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Foundation
2+
import CoreGPX
3+
4+
// Example: Generate GPX string
5+
6+
let root = GPXRoot(creator: "CoreGPX Playground")
7+
8+
let track = GPXTrack()
9+
let firstSegment = GPXTrackSegment()
10+
11+
let metadata = GPXMetadata()
12+
13+
metadata.time = Date()
14+
metadata.copyright = GPXCopyright(author: "Vincent Neo")
15+
metadata.desc = "This GPX File is created to facilitate the understanding of CoreGPX library's usage!"
16+
17+
root.metadata = metadata
18+
19+
let firstTrkPt = GPXTrackPoint(latitude: 1.2345, longitude: 2.3456)
20+
firstTrkPt.elevation = 31.92492
21+
firstTrkPt.extensions = GPXExtensions()
22+
firstTrkPt.extensions!["customproperties"] = ["Location" : "Sembawang, Singapore", "CompassDegree" : "120"]
23+
24+
let secondTrkPt = GPXTrackPoint(latitude: 0.294, longitude: 38.019)
25+
26+
firstSegment.add(trackpoint: firstTrkPt)
27+
firstSegment.add(trackpoint: secondTrkPt)
28+
29+
track.add(trackSegment: firstSegment)
30+
31+
root.add(track: track)
32+
33+
print(root.gpx())
34+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

0 commit comments

Comments
 (0)