VNX extensions
For VNX 0.11.0. Pre-release: these extensions and VNX itself may change at any time.
Agents do a great job of converting your files to VNX
Give your AI agent your trail data (GPX, KML, GeoJSON, spreadsheets or your own notes) and our VNX skill. It reads the files, builds the network and writes a VNX file that Viatrail opens.
Give this prompt to your agent:
Convert my trail data to a Viatrail VNX file using the skill at https://viatrail.app/convert/SKILL.md. Follow its best practices.
Viatrail reads and writes VNX files. VNX defines trail networks, plans, tracks, points and areas, and it lets each application add its own data. This page lists what Viatrail adds. It is for developers and agents who want to read Viatrail's data from a VNX file, or write a file that Viatrail understands.
The general rules for extensions (data records, type IDs, application keys and attachments) are on vnx.tools. This page uses them and does not repeat them.
JSON Schema
Every type on this page is in one machine-readable file: viatrail-extensions.schema.json (JSON Schema 2020-12). The app's code generates it, so it matches the app. The tables below come from the same file.
- Validate a whole document against it to check the two application keys.
- Each data record type is a
$defsentry named by its@type. Check a record against the entry that its@typenames. - Keys that start with
x-give facts that JSON Schema has no word for: where a record can be (x-vnx-locations), whether Viatrail writes it only itself (x-internal), a field's kind (x-kind), a date's encoding (x-encoding), attachment paths (x-attachment-paths), the data condition operators (x-data-operators) and the built-in types a definition may extend (x-nameable-built-in-types).
Names and reading rules
Viatrail's type IDs and application keys all start with app.viatrail., because Viatrail owns the domain viatrail.app. Other applications must not define types under this prefix.
Viatrail reads two application keys: app.viatrail.datatypes (custom data types) and app.viatrail.rulesets (rule sets). The import reports any other application key and does not store it.
When Viatrail imports a file:
- A record of a type on this page is read as its table says.
- A record of any other type, under
app.viatrail.or any other prefix, is kept unchanged with no report. It is written back unchanged on the next export. - A built-in record type can hold keys that its table does not name. The app keeps them. The built-in field lists can change.
- Types marked internal below are written by Viatrail. Read them if they help you. Do not write them, and keep them unchanged when you write a file back.
Data record types
Each record is an object in the data array of an item, with an @type and the fields below. Every field is optional. "Where" lists the places in a VNX document where Viatrail reads the type.
{
"name": "Corrour bothy",
"at": [-3.6878, 57.0221, 560],
"data": [
{ "@type": "app.viatrail.shelter", "rating": 4, "booking": false, "beds": 8 },
{ "@type": "app.viatrail.water", "seasonal": false },
{ "@type": "app.viatrail.note", "text": "Burn **200 m** south. Bring a stove." }
]
}
Built-in types at a glance
The app supplies the label, hosts, fields and summary of each built-in type, so a file does not need to define them. A definition can name one of these types to change it in its folder and the folders below (see Two definitions of one type). It can add fields, change an enum's options, or replace the hosts or the summary. The type's name stays the app's. Tag, Photo and the internal types cannot be named.
| Type | Label | Hosts | Summary |
|---|---|---|---|
app.viatrail.camp | Camp | waypoint | stars for rating |
app.viatrail.shelter | Shelter | waypoint | "★★★ · 4 beds" |
app.viatrail.hotel | Hotel | waypoint | "★★★★ · 12 rooms" |
app.viatrail.shop | Shop | waypoint | the resupply option |
app.viatrail.settlement | Settlement | waypoint, area | none |
app.viatrail.water | Water | waypoint | "★★ · seasonal" |
app.viatrail.tag | Tag | all six | none |
app.viatrail.note | Note | all six | none |
app.viatrail.photo | Photo | all six | none |
app.viatrail.route | Route | highlight | stars for rating |
app.viatrail.terrain | Terrain | highlight | the terrain option |
app.viatrail.hazard | Hazard | waypoint, highlight, area | the first line of description |
The app writes app.viatrail.routing and app.viatrail.compute-failed on arcs itself. A user never adds them, and they never title an item. In a routing record, the import reports a key that it does not define, in the record or in its config, as an unknown key. A source value that is not in the schema refuses the file. When source is "engine", config must have library-enabled, base-map-enabled, cross-country-enabled and forest-avoidance, or the import fails.
The app does not list Tag, Routing or Routing failed as data types in its menus, pickers or default rule set. Tag has its own chip control. A file can still hold records of all three, and the app imports and exports them unchanged.
app.viatrail.camp Camp
Where: points[], networks[].points[].
| Field | Type | Values | Meaning |
|---|---|---|---|
rating | integer, 1 to 5 (stars) | Overall rating? | |
flat | integer, 1 to 5 (stars) | How flat is the ground? | |
sheltered | integer, 1 to 5 (stars) | How sheltered is the camp from the wind? | |
water | integer, 1 to 5 (stars) | How convenient / clean is the water source? | |
booking | boolean | Does the camp need booking? |
app.viatrail.shelter Shelter
Where: points[], networks[].points[].
| Field | Type | Values | Meaning |
|---|---|---|---|
rating | integer, 1 to 5 (stars) | Overall rating? | |
booking | boolean | Does the shelter need booking? | |
beds | integer | Approximately how many beds? |
app.viatrail.hotel Hotel
Where: points[], networks[].points[].
| Field | Type | Values | Meaning |
|---|---|---|---|
rating | integer, 1 to 5 (stars) | Overall rating? | |
booking | boolean | Does the hotel need booking? | |
rooms | integer | Approximately how many rooms? |
app.viatrail.shop Shop
Where: points[], networks[].points[].
| Field | Type | Values | Meaning |
|---|---|---|---|
resupply | string | kiosk Kiosk, grocery Grocery, market Market | What can you resupply here? |
app.viatrail.settlement Settlement
Where: points[], networks[].points[], areas[], networks[].areas[].
| Field | Type | Values | Meaning |
|---|---|---|---|
hotels | boolean | Does this settlement have hotels? | |
resupply | string | kiosk Kiosk, grocery Grocery, market Market | What can you resupply here? |
app.viatrail.water Water
Where: points[], networks[].points[].
| Field | Type | Values | Meaning |
|---|---|---|---|
rating | integer, 1 to 5 (stars) | Overall rating? | |
seasonal | boolean | Is this water source dry in some seasons? |
app.viatrail.note Note
Where: networks[], tracks[], points[], networks[].points[], networks[].highlights[], plans[], areas[], networks[].areas[].
| Field | Type | Values | Meaning |
|---|---|---|---|
text | string | Text |
app.viatrail.photo Photo
Where: networks[], tracks[], points[], networks[].points[], networks[].highlights[], plans[], areas[], networks[].areas[].
A data type definition cannot name this type. Its photos travel only in a .vnz, as the files it names.
| Field | Type | Values | Meaning |
|---|---|---|---|
photos | list of string | an archive entry, app.viatrail.photo/{id}.jpg | Photos |
app.viatrail.route Route
Where: networks[].highlights[].
| Field | Type | Values | Meaning |
|---|---|---|---|
rating | integer, 1 to 5 (stars) | Overall rating? |
app.viatrail.terrain Terrain
Where: networks[].highlights[].
| Field | Type | Values | Meaning |
|---|---|---|---|
terrain | string | major_road Major Road, minor_road Minor Road, trail Trail, cross_country Cross-Country, bush_bash Bush Bash | Terrain type |
app.viatrail.hazard Hazard
Where: points[], networks[].points[], networks[].highlights[], areas[], networks[].areas[].
| Field | Type | Values | Meaning |
|---|---|---|---|
description | string | Description of the hazard |
Internal types
The app does not list these as data types. Each one's own description says who may write it. Keep them unchanged when you write a file back.
app.viatrail.tag Tag
Internal. Where: networks[], tracks[], points[], networks[].points[], networks[].highlights[], plans[], areas[], networks[].areas[].
A free-text tag. Any application may write it. It is internal only in that the app does not list it as a data type: it shows tags as chips. A data type definition cannot name this type.
| Field | Type | Values | Meaning |
|---|---|---|---|
value | string | Value |
app.viatrail.routing Routing (internal)
Internal. Where: plans[].arcs{}, networks[].arcs{}.
Written by Viatrail; do not write.
| Field | Type | Values | Meaning |
|---|---|---|---|
source | string | engine, gpx-import, gps-recording, user-snap, user-drawn, copied | How the arc's line was made. Only "engine" marks the arc as routed by an engine; with any other value, or no record, Viatrail does not route the arc again. |
config | object | The engine settings the arc was routed with. When source is "engine", config must have library-enabled, base-map-enabled, cross-country-enabled and forest-avoidance, or the import fails. |
app.viatrail.compute-failed Routing failed
Internal. Where: plans[].arcs{}, networks[].arcs{}.
Written by Viatrail; do not write. Its presence on an arc says the engine could not route it, and the line is a straight placeholder. It has no fields.
No fields.
A record on an item whose app.viatrail. type the app does not know is kept as an unknown record. So is a record of a type in another namespace. On an arc, the import keeps only app.viatrail.routing and app.viatrail.compute-failed, and drops any other record with no report.
Photos
An app.viatrail.photo record holds an ordered list of photos for its item. In a VNX document, each photo is the entry name of a JPEG file in the same .vnz archive:
{ "@type": "app.viatrail.photo", "photos": ["app.viatrail.photo/3f2a9c41.jpg"] }
The files go in a folder named after the type, as VNX recommends (VNX §7.2):
doc.vnx
app.viatrail.photo/3f2a9c41.jpg
app.viatrail.photo/77b01e8d.jpg
{id}is an ID that the exporting app chose for the photo. It has no meaning outside the file. On import, Viatrail gives each photo a new ID.- Viatrail finds a photo by the entry name that its record lists. It ignores files in the archive that no record names, with no error.
- A plain
.vnxfile cannot carry photos. When Viatrail exports without photos, it leaves out the photo records that list photos. A photo record with an empty list stays. - The same photo can be listed by more than one record. The archive holds it once.
Photo file rules
Each photo file must be:
- a JPEG;
- with EXIF orientation 1, or with no orientation tag. Apply the rotation to the pixels before you write the file;
- at most 2560 pixels on its long edge;
- with an EXIF block that can be read, if it has one.
The import drops a photo file that breaks one of these rules, and reports the item. It also drops, with a report, a photo that the record names and the archive does not hold. The rest of the item and the file import.
Look and behaviour
VNX defines no style. Viatrail carries how an item is drawn in data records of its own, one record type for each section of the app's style editor. Each record goes in the data array of the item it styles.
| Record | Editor section | On |
|---|---|---|
app.viatrail.style.marker | Marker | points, areas, tracks, plans, networks |
app.viatrail.style.line | Line | areas, tracks, plans, networks |
app.viatrail.style.fill | Fill | areas |
app.viatrail.style.card | Card | points, areas, tracks, plans, networks |
app.viatrail.behaviour | Behaviour | areas, tracks, plans, networks (a point is always selectable) |
- An item carries only the records for the sections it sets. A record or key that is not there means Automatic: the rule sets decide.
- An item holds at most one record of each type. A second one is reported and ignored.
- A highlight has no look of its own: its line comes from its network and the rules. Viatrail reports a look or behaviour record on a highlight and does not store it.
- Colours are a
hue, an angle in degrees on a colour wheel from 0 to 359, with anintensityand adarkness. importanceis any 32-bit whole number, 0 by default. Higher is more important. An item's rank on the map is itsimportanceplus theboostof each of its records that shows a mark. The rank decides which mark or card stays when two collide. Its weight is (1 + rank)² from 0 up, and 1 / (1 − rank)² below 0.show-cardsays whether the item can have a card on the map. A line or area withyeshas a card or nothing, never a mark alone. Withnoit has no card and no mark, only its name along it. A point withnohas its marks or a dot, never a card. A card always shows the item's name.selectableis about taps.nomeans that a tap on the item's pin, line or outline does not select the item, and the item is not listed when a tap hits several items. A tap on its placed card still selects it. A point is always selectable, soapp.viatrail.behaviouron a point is reported and dropped.hideis a rule key only. An item's own hidden state is VNXhidden, so ahidein an item's behaviour record is reported and dropped.
Highlights
A highlight is a light container for data records along a walk of its network's arcs. It has an optional name and no notes of its own. It has no look or behaviour records: the rules alone draw it. A look or behaviour record on a highlight is reported and not stored. With no name, its records title it in the app. A notes key on a highlight is not in VNX, so the reader reports it as an unknown key and drops it. The import trims a highlight's name, and a name of spaces alone is no name.
In GeoJSON and KML, the VNX writer names a highlight by its name. With no name, it gives the highlight a number that is unique in its network. A record's label is not a name, so a highlight titled only by its records gets a number too. GeoJSON puts the network's name in front ("Ridges / West ridge", "Ridges / 1"). KML writes the bare name in the network's folder ("West ridge", "1"). An import does not assume that a file came from Viatrail: a line's name becomes the highlight's name as the file spells it ("Ridges / 1" in GeoJSON, "1" in KML).
{
"name": "Wild camp",
"at": [-3.6878, 57.0221, 560],
"data": [
{ "@type": "app.viatrail.camp", "rating": 4 },
{ "@type": "app.viatrail.style.marker", "icon": "lucide:tent", "hue": 105, "outline": "circle" },
{ "@type": "app.viatrail.style.card", "importance": 4, "show-card": "yes" }
]
}
app.viatrail.style.marker Marker
Where: points[], networks[].points[], plans[], tracks[], areas[], networks[].areas[], networks[].
The item's own marker. A rule styles markers with app.viatrail.style.marker.item and app.viatrail.style.marker.data instead. Write at most one per item or rule. An absent key is Automatic: the rule sets decide. A value the app cannot use is dropped with a report and the rest are kept.
| Field | Type | Values | Meaning |
|---|---|---|---|
icon | string | An icon: "lucide:<id>" for a Lucide icon or "emoji:<id>" for an emoji. "none" draws no glyph. An id the app does not have is dropped with a report. | |
hue | integer, 0 to 359 | ||
intensity | string | pale, normal, intense | |
darkness | string | light, normal, dark | |
outline | string | circle, square, hexagon, diamond, flag, none |
app.viatrail.style.line Line style
Where: plans[], tracks[], areas[], networks[].areas[], networks[].
How the item's line is drawn: on a plan, a track, a network or an area. In a rule: the line of each item it matches. Write at most one per item or rule. An absent key is Automatic: the rule sets decide. A value the app cannot use is dropped with a report and the rest are kept.
| Field | Type | Values | Meaning |
|---|---|---|---|
hue | integer, 0 to 359 | ||
intensity | string | pale, normal, intense | |
darkness | string | light, normal, dark | |
width | integer | 2, 4, 6 | |
casing | string | light, dark | |
stripe | string | none, solid, dashes, dots | |
show-name | string | yes, no |
app.viatrail.style.fill Fill style
Where: areas[], networks[].areas[].
How an area is filled. Write at most one per item or rule. An absent key is Automatic: the rule sets decide. A value the app cannot use is dropped with a report and the rest are kept.
| Field | Type | Values | Meaning |
|---|---|---|---|
hue | integer, 0 to 359 | ||
intensity | string | pale, normal, intense | |
darkness | string | light, normal, dark | |
strength | string | light, medium, strong | |
pattern | string | solid, hatch, none |
app.viatrail.style.card Card
Where: points[], networks[].points[], plans[], tracks[], areas[], networks[].areas[], networks[].
The item's card on the map. Write at most one per item or rule. An absent key is Automatic: the rule sets decide. A value the app cannot use is dropped with a report and the rest are kept.
| Field | Type | Values | Meaning |
|---|---|---|---|
importance | integer (any 32-bit whole number) | Any whole number a 32-bit signed integer holds. The map places the labels of an item with a higher importance first. 0 is the default. | |
show-card | string | yes, no | |
tag-fill | string | card, solid |
app.viatrail.behaviour Behaviour
Where: points[], networks[].points[], plans[], tracks[], areas[], networks[].areas[], networks[].
Whether a tap selects the item. In a rule, hide hides the items it matches; an item cannot hide itself. Write at most one per item or rule. An absent key is Automatic: the rule sets decide. A value the app cannot use is dropped with a report and the rest are kept.
| Field | Type | Values | Meaning |
|---|---|---|---|
hide | string | yes, no | |
selectable | string | yes, no | Whether a tap on the map can select the item. It has no effect on a "waypoint" or a "highlight" item, which is always selectable; an item's own settings on one are refused. "waypoint" means a VNX point, top-level or in a network. |
The marker shape used by markers in rules
| Field | Type | Values | Meaning |
|---|---|---|---|
icon | string | An icon: "lucide:<id>" for a Lucide icon or "emoji:<id>" for an emoji. "none" draws no glyph. An id the app does not have is dropped with a report. | |
hue | integer, 0 to 359 | ||
intensity | string | pale, normal, intense | |
darkness | string | light, normal, dark | |
outline | string | circle, square, hexagon, diamond, flag, none |
Icon IDs
A marker's icon (on an item, in a rule, or in a custom data type) is one of three things:
| Value | Meaning |
|---|---|
lucide:<id> | A Lucide icon. The id is Lucide's own icon name, for example lucide:tent or lucide:mountain-snow. |
emoji:<id> | An emoji, named by an id made from its Unicode name (below), for example emoji:tent for ⛺. |
none | No glyph: the marker is drawn with nothing in it. |
Viatrail accepts only the ids in its two lists. They are published here so that a writer can look an id up:
lucide-ids.json: 1,665 Lucide ids. They are the icons Viatrail ships, taken from Lucide's published icon set. Use this list, not the newest Lucide release: an icon added to Lucide later is not in the app.emoji-ids.json: 1,898 emoji, each with its id, the emoji character and its Unicode name.
An icon whose id is not in its list, a value with no lucide: or emoji: prefix, and a bare word such as tent are dropped with a report. The rest of the record is kept.
How an emoji id is made
The emoji set is Unicode Emoji 15.1: every fully-qualified emoji, without skin-tone variants. The id is the emoji's Unicode name, changed to ASCII snake_case in three steps:
- Spell
#as "number sign" and*as "asterisk". - Decompose the name (Unicode NFKD) and drop every character that is not ASCII. Accents go, and so does a curly apostrophe, with no space in its place.
- Lower-case it, change each run of characters other than
a–zand0–9to one_, and trim_from both ends.
| Emoji | Unicode name | Value |
|---|---|---|
| #️⃣ | keycap: # | emoji:keycap_number_sign |
| 🥇 | 1st place medal | emoji:1st_place_medal |
| 🪅 | piñata | emoji:pinata |
| 🇨🇮 | flag: Côte d’Ivoire | emoji:flag_cote_divoire |
Style samples in notes
Any markdown text in Viatrail, such as the text of an app.viatrail.note record, can draw a small sample of a map style inline: a line, a marker or an area. The app draws it exactly as the map draws that style. Use samples to write a key that tells the reader what each style on the map means.
A sample is a markdown link with the viatrail-style: scheme:
[Main trail](viatrail-style:line?hue=120&width=4&stripe=dashes)
[Campsite](viatrail-style:marker?icon=lucide:tent&hue=30&outline=circle)
[Protected area](viatrail-style:area?fill-hue=120&fill-pattern=hatch&line-hue=120&line-stripe=dashes)
- The text after
viatrail-style:is the kind (line,markerorarea), then?and the keys, joined by&. Each key can occur once. Keys and values are case-sensitive: write them in lower case. - Only the inline link form draws a sample. A reference-style link shows its label only.
- The link text is the label, which the app shows next to the sample. The label is optional:
[](viatrail-style:line?hue=120)draws the sample with no label. - The keys and values are the ones the style records use (see Look and behaviour). A hue is a whole number from
0to359; there are no hue names. A key that is not required takes its default when it is absent.autois not a value here.
The keys
A line sample:
| Key | Values | Required | Default |
|---|---|---|---|
hue | 0 to 359 | yes | |
intensity | pale, normal, intense | no | normal |
darkness | light, normal, dark | no | normal |
width | 2, 4, 6 | no | 4 |
casing | light, dark | no | dark |
stripe | none, solid, dashes, dots | no | none |
A marker sample:
| Key | Values | Required | Default |
|---|---|---|---|
icon | an icon ID with its set, such as lucide:tent or emoji:tent (see Icon IDs); not none | yes | |
hue | 0 to 359 | yes | |
intensity | pale, normal, intense | no | normal |
darkness | light, normal, dark | no | normal |
outline | circle, square, hexagon, diamond, flag, none | no | none |
An area sample has an outline and a fill. The outline takes the line keys with the prefix line-, and the fill takes these keys with the prefix fill-:
| Key | Values | Required | Default |
|---|---|---|---|
line-hue | 0 to 359 | yes | |
line-intensity, line-darkness, line-width, line-casing, line-stripe | as for a line | no | as for a line |
fill-hue | 0 to 359 | yes | |
fill-intensity | pale, normal, intense | no | normal |
fill-darkness | light, normal, dark | no | normal |
fill-strength | light, medium, strong | no | medium |
fill-pattern | solid, hatch, none | no | solid |
A sample that is not valid
A sample with an unknown kind, an unknown or repeated key, a value that is not in the tables, or a missing required key is not drawn. The app shows its label as plain text, and logs the problem. A sample with no label and an error shows nothing.
Other markdown viewers do not know the viatrail-style: scheme. They show the label as a link.
A key table
A key is a plain markdown table whose first column holds samples. Put it in the note of a network that uses several styles. When every cell of a table's header row is empty, the app does not show the header row.
| | |
|---|---|
| [](viatrail-style:line?hue=120&width=4) | Main trail |
| [](viatrail-style:line?hue=30&stripe=dots) | Alternative |
| [](viatrail-style:marker?icon=lucide:tent&hue=30) | Campsite |
| [](viatrail-style:area?fill-hue=120&line-hue=120&fill-pattern=hatch) | Protected area |
Custom data types
A data type definition tells Viatrail about records of a type that you own, for example org.example.rapid. Users can also make one in the app. With a definition, the app can:
- offer the type in an item's settings page, with a control for each field;
- show the type's label and a summary of each record on the map card and in the item's title;
- let a rule test the type's fields.
Records of a type with no definition are still kept, and rules can still style them. But the settings page does not offer the type, and its records have no label or summary, so they never title an item.
Where a definition goes
Definitions travel in the top-level application key app.viatrail.datatypes. Its value is a list. Each entry is one data type set: a named set of types, which shows in the library like a folder's other items. Its keys are in the Data type set table below.
- If
folderis absent or"", the set goes into the folder that the user imports into. Iffoldernames a folder that is not in the file, the set also goes there, and the import reports it. pinnedis when the user pinned the set: a VNX timestamp. Absent means not pinned. Apinnedvalue that is not a readable timestamp is reported, and the set is not pinned.- A definition applies to items in its folder and in every folder below it. A definition in the library's root applies to every item.
A type
Each entry of types describes one type. Its keys are in the Type table below.
- For a new type, use a globally unique identifier as
datatype: a reverse-DNS name that you own, or a UUID. The app gives a type made in its settings a UUID, and does not show it. - The
app.viatrail.namespace is for the built-in types.datatypemay name one of them, spelled exactly, to change it in the definition's folder. Any other name that starts withapp.viatrail., in any letter case, is refused. - A custom type needs
datatype,labelandhosts. - On a built-in type,
label,hosts,markerandbehavioursmust not be present. The import removes each one and reports it. A built-in type keeps its own name, hosts, marker and behaviours. - A type with no
fieldsis legal. A rule can still test whether an item carries a record of it.
The marker
marker is the type's own icon and colour. The app shows it on the type's page and on the Camps settings rows. On the map, a custom type a point can hold shows this marker with no rule needed; a rule set can change it. It is drawn in a circle, at normal intensity and darkness.
"marker": {"icon": "lucide:tent", "hue": 105}
iconis an icon id with its set:lucide:…oremoji:…(see Icon IDs).noneis not an icon here.hueis a whole number from 0 to 359, as in a rule.- A custom type with no
markergets the default:lucide:shapesat hue 0 (red). - A
markerthat breaks a rule is removed and reported at import. The type is kept, with the default marker. - When two definitions in scope name the same custom type, the first one's
markeris used, as itslabelis. If the first one has none, the type gets the default. - When the app's type editor turns a custom type into a built-in one, the app keeps the type's marker in
customMarker. This is the app's own state, not part of a file: export does not write it, and import removes it and reports it. - Rule sets still draw the map. The default rule set gives each built-in type its marker.
Behaviours
behaviours is a list of names: plan, list and camp.
"behaviours": ["plan", "list", "camp"]
- With
plan, the first record of the type on a network highlight shows a button named after the type, for example "Plan this Canoe trip". The button makes a plan along the highlight's line. The built-in Route type hasplanalready; its button is "Plan this route". An item shows one Plan button, on its first record with the behaviour. - With
list, a network's Overview shows the type's records in a section of their own, headed with the type's label. Each record on a shown highlight of the network is one row. The built-in Route type haslistalready; its section is "Routes", and it comes first. - With
camp, a plan's Camps page lists the type, and a waypoint or network point that holds a record of it can end a day of a plan that has the type on. The type'shostsmust also namewaypoint. The built-in Camp, Shelter, Hotel and Settlement types havecampalready. - A name that the app does not know is removed and reported at import. The other names are kept.
- When two definitions in scope name the same custom type, the first one's
behavioursare used, as itslabelis. - When the app's type editor turns a custom type into a built-in one, the app keeps the behaviours in
customBehaviours. This is the app's own state: export does not write it, and import removes it and reports it.
Labels and notes
A label is an object from language code to text:
"label": {"en": "Rapid", "fr": "Rapide"}
enis required.- A language code is two or three lowercase letters:
en,fr,gsw.en-GBandENare refused. - A text must not be empty.
The app shows the text for the app language, else the English text.
A field and an option have a label too, and can have a note with the same shape. A note is a short help text that the settings page shows under the control. In the app, a custom field's note is its "Description", and a custom option has one too. The app edits them in the app language. An empty description removes the note in every language. A built-in option's note is the app's own, and the app does not edit it. An option that a folder adds to a built-in Choice can have its own note.
On the first definition of a built-in type, a built-in option's note is used only when the option also has its own label, and only when the app has no note of its own for that option (for example, Terrain's options have one). Any other note on a built-in option of that definition is one that the app never shows: the import removes it and reports it. A later definition of the same type does not change an option's note.
Hosts
hosts is a list of these:
| Host | Item |
|---|---|
network | a whole network |
track | a track |
waypoint | a waypoint, in the library or inside a network |
highlight | a highlight inside a network |
plan | a plan in the library |
area | an area, in the library or inside a network |
waypointandareaeach cover both places. A type cannot apply to only the waypoints in the library, or only the waypoints inside a network.- Any other value is an unknown host, and the import refuses the type.
arcis refused: an arc has no settings page.- A type with no hosts (
hostsabsent, or an empty list) is allowed. It applies to nothing: no settings page offers it. This is not an error. - Hosts control only what the settings page offers. The import does not check hosts. A record of your type on another kind of item is kept.
Fields
Each entry of fields is one field. Its keys are in the Field table below. The settings page shows the fields in list order.
nameis the key in the record. It may only usea–z,0–9and_, and must not be empty. Two fields must not have the same name.- An option's
valuehas the same rule: onlya–z,0–9and_, not empty, and two options of one field must not have the same value. - The app's editor changes what you type to fit this rule. An import refuses a type that breaks it. So a template can read every field as
.name. optionsholds the values of an enum field. An enum may have no options (an empty Choice). On a field of another kind,optionsis kept and not used, so a change back toenumgets the list back.- No field name is special. The record panel shows every field that has a value as a row, in field order. A record's summary is what the app shows where it has room for one line only.
The kinds, and the value a record holds for each:
| Kind | Record value |
|---|---|
text | a string, one line |
markdown | a string, shown as markdown |
bool | true or false |
number | a number |
integer | a whole number |
stars | a rating from 1 to 5. No rating is an absent key, not 0. |
enum | one option's value, a string |
date | a string: ISO 8601 in UTC with a Z, for example 2026-10-10T08:30:00Z |
The kind reference is refused in a custom type.
Two definitions of one type
Two definitions in scope can name the same datatype. The app takes them in this order: the root's items first, then each folder's items down to the item's folder. In one folder, items go in order of name, then of id. In one item, types go in list order. A built-in type is always first: the app supplies it before any definition.
A later definition:
- replaces the
hosts, except on a built-in type, which always keeps its own hosts; - adds new fields at the end. It never removes a field;
- for a field with the same name and the same kind, replaces its options, in that field's place. A field with the same name and another kind is not used, and the field stays as the earlier definition had it;
- replaces the summary if it has one. A later definition with no summary keeps the earlier one.
Names never change. The first definition that defines a type, a field or an option gives its label and note. A later definition's label for the same type, field name or option value is not used, even when a definition in between left the option out. A new field or a new option uses its own label. Labels are still required everywhere, because the folder decides whether a definition comes first.
A definition of a built-in type is different. The built-in type is always first, so its own name and the names of its own fields are always used, and the definition needs no label for them. The built-in type names an option of a built-in field, unless a definition gives the option a label. Then the first definition that labels it names it in that folder, language by language: in a language that the definition has, its label shows; in any other language, the built-in name shows. A field or an option that the built-in type does not have still needs a label.
On import, a type that restates a field of a built-in type with another kind is not imported, and the report says so.
For example, this definition extends the built-in Camp type with one field. It names the built-in type and gives only the new field, with no label or hosts:
{"datatype": "app.viatrail.camp",
"fields": [{"name": "tents", "kind": "integer", "label": {"en": "Tents"}}]}
A complete example
This file holds one folder and one data type set:
{
"vnx": "0.11.0",
"folders": [{"id": "f1", "name": "Rivers"}],
"app.viatrail.datatypes": [
{
"name": "Paddling types",
"folder": "f1",
"types": [
{
"datatype": "org.example.rapid",
"label": {"en": "Rapid", "fr": "Rapide"},
"hosts": ["waypoint"],
"fields": [
{
"name": "grade",
"kind": "enum",
"label": {"en": "Grade", "fr": "Classe"},
"options": [
{"value": "2", "label": {"en": "Grade 2", "fr": "Classe 2"}},
{"value": "3", "label": {"en": "Grade 3", "fr": "Classe 3"}},
{"value": "4", "label": {"en": "Grade 4", "fr": "Classe 4"}, "note": {"en": "Look at it from the bank first."}}
]
},
{"name": "portages", "kind": "integer", "label": {"en": "Portages", "fr": "Portages"}},
{"name": "notes", "kind": "markdown", "label": {"en": "Notes", "fr": "Notes"}}
],
"summary": "{{option \"grade\"}}{{with whole .portages}}{{if ne . \"0\"}}, {{t \"portages\" .}}{{end}}{{end}}",
"strings": {
"portages": {
"en": {"one": "{n} portage", "other": "{n} portages"},
"fr": {"one": "{n} portage", "other": "{n} portages"}
}
}
}
]
}
]
}
A waypoint in the folder "Rivers" can then carry this record:
{"@type": "org.example.rapid", "grade": "3", "portages": 2}
In English, its summary is "Grade 3, 2 portages". If the waypoint has no name, its title is "Rapid · Grade 3, 2 portages".
Field tables
These tables come from the JSON Schema.
Data type set
| Field | Type | Values | Meaning |
|---|---|---|---|
name required | string | The data type set's name. It may be empty. | |
folder | string | The id of a folder in the same document. Absent or empty: the import places it where the user chooses. A folder the document does not have: the import places it there too, and reports it. | |
pinned | string | When the data type set was pinned: a VNX timestamp (§4.3). | |
types required | list of datatype-type |
Type
One type. A type that breaks a rule is left out at import, alone, with a report; an unknown key is removed with a report.
| Field | Type | Values | Meaning |
|---|---|---|---|
datatype required | string | The @type of the records this type describes. Inside app.viatrail. it must be one of the built-in types a definition may name (x-nameable-built-in-types), spelled exactly: such a type is extended, not replaced. | |
label | object: label-map | Custom types only, and required there: the type's name. An extended built-in type has the registry's name. | |
hosts | list of strings | network, track, waypoint, highlight, plan, area | Custom types only: the item kinds the type is meant for. Viatrail does not check it on import. "waypoint" means a VNX point, top-level or in a network. |
fields | list of datatype-field | ||
summary | string | A template for a one-line summary of a record. A fault drops the summary, not the type. | |
strings | object | Phrases a summary can use: phrase key, then language, then a text or a text for each plural form. English is required, and a plural table needs every form the language uses. | |
behaviours | list of strings | plan, list, camp | Custom types only. plan: a highlight with a record of the type can start a plan along its line. list: the network lists the records of the type on its highlights. camp: a point with a record of the type can end a day of a plan. |
marker | object | Custom types only: the type's icon and hue. Absent: lucide:shapes at hue 0. An unusable value is removed with a report, and the type then has that default. |
Field
| Field | Type | Values | Meaning |
|---|---|---|---|
name required | string | The key in the record body. | |
kind required | string | text, markdown, bool, number, integer, stars, enum, date | |
label | object: label-map | Required, except on a field the extended built-in type already has. | |
note | object: label-map | ||
options | list of datatype-option | The values of an enum field. Kept but not used on a field of another kind. |
Enum option
| Field | Type | Values | Meaning |
|---|---|---|---|
value required | string | ||
label | object: label-map | Required, except on an option the extended built-in field already has. | |
note | object: label-map |
Label
Text by language: each key is two or three lowercase letters (en, fr, gsw); en-GB and EN are refused. English is required. A text may not be blank.
Summary templates
What a summary is
A summary is a short text about one record, for example "4 beds" or "Trail". The app shows it in two places:
- On the map card. Each row of an item's card reads "label · summary".
- In the item's title, when the item has no name. The title is "label · summary" from the item's strongest record: the first row of the map card whose type has a label. If no row has one, it is the first record in the item's
datalist that shows no mark and whose type has a label. The records that the app writes itself never title an item. The same title shows in the library, the details page, search results and, for a line or an area, along it on the map.
If the summary is empty, the row and the title show the label alone.
A summary comes from the type's summary key: one Go text/template string. One template serves every language. Phrases in other languages come from the type's strings table (see Strings and plurals).
Only a file can supply strings. The app's type editor can change a template, but it cannot add or change phrases: it keeps the strings table that the file gave. So a template that uses t must come from a file. The one exception: a type that extends a built-in type already has the built-in type's phrases, and its template can use them.
The full Go template language is available: if, else, with, range, and, or, not, eq, printf, index, len and the rest. A template sees only the record and the helpers below. It cannot read files, use the network or start programs.
Template values
A template can read these values with a dot:
| Value | What it is |
|---|---|
.<field name> | The record's value for a field that the definition names, for example .portages. A field that the record does not hold is its kind's zero value (see below). |
.Lang | The app language code, for example en or fr. |
Do not name a field Lang. .Lang replaces it.
Field values
Every field that the definition names is present, with a value of this type:
| Kind | Value in the template | When the record does not hold it |
|---|---|---|
bool | a boolean | false |
number, integer, stars | a floating-point number | 0 |
text, markdown, enum, date | a string | "" |
- A JSON
nullis the same as an absent key. - A key that the definition does not name is not a value. For example,
.colourfor a field that the definition does not have stops the run with an error. It never prints<no value>. - If the record holds a value of the wrong JSON type for its field (for example
"portages": "two"), that field is not a value. A template that reads it stops with an error. A template that does not read it runs as usual. - To test whether the record holds a field at all, use
has.
Notes on the Go template language
- Comparisons work on any number.
eq,ne,lt,le,gtandgecompare numbers by value, soge .rating 1,ge .rating 1.0andeq .portages 0all work. Strings and booleans compare as usual.eqwith more than one argument (eq .class 1 2 3) is true if any of them matches. A comparison of a number with a string stops the run with an error. - Empty values are false.
if .notesis false for"", andif .portagesis false for0. - Whitespace. The output is folded to one line (see Output), so you can lay out a long template freely.
Helpers
These are all the helpers that a template can call:
| Helper | Use | Result |
|---|---|---|
t | t "key" or t "key" count | The phrase key from the type's strings table, in the app language, else English. With a count, the plural form for that count, with {n} replaced by the count. The key must be a literal string. A count must be a number, or a string that holds a number. |
option | option "field" | The label of the record's option for an enum field, in the app language, else English. "" if the record has no value, or a value that the field does not define. The run stops with an error if the field is not an enum field. |
has | has "field" | true if the record holds the key and its value is not null. |
whole | whole x | x as a whole number in plain text, with no thousands separator, for example "4" or "1500". "" if x is not a whole number, or if its size is more than 2⁵³. Use it for a count that you give to t or repeat. |
num | num x | x as text in its shortest form, written in the app language: 2.5, 4, 1,000,000 in English, 1 000 000 in French. "" if x is not a number. |
firstLine | firstLine x | The first line of markdown text that has words in it, as plain text. Heading marks, quote and list marks, emphasis, code marks and link targets are removed. "" if x is not a string. |
repeat | repeat "s" n | s written n times. n must be a whole number, 0 or more. More than 100 is cut to 100. |
num and the {n} of t write a number in the app language. English groups the digits with , and uses . for a decimal point (1,500.5). French groups them with a narrow no-break space (U+202F) and uses , for a decimal point (1 500,5). num reads the value as a number and writes it in its shortest form, so 1.50 becomes 1.5 and 1e3 becomes 1,000. (A field's value in a record panel is different: there every digit stays as the record has it.)
To show a grouped number in a summary, use num: {{num .beds}} gives 1,500, but a bare {{.beds}} gives 1500.
whole does not group. Its text is for the helpers that read a number back: t and repeat. A count can also be what num wrote, so {{t "beds" (num .beds)}} works.
Output
The app cleans the template's output:
- Bidirectional control characters are removed.
- Each run of spaces, new lines and other control characters becomes one space. Spaces at the start and end are removed. A no-break space (U+00A0) and a narrow no-break space (U+202F) stay as they are, so a number that
numgroups in French does not break across two lines. - The text is cut to 160 bytes, at a character boundary.
A run that writes more than 64 KiB stops with an error.
The built-in templates
The built-in types use the same mechanism. Their summary files are below. They are good examples.
Camp and Route: stars for a rating from 1 to 5. Nothing for no rating, or for a rating that is not whole. The two files are the same.
{
"summary": "{{if has \"rating\"}}{{if and (ge .rating 1.0) (le .rating 5.0)}}{{with whole .rating}}{{repeat \"★\" .}}{{end}}{{end}}{{end}}"
}
Hazard: the first line of the hazard's markdown text.
{
"summary": "{{firstLine .description}}"
}
Hotel: the stars of a rating from 1 to 5, then the number of rooms with a plural phrase, joined with " · ". Either part can be missing.
{
"summary": "{{$s := \"\"}}{{if has \"rating\"}}{{if and (ge .rating 1.0) (le .rating 5.0)}}{{with whole .rating}}{{$s = repeat \"★\" .}}{{end}}{{end}}{{end}}{{$o := \"\"}}{{if has \"rooms\"}}{{with whole .rooms}}{{$o = t \"rooms\" .}}{{end}}{{end}}{{$s}}{{if and $s $o}} · {{end}}{{$o}}",
"strings": {
"rooms": {
"en": {"one": "{n} room", "other": "{n} rooms"},
"fr": {"one": "{n} chambre", "other": "{n} chambres"}
}
}
}
Shelter: the stars, then the number of beds, as Hotel. Zero beds is "0 beds" in English and "0 lit" in French, because the two languages use different forms for zero.
{
"summary": "{{$s := \"\"}}{{if has \"rating\"}}{{if and (ge .rating 1.0) (le .rating 5.0)}}{{with whole .rating}}{{$s = repeat \"★\" .}}{{end}}{{end}}{{end}}{{$o := \"\"}}{{if has \"beds\"}}{{with whole .beds}}{{$o = t \"beds\" .}}{{end}}{{end}}{{$s}}{{if and $s $o}} · {{end}}{{$o}}",
"strings": {
"beds": {
"en": {"one": "{n} bed", "other": "{n} beds"},
"fr": {"one": "{n} lit", "other": "{n} lits"}
}
}
}
Shop: the label of an enum option, for example "Grocery". Terrain is the same over its terrain field, for example "Trail".
{
"summary": "{{option \"resupply\"}}"
}
Water: the stars, then one phrase with no plural, only when a bool field is true, as Hotel.
{
"summary": "{{$s := \"\"}}{{if has \"rating\"}}{{if and (ge .rating 1.0) (le .rating 5.0)}}{{with whole .rating}}{{$s = repeat \"★\" .}}{{end}}{{end}}{{end}}{{$o := \"\"}}{{if .seasonal}}{{$o = t \"seasonal\"}}{{end}}{{$s}}{{if and $s $o}} · {{end}}{{$o}}",
"strings": {
"seasonal": {
"en": "seasonal",
"fr": "saisonnière"
}
}
}
Strings and plurals
strings is an object from phrase key to languages. Each language has one of two shapes:
- A plain text. The phrase is the same at every count:
"seasonal": {"en": "seasonal", "fr": "saisonnière"}. - An object of plural forms. The app chooses the form from the count:
"en": {"one": "{n} bed", "other": "{n} beds"}.
The rules:
- Every phrase needs
en. - A language code is two or three lowercase letters, as in a label.
- A form name is one of
zero,one,two,few,many,other. - An object of forms must have
other, and every form that the language uses for whole numbers. The import names any form that is missing. English and French each useoneandother. Other languages can need more forms. - A text must not be empty.
- Every key that the template gives to
tmust be instrings. The key must be a literal string in the template, so that the import can check it.
The app chooses plural forms from the CLDR 32 rules. Do not try to choose a form in the template: English and French differ at zero ("0 beds", "0 lit"). A count that is not whole always takes other. t "key" with no count takes other.
In a phrase, {n} is replaced by the count. A phrase in a language that the table does not have is taken from English.
What the import reports
The import checks each data type definition and shows a report line for each problem. The report line names the type, but not the reason. The reason is an English phrase in the app's log, with the place in the file, for example /app.viatrail.datatypes/0.
| Report line | What happened |
|---|---|
| Skipping {type}: its definition has an error. | The type breaks a rule in Custom data types. The type is not stored. Other types in the same set still import. |
| Skipping an untitled data type set: its definition has an error. | The same, for a set whose name is "", when the problem is with the set and not with one type. |
| Ignoring {key} in {type}: this app does not know it. | The definition has a key that this page does not list. The key is not stored. The type still imports. |
| Not using the summary of {type}: its template has an error. | The summary or the strings breaks a rule. The type imports without it, so its items show the type label alone. |
| Not using the marker of {type}: it has an error. | The marker breaks a rule (see The marker). The type imports with the default marker. |
| Not using the descriptions on built-in options in {type}. | A note on a built-in option that the app never shows (see Labels and notes). The note is not stored. The type still imports. The log lists each field.option. |
| The data type set "{name}" belongs to a folder that is not in the file, so it was put in the folder you imported into. | folder names a folder that the file does not have. |
| The file carries something in its data type sets that this app cannot read, so it was not imported. | app.viatrail.datatypes is not a list, or an entry is not an object, or its name or folder is not a string. |
If types is absent, or no type in the set can be used, the whole set is skipped.
A field name or option value with a character other than a–z, 0–9 and _ skips its type. The log names it:
Skipping org.example.rapid: field key 'one-way' may only use a–z, 0–9 and _.
Skipping org.example.rapid: option value 'bush-bash' of field grade may only use a–z, 0–9 and _.
A summary is not used when:
- the template does not parse;
thas no key, or its key is not a literal string;tasks for a key thatstringsdoes not have;summaryis not a string;stringsbreaks a rule in Strings and plurals. Thenstringsis not used, and a summary that uses its phrases is not used either. The import shows a line for each.
The log line holds the detail. For a template that does not parse, the detail is the error from Go's template parser, which names the line. For example, a template with an {{if}} and no {{end}}:
Not using the summary of org.example.rapid: its summary template cannot be used (the summary template does not parse: template: summary:1: unexpected EOF).
And a template that asks for a phrase that strings does not have:
Not using the summary of org.example.rapid: its summary template cannot be used (t's phrase "portage" is not in strings).
Errors when a template runs
The import cannot run a template on every record. A template that parses can still stop with an error on one record, for example when it compares a number with a string, or reads a field of the wrong type. Then:
- the summary for that record is empty, so the title is the type label alone;
- the app writes one line to its log for each type and each different error, once in each session:
summary of org.example.rapid: <the error>; no summary shown.
No report line shows. Test your template on records with every field absent, present, and holding unusual values.
Rule sets
A rule set is an ordered list of rules. It says how the map draws the items in a folder and in every folder below it. Rule sets travel in the top-level application key app.viatrail.rulesets, as a list. A file holds only the user's own rule sets. Viatrail's default rule set is never exported, whether the user changed it or not.
- With no
folder, a rule set goes into the folder that the user imports into. Iffoldernames a folder that the file does not have, the rule set is not imported: the app does not guess a wider scope. pinnedis when the user pinned the rule set: a VNX timestamp. Absent means not pinned. Apinnedvalue that is not a readable timestamp is reported, and the rule set is not pinned.
"app.viatrail.rulesets": [
{
"name": "Highlight wet ground",
"enabled": true,
"rules": [
{
"name": "Boggy stretches in blue",
"item-types": ["highlight"],
"conditions": [{ "field": "tag", "operator": "contains", "value": "boggy" }],
"style": [
{ "@type": "app.viatrail.style.line", "hue": 210, "intensity": "intense", "width": 6, "stripe": "dashes" }
]
},
{
"name": "Water sources",
"item-types": ["waypoint"],
"style": [
{ "@type": "app.viatrail.style.marker.data", "markers": [
{ "type": "app.viatrail.water", "marker": { "icon": "lucide:droplet", "hue": 210 }, "marker-type": "primary", "boost": 2 }
] }
]
}
]
}
]
A rule's style list holds app.viatrail.style.line, .fill and .card records, the same as on an item, plus two that only a rule has: app.viatrail.style.marker.item (a marker for each item kind the rule matches) and app.viatrail.style.marker.data (the data types the rule styles: for each, a marker, a marker-type of none, primary or secondary, and a boost). A rule's behaviour key holds the same app.viatrail.behaviour record as on an item, and only a rule may set its hide, which hides the matched items from the map. The rule's other fields (item-types, match-any, conditions) say which items it matches. In these lists, "waypoint" means a VNX point.
How rules apply
A rule set with enabled: false does not apply. For each item, the app goes through the enabled rule sets in this order:
- the built-in default rule set;
- the root's rule sets;
- the rule sets of each folder from the root down to the item's folder.
In one folder, rule sets go in order of name, then of id. In a rule set, rules go in list order.
A rule applies to an item when the item's type is in the rule's item-types and its conditions pass. Each property that a rule sets replaces the value from earlier rules. A property that a rule does not set keeps the earlier value. Last, the item's own look and behaviour records replace every rule.
Rule details
- An empty
item-typeslist matches nothing: the rule styles no item. - An empty
conditionslist always passes. - A behaviour record in a rule's
stylelist is reported and ignored. Put it inbehaviour. - In
app.viatrail.style.marker.item, each entry gives the mark that an item of that type draws when no record shows a mark. Eachtypemust be initem-types, at most once. - In
app.viatrail.style.marker.data, the entries are the rule's data types, in order, at most one entry for eachtype. An entry with only itstypepicks the type and changes nothing. Eachtypemust be a string that is not empty.
marker-type says how the type's records show:
none: no mark and no row on the card.primary: a mark on the map, and a row with its name on the card.secondary: a small icon in one shared row on the card (or its own named row when it is the card's only secondary type). On the map only when the item has no primary mark, and then only the strongest one.
A later rule's marker-type replaces an earlier one's. When no rule sets it, the default rule set's value holds: secondary for app.viatrail.note and app.viatrail.photo, and primary for the other types with a marker, including a custom type that a point can hold. A shown record with no icon gets a letter chip: the first letter of its type's label. A shown record's boost (0 by default, any 32-bit whole number) moves it up or down the card and adds to the item's rank.
hide (yes or no) in a rule's behaviour takes the items that the rule matches off the map, as if each item were hidden. no, or no hide, does not hide them. A later rule's no shows an item again that an earlier rule hid. A rule that hides a network hides every item in that network. hide is independent of an item's own hidden state (VNX hidden), and applies to every item type.
The import checks each value. It drops a value that it cannot use, with a report line, and keeps the rest of the rule. It drops a rule whose item-types lists only types that it does not know.
Conditions
A text condition tests a text of the item:
{"field": "name", "operator": "contains", "value": "bothy"}
field | Tests |
|---|---|
name | the item's name |
text | the name, then each text and markdown field of the item's records whose type is built-in or defined. One match is enough. |
folder | the name of the item's folder |
path | the names of the item's folders from the root, joined with / |
tag | the value of each tag record. One match is enough. |
operator | Passes when |
|---|---|
contains | the text contains value, in any letter case |
starts_with | the text starts with value, in any letter case |
matches_regex | the Go regular expression value matches. Letter case counts unless the expression starts with (?i). |
A data condition tests the item's records:
{"field": "data", "type": "org.example.rapid", "operator": "ge", "data-field": "portages", "operand": 1}
typeis the record type. It is required.data-fieldis the field to test. It is required for every operator exceptpresentandabsent, which must not have it.operandis the value to compare with. Its shape depends on the operator.valuemust not be present.
| Operators | For | operand |
|---|---|---|
present, absent | the type itself: the item has, or does not have, a record of type | none |
set, unset | any field | none |
eq, ne, lt, le, gt, ge | number, integer, stars | a number (1 to 5 for stars) |
is_true, is_false | bool | none |
is, is_not | enum | an option value, a string |
one_of | enum | a list of one or more option values |
contains, starts_with, matches_regex | text, markdown | a string |
before, after | date | a day, YYYY-MM-DD |
A data condition works the same way for built-in types, custom types and types with no definition.
A condition with a field or operator that the app does not know is kept and reported. It never passes. A data condition that breaks a rule above is kept and reported too.
An example
"app.viatrail.rulesets": [
{
"name": "Rapids",
"enabled": true,
"folder": "f1",
"rules": [
{
"name": "Show rapids",
"item-types": ["waypoint"],
"conditions": [],
"style": [
{"@type": "app.viatrail.style.marker.data", "markers": [
{"type": "org.example.rapid", "marker": {"icon": "lucide:waves", "hue": 206, "intensity": "intense", "outline": "circle"}, "marker-type": "primary", "boost": 1}
]}
]
},
{
"name": "Hide closed rapids",
"item-types": ["waypoint"],
"conditions": [{"field": "tag", "operator": "contains", "value": "closed"}],
"behaviour": {"@type": "app.viatrail.behaviour", "hide": "yes"}
}
]
}
]
Field tables
These tables come from the JSON Schema.
Rule set
| Field | Type | Values | Meaning |
|---|---|---|---|
name required | string | ||
enabled required | boolean | ||
folder | string | The id of a folder in the same document. Absent or empty: the import places it where the user chooses. A folder the document does not have drops the rule set with a report. | |
rules | list of rule | ||
pinned | string | When the rule set was pinned: a VNX timestamp (§4.3). |
Rule
| Field | Type | Values | Meaning |
|---|---|---|---|
name | string | ||
item-types | list of strings | waypoint, plan, track, highlight, area, network | The kinds of item the rule matches. An empty list matches nothing. "waypoint" means a VNX point, top-level or in a network. |
match-any | boolean | True: an item matches when any condition holds. Absent or false: all must hold. | |
conditions | list of condition | ||
style | list of records: app.viatrail.style.line, app.viatrail.style.fill, app.viatrail.style.card, app.viatrail.style.marker.item, app.viatrail.style.marker.data | The rule's style: its style records, each an object with its @type, at most one of each type. | |
behaviour | object: app.viatrail.behaviour |
Condition
A condition the app does not know (field or operator) is kept with a report and never matches.
| Field | Type | Values | Meaning |
|---|---|---|---|
field required | string | name, text, folder, path, tag, data | What the condition tests: one of the item's texts, or (data) its data records. |
operator required | string | ||
value | string | A text condition's text. A data condition has none. | |
type | string | A data condition's data type: any @type, built-in, custom or undefined. | |
data-field | string | A data condition's field, for an operator that tests a field. | |
operand | any JSON value | A data condition's value; its shape is the operator's (x-data-operators). |
| Condition | field | operator |
|---|---|---|
| Text condition | name, text, folder, path, tag | contains, starts_with, matches_regex |
| Data condition | data | present, absent, contains, starts_with, matches_regex, set, unset, is_true, is_false, eq, ne, lt, le, gt, ge, is, is_not, one_of, before, after |
app.viatrail.style.marker.item Item markers
A rule's marker for each item kind it lists in item-types: at most one entry per kind. Rules only. "waypoint" means a VNX point, top-level or in a network.
| Field | Type | Values | Meaning |
|---|---|---|---|
markers | list of object |
Each entry in markers:
| Field | Type | Values | Meaning |
|---|---|---|---|
type required | string | waypoint, plan, track, highlight, area, network | |
marker | object: marker |
app.viatrail.style.marker.data Data markers
A rule's data types and their markers: one entry per data type the rule styles, at most one per type, in the rule's order. Rules only. marker-type: none (no marker, no card row), primary (its own marker on the map and its own named row on cards) or secondary (a small icon in one shared row on cards; on the map only when the item has no primary marker, then only the strongest). An entry with only its type picks the type and changes nothing.
| Field | Type | Values | Meaning |
|---|---|---|---|
markers | list of object |
Each entry in markers:
| Field | Type | Values | Meaning |
|---|---|---|---|
type required | string | The data type's id: a string that is not empty. | |
marker | object: marker | ||
marker-type | string | none, primary, secondary | |
boost | integer (any 32-bit whole number) | Any whole number a 32-bit signed integer holds. It adds to the importance of an item with a record of the type, and orders the item's marks and records: within a marker type, a higher boost comes first. 0 is the default. |
A minimal program
This Go program writes a small valid file: one network with three nodes, two arcs, a highlight and a water point. Run it in an empty folder:
go mod init example && go get github.com/dave/vnx/go@main
go run .
go run github.com/dave/vnx/go/cmd/vnx@main validate out.vnx
package main
import (
"log"
"os"
"github.com/dave/vnx/go/pkg/vnx"
)
func main() {
doc := &vnx.Document{Version: vnx.Version}
doc.Folders = []vnx.Folder{{ID: "f1", Name: "Example trails"}}
doc.Networks = []vnx.Network{{
Folder: "f1",
Name: "Example valley",
// Nodes are trail ends and junctions; positions are lon, lat.
Nodes: map[string]vnx.Vertex{
"car-park": {Lon: 10.000, Lat: 46.000},
"junction": {Lon: 10.010, Lat: 46.010},
"lake": {Lon: 10.020, Lat: 46.020},
},
// An arc joins two different nodes; pips are the points between them.
Arcs: map[string]vnx.Arc{
"valley-path": {From: "car-park", To: "junction",
Pips: []vnx.Vertex{{Lon: 10.004, Lat: 46.005}}},
"lake-path": {From: "junction", To: "lake"},
},
// A highlight is a named walk over the arcs.
Highlights: []vnx.Highlight{{Name: "Lake trail", Walk: []vnx.Pass{
{Arc: "valley-path", From: &vnx.Endpoint{Node: "car-park"}},
{Arc: "lake-path", To: &vnx.Endpoint{Node: "lake"}},
}}},
Points: []vnx.Point{{Name: "Lake spring", At: vnx.Position{Lon: 10.019, Lat: 46.019},
Data: []vnx.Record{{Type: "app.viatrail.water", Body: map[string]any{"seasonal": true}}}}},
}}
raw, err := vnx.Encode(doc)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("out.vnx", raw, 0o644); err != nil {
log.Fatal(err)
}
}