Development & Production Builds
To keep the amount of data in the graphs as small as possible, the same path and node attributes are combined. The creation of a production friendly graph is initialised with the getProductionBuild()
function:
import { getProductionGraph } from indoorgraphs;
const prodBuild = getProductionBuild(devGraph);
Here, the same nodes and path attributes are joined together, identified with an ID, and referenced at the respective node objects. The following development graph...
{
"nodes": {
"EG_t1": {
"level":"EG",
"id":"EG_t1",
"attributes": { "doorWidth": 200 },
"coordinates": [6.941008893617368,50.94825669486369],
"adjacentNodes": ["EG_t2"]
},
"EG_t2":{
"level":"EG",
"id":"EG_t2",
"attributes": { "doorWidth": 200 },
"coordinates": [6.946676519794531,50.948986044330525],
"adjacentNodes": ["EG_t1"]
}
},
"pathAttributes": {
"EG_t2-EG_t1": {
"pathWidth":200, "isWellLit":true
}
}
}
...is converted to the following production graph:
{
"nodes": {
"EG_t1": [[6.941008893617368,50.94825669486369], "EG_t1", "EG", "f64f", ["EG_t2:b54e"]],
"EG_t2": [[6.946676519794531,50.948986044330525], "EG_t2", "EG", "f64f", ["EG_t1:b54e"]]
},
"pa": { "b54e": {"0":200, "1":true}},
"pan": ["pathWidth", "isWellLit"],
"na": { "f64f": {"0": 200}},
"nan": ["doorWidth"]
}
pa = path attributes
pan = path attributes names
na = node attributes
nan = node attributes names
The returned production graph can also be stored in a JSON file and used to initialise the indoor graph. It is highly recommended to use a production graph when calculating a route. If you use a development graph when determining a route, this graph will be converted to a production graph on runtime.
Last updated