Skip to content

Latest commit

 

History

History
113 lines (103 loc) · 4.22 KB

features.md

File metadata and controls

113 lines (103 loc) · 4.22 KB
type Workspace Key
title Layer features
description Inline layer features, and featureSet and featureLookup which restrict and enrich the features a layer displays; use for layers without a table or showing a subset of one.
resource ../../../apps/mapp/lib/layer/featureStyle.mjs
tags
workspace
layer
mapp
status draft
x-xyz-keys
key type formats description
layer.features
array
wkt
geojson
cluster
vector
Inline features, parsed with layer.featureFormat. A layer with features requests no data.
key type description
layer.featureSet
array
Feature IDs to display; other features are not styled. An empty array displays all.
key type description
layer.featureLookup
array
Objects whose ID property matches a feature ID; only matched features display, with the object's properties.
key type open description
layer.featureLookup[]
object
true
The properties of a feature.
key type default requires description
layer.featureLookupId
string
id
layer.featureLookup
Property of the featureLookup objects which holds the feature ID.
sources
id resource
style
../../../apps/mapp/lib/layer/featureStyle.mjs
id resource
vector
../../../apps/mapp/lib/layer/format/vector.mjs
id resource
mvt
../../../apps/mapp/lib/layer/format/mvt.mjs
id resource
decorate
../../../apps/mapp/lib/layer/decorate.mjs
id resource
featureFormats
../../../apps/mapp/lib/layer/featureFormats.mjs
resource
../../../apps/xyz/mod/workspace/templates/layer_extent.js
resource
../../../apps/ui/lib/locations/entries/layer.mjs

Layer features

Inline features. A vector format layer with features parses them with featureFormat, which defaults to format, and never requests data; reload only re-renders.1 geojson features are GeoJSON Feature objects with id, geometry and properties; wkt features are records [id, wkt_geometry, …fields]. The geometry is read in srid, so srid and qID are still required.2 There is no vector feature format: a vector layer with features sets featureFormat.

featureSet lists the feature IDs which are displayed. The MAPP library converts the array to a Set; features whose id is not in it are not styled, and clustering ignores them.3

featureLookup is an array of objects. A feature is displayed only when an object's featureLookupId property, id by default, equals the feature ID; the object's properties are then assigned to the feature, so themes and labels can use them. On an MVT layer a featureLookup requests tiles with geometry and ID only, so the lookup supplies the properties.4

The zoom to extent button of a layer with a featureSet or featureLookup queries the extent of those IDs only.5 Location layer entries set featureSet and featureLookup from the location's data at runtime.

Pitfalls

  • IDs are compared with ===: ["1", "2"] matches no integer IDs. Use the type the query returns for qID.
  • An empty featureSet displays every feature; an empty featureLookup displays none.
  • featureLookup takes precedence over featureSet for the extent query.

Examples

The devdb locations restricted to two IDs, and an inline GeoJSON point.

{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "capitals": {
        "display": true,
        "format": "wkt",
        "table": "example.locations",
        "geom": "geom",
        "srid": "4326",
        "qID": "id",
        "featureSet": [2, 3]
      },
      "inline": {
        "display": true,
        "format": "vector",
        "featureFormat": "geojson",
        "srid": "4326",
        "qID": "id",
        "features": [
          {
            "type": "Feature",
            "id": 1,
            "geometry": { "type": "Point", "coordinates": [-0.1276, 51.5072] },
            "properties": { "name": "Geolytix" }
          }
        ]
      }
    }
  }
}

Footnotes

  1. layer/format/vector.mjs vector, setSource and reload ↩

  2. layer/featureFormats.mjs geojson and wkt ↩

  3. layer/featureStyle.mjs featureProperties; format/vector.mjs clusterGeometry ↩

  4. layer/format/mvt.mjs wktTileUrlFunction ↩

  5. decorate.mjs getExtent ↩