PostGIS integration
Extra
Not all dependencies for the PostGIS integration are not installed by default. Please use the postgis
extra during installation.
The package provides an (opinionated) interface to save/load tracks to/from a Postgres database using the PostGIS extension. The functions are located in the geo_track_analyzer.postgis
module and operate on SQLAlchemy Engine that is passed into the functions.
API Reference
create_tables(engine, schema, track_table, points_table, extensions=None)
Create the tables for the tracks and points using the passed Engine
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine
|
Engine
|
SQLLalchemy Engine for the Postgres database |
required |
schema
|
str
|
Name of the schema in the database |
required |
track_table
|
str
|
Name of the table containing track information |
required |
points_table
|
str
|
Name of the table containing the points of all tracks |
required |
extensions
|
list[tuple[str, str]] | None
|
Extensions columns (tuple of name and type). If None is passed heartrate, cadence, power, and temperature are created |
None
|
Source code in geo_track_analyzer/postgis/db.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
insert_track(track, engine, schema, track_table, points_table, source)
Insert a track into the database
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track
|
Track
|
Track to be inserted |
required |
engine
|
Engine
|
SQLLalchemy Engine for the Postgres database |
required |
schema
|
str
|
Name of the schema in the database |
required |
track_table
|
str
|
Name of the table containing track information |
required |
points_table
|
str
|
Name of the table containing the points of all tracks |
required |
source
|
str
|
Set a source of the track in the track table. |
required |
Returns:
Type | Description |
---|---|
int | None
|
None if insertion failed and track_id if successfull |
Source code in geo_track_analyzer/postgis/db.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
load_track(track_id, engine, schema, track_table, points_table, **track_kwargs)
Insert a track into the database
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track_id
|
int
|
id of the track in the database |
required |
engine
|
Engine
|
SQLLalchemy Engine for the Postgres database |
required |
schema
|
str
|
Name of the schema in the database |
required |
track_table
|
str
|
Name of the table containing track information |
required |
points_table
|
str
|
Name of the table containing the points of all tracks |
required |
track_kwargs
|
Additional keyword arguments passed to the Track. |
{}
|
Returns:
Type | Description |
---|---|
Track
|
Track Object. |
Source code in geo_track_analyzer/postgis/db.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|