pyxctsk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyxctsk-0.1.0/LICENSE +21 -0
- pyxctsk-0.1.0/PKG-INFO +260 -0
- pyxctsk-0.1.0/README.md +223 -0
- pyxctsk-0.1.0/pyproject.toml +81 -0
- pyxctsk-0.1.0/setup.cfg +4 -0
- pyxctsk-0.1.0/src/pyxctsk/__init__.py +73 -0
- pyxctsk-0.1.0/src/pyxctsk/__main__.py +6 -0
- pyxctsk-0.1.0/src/pyxctsk/cli.py +97 -0
- pyxctsk-0.1.0/src/pyxctsk/distance.py +126 -0
- pyxctsk-0.1.0/src/pyxctsk/exceptions.py +27 -0
- pyxctsk-0.1.0/src/pyxctsk/geojson.py +282 -0
- pyxctsk-0.1.0/src/pyxctsk/optimization_config.py +36 -0
- pyxctsk-0.1.0/src/pyxctsk/parser.py +104 -0
- pyxctsk-0.1.0/src/pyxctsk/qrcode_task.py +547 -0
- pyxctsk-0.1.0/src/pyxctsk/route_optimization.py +462 -0
- pyxctsk-0.1.0/src/pyxctsk/sss_calculations.py +167 -0
- pyxctsk-0.1.0/src/pyxctsk/task.py +445 -0
- pyxctsk-0.1.0/src/pyxctsk/task_distances.py +308 -0
- pyxctsk-0.1.0/src/pyxctsk/turnpoint.py +388 -0
- pyxctsk-0.1.0/src/pyxctsk/utils.py +78 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/PKG-INFO +260 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/SOURCES.txt +34 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/dependency_links.txt +1 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/entry_points.txt +2 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/requires.txt +17 -0
- pyxctsk-0.1.0/src/pyxctsk.egg-info/top_level.txt +1 -0
- pyxctsk-0.1.0/tests/test_basic.py +169 -0
- pyxctsk-0.1.0/tests/test_distance.py +61 -0
- pyxctsk-0.1.0/tests/test_distance_basic.py +147 -0
- pyxctsk-0.1.0/tests/test_distance_integration.py +317 -0
- pyxctsk-0.1.0/tests/test_distance_slow.py +131 -0
- pyxctsk-0.1.0/tests/test_iterative_refinement.py +106 -0
- pyxctsk-0.1.0/tests/test_qrcode.py +133 -0
- pyxctsk-0.1.0/tests/test_sss_route_bug.py +206 -0
- pyxctsk-0.1.0/tests/test_sss_route_visual.py +389 -0
- pyxctsk-0.1.0/tests/test_xctrack.py +224 -0
pyxctsk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pyxctsk Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pyxctsk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyxctsk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python implementation of XCTrack's task format
|
|
5
|
+
Author-email: Simon Steiner <simonsteiner@users.noreply.github.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/simonsteiner/pyxctsk
|
|
8
|
+
Project-URL: Repository, https://github.com/simonsteiner/pyxctsk
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: click>=8.0.0
|
|
22
|
+
Requires-Dist: geopy>=2.0.0
|
|
23
|
+
Requires-Dist: Pillow>=8.0.0
|
|
24
|
+
Requires-Dist: polyline>=2.0.0
|
|
25
|
+
Requires-Dist: pyproj>=3.0.0
|
|
26
|
+
Requires-Dist: pyzbar>=0.1.9
|
|
27
|
+
Requires-Dist: qrcode[pil]>=7.0.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: beautifulsoup4>=4.9.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=21.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: flake8>=3.8.0; extra == "dev"
|
|
32
|
+
Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy>=0.800; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=2.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: requests>=2.25.0; extra == "dev"
|
|
37
|
+
|
|
38
|
+
# pyxctsk - Python implementation of XCTrack's task format
|
|
39
|
+
|
|
40
|
+
A comprehensive Python ecosystem for parsing, analyzing, and visualizing XCTrack task files and formats.
|
|
41
|
+
|
|
42
|
+
This repository contains the core module:
|
|
43
|
+
|
|
44
|
+
- **`xctrack`** - Core library for parsing and manipulating XCTrack task files
|
|
45
|
+
|
|
46
|
+
## Modules Overview
|
|
47
|
+
|
|
48
|
+
### pyxctsk Core (`src/pyxctsk/`)
|
|
49
|
+
|
|
50
|
+
The core Python library providing:
|
|
51
|
+
|
|
52
|
+
- Reading and writing `.xctsk` task files (JSON format)
|
|
53
|
+
- Generating and parsing `XCTSK:` URLs for task sharing
|
|
54
|
+
- Creating and decoding QR codes containing task data
|
|
55
|
+
- Converting tasks to KML format for visualization
|
|
56
|
+
- Command-line interface for format conversion
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Core Library Only
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install pyxctsk
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Development Installation
|
|
67
|
+
|
|
68
|
+
#### Setting up Virtual Environment
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/simonsteiner/pyxctsk.git
|
|
72
|
+
cd pyxctsk
|
|
73
|
+
|
|
74
|
+
# Create and activate virtual environment
|
|
75
|
+
python3 -m venv venv
|
|
76
|
+
source venv/bin/activate
|
|
77
|
+
# in subfolder use this command
|
|
78
|
+
source /home/simon/git/pyxctsk/venv/bin/activate
|
|
79
|
+
|
|
80
|
+
# Install core library in development mode with dev dependencies
|
|
81
|
+
pip install -e ".[dev]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Development Workflow
|
|
85
|
+
|
|
86
|
+
Once your virtual environment is set up:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Format code before committing
|
|
90
|
+
black src/ tests/
|
|
91
|
+
isort src/ tests/
|
|
92
|
+
|
|
93
|
+
# Run linting
|
|
94
|
+
flake8 src/ tests/
|
|
95
|
+
|
|
96
|
+
# Run type checking
|
|
97
|
+
mypy src/
|
|
98
|
+
|
|
99
|
+
# Run tests
|
|
100
|
+
pytest
|
|
101
|
+
|
|
102
|
+
# Deactivate when done
|
|
103
|
+
deactivate
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Verification
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Test that pyxctsk is properly installed
|
|
110
|
+
pyxctsk --help
|
|
111
|
+
|
|
112
|
+
# Run tests to ensure everything works
|
|
113
|
+
pytest
|
|
114
|
+
|
|
115
|
+
# Check code quality tools are available
|
|
116
|
+
black --version
|
|
117
|
+
isort --version
|
|
118
|
+
flake8 --version
|
|
119
|
+
mypy --version
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Quick Start
|
|
123
|
+
|
|
124
|
+
### Core Library Usage
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from pyxctsk import parse_task
|
|
128
|
+
|
|
129
|
+
# From file
|
|
130
|
+
task = parse_task('my_task.xctsk')
|
|
131
|
+
|
|
132
|
+
# From XCTSK: URL
|
|
133
|
+
task = parse_task('XCTSK:{"version":1,"taskType":"CLASSIC",...}')
|
|
134
|
+
|
|
135
|
+
# From QR code image (requires pyzbar and PIL)
|
|
136
|
+
task = parse_task('qr_code.png')
|
|
137
|
+
|
|
138
|
+
print(f"Task type: {task.task_type}")
|
|
139
|
+
print(f"Number of turnpoints: {len(task.turnpoints)}")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Command Line Tools
|
|
143
|
+
|
|
144
|
+
Core XCTrack CLI:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Convert task file to JSON
|
|
148
|
+
pyxctsk convert task.xctsk --format json
|
|
149
|
+
|
|
150
|
+
# Generate QR code
|
|
151
|
+
pyxctsk convert task.xctsk --format png --output qr.png
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Creating a task
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from pyxctsk import Task, TaskType, Turnpoint, Waypoint
|
|
158
|
+
|
|
159
|
+
task = Task(
|
|
160
|
+
task_type=TaskType.CLASSIC,
|
|
161
|
+
version=1,
|
|
162
|
+
turnpoints=[
|
|
163
|
+
Turnpoint(
|
|
164
|
+
radius=1000,
|
|
165
|
+
waypoint=Waypoint(
|
|
166
|
+
name="TP01",
|
|
167
|
+
lat=46.5,
|
|
168
|
+
lon=8.0,
|
|
169
|
+
alt_smoothed=1000
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
]
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# Save as JSON
|
|
176
|
+
with open('task.xctsk', 'w') as f:
|
|
177
|
+
f.write(task.to_json())
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### QR Code Generation
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from pyxctsk.utils import generate_qr_code
|
|
184
|
+
|
|
185
|
+
# Convert task to QR code format and generate image
|
|
186
|
+
qr_task = task.to_qr_code_task()
|
|
187
|
+
qr_string = qr_task.to_string()
|
|
188
|
+
qr_image = generate_qr_code(qr_string)
|
|
189
|
+
qr_image.save('task_qr.png')
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### KML Export
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from pyxctsk.utils import task_to_kml
|
|
196
|
+
|
|
197
|
+
kml_content = task_to_kml(task)
|
|
198
|
+
with open('task.kml', 'w') as f:
|
|
199
|
+
f.write(kml_content)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Command Line Interface
|
|
203
|
+
|
|
204
|
+
The package includes a command-line tool for format conversion:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Convert task to different formats
|
|
208
|
+
python -m pyxctsk task.xctsk --format json # JSON output
|
|
209
|
+
python -m pyxctsk task.xctsk --format kml # KML output
|
|
210
|
+
python -m pyxctsk task.xctsk --format qrcode-json # XCTSK: URL
|
|
211
|
+
python -m pyxctsk task.xctsk --format png -o qr.png # QR code image
|
|
212
|
+
|
|
213
|
+
# Parse from different inputs
|
|
214
|
+
python -m pyxctsk qr_code.png --format json # From QR image
|
|
215
|
+
cat task.xctsk | python -m pyxctsk --format kml # From stdin
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Requirements
|
|
219
|
+
|
|
220
|
+
- Python 3.8+
|
|
221
|
+
- Click (for CLI)
|
|
222
|
+
- Optional QR code support:
|
|
223
|
+
- Pillow (PIL) for image generation
|
|
224
|
+
- qrcode for QR code generation
|
|
225
|
+
- pyzbar for QR code reading from images
|
|
226
|
+
|
|
227
|
+
## Data Structures
|
|
228
|
+
|
|
229
|
+
The library provides comprehensive data classes for XCTrack task components:
|
|
230
|
+
|
|
231
|
+
- `Task`: Main task container
|
|
232
|
+
- `Turnpoint`: Individual waypoints with radius and type information
|
|
233
|
+
- `Waypoint`: Geographic coordinates and metadata
|
|
234
|
+
- `SSS`: Start of speed section configuration
|
|
235
|
+
- `Goal`: Goal/finish line configuration
|
|
236
|
+
- `Takeoff`: Takeoff location
|
|
237
|
+
- `TimeOfDay`: Time representation with validation
|
|
238
|
+
|
|
239
|
+
All classes support JSON serialization/deserialization and maintain compatibility with the XCTrack file format.
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
244
|
+
|
|
245
|
+
## AI-Assisted Migration
|
|
246
|
+
|
|
247
|
+
This Python implementation was migrated from the original Go codebase with the assistance of GitHub Copilot. The migration process involved:
|
|
248
|
+
|
|
249
|
+
- **AI Model**: Claude 4 Sonnet (via GitHub Copilot Chat)
|
|
250
|
+
- **Migration Approach**: Automated code analysis and conversion with human oversight
|
|
251
|
+
- **Process**: Complete rewrite maintaining API compatibility and feature parity
|
|
252
|
+
- **Validation**: Comprehensive testing against XCTrack Competition Interfaces specification
|
|
253
|
+
- **Quality Assurance**: Manual verification of all core functionality and edge cases
|
|
254
|
+
|
|
255
|
+
The AI assistant analyzed the Go source code structure, understood the XCTrack protocol specifications, and generated equivalent Python implementations while ensuring compatibility with the original format and adding modern Python idioms and type hints.
|
|
256
|
+
|
|
257
|
+
## Original Go Implementation
|
|
258
|
+
|
|
259
|
+
This Python library is based on the Go implementation by Tom Payne:
|
|
260
|
+
<https://github.com/twpayne/go-xctrack>
|
pyxctsk-0.1.0/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# pyxctsk - Python implementation of XCTrack's task format
|
|
2
|
+
|
|
3
|
+
A comprehensive Python ecosystem for parsing, analyzing, and visualizing XCTrack task files and formats.
|
|
4
|
+
|
|
5
|
+
This repository contains the core module:
|
|
6
|
+
|
|
7
|
+
- **`xctrack`** - Core library for parsing and manipulating XCTrack task files
|
|
8
|
+
|
|
9
|
+
## Modules Overview
|
|
10
|
+
|
|
11
|
+
### pyxctsk Core (`src/pyxctsk/`)
|
|
12
|
+
|
|
13
|
+
The core Python library providing:
|
|
14
|
+
|
|
15
|
+
- Reading and writing `.xctsk` task files (JSON format)
|
|
16
|
+
- Generating and parsing `XCTSK:` URLs for task sharing
|
|
17
|
+
- Creating and decoding QR codes containing task data
|
|
18
|
+
- Converting tasks to KML format for visualization
|
|
19
|
+
- Command-line interface for format conversion
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Core Library Only
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install pyxctsk
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Development Installation
|
|
30
|
+
|
|
31
|
+
#### Setting up Virtual Environment
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/simonsteiner/pyxctsk.git
|
|
35
|
+
cd pyxctsk
|
|
36
|
+
|
|
37
|
+
# Create and activate virtual environment
|
|
38
|
+
python3 -m venv venv
|
|
39
|
+
source venv/bin/activate
|
|
40
|
+
# in subfolder use this command
|
|
41
|
+
source /home/simon/git/pyxctsk/venv/bin/activate
|
|
42
|
+
|
|
43
|
+
# Install core library in development mode with dev dependencies
|
|
44
|
+
pip install -e ".[dev]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Development Workflow
|
|
48
|
+
|
|
49
|
+
Once your virtual environment is set up:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Format code before committing
|
|
53
|
+
black src/ tests/
|
|
54
|
+
isort src/ tests/
|
|
55
|
+
|
|
56
|
+
# Run linting
|
|
57
|
+
flake8 src/ tests/
|
|
58
|
+
|
|
59
|
+
# Run type checking
|
|
60
|
+
mypy src/
|
|
61
|
+
|
|
62
|
+
# Run tests
|
|
63
|
+
pytest
|
|
64
|
+
|
|
65
|
+
# Deactivate when done
|
|
66
|
+
deactivate
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Verification
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Test that pyxctsk is properly installed
|
|
73
|
+
pyxctsk --help
|
|
74
|
+
|
|
75
|
+
# Run tests to ensure everything works
|
|
76
|
+
pytest
|
|
77
|
+
|
|
78
|
+
# Check code quality tools are available
|
|
79
|
+
black --version
|
|
80
|
+
isort --version
|
|
81
|
+
flake8 --version
|
|
82
|
+
mypy --version
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
### Core Library Usage
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from pyxctsk import parse_task
|
|
91
|
+
|
|
92
|
+
# From file
|
|
93
|
+
task = parse_task('my_task.xctsk')
|
|
94
|
+
|
|
95
|
+
# From XCTSK: URL
|
|
96
|
+
task = parse_task('XCTSK:{"version":1,"taskType":"CLASSIC",...}')
|
|
97
|
+
|
|
98
|
+
# From QR code image (requires pyzbar and PIL)
|
|
99
|
+
task = parse_task('qr_code.png')
|
|
100
|
+
|
|
101
|
+
print(f"Task type: {task.task_type}")
|
|
102
|
+
print(f"Number of turnpoints: {len(task.turnpoints)}")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Command Line Tools
|
|
106
|
+
|
|
107
|
+
Core XCTrack CLI:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Convert task file to JSON
|
|
111
|
+
pyxctsk convert task.xctsk --format json
|
|
112
|
+
|
|
113
|
+
# Generate QR code
|
|
114
|
+
pyxctsk convert task.xctsk --format png --output qr.png
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Creating a task
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from pyxctsk import Task, TaskType, Turnpoint, Waypoint
|
|
121
|
+
|
|
122
|
+
task = Task(
|
|
123
|
+
task_type=TaskType.CLASSIC,
|
|
124
|
+
version=1,
|
|
125
|
+
turnpoints=[
|
|
126
|
+
Turnpoint(
|
|
127
|
+
radius=1000,
|
|
128
|
+
waypoint=Waypoint(
|
|
129
|
+
name="TP01",
|
|
130
|
+
lat=46.5,
|
|
131
|
+
lon=8.0,
|
|
132
|
+
alt_smoothed=1000
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# Save as JSON
|
|
139
|
+
with open('task.xctsk', 'w') as f:
|
|
140
|
+
f.write(task.to_json())
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### QR Code Generation
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from pyxctsk.utils import generate_qr_code
|
|
147
|
+
|
|
148
|
+
# Convert task to QR code format and generate image
|
|
149
|
+
qr_task = task.to_qr_code_task()
|
|
150
|
+
qr_string = qr_task.to_string()
|
|
151
|
+
qr_image = generate_qr_code(qr_string)
|
|
152
|
+
qr_image.save('task_qr.png')
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### KML Export
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from pyxctsk.utils import task_to_kml
|
|
159
|
+
|
|
160
|
+
kml_content = task_to_kml(task)
|
|
161
|
+
with open('task.kml', 'w') as f:
|
|
162
|
+
f.write(kml_content)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Command Line Interface
|
|
166
|
+
|
|
167
|
+
The package includes a command-line tool for format conversion:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Convert task to different formats
|
|
171
|
+
python -m pyxctsk task.xctsk --format json # JSON output
|
|
172
|
+
python -m pyxctsk task.xctsk --format kml # KML output
|
|
173
|
+
python -m pyxctsk task.xctsk --format qrcode-json # XCTSK: URL
|
|
174
|
+
python -m pyxctsk task.xctsk --format png -o qr.png # QR code image
|
|
175
|
+
|
|
176
|
+
# Parse from different inputs
|
|
177
|
+
python -m pyxctsk qr_code.png --format json # From QR image
|
|
178
|
+
cat task.xctsk | python -m pyxctsk --format kml # From stdin
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Requirements
|
|
182
|
+
|
|
183
|
+
- Python 3.8+
|
|
184
|
+
- Click (for CLI)
|
|
185
|
+
- Optional QR code support:
|
|
186
|
+
- Pillow (PIL) for image generation
|
|
187
|
+
- qrcode for QR code generation
|
|
188
|
+
- pyzbar for QR code reading from images
|
|
189
|
+
|
|
190
|
+
## Data Structures
|
|
191
|
+
|
|
192
|
+
The library provides comprehensive data classes for XCTrack task components:
|
|
193
|
+
|
|
194
|
+
- `Task`: Main task container
|
|
195
|
+
- `Turnpoint`: Individual waypoints with radius and type information
|
|
196
|
+
- `Waypoint`: Geographic coordinates and metadata
|
|
197
|
+
- `SSS`: Start of speed section configuration
|
|
198
|
+
- `Goal`: Goal/finish line configuration
|
|
199
|
+
- `Takeoff`: Takeoff location
|
|
200
|
+
- `TimeOfDay`: Time representation with validation
|
|
201
|
+
|
|
202
|
+
All classes support JSON serialization/deserialization and maintain compatibility with the XCTrack file format.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
207
|
+
|
|
208
|
+
## AI-Assisted Migration
|
|
209
|
+
|
|
210
|
+
This Python implementation was migrated from the original Go codebase with the assistance of GitHub Copilot. The migration process involved:
|
|
211
|
+
|
|
212
|
+
- **AI Model**: Claude 4 Sonnet (via GitHub Copilot Chat)
|
|
213
|
+
- **Migration Approach**: Automated code analysis and conversion with human oversight
|
|
214
|
+
- **Process**: Complete rewrite maintaining API compatibility and feature parity
|
|
215
|
+
- **Validation**: Comprehensive testing against XCTrack Competition Interfaces specification
|
|
216
|
+
- **Quality Assurance**: Manual verification of all core functionality and edge cases
|
|
217
|
+
|
|
218
|
+
The AI assistant analyzed the Go source code structure, understood the XCTrack protocol specifications, and generated equivalent Python implementations while ensuring compatibility with the original format and adding modern Python idioms and type hints.
|
|
219
|
+
|
|
220
|
+
## Original Go Implementation
|
|
221
|
+
|
|
222
|
+
This Python library is based on the Go implementation by Tom Payne:
|
|
223
|
+
<https://github.com/twpayne/go-xctrack>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyxctsk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python implementation of XCTrack's task format"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Simon Steiner", email = "simonsteiner@users.noreply.github.com"}
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
]
|
|
25
|
+
requires-python = ">=3.8"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"click>=8.0.0",
|
|
28
|
+
"geopy>=2.0.0",
|
|
29
|
+
"Pillow>=8.0.0",
|
|
30
|
+
"polyline>=2.0.0",
|
|
31
|
+
"pyproj>=3.0.0",
|
|
32
|
+
"pyzbar>=0.1.9",
|
|
33
|
+
"qrcode[pil]>=7.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"beautifulsoup4>=4.9.0",
|
|
39
|
+
"black>=21.0.0",
|
|
40
|
+
"flake8>=3.8.0",
|
|
41
|
+
"isort>=5.0.0",
|
|
42
|
+
"mypy>=0.800",
|
|
43
|
+
"pytest-cov>=2.0.0",
|
|
44
|
+
"pytest>=6.0.0",
|
|
45
|
+
"requests>=2.25.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
pyxctsk = "pyxctsk.cli:main"
|
|
50
|
+
|
|
51
|
+
[project.urls]
|
|
52
|
+
Homepage = "https://github.com/simonsteiner/pyxctsk"
|
|
53
|
+
Repository = "https://github.com/simonsteiner/pyxctsk"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.package-dir]
|
|
59
|
+
"" = "src"
|
|
60
|
+
|
|
61
|
+
[tool.black]
|
|
62
|
+
line-length = 88
|
|
63
|
+
target-version = ['py38']
|
|
64
|
+
|
|
65
|
+
[tool.isort]
|
|
66
|
+
profile = "black"
|
|
67
|
+
multi_line_output = 3
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
python_version = "3.8"
|
|
71
|
+
warn_return_any = true
|
|
72
|
+
warn_unused_configs = true
|
|
73
|
+
disallow_untyped_defs = true
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
minversion = "6.0"
|
|
77
|
+
addopts = "-ra -q"
|
|
78
|
+
testpaths = ["tests"]
|
|
79
|
+
markers = [
|
|
80
|
+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
81
|
+
]
|
pyxctsk-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pyxctsk - Python implementation of XCTrack's task format.
|
|
3
|
+
|
|
4
|
+
This package implements XCTrack's task format for reading and writing .xctsk files,
|
|
5
|
+
generating and parsing XCTSK: URLs, and encoding/decoding XCTSK: URLs as QR codes.
|
|
6
|
+
|
|
7
|
+
See http://xctrack.org/ and http://xctrack.org/Competition_Interfaces.html
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .distance import (
|
|
11
|
+
TaskTurnpoint,
|
|
12
|
+
calculate_task_distances,
|
|
13
|
+
distance_through_centers,
|
|
14
|
+
optimized_distance,
|
|
15
|
+
)
|
|
16
|
+
from .exceptions import (
|
|
17
|
+
EmptyInputError,
|
|
18
|
+
InvalidFormatError,
|
|
19
|
+
InvalidTimeOfDayError,
|
|
20
|
+
)
|
|
21
|
+
from .geojson import generate_task_geojson
|
|
22
|
+
from .parser import parse_task
|
|
23
|
+
from .qrcode_task import QRCodeTask
|
|
24
|
+
from .task import (
|
|
25
|
+
SSS,
|
|
26
|
+
Direction,
|
|
27
|
+
EarthModel,
|
|
28
|
+
Goal,
|
|
29
|
+
GoalType,
|
|
30
|
+
SSSType,
|
|
31
|
+
Takeoff,
|
|
32
|
+
Task,
|
|
33
|
+
TaskType,
|
|
34
|
+
TimeOfDay,
|
|
35
|
+
Turnpoint,
|
|
36
|
+
TurnpointType,
|
|
37
|
+
Waypoint,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Constants
|
|
41
|
+
EXTENSION = ".xctsk"
|
|
42
|
+
MIME_TYPE = "application/xctsk"
|
|
43
|
+
VERSION = 1
|
|
44
|
+
|
|
45
|
+
__version__ = "1.0.0"
|
|
46
|
+
__all__ = [
|
|
47
|
+
"Task",
|
|
48
|
+
"Takeoff",
|
|
49
|
+
"SSS",
|
|
50
|
+
"Goal",
|
|
51
|
+
"Turnpoint",
|
|
52
|
+
"Waypoint",
|
|
53
|
+
"TimeOfDay",
|
|
54
|
+
"Direction",
|
|
55
|
+
"EarthModel",
|
|
56
|
+
"GoalType",
|
|
57
|
+
"SSSType",
|
|
58
|
+
"TaskType",
|
|
59
|
+
"TurnpointType",
|
|
60
|
+
"generate_task_geojson",
|
|
61
|
+
"QRCodeTask",
|
|
62
|
+
"parse_task",
|
|
63
|
+
"calculate_task_distances",
|
|
64
|
+
"optimized_distance",
|
|
65
|
+
"distance_through_centers",
|
|
66
|
+
"TaskTurnpoint",
|
|
67
|
+
"EmptyInputError",
|
|
68
|
+
"InvalidFormatError",
|
|
69
|
+
"InvalidTimeOfDayError",
|
|
70
|
+
"EXTENSION",
|
|
71
|
+
"MIME_TYPE",
|
|
72
|
+
"VERSION",
|
|
73
|
+
]
|