TCXZpot-Swift 0.1.1

TCXZpot-Swift 0.1.1

测试已测试
Lang语言 SwiftSwift
许可证 Apache 2
发布最新发布2017年8月
SwiftSwift 版本3.0
SPM支持 SPM

TomásRuizLópez 维护。



  • Tomás Ruiz-López

TCXZpot

一个用于创建 TCX 文件的流畅 Swift 库。请注意,这是一个正在开发中的库,尚未包含 TCX 所有支持的功能。它们将在未来的版本中添加。

有关 TCX 格式的详细规范,请访问 Garmin 规范

支持的功能

TCX 文件的根是 TrainingCenterDatabase,它可以有多个类型的子项。以下是支持的类型:

  • 文件夹
  • 活动
  • 训练
  • 课程
  • 作者
  • 扩展

在支持的模块中,除了扩展外,所有功能都已实现。

示例

您可以使用 TCXZpot 中的流畅语法轻松创建 TCX 文件

let db = TrainingCenterDatabase(activities:
                                    Activities(with:
                                        Activity(id: TCXDate(day: 10, month: 2, year: 2017, hour: 10, minute: 42, second: 0)!,
                                                 laps: [Lap(startTime: TCXDate(day: 10, month: 2, year: 2017, hour: 10, minute: 42, second: 0)!,
                                                           totalTime: 3000,
                                                           distance: 1200,
                                                           calories: 100,
                                                           intensity: .active,
                                                           triggerMethod: .manual,
                                                           tracks: Track(with:
                                                                Trackpoint(time: TCXDate(day: 10, month: 2, year: 2017, hour: 10, minute: 42, second: 0)!,
                                                                           position: Position(latitude: -3.6714, longitude: 36.8936)),
                                                                Trackpoint(time: TCXDate(day: 10, month: 2, year: 2017, hour: 10, minute: 42, second: 43)!,
                                                                      position: Position(latitude: -3.6727, longitude: 36.8946)),
                                                                Trackpoint(time: TCXDate(day: 10, month: 2, year: 2017, hour: 10, minute: 43, second: 20)!,
                                                                           position: Position(latitude: -3.6733, longitude: 36.901))
                                                                )
                                                        )],
                                                 notes: Notes(text: "A sample session"),
                                                 creator: Device(name: "BreathZpot Sensor",
                                                                 unitID: 1,
                                                                 productID: 1234567,
                                                                 version: Version(versionMajor: 1, versionMinor: 0)),
                                                 sport: .running)),
                                author:
                                    Application(name: "BreathZpot",
                                                build: Build(version: Version(versionMajor: 1, versionMinor: 0)),
                                                languageID: "en",
                                                partNumber: "123-45678-90"))
let serializer = FileSerializer()
db.serialize(to: serializer)
serializer.save(toPath : "path/to/file") // Can throw SerializationError.fileNotSaved

许可证

Copyright 2017 SweetZpot AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.