Exploitation commands¶
Delete attachment from disk¶
When an attachment (eg. pictures) is removed, its file is not automatically removed from disk.
sudo geotrek clean_attachments # remove old files
sudo geotrek thumbnail_cleanup # remove old thumbnails
docker compose run --rm web ./manage.py clean_attachments # remove old files
docker compose run --rm web ./manage.py thumbnail_cleanup # remove old thumbnails
Remove duplicate paths¶
Duplicate paths can appear while adding paths with commands or directly in the application. Duplicate paths can cause some problems of routing for topologies, it can generate corrupted topologies (that become MultiLineStrings instead of LineStrings).
sudo geotrek remove_duplicate_paths
docker compose run --rm web ./manage.py remove_duplicate_paths
During the process of the command, every topology on a duplicate path will be set on the original path, and the duplicate path will be deleted.
Merge segmented paths¶
A path network is most optimized when there is only one path between intersections. If the path database includes many fragmented paths, they could be merged to improve performances.
sudo geotrek merge_segmented_paths
docker compose run --rm web ./manage.py merge_segmented_paths
Important
This command can take several hours to run. During the process, every topology on a path will be set on the path it is merged with, but it would still be more efficient (and safer) to run it before creating topologies.
Before :
p1 p2 p3 p5 p6 p7 p8 p9 p14
+-------+------+-------+------+-------+------+-------+------+------+
| |
| p4 | p13
| |
+ +-------
| | |
| p10 | p16 |
p11 | | |
+------+------+ p15 --------
|
| p12
|
After :
p1 p6 p14
+--------------+-----------------------------+---------------------+
| |
| | p13
| |
| p10 +-------
| | |
| | p16 |
p11 | | |
+------+------+ p15 --------
|
| p12
|
Unset structure on categories¶
Use this command if you wish to undo linking categories to structures for some models :
sudo geotrek unset_structure
docker compose run --rm web ./manage.py unset_structure
usage: manage.py unset_structure [-h] [--all] [--list] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
[--skip-checks]
[model [model ...]]
Unset structure in lists of choices and group choices with the same name.
positional arguments:
model List of choices to manage
optional arguments:
-h, --help show this help message and exit
--all Manage all models
--list Show available models to manage
--version show program's version number and exit
-v {0,1,2,3}, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
--settings SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
--pythonpath PYTHONPATH
A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
--traceback Raise on CommandError exceptions
--no-color Don't colorize the command output.
--force-color Force colorization of the command output.
--skip-checks Skip system checks.
Note
You can’t chose for each choice which set of category you want to unset structures, it will happen for all categories.
Firstly, if a categroy is linked to a structure, it creates the same category but with no structure associated. Secondly, every element with this old category gets assigned to this new category. Finally all old categories are removed.
Reorder topologies¶
All topologies have information about which path they go through on and in which order. Actually, when a path is split in 2 by another path, a new path is added to the database. We need to add information for all topologies that need to go through this new path. This is badly managed at the moment, especially for the order of passage of the paths.
sudo geotrek reorder_topologies
docker compose run --rm web ./manage.py reorder_topologies
It removes a lot of useless information which can accelerate the process of editing topologies afterward.
During the process of this command, it tries to find a good order of passage on the paths which creates only one Linestring from start to end. It stays as close as possible to the corrupted order. This command uses the same algorithm to generate one Linestring when the order is not well managed during topologies’ display.
Note
It can happen that this algorithm can’t find any solution and will genereate a MultiLineString. This will be displayed at the end of the reorder.
Automatic commands¶
You can set up automatic commands by creating a cron file under /etc/cron.d/geotrek_command
that contains:
0 3 * * * root /usr/sbin/geotrek <command> <options>
0 3 * * * root /usr/bin/docker compose run --rm web ./manage.py <command> <options>
This example will automatically reorder topologies at 4 am every day.
0 4 * * * root /usr/sbin/geotrek reorder_topologies
This example will automatically reorder topologies at 4 am every day.
0 4 * * * root /usr/bin/docker compose run --rm web ./manage.py reorder_topologies
Hint
To help you find cron schedule expression you can use crontab guru.