82 lines
2.3 KiB
Markdown
82 lines
2.3 KiB
Markdown
# Pipeline route calculation
|
|
|
|
A function that exposes the pipeline route calculations.
|
|
|
|
The pipeline route can be defined by various means
|
|
- `kml` route file
|
|
- `kmz` route file
|
|
- `csv` of the x,y, and optionally z coordinates of the pipeline.
|
|
|
|
If the elevation is missing, we utilise one of the following services to obtain
|
|
the elevation of each waypoint on the pipeline.
|
|
|
|
- Google maps
|
|
- Map box
|
|
- Open elevation
|
|
|
|
This function implements the calculation of this following part of the BPML:
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
Start((Start))
|
|
Start --> KML{User upload .kml or .csv?}
|
|
KML -->|.kml| V("Calculate pipeline measures (Vincenty's Method) - Calculation #2")
|
|
KML -->|.csv| POS{Is position in UTM or Lat/Lon?}
|
|
POS -->|UTM| PROJ(Poject to Lat/Lon - Calculation #3)
|
|
PROJ --> MEAS
|
|
POS -->|Lat/Lon| MEAS{Does the file contain the measure?}
|
|
MEAS -->|no| V
|
|
MEAS -->|yes| Done
|
|
V --> Done((Done))
|
|
```
|
|
|
|
## Input
|
|
|
|
### Arguments
|
|
|
|
- `org_id`: as string which should be a valid `uuid` for the organization
|
|
- `project_id`: the id of the data project where the pipeline data is found
|
|
- `elevation_provider`: a `string` value should be one of the following types
|
|
- `mapbox`
|
|
- `google_maps`
|
|
- `open_elevation`
|
|
- `pipeline_id`: an `array` of `strings` which should each be a valid uuid representing a pipeline.
|
|
- `route_file`: an `array` of `objects` containing the details of the uploaded file.
|
|
|
|
Note the pipeline_id array and route_file array should be the length such that
|
|
the first entry in each array corresponds to one another.
|
|
|
|
## Creating the function on the platform
|
|
|
|
To create this function on the platform using the `cli` set up the port forwarding as shown in README.
|
|
|
|
Then run the following command to create the function.
|
|
|
|
```bash
|
|
cargo run functions create \
|
|
-f functions/pipeline_route \
|
|
-d "Processes a pipeline route KML/KMZ/CSV file and creates the pipeline route sequence" \
|
|
-o pipeline_id=array \
|
|
-o project_id=string \
|
|
-o org_id=string \
|
|
-i org_id=string \
|
|
-i project_id=string \
|
|
-i elevation_provider=string \
|
|
-i pipeline_id=array \
|
|
-i route_file=array
|
|
```
|
|
|
|
## Testing the function locally
|
|
|
|
You can run and test the function locally by running
|
|
|
|
```bash
|
|
cargo run
|
|
```
|
|
|
|
Then you can check it work with `curl` as follows
|
|
|
|
```bash
|
|
curl localhost:8080 -d $(jq '. | tojson' functions/pipeline_route/example_input.json)
|
|
```
|