Workspace Documents

Workspace documents are a json data structure passed to the client along with KML files to specify how feature classes within that file can be interacted with. Primarily, this interaction takes the form of options available in the editing toolbar. Workspaces indicate for each feature class:

  • Alternative representations available within the Export menu, such as kml or shapefile downloads.
  • Related files that can be downloaded, such as spreadsheet or pdf reports.
  • Editing actions that can be performed
  • How to create, update, and delete instances
  • How to view feature attributes in the sidebar

Note

Workspace documents are automatically created and embedded within kml files by the features app. For project implementations, it should be unnecessary to modify these files directly. This documentation is intended for Madrona developers who may need to add generic features to the core framework.

example workspace document

{
  "feature-classes": [
    {
      "title": "Marine Protected Area",
      "id": "features_mpa",
      "link-relations": {
        "self": {
          "uri-template": "/features/mpa/{id}/"
        },
        "create": {
          "uri-template": "/features/mpa/form/"
        },
        "related": [
          {
            "title": "Habitat Spreadsheet",
            "uri-template": "/features/mpa/links/habitat-spreadsheet/{id+}/",
            "select": "single",
            "rel": "related"
          }
        ],
        "update": {
          "uri-template": "/features/mpa/{id}/form/"
        }
      }
    },
    {
      "title": "Renewable Energy Site",
      "id": "features_renewableenergysite",
      "link-relations": {
        "self": {
          "uri-template": "/features/renewableenergysite/{id}/"
        },
        "create": {
          "uri-template": "/features/renewableenergysite/form/"
        },
        "related": [
          {
            "title": "Viewshed Map"
            "uri-template": "/features/renewableenergysite/links/viewshed-map/{id+}/",
            "select": "single",
            "rel": "related"
          }
        ],
        "update": {
          "uri-template": "/features/renewableenergysite/{id}/form/"
        }
      }
    },
    {
      "title": "Folder",
      "id": "features_folder",
      "collection": {
        "add-uri-template": "/features/collections/add/{id+}/",
        "remove-uri-template": "/features/collections/remove/{id+}/",
        "valid-children": [
          "features_folder",
          "features_mpa",
          "features_renewableenergysite"
        ]
      },
      "link-relations": {
        "edit": [
          {
            "title": "Delete folder and contents"
            "method": "POST",
            "uri-template": "/features/folder/links/delete-folder-and-contents/{id+}/",
            "select": "single multiple",
            "rel": "edit"
          }
        ],
        "self": {
          "uri-template": "/features/folder/{id}/"
        },
        "create": {
          "uri-template": "/features/folder/form/"
        },
        "update": {
          "uri-template": "/features/folder/{id}/form/"
        }
      }
    }
  ]
  "generic-links": [
    {
      "title": "Copy",
      "uri-template": "/features/generic-links/links/copy/{id+}/",
      "rel": "edit",
      "method": "POST",
      "select": "multiple single",
      "models": [
        "features_folder",
        "features_mpa",
        "features_renewableenergysite"
      ]
    },
    {
      "title": "Export KML",
      "uri-template": "/features/generic-links/links/export-kml/{id+}/",
      "select": "multiple single",
      "rel": "alternate",
      "models": [
        "features_folder",
        "features_mpa",
        "features_renewableenergysite"
      ]
    }
  ]
}

Root

The root of the workspace is a javascript object with two properties, generic-links and feature-classes.

feature-classes

feature-classes contains an array of objects that represent every feature class present in the kml document. Each of these objects describe how the feature should be displayed, crud operations can be performed, any related downloads or non-standard editing operations supported.

feature-class objects

Each contain the following properties:

title

The title that this feature class should be referred to within the user interface. The most prominent use of this property is in the “Create New” menu.

id

The unique id for this feature class. Each instance of a feature class has an id composed of {class.id}_{instance.pk}. When instances are selected in the user-interface, the id of it’s class can be derived by matching all characters preceding the final underscore _.