orstools-qgis-plugin icon indicating copy to clipboard operation
orstools-qgis-plugin copied to clipboard

Made ORSTools ready for qgis_process

Open jannefleischer opened this issue 7 months ago • 8 comments

Because I need to run our plugin OS-WALK-EU (which depends on isocrone calculations from ORStools) from within a qgis_process setup headless I needed some upstream changes:

  1. moved the initiation of the processing toolbox to initProcessing, so qgis_process can skip everything with a GUI involved
  2. Added some recasting of parameters to int, because qgis_process interprets numbers as strings...
  3. Added an configuration-processing-algorithm (so my headless machine can have a custom provider). Added a test to that, but never done tests before (just a urban planner doing some programming...)

Now I can run something like this from the command line:

qgis_process plugins enable "ORStools" && qgis_process run "ORS Tools:set_provider_config_to_ors_via_algorithm" -- distance_units=meters area_units=m2 ellipsoid=EPSG:7019 ors_provider_name=ors.onmyserver.de ors_provider_api_key= ors_provider_url=https://ors.onmyserver.de ors_provider_timeout=240 ors_provider_overwrite=true

followed by:

echo '{                                                                                                            
        "distance_units": "meters", 
        "area_units": "m2",
        "ellipsoid": "EPSG:7019",
        "inputs": {
                "INPUT_PROVIDER": 1,
                "INPUT_PROFILE": 0,
                "INPUT_POINT_LAYER": "/home/fleischer/srv-fs1/u/02_Code_Working_Trees/os-walk-eu/SampleData/SampleGrid_centroids.shp",
                "INPUT_FIELD": "GRD_ID",
                "INPUT_METRIC": 1,
                "INPUT_RANGES": "250,500,750,1000",
                "LOCATION_TYPE": 0,
                "INPUT_SMOOTHING": 0,
                "INPUT_AVOID_FEATURES": [],
                "INPUT_AVOID_COUNTRIES": null,
                "INPUT_AVOID_BORDERS": null,
                "OUTPUT": "/home/fleischer/srv-fs1/u/02_Code_Working_Trees/os-walk-eu/SampleData/SampleGrid_centroid_isochrones_orstools.shp"
    }
}' | qgis_process run "ORS Tools:isochrones_from_layer" -

Due to None/null-Values and [] as parameters, only the json-piping is working.

jannefleischer avatar May 22 '25 12:05 jannefleischer