Refactoring: move all code files into a src directory

This commit is contained in:
Pieter Vander Vennet 2023-07-09 13:09:05 +02:00
parent de99f56ca8
commit e75d2789d2
389 changed files with 0 additions and 12 deletions

View file

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