import { FeatureSource } from "../FeatureSource" import { ImmutableStore, Store } from "../../UIEventSource" import { Feature } from "geojson" /** * A simple, read only feature store. */ export default class StaticFeatureSource implements FeatureSource { public readonly features: Store constructor(features: Store | T[] | { features: T[] } | { features: Store }) { if (features === undefined) { throw "Static feature source received undefined as source" } let feats: T[] | Store if (features["features"]) { feats = features["features"] } else { feats = >features } if (Array.isArray(feats)) { this.features = new ImmutableStore(feats) } else { this.features = feats } } public static fromGeojson(geojson: T[]): StaticFeatureSource { return new StaticFeatureSource(geojson) } }