refactoring
This commit is contained in:
parent
b94a8f5745
commit
5d0fe31c41
114 changed files with 2412 additions and 2958 deletions
41
Logic/FeatureSource/Actors/GeoIndexedStore.ts
Normal file
41
Logic/FeatureSource/Actors/GeoIndexedStore.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import FeatureSource, { FeatureSourceForLayer } from "../FeatureSource"
|
||||
import { Feature } from "geojson"
|
||||
import { BBox } from "../../BBox"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
import { Store } from "../../UIEventSource"
|
||||
import FilteredLayer from "../../../Models/FilteredLayer"
|
||||
|
||||
/**
|
||||
* Allows the retrieval of all features in the requested BBox; useful for one-shot queries;
|
||||
*
|
||||
* Use a ClippedFeatureSource for a continuously updating featuresource
|
||||
*/
|
||||
export default class GeoIndexedStore implements FeatureSource {
|
||||
public features: Store<Feature[]>
|
||||
|
||||
constructor(features: FeatureSource | Store<Feature[]>) {
|
||||
this.features = features["features"] ?? features
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current features within the given bbox.
|
||||
*
|
||||
* @param bbox
|
||||
* @constructor
|
||||
*/
|
||||
public GetFeaturesWithin(bbox: BBox): Feature[] {
|
||||
// TODO optimize
|
||||
const bboxFeature = bbox.asGeoJson({})
|
||||
return this.features.data.filter(
|
||||
(f) => GeoOperations.intersect(f, bboxFeature) !== undefined
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export class GeoIndexedStoreForLayer extends GeoIndexedStore implements FeatureSourceForLayer {
|
||||
readonly layer: FilteredLayer
|
||||
constructor(features: FeatureSource | Store<Feature[]>, layer: FilteredLayer) {
|
||||
super(features)
|
||||
this.layer = layer
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue