Skip to content

Feature Services

Preston edited this page Sep 26, 2019 · 2 revisions

Feature Services are configured by creating a feature service configuration document and at least one TDE.

TDE

{
  "template": {
    "_comment": [
      "Set the context, collections, vars (optional), and rows",
      "* context: a xpath to where we should look for our row's documents",
      "* collections: an array of collections to be used to identify documents for this TDE",
      "* vars: (optional) an array of {\"name\": \"foo\", \"val\": \"bar\"}.",
      "*       val: a xpath string or a constant. If using a constant, wrap the string in a single quote.",
      "* rows: an array of objects with the following structure",
      "*     schemaName: a string",
      "*     viewName: a string. This will be used with SQL. Example: SELECT * FROM objects",
      "*     columns: an array of objects defining the columns for the TDE",
      "*         name: a string for the name of the column",
      "*         scalarType: a string defining the data for this column.",
      "*                     Koop requires that a column identifying the point has a unsignedInt type is REQUIRED",
      "*         val: a xpath to identify the data for this column",
      "*         nullable: can this data be null? true/false"
    ],
    "context": "/",
    "collections": ["documentType:propertySet"],
    "vars": [
      {
        "name": "searchUrlPrefix",
        "val": "'http://localhost:8080/search?objectId='"
      },
      { "name": "objectUUID", "val": "./objectId" },
      {
        "name": "iconPrefix",
        "val": "'http://localhost:8080/assets/icon/'"
      },
      { "name": "iconPostfix", "val": "'?size=100'" },
      { "name": "iconId", "val": ".//objectType" }
    ],
    "rows": [
      {
        "schemaName": "Lorem",
        "viewName": "Objects",
        "columns": [
          { 
            "name": "OBJECTID", 
            "scalarType": "unsignedInt", 
            "val": "koopObjectId", 
            "nullable": true 
          },
          {
            "name": "LABEL",
            "scalarType": "string",
            "val": "fn:string-join(./names/text(), ', ')",
            "nullable": true
          },
          {
            "name": "LINK",
            "scalarType": "string",
            "val": "fn:concat($searchUrlPrefix, $objectUUID)",
            "nullable": true
          },
          {
            "name": "ICON",
            "scalarType": "string",
            "val": "fn:concat($iconPrefix, $objectUUID, $iconPostfix, $iconId[1])",
            "nullable": true
          }
        ]
      }
    ]
  }
}

Feature Service Configuration

Optional

Search Profiles

Add a search section to a feature service descriptor in order to make the feature service available to the add-in and expose one or more search profiles. Each profile requires a Search Options and a REST transform to be used by the add-in when performing queries and viewing documents.

An example:

"search": {
    "Articles": {   // search profile's name
        "options": "example-gkg-options",           // search options
        "geometryType": "Point",                    // geometry type
        "geoConstraint": "Location",                // geospatial constraint in the search options
        "values": "points",                         // values name in the search options
        "docTransform": "example-gkg-transform",    // transform used when viewing documents
        "schema": "GDeltGKG",                       // TDE schema
        "view": "Article"                           // TDE view
    }
}

These can also be found in the Example's feature service descriptors.

Protecting Layers

The add-in allows users to replace the configuration of a feature layer with their own search parameters. To prevent a feature layer from being overwritten, you can add a readOnly attribute to the feature layer's descriptor and set it to true.