diff --git a/docs/configuration.md b/docs/configuration.md index 4524ab6..ecd801e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -202,13 +202,14 @@ a **QGIS project**: We offer you [here](../tests/lizmap/instances/pgrouting) a basic project which contains only the layers required and configured for Lizmap. -If you want create your project or use another existing project to use this module: +If you want **create your project** or use another existing project to use this module: -* Add the **Edges** and **Nodes** layers -* The QGIS project must be called `pgrouting.qgs` +* Add the **edges** and **nodes** layers with these exact names. +* The QGIS project must be called `pgrouting.qgs` or contain a QGIS **project variable** + called `lizmap_pgrouting_enabled` with the value `yes` ![pgrouting_layers](media/pgrouting_layers.jpg) -* You must then create a configuration for Lizmap with the **Lizmap plugin**. No specific +* You must then create a **configuration** for Lizmap with the **Lizmap plugin**. No specific configuration is needed for the module. You can configure like you want or just click on the apply button. diff --git a/pgrouting/classes/pgroutingDockable.listener.php b/pgrouting/classes/pgroutingDockable.listener.php index f5064a9..cdcde1a 100644 --- a/pgrouting/classes/pgroutingDockable.listener.php +++ b/pgrouting/classes/pgroutingDockable.listener.php @@ -30,7 +30,13 @@ public function onmapDockable($event) } } else { // Project name must contain 'pgrouting' to enable the module - if (strpos($event->project, 'pgrouting') !== false) { + // OR the QGIS project variable lizmap_pgrouting_enabled must be yes + $p = \lizmap::getProject($repository . '~' . $project); + $customVariables = $p->getCustomProjectVariables(); + if (strpos($project, 'pgrouting') !== false || ( + array_key_exists('lizmap_pgrouting_enabled', $customVariables) + && strtolower(trim($customVariables['lizmap_pgrouting_enabled'])) == 'yes' + )) { $bp = jApp::urlBasePath(); // dock $content = ''; diff --git a/pgrouting/controllers/default.classic.php b/pgrouting/controllers/default.classic.php index 984ea42..d880f01 100644 --- a/pgrouting/controllers/default.classic.php +++ b/pgrouting/controllers/default.classic.php @@ -147,7 +147,7 @@ public function index() $p = lizmap::getProject($repository . '~' . $project); if (!$p) { - $resp->data = array('status' => 'error', 'message' => 'A problem occured while loading project with Lizmap'); + $resp->data = array('status' => 'error', 'message' => 'A problem occurred while loading project with Lizmap'); return $resp; } diff --git a/tests/lizmap/instances/pgrouting/pgrouting.qgs b/tests/lizmap/instances/pgrouting/pgrouting.qgs index 5a4ad32..d116de0 100644 --- a/tests/lizmap/instances/pgrouting/pgrouting.qgs +++ b/tests/lizmap/instances/pgrouting/pgrouting.qgs @@ -1,4 +1,4 @@ - + @@ -44,9 +44,9 @@ - + @@ -76,111 +76,6 @@ 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -431,8 +326,8 @@ - - + + 0 @@ -870,8 +765,8 @@ def my_form_open(dialog, layer, feature): - - + + 0 @@ -880,6 +775,7 @@ def my_form_open(dialog, layer, feature): + @@ -1209,8 +1105,8 @@ def my_form_open(dialog, layer, feature): - - + + 0 @@ -1423,6 +1319,10 @@ def my_form_open(dialog, layer, feature): m2 meters + + 0 + 0 + 5 2.5 @@ -1450,10 +1350,12 @@ def my_form_open(dialog, layer, feature): + lizmap_pgrouting_enabled lizmap_user lizmap_user_groups + yes @@ -1573,7 +1475,7 @@ def my_form_open(dialog, layer, feature): - + PROJCRS["RGF93 v1 / Lambert-93",BASEGEOGCRS["RGF93 v1",DATUM["Reseau Geodesique Francais 1993 v1",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4171]],CONVERSION["Lambert-93",METHOD["Lambert Conic Conformal (2SP)",ID["EPSG",9802]],PARAMETER["Latitude of false origin",46.5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",3,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",49,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",44,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",700000,LENGTHUNIT["metre",1],ID["EPSG",8826]],PARAMETER["Northing at false origin",6600000,LENGTHUNIT["metre",1],ID["EPSG",8827]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Engineering survey, topographic mapping."],AREA["France - onshore and offshore, mainland and Corsica."],BBOX[41.15,-9.86,51.56,10.38]],ID["EPSG",2154]] +proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs @@ -1602,4 +1504,4 @@ def my_form_open(dialog, layer, feature): - \ No newline at end of file +