Files
iD/data/presets
Bryan Housel 720b26142f Presets (volcano, saddle, adit, tree_row)
Squashed commit of the following:

commit a100cc377da4d0790582fb2bd69e691d99084f0c
Author: Bryan Housel <bryan@7thposition.com>
Date:   Tue Jun 30 10:26:12 2015 -0400

    run make

commit cedd5d1c3dd43576ee42a6ab211d2f26eaaa732c
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Mon Jun 29 18:53:36 2015 +0200

    Update volcano.json

commit 38c4a782f6941064f3c8132bce61896ea14e70e9
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Mon Jun 29 16:28:28 2015 +0200

    Solver problem in man_made/adit/depth

commit 5e6d35dc3ed822ff1716cf0c80e6606545e337bd
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Mon Jun 29 16:12:13 2015 +0200

    Solver problem in man_made/adit/resource

commit bb582143ce90ec00b5d2a7b1efd8fb2415cca16d
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Mon Jun 29 13:54:29 2015 +0200

    Revert changes to ES locale

commit 8537162ad1bc6f6377c90f41cd6f24c103561ca5
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Mon Jun 29 13:50:49 2015 +0200

    Some natural and man_made presets

commit 4c41d88f63950787ca5372414ebcda4609458d26
Author: jmespadero <josemiguel.espadero@urjc.es>
Date:   Fri Jun 26 15:57:38 2015 +0200

    Some natural/* and man_made/* translations
2015-06-30 10:27:24 -04:00
..

Presets

iD uses a simple presets system based on JSON preset definitions and simple structure.

Individual Presets

Specific presets are located under data/presets/presets. They're organized in a directory hierarchy based on OSM key/value pairs. For example, the preset that matches the tag leisure=park is in the file data/presets/presets/leisure/park.json.

Preset Format

A basic preset is of the form:

{
    // The icon in iD which represents this feature.
    "icon": "park",
    // An array of field names. See the fields documentation for details of what's valid here.
    "fields": [
        "address"
    ],
    // The geometry types for which this preset is valid.
    // options are point, area, line, and vertex.
    // vertexes are points that are parts of lines, like the nodes
    // in a road
    // lines are unclosed ways, and areas are closed ways
    "geometry": [
        "point", "area"
    ],
    // Terms are synonyms for the preset - these are added to fuel
    // the search functionality. searching for 'woodland' will bring
    // up this 'park' preset
    "terms": [
        "esplanade",
        "village green",
        "woodland"
    ],
    // Tags that are added to the feature when selecting the preset,
    // and also used to match the preset against existing features.
    // You can use the value "*" to match any value.
    "tags": {
        "leisure": "park"
    },
    // English language display name for this map feature.
    "name": "Park"
}

Fields

Fields are, like presets, defined in JSON structures. A typical field is

{
    "key": "access",
    "type": "combo"
}

In which type is the fields's type. Valid field types are

  • textarea
  • radio
  • combo
  • address
  • check - a tri-state checkbox: yes, no, or unknown (no tag)
  • defaultcheck - a boolean checkbox where checked produces a *=yes tag and unchecked produces no tag

The key property names the OSM key that the field will edit. Alternatively, for compound fields like address, you can specify an array of keys in the keys property.

Each field definition lives in a separate file in data/presets/fields. The field name (used in the preset fields property) is the name of the file (minus the .json extension).

Icons

Preset icons in iD are pulled from the open source POI icon set, Maki. Icons are stored in dist/img/maki-sprite.png. The icons are identified in iD by the same name as they are on the Maki home. Use those names when identifying the icon to be used for a given preset.

Building

To build presets, all you need to do is run make.

This command will take care of running the build script, which packages all presets together with imagery data, and deprecated or discarded tags into one file, data/data.js, which is included in the packaged iD.js file.

Custom Presets

iD supports deployments which use a custom set of presets. You can supply presets via the presets accessor:

var id = iD().presets({
    presets: { ... },
    fields: { ... },
    defaults: { ... },
    categories: { ... }
});

All four parts (presets, fields, defaults, and categories) must be supplied. In addition, several base presets and fields must be included.

Basic geometric presets must be included so that every feature matches at least one preset. For example:

"area": {
    "name": "Area",
    "tags": {},
    "geometry": ["area"],
    "matchScore": 0.1
},
"line": {
    "name": "Line",
    "tags": {},
    "geometry": ["line"],
    "matchScore": 0.1
},
"point": {
    "name": "Point",
    "tags": {},
    "geometry": ["point"],
    "matchScore": 0.1
},
"vertex": {
    "name": "Other",
    "tags": {},
    "geometry": ["vertex"],
    "matchScore": 0.1
}

A "name" field must be included:

"name": {
    "key": "name",
    "type": "localized",
    "label": "Name",
    "placeholder": "Common name (if any)"
}