Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PGRouting to handle routing directly in Database through API #4070

Draft
wants to merge 170 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
ab8936b
Add TrekGeometry view with get and post methods
Apr 10, 2024
5723906
Add a parameter to TrekGeometry post method
Apr 10, 2024
e3d0998
Add graph and steps info being sent to TrekGeometry view
Apr 12, 2024
bcc1e01
Add computing of the dijkstra matrix and start and end nodes (only ha…
Apr 12, 2024
0f84c13
Add computing of the path to follow (node to node) (handles whole edg…
Apr 15, 2024
64cad5c
Modify path in response: it's now from start to end
Apr 15, 2024
3841dad
Refacto: nodes idx to id correspondence
Apr 15, 2024
da2ba95
Add structure of algorithm handling partial edges and more than 2 steps
Apr 15, 2024
2146122
ADD handling of edge percentage and more than 2 markers
Apr 16, 2024
087e311
Add display of a hard-coded polyline sent from the TrekGeometry view
Apr 16, 2024
40cf585
The graph is directly taken from the backend
Apr 16, 2024
e77cb85
Add handling of GPS coordinates as input
Apr 17, 2024
cc5b615
Add use of Point ewkt when using sql
Apr 17, 2024
496e140
Add TODOs for next step: obtaining a LineString from dijkstra results
Apr 17, 2024
dcb207b
Starting to work on converting the resulting nodes list into LineStrings
Apr 17, 2024
d5231de
Add conversion of dijstra results into a displayed Linestring
Apr 18, 2024
6be5b61
Correctng some comments
Apr 23, 2024
bf02e89
Fix path not computed if adjacent steps are on the same edge
Apr 23, 2024
522b842
Fix negative dijkstra weight when we're going backwards relative to a…
Apr 23, 2024
6696f18
Fix path not computed when going backwards on a Path if going through…
Apr 23, 2024
fd4f0c0
Starting to display fetched route instead of locally computed route
Apr 25, 2024
262a1be
Preparing topology_helper to handle several linestrings
Apr 25, 2024
911e56f
Automating the geojson generation in the view
Apr 25, 2024
3ffac2e
Add handling of several steps
Apr 26, 2024
40d3914
Replacing MultiLineString by GeometryCollection in Response
Apr 26, 2024
c893bad
Fixing the organization of layers in the displayed path
Apr 26, 2024
e47d164
Removing old code related to the graph
Apr 26, 2024
1466005
Removing old code
Apr 26, 2024
03a9cae
Removing old code
Apr 26, 2024
0977216
Making the TrekGeometry post method into a PathViewSet action
Apr 29, 2024
7a23ce3
Reordering PathRouter methods
Apr 29, 2024
e6f7313
Removing graph action of PathViewSet
Apr 29, 2024
f8cdc8a
Moving initial graph generation into the PathRouter class
Apr 29, 2024
728108e
Removing no longer used imports
Apr 29, 2024
a49c625
Renaming graph.py to path_router.py
Apr 29, 2024
3255d30
Adding parameters error handling for the route_geometry action
Apr 29, 2024
f72cabc
Using dict.update instead of a custom method
Apr 29, 2024
b08a527
Adding status codes to Responses
Apr 30, 2024
9b4ca7a
Optimizing the cs_graph generation (generating the upper triangle the…
May 2, 2024
432041e
Optimizing matrix generation: it is now generated at init and modifie…
May 2, 2024
fb7783f
Optimizing matrix generation by using its symmetrical property
May 2, 2024
5bfff8b
Refactoring: making duplicate code into a method
May 3, 2024
c30123d
The route is now fetched only when the marker dragging stops
May 3, 2024
6c9e29e
Saving the dijkstra matrix in the cache
May 6, 2024
2f7360f
Saving the path graph in the cache
May 6, 2024
eff6c00
Moving duplicate cache-related code into a single method
May 6, 2024
5bb7cfe
Add handling of an impossible path: the view returns a status 204 and…
May 6, 2024
9d78eb3
Modify error handling in js: using Promise.reject
May 6, 2024
e05b9f1
Correct returns when no path could be found
May 13, 2024
be37394
Replaces status 204 by status 400 when no path can be found
May 13, 2024
87b6b4f
Add a spinner when the route is being fetched
May 14, 2024
1d9d3df
Add sending of the modified steps indexes to fetchRoute
May 14, 2024
ac07bb5
Adds fetching of the route for only the modified steps
May 14, 2024
8b8c35a
Add algorithm that updates the displayed route layers
May 16, 2024
7ca12fe
Add use of currently displayed layers indexes to replace them
May 16, 2024
3c12db5
Fix replacing the currently displayed layers indexes by new ones
May 16, 2024
4cdb3d7
Fix updating layers not working after removing a marker
May 16, 2024
e62ed49
Bump leaflet.textpath.js to v1.1.0
May 17, 2024
346db57
Move leaflet static files into a vendor directory
May 17, 2024
133cc1e
Bump leaflet.lineextremities.js to v0.1.1
May 21, 2024
1a68256
Fix missing path layer when an unlinkable via marker is removed
May 21, 2024
4e58ddf
Remove console logs
May 21, 2024
cb7a038
Add coloring of the markers when one is isolated
May 22, 2024
73ac66e
Add coloring of all markers to normal appearance when back to normal
May 22, 2024
1124dec
Add enabling/disabling of markers drag when a route is correct/incorrect
May 22, 2024
1a1d738
Add enabling/disabling of markers deletion when a route is correct/in…
May 22, 2024
ab08572
Add impossibility of creating new via-steps while the route is invalid
May 23, 2024
c4ade38
Move spinner.stop() into a finally()
May 23, 2024
c5b9fdb
Fix one route layer missing when an isolated via-step is corrected
May 24, 2024
61785c2
Add deletion of a marker if not dropped on a path
May 24, 2024
efd7c09
Add resetting of a marker to its previous valid position when not dro…
May 24, 2024
17d8dd9
Fix isolated marker highlight being removed when reset to its previou…
May 24, 2024
20bdc58
Remove duplicate part of code
May 24, 2024
169c4c2
Remove hiding of route layer when the start or end marker is moved
May 24, 2024
c1092aa
Fix out of date step idx used when deleting a via point
May 24, 2024
8b00ec8
Add display of an error toast when a marker is incorrect
May 27, 2024
e5af25f
Modify error_toast elements class names for genericity
May 30, 2024
2eab2e2
Fix toast stacking: top toast not on the bottom when it's the only on…
May 30, 2024
73dd40b
Fix wrong marker being deleted after trying to create an unsnapped ma…
May 30, 2024
66736ae
Fix route layer not displayed after start and end markers created and…
May 30, 2024
46b0e94
Add disabling of markers when the route is being fetched
May 30, 2024
8605485
Add saving of the route topology through the form
May 30, 2024
324aa6a
Add modification of the route topology through the edit form
Jun 3, 2024
c0e776b
Fix Geotrek object no longer created before use
justinefricou Jun 10, 2024
2e77a83
Remove use of non-sparse matrix for dijkstra (using csr_array)
justinefricou Jun 10, 2024
785bf6e
Modify use of sparse array (using lil_array instead of csr_array)
justinefricou Jun 11, 2024
39ad419
Optimize dijkstra matrix generation
justinefricou Jun 12, 2024
0479a7c
Remove calls to now deleted js scripts
justinefricou Jun 12, 2024
9ded3c8
Remove no longer used methods
justinefricou Jun 12, 2024
f632c09
Add benchmarking system based on frontend routing version
justinefricou Jul 1, 2024
0ac1d74
Fix typo in cypress.config.js
justinefricou Jul 1, 2024
21aca15
Startng to work on adapting frontend benchmark system for backend
justinefricou Jul 1, 2024
4507171
Add record of the number of runs for a benchmark measure
justinefricou Jul 2, 2024
9c3caae
Modify route control clicking via cypress
justinefricou Jul 2, 2024
3e0bf86
Replace broken 3 via-pts topology with a 2 via-pts topology
justinefricou Jul 2, 2024
0113d99
Modify cypress benchmark: adapt the frontend version to work with bac…
justinefricou Jul 2, 2024
17ebe8b
Modify python time measures: now in milliseconds instead of seconds
justinefricou Jul 2, 2024
5d74120
Modify time measurement: startTime is now recorded before the click/d…
justinefricou Jul 2, 2024
4366a2d
Modify benchmark.sh: making the session id a variable
justinefricou Jul 2, 2024
d05f53f
Add scenario using the big DB and no via point
justinefricou Jul 2, 2024
af3b210
Add display of current branch name for each measure
justinefricou Jul 3, 2024
b6391d7
Replace big database no via pts scenario with 25 via pts scenario
justinefricou Jul 4, 2024
dfd3479
Add readme for the benchmarking system
justinefricou Jul 4, 2024
b493a43
Modify benchmarking script: cypress spec file and session id are now …
justinefricou Jul 4, 2024
f1d4092
Fix crash when computing time averages if a file is missing
justinefricou Jul 4, 2024
0421d5d
Add 2 via-pts topology for big database
justinefricou Jul 5, 2024
d644994
Replace 25-via-pts scenario with 2-via-pts scenario for big database
justinefricou Jul 5, 2024
6657997
Add unit tests for route_geometry view (check of request body)
justinefricou Jul 5, 2024
11b010e
Modify cypress timeouts: now 30min
justinefricou Jul 5, 2024
7c0c5cb
Start to work on impossible and possible path test cases
justinefricou Jul 5, 2024
215b10e
Add check of lat and lng type and range in route_geometry view
justinefricou Jul 5, 2024
f8250c9
Fix request body not sent in the right format (route_geometry tests)
justinefricou Jul 5, 2024
2f9e808
Add new scenario for big DB with no via point
justinefricou Jul 8, 2024
4f4a98d
Add test case: steps not on paths
justinefricou Jul 8, 2024
7e28e04
Add test case: steps one paths not linked
justinefricou Jul 8, 2024
37f0437
Add tests for route_geometry view
justinefricou Jul 8, 2024
6a69385
Fix test for the route_geometry view
justinefricou Jul 8, 2024
b254420
Remove prints
justinefricou Jul 8, 2024
d627bf3
Move benchmarking directory into tools/
justinefricou Jul 8, 2024
e8d68e5
Fix norm
justinefricou Jul 8, 2024
a1023c2
Modify Cypress 'create trek' test after routing changes
justinefricou Jul 8, 2024
6e7a67a
Try to fix cypress e2e tests
justinefricou Jul 9, 2024
af2a86e
Uncomment env_dev settings
justinefricou Jul 9, 2024
1474572
Modify Cypress e2e tests: actually click on paths to create a trek
justinefricou Jul 9, 2024
9e84bd3
Remove console.log and debugger
justinefricou Jul 9, 2024
6d5a765
Fix cypress e2e tests: id of clicked path
justinefricou Jul 9, 2024
764536a
Add test case for route_geometry view: error 500
justinefricou Jul 9, 2024
ea2fa26
Try to fix cypress tests: ensure the topology control is enabled befo…
justinefricou Jul 9, 2024
a32c588
Comment content of test_graph temporarily
justinefricou Jul 9, 2024
cb4ea32
Adapt graph generation tests to the new routing system
justinefricou Jul 10, 2024
9faac24
Add tests for path_router
justinefricou Jul 10, 2024
439ddcc
Add unit test for cache handling in path_router
justinefricou Jul 10, 2024
ca7acec
Fix cache-related test for PathRouter
justinefricou Jul 10, 2024
e24f46c
Modify test_route_geometry_not_fail_with_via_points_several_paths to …
justinefricou Jul 11, 2024
20fb3d0
Modify route_geometry tests: more precision when checking results
justinefricou Jul 11, 2024
2cdf4de
Remove old unit test for route_geometry view
justinefricou Jul 11, 2024
de63d77
Remove redundant unit test for path_router
justinefricou Jul 12, 2024
401285f
Add script to take backend time measures
justinefricou Jul 12, 2024
2297164
Add steps for route with 100 via-pts for backend time measures script
justinefricou Jul 12, 2024
9caba2d
Fix topology used in 100-via-pts fixture
justinefricou Jul 15, 2024
8d405b2
Add big database topology in backend time measuring script
justinefricou Jul 15, 2024
c3c034a
Improve readability of path_router test: using yied
justinefricou Jul 15, 2024
6f66a7d
Update benchmark README to include the new script
justinefricou Jul 15, 2024
dd2e244
Fix requirements.txt after rebase
justinefricou Jul 23, 2024
b626d70
Modify leaflet map: start spinner and disable markers ASAP
justinefricou Jul 30, 2024
78e3b03
Modify leaflet map: stop spinner and reenable markers as late as poss…
justinefricou Jul 30, 2024
e17d8e0
Adapt backend benchmark script to new PR
justinefricou Aug 5, 2024
17513d7
Modify display of route layers: only redisplay those affected by a ro…
justinefricou Aug 14, 2024
507d7aa
Fix route modif not saved if an incorrect marker has been fixed
justinefricou Aug 27, 2024
563308c
Fix path layers not displayed at creation
justinefricou Aug 27, 2024
81d72f6
Use pg routing (#4245)
justinefricou Sep 13, 2024
762e191
🐛 [BUG] Fix reset layer
Chatewgne Sep 17, 2024
0f4f2b0
🏗 [MAINT] Remove unused dependency scipy
Chatewgne Sep 17, 2024
a7f7c86
🏗 [MAINT] Remove unused dependency scipy
Chatewgne Sep 17, 2024
85ea074
Fix code norm
justinefricou Nov 25, 2024
3e311a7
Add pgrouting to check_versions command
justinefricou Nov 28, 2024
420700a
Add warnings to changelog
justinefricou Nov 28, 2024
f2a74cb
Update installation and upgrade docs for pgrouting use
justinefricou Nov 28, 2024
85cffb0
Fix doc: underline too short
justinefricou Nov 28, 2024
548a0c7
Fix requirements.txt after rebase
justinefricou Nov 28, 2024
37889ae
Bump pgrouting to v.3.0.0
justinefricou Dec 2, 2024
902f2b2
Use pgr_full_version for check_versions command
justinefricou Dec 2, 2024
39661aa
Refactoring routing unit tests
justinefricou Dec 6, 2024
738e74c
Fix norm
justinefricou Dec 11, 2024
9e3fcdf
Remove temporary comments
justinefricou Dec 11, 2024
d3f0b86
Refacto: remove duplicate checking of same case in unit tests
justinefricou Dec 11, 2024
efda6bd
Refacto unit tests: use path3 instead of path4 in some tests so that …
justinefricou Dec 11, 2024
83570f9
Use pgRouting A star (#4263)
justinefricou Dec 11, 2024
2f7697c
Invert path's direction in unit test case so that test coverage is co…
justinefricou Dec 11, 2024
e2359b7
Update changelog
justinefricou Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
name: Python Unittests
runs-on: ubuntu-latest
container: makinacorpus/geodjango:${{ matrix.os }}

permissions:
packages: write # required to publish docker image

Expand All @@ -60,7 +60,7 @@ jobs:

services:
postgres:
image: postgis/postgis:12-2.5
image: pgrouting/pgrouting:12-3.0-3.0.0
env:
POSTGRES_DB: ci_test
POSTGRES_PASSWORD: ci_test
Expand Down Expand Up @@ -261,7 +261,7 @@ jobs:

services:
postgres:
image: postgis/postgis:12-2.5
image: pgrouting/pgrouting:12-3.0-3.0.0
env:
POSTGRES_DB: ci_test
POSTGRES_PASSWORD: ci_test
Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:

services:
postgres:
image: postgis/postgis:12-2.5
image: pgrouting/pgrouting:12-3.0-3.0.0
env:
POSTGRES_DB: ci_test
POSTGRES_PASSWORD: ci_test
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ __pycache__/
geotrek/settings/custom.py
geotrek/cypress/node_modules
Makefile.perso.mk

# Benchmarking
tools/benchmarking/time_measures/
tools/benchmarking/cypress/videos/
tools/benchmarking/cypress/screenshots/
tools/benchmarking/node_modules/

# buildout stuff
.mr.developer.cfg
.installed.cfg
Expand Down
11 changes: 4 additions & 7 deletions cypress/integration/nav_create_trek.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ describe('Create trek', () => {
cy.visit('/trek/list');
cy.wait('@tiles');
cy.server();
cy.route('/api/path/drf/paths/graph.json').as('graph');
cy.get("a.btn-success[href='/trek/add/']").contains('Add a new trek').click();
cy.wait('@graph');
cy.get("a.linetopology-control").click();
cy.get("textarea[id='id_topology']").type('[{"pk": 2, "kind": "TREK", "offset": 0.0, "paths": [3], "positions": {"0": [0.674882030756843, 0.110030805790642]}}]', {
force: true,
parseSpecialCharSequences: false
});
cy.get("input[id='id_duration']").type('100');
cy.get("input[name='name_en']").type('Trek number 1');
cy.get("a[href='#name_fr']").click();
Expand All @@ -52,6 +45,10 @@ describe('Create trek', () => {
cy.setTinyMceContent('id_description_teaser_en', 'Description teaser number 1');
cy.setTinyMceContent('id_ambiance_en', 'Ambiance number 1');
cy.setTinyMceContent('id_description_en', 'Description number 1');
cy.get("a.linetopology-control").click();
cy.clickOnPath(3, 67);
cy.clickOnPath(3, 11);
cy.get('[data-test^="route-step-"]');
cy.get('#save_changes').click();
cy.url().should('not.include', '/trek/add/');
cy.get('.content').should('contain', 'Trek number 1');
Expand Down
51 changes: 51 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,55 @@ Cypress.Commands.add('loginByCSRF', (username, password) => {

Cypress.Commands.add('mockTiles', (username, password) => {
cy.intercept("https://*.tile.opentopomap.org/*/*/*.png", {fixture: "images/tile.png"}).as("tiles");
});

Cypress.Commands.add('getCoordsOnMap', (pathPk, percentage) => {
cy.getPath(pathPk).then(path => {
let domPath = path.get(0);

// Get the coordinates relative to the map element
let pathLength = domPath.getTotalLength();
let lengthAtPercentage = percentage * pathLength / 100;
return domPath.getPointAtLength(lengthAtPercentage);
})
});

Cypress.Commands.add('getCoordsOnPath', (pathPk, percentage) => {
cy.getPath(pathPk).then(path => {
cy.getCoordsOnMap(pathPk, percentage).then(coordsOnMap => {
// Convert the coords so they are relative to the path
cy.getMap().then(map => {
let domMap = map.get(0);
let domPath = path.get(0);

// Get the coords of the map and the path relative to the root DOM element
let mapCoords = domMap.getBoundingClientRect();
let pathCoords = domPath.getBoundingClientRect();
let horizontalDelta = pathCoords.x - mapCoords.x;
let verticalDelta = pathCoords.y - mapCoords.y;

// Return the coords relative to the path element
return {
x: coordsOnMap.x - horizontalDelta,
y: coordsOnMap.y - verticalDelta,
}
});
})

})
})

Cypress.Commands.add('getMap', () => cy.get('[id="id_topology-map"]'));
Cypress.Commands.add('getPath', pathPk => cy.get(`[data-test=pathLayer-${pathPk}]`));

Cypress.Commands.add('clickOnPath', (pathPk, percentage) => {
// Get the coordinates of the click and execute it
cy.getCoordsOnPath(pathPk, percentage).then(clickCoords => {
let startTime;
cy.getPath(pathPk)
.then((path) => {startTime = performance.now(); return path})
.click(clickCoords.x, clickCoords.y, {force: true})
// Return startTime so it is yielded by the command
.then(() => startTime);
});
});
1 change: 1 addition & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ if [ "$MANAGE_DB" = "true" ] && [ -z "$2" ]; then
# postgis_raster is only useful on postgis 3, it fails on postgis 2 but this is harmless
su postgres -c "psql -q -d $POSTGRES_DB -c 'CREATE EXTENSION postgis_raster;'" || true
su postgres -c "psql -q -d $POSTGRES_DB -c 'CREATE EXTENSION pgcrypto;'" || true
su postgres -c "psql -q -d $POSTGRES_DB -c 'CREATE EXTENSION pgrouting;'" || true
fi

# Generate secret key
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ x-images:

services:
postgres:
image: postgis/postgis:12-2.5
image: pgrouting/pgrouting:12-3.0-3.0.0
env_file:
- .env
ports:
Expand Down
14 changes: 14 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ CHANGELOG
2.111.0+dev (XXXX-XX-XX)
----------------------------

**Warnings**

- When adding a via-point to a linear object's topology, it is now required to drop the new marker onto a path before the updated route is displayed, as the preview is no longer available when dragging the marker. This is due to the route computation now being performed on the backend. For more information, see https://github.com/GeotrekCE/Geotrek-admin/issues/4286
- After adding new paths, pre-existing topologies can follow routes that are no longer the shortest. When editing topology-based linear objects through the interface, their route will no longer be automatically recomputed to the shortest option, which was unwanted behavior. This means you might now encounter topologies that take a detour despite not using a via-point marker. Be careful when editing such a route, as moving or adding neighboring markers will remove the detour. Note: this does not address the topology ordering issue when adding new paths. For more information, see https://github.com/GeotrekCE/Geotrek-admin/issues/4286

**Improvements**

- Optimize routing: computation is now done in the backend using the A* algorithm (#4070)
- Prevent from placing route markers outside of paths or on unreachable paths (#4070)

**Bug fixes**

- Fix editing of topology-based linear objects via the interface: objects are no longer automatically rerouted (#4070)

**Documentation**

- Update theme color
Expand Down
62 changes: 41 additions & 21 deletions docs/install/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ or `via QGis following this blog post <https://makina-corpus.com/sig-webmapping/
* **Geometric type** : Linestring
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`paths.geojson <../files/import/paths.geojson>`
* **Good to know** :
* **Good to know** :
* The default SRID code is 4326
* The default encoding is UTF-8
* Imported paths are unpublished by default
Expand Down Expand Up @@ -139,6 +139,26 @@ or `via QGis following this blog post <https://makina-corpus.com/sig-webmapping/
--name-attribute id \
--comments-attribute commentaire

After importing a large quantity of paths, it is recommended to pre-generate the
paths graph needed for the routing. This action is not mandatory, but will reduce the time needed for the first
routing following the import.

To pre-generate the graph, use the ``generate_pgr_network_topology`` command::

sudo geotrek generate_pgr_network_topology
OR
docker compose run --rm web ./manage.py generate_pgr_network_topology

After importing a large quantity of paths, it is recommended to pre-generate the
paths graph needed for the routing. This action is not mandatory, but will reduce the time needed for the first
routing following the import.

To pre-generate the graph, use the ``generate_pgr_network_topology`` command::

sudo geotrek generate_pgr_network_topology
OR
docker compose run --rm web ./manage.py generate_pgr_network_topology

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated paragraph

.. _import-data-from-touristic-data-systems-sit:

Import data from touristic data systems (SIT)
Expand Down Expand Up @@ -228,7 +248,7 @@ Don't forget the u character before strings if they contain non-ascii characters

In this case categories and types in Geotrek database have to be the same as in Esprit parc database. Otherwise missing categories and types will be created in Geotrek database.

Imported contents will be automatically published and approved.
Imported contents will be automatically published and approved.

If you use an url that filters a unique category, you can change its name. Example to get only Honey products and set the Geotrek category and type in which import them:

Expand Down Expand Up @@ -257,7 +277,7 @@ When sensitive areas module is enabled, Geotrek provides 3 parsers to import dat

* **Import sensitive areas from http://biodiv-sports.fr** (``geotrek.sensitivity.parsers.BiodivParser``). By default this
parser imports all sensitive areas in configured spatial extent.
* **Import species sensitive areas from a zipped shapefile**.
* **Import species sensitive areas from a zipped shapefile**.
Imported field names are: ``espece`` (required), ``contact`` and ``descriptio``. Species with corresponding names have to be created manually before import.
* **Import regulatory sensitive areas from a zipped shapefile**. Imported field names are: ``nom`` (required), ``contact``, ``descriptio``, ``periode`` (month numbers separated with comas), ``pratiques`` (separated with comas), and ``url``. Practices with corresponding names have to be created manually before import.

Expand Down Expand Up @@ -312,7 +332,7 @@ In the following example, ``Provider_1Parser`` and ``Provider_2Parser`` will eac


.. danger::
It is recommended to use ``provider`` from the first import - Do not add a ``provider`` field to preexisting parsers that already imported objects, or you will have to manually set the same value for ``provider`` on all objects already created by this parser.
It is recommended to use ``provider`` from the first import - Do not add a ``provider`` field to preexisting parsers that already imported objects, or you will have to manually set the same value for ``provider`` on all objects already created by this parser.


.. danger::
Expand Down Expand Up @@ -448,17 +468,17 @@ It is also possible to import sensitive areas through command line:

sudo geotrek import geotrek.sensitivity.parsers.BiodivParser

.. warning::
If you don't see any data in your area, it means that Biodiv'Sports does not contains data for your territory.
Then it is widely recommended to add your data directly into Biodiv'Sports, as it will be available for
multiple users, and then retrieve them into your Geotrek instance. To import data in Biodiv'Sports
.. warning::
If you don't see any data in your area, it means that Biodiv'Sports does not contains data for your territory.
Then it is widely recommended to add your data directly into Biodiv'Sports, as it will be available for
multiple users, and then retrieve them into your Geotrek instance. To import data in Biodiv'Sports
go visit its website: https://biodiv-sports.fr


Import from shapefile
---------------------

Imported data must be in standard ESRI shapefile format.
Imported data must be in standard ESRI shapefile format.
The various Shapefile files (``.shp``, ``.shx``, ``.dbf``, ``.prj``, *etc*.) must be assembled in a zip archive.

.. warning::
Expand All @@ -468,7 +488,7 @@ Attribute data for sensitive areas species

- ``espece``: Species name. Mandatory. A species with this name must first have been created in Biodiv'sports. Otherwise, import of the line will fail.
- ``contact``: Contact in text or HTML format. *Optional*.
- ``descriptio``: Description in text or HTML format. *Optional*.
- ``descriptio``: Description in text or HTML format. *Optional*.

.. warning::
Species name must strictly respect the species name string (accentuation, case and punctuation).
Expand Down Expand Up @@ -512,7 +532,7 @@ or:
sudo geotrek import geotrek.sensitivity.parsers.RegulatorySensitiveAreaShapeParser <file.shp>.


.. warning::
.. warning::
Relaunching an import **with the same file** will create duplicates.


Expand All @@ -534,7 +554,7 @@ You can also use some of Geotrek commands to import data from a vector file hand

Possible data are e.g.: POI, infrastructures, signages, cities, districts, restricted areas, paths.

You must use these commands to import spatial data because of the dynamic segmentation, which will not be computed if you enter the data manually.
You must use these commands to import spatial data because of the dynamic segmentation, which will not be computed if you enter the data manually.

Here are the Geotrek commands available to import data from file:

Expand All @@ -553,7 +573,7 @@ To get help about a command:
::

sudo geotrek help <subcommand>

.. _import-dem-altimetry:


Expand Down Expand Up @@ -671,7 +691,7 @@ Import POIs
* **Geometric type** : Point
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`poi.geojson <../files/import/poi.geojson>`
* **Good to know** :
* **Good to know** :
* The SRID must be 4326
* The default encoding is UTF-8
* Imported POIs are unpublished by default
Expand Down Expand Up @@ -801,7 +821,7 @@ Import Infrastructure
* **Geometric type** : Point
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`infrastructure.geojson <../files/import/infrastructure.geojson>`
* **Good to know** :
* **Good to know** :
* The SRID must be 4326
* The default encoding is UTF-8
* Imported infrastructures are unpublished by default
Expand Down Expand Up @@ -980,7 +1000,7 @@ Import Signage
* **Geometric type** : Point
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`signage.geojson <../files/import/signage.geojson>`
* **Good to know** :
* **Good to know** :
* The default SRID code is 4326
* The default encoding is UTF-8
* Imported signage are unpublished by default
Expand Down Expand Up @@ -1058,7 +1078,7 @@ Import Cities
* **Geometric type** : Polygon
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`cities.geojson <../files/import/cities.geojson>`
* **Good to know** :
* **Good to know** :
* The default SRID code is 4326
* The default encoding is UTF-8
* Imported cities are unpublished by default
Expand Down Expand Up @@ -1145,7 +1165,7 @@ Import Districts
* **Geometric type** : Polygon
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`districts.geojson <../files/import/districts.geojson>`
* **Good to know** :
* **Good to know** :
* The default SRID code is 4326
* The default encoding is UTF-8
* Imported districts are unpublished by default
Expand Down Expand Up @@ -1219,7 +1239,7 @@ Import Restricted areas
* **Geometric type** : Polygon
* **Expected formats** (supported by GDAL) : Shapefile, Geojson, Geopackage
* **Template** : :download:`restrictedareas.geojson <../files/import/restrictedareas.geojson>`
* **Good to know** :
* **Good to know** :
* The default SRID code is 4326
* The default encoding is UTF-8
* Imported restricted areas are unpublished by default
Expand Down Expand Up @@ -1265,10 +1285,10 @@ 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.

You can run ``sudo geotrek merge_segmented_paths``.
You can run ``sudo geotrek merge_segmented_paths``.

.. danger::
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.
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 :
::
Expand Down
4 changes: 2 additions & 2 deletions docs/install/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ If you are not confident with the ``install.sh`` script, or if you are having tr
1. Add ``deb https://packages.geotrek.fr/ubuntu bionic main`` to APT sources list.
2. Add https://packages.geotrek.fr/geotrek.gpg.key to apt keyring.
3. Run ``apt-get update``
4. If you want to use a local database, install PostGIS package (before installing Geotrek-admin, not at the same time).
If not, you must create database and enable PostGIS extension before.
4. If you want to use a local database, install the pgRouting package by running ``sudo apt install -y postgresql-pgrouting wget software-properties-common`` (before installing Geotrek-admin, not at the same time).
If not, you must create database and enable PostGIS and pgRouting extensions before.
5. Install the Geotrek-admin package (``sudo apt install geotrek-admin``).

.. note ::
Expand Down
Loading
Loading