ConservationInternational / cplus-plugin

QGIS plugin for using CPLUS framework in effective land-use planning
https://conservationinternational.github.io/cplus-plugin/
GNU General Public License v3.0
3 stars 5 forks source link

Sync input layer that the user can access in the API to the plugin layer mapping #462

Open danangmassandy opened 1 month ago

danangmassandy commented 1 month ago

Background User is able to access input layer in the server with following rules:

Plugin needs to be able to do mapping between layers that will be used for the analysis and the accessible layers in the server side so the plugin can avoid uploading layer that already exists in the server.

Proposed Solution The simplest solution that we discussed during sprint meeting is that the plugin just check and upload layer before running analysis. If the plugin detects a new layer, then the plugin will begin uploading the layer and once finished, the plugin will save the server identifier (layer_uuid). This has been implemented in current plugin version. However, user is not able to use common/internal layers that already exists in the server.

I'm proposing to use a client_id to do mapping between layer_uuid and client_id. Layers can have client_id if only the layers are inside the CPLUS base directory. The reason is the plugin may have default pathways and carbon layers inside this directory. The format to generate client_id would be:

{relative_filepath}_{crs}_{size_x}_{size_y}_{file_size}

Consider the directory tree below for an example to generate the client_id. ├── CPLUS │ ├── ncs_pathways │ │ ├── Final_Alien_Invasive_Plant_priority_norm.tif │ │ ├── Final_Avoided_Wetland_priority_norm.tif │ ├── ncs_carbon │ │ ├── bou_SOC_carbonsum_norm_null_con_clip.tif

The generated client_id would be in following table.

File client_id
Final_Alien_Invasive_Plant_priority_norm.tif ncs_pathways--Final_Alien_Invasive_Plant_priority_norm.tif_4326_200_200_1072586664
Final_Avoided_Wetland_priority_norm.tif ncs_pathways--Final_Avoided_Wetland_priority_norm.tif_4326_300_300_1072586664
bou_SOC_carbonsum_norm_null_con_clip.tif ncs_carbon--bou_SOC_carbonsum_norm_null_con_clip.tif_4326_100_100_171920932

When the plugin is able to sync client_id between local layer files and layer files in the server, the user can do analysis in both local and online seamlessly.

danangmassandy commented 1 month ago

This is implemented in above PRs, however I still need to handle duplication of client_id in server side. It's possible to have same client_id but we need to ensure the API returns the input layer that the file is ready.