The low-level door of the package: the input and the options as JSON text
in the formats of the Rust core (milkflow::pipeline::run_json),
the output JSON text out, unchanged. flowmap() builds the JSON from data
frames and parses the output; this function is for reproducing a run
exactly across languages, or for inputs kept as JSON files.
Arguments
- input
JSON text: an object with
nodes(id,x,y, optionallabel,weight,group,groups: an object of groups by level),flows(origin,destination,value, optionalcategory) and optionallycrs,units,skeleton(pairs of ids) andboundary(a list of polylines).- options
JSON text with the options (
group,k,filter,mu,max_stretch,skeleton,represent,schematic,schematic_options,tikz,geojson,html,lines,max_categories,style; seeflowmap());""or"{}"for the defaults.filteris an object such as{"kind": "dominant"};groupistrue,falseor the name of a level of the nodes'groups.- json
The output of
flowmap_json().
Value
One string: a JSON object with spec, svg, schematic_spec,
schematic_svg, schematic_error, with "tikz": true also tikz and
schematic_tikz, with "geojson": true also geojson and
schematic_geojson, and with "html": true also html. Errors of the core are signalled as conditions of
class milkflow_error, with the core's message unchanged (positions
such as flow #0 count from 0 in the JSON arrays).
Examples
input <- '{"nodes":[{"id":"a","x":0,"y":0},{"id":"b","x":10,"y":0}],
"flows":[{"origin":"a","destination":"b","value":5}]}'
out <- flowmap_json(input)
substr(out, 1, 60)
#> [1] "{\"spec\":{\"version\":\"0.1\",\"crs\":null,\"units\":null,\"meta\":{\"pa"
m <- new_milkflow(out)
m
#> <milkflow> 2 places (from 2 nodes), 1 segments, 1 width classes
#> Volume: 5 in 1 pairs (1 routed)
#> in corridors 100.0%
#> internal 0.0%
#> filtered out 0.0%
#> without a path 0.0%
#> Detour: mean 1.00, max 1.00