-
Notifications
You must be signed in to change notification settings - Fork 0
Map Format
What does a KainPlan map-file look like?
All maps will be stored server-side in the res/maps
directory. The filenames are based on the following pattern: [map-name].map.json
. Each file will be of the JSON
format and will have standardized attributes.
Contrary to older versions of the KainPlan-Format, map files should only contain information valuable to the read-only represenation of the map. There is no place for attributes that are only relevant for the visual representation of elements or specific to map-creator tasks.
{
"version": "[version]", // specifies the map's version
"nodes": [ // contains one array of nodes per floor
[ // contains all of the nodes on the floor
{
"x": x, // the node's x coordinate
"y": y, // the node's y coordinate
"edges": [ // array containing all connections the node has
{
"to": "[to-node-id]" // the id of the node on the other end of the edge
},
...
],
"id": "[node-type];[x];[y];[z]", // the node's unique identifier; z is the index of the floor the node is on
"title": "[title]", // [optional - only present in EndPoint nodes]: the node's title
"description": "[description]", // [optional - only present in EndPoint nodes]: the node's description
},
...
],
...
],
"beacons": [ // contains all beacon nodes - used for positioning
[
{
"x": x, // the beacon's x coordinate
"y": y, // the beacon's y coordinate
"id": "b;[x];[y];[z]", // the beacon's unique identifier; z is the index of the floor the node is on
"iid": "[instance-id]" // the Eddystone beacon's 6-byte instance identifier
},
...
],
...
],
"width": width, // the map's width
"height": height, // the map's height
"background": { // information related to the map's background(s)
"srcs": [ // array containing all background sources; one background per floor
"[background-source]", // individual source; absolute path to media file (ideally SVG)
...
]
}
}
When loading a map in the frontend, some attributes important to viewing the map are added to the format mentioned above (JSON Format
).
{
"version": "[version]",
"nodes": [
[
{
"x": x,
"y": y,
"edges": [
{
"to": "[to-node-id]"
},
...
],
"id": "[node-type];[x];[y];[z]"
},
...
],
...
],
"beacons": [
[
{
"x": x,
"y": y,
"id": "b;[x];[y];[z]",
"iid": "[instance-id]"
},
...
],
...
],
"width": width,
"height": height,
"background": {
"srcs": [
"[background-source]",
...
],
"objs": [ // array containing all Image objects for the background images
...
]
},
"current_floor": current_floor // specifies the index of the floor the user is currently viewing
}
When loading the maps into the map-creator, their format changes a little, since much data, important to editing maps and displaying the nodes and their edges, will be added to the map object. However, the map's sent to the server, ready to be stored, will have the standardized format mentioned above (JSON Format
).
{
"version": "[version]",
"nodes": [
[
{
"x": x,
"y": y,
"z": z, // the index of the floor that the node is on
"edges": [
{
"to": "[to-node-id]",
"color": "[color]" // the edge's color
},
...
],
"stroke": "[stroke-color]", // the node's stroke color
"fill": "[fill-color]", // the node's fill color
"radius": radius, // the node's displayed radius
"id": "[node-type];[x];[y];[z]"
},
...
],
...
],
"beacons": [
[
{
"x": x,
"y": y,
"id": "b;[x];[y];[z]",
"iid": "[instance-id]"
},
...
],
...
],
"width": width,
"height": height,
"background": {
"srcs": [
"[background-source]",
...
],
"objs": [ // array containing all Image objects for the background images
...
]
},
"current_floor": current_floor // specifies the index of the floor the user is currently viewing
}