Fix contributor count

This commit is contained in:
Pieter Vander Vennet 2023-04-14 00:12:15 +02:00
parent 43601987dc
commit 466dd16568
2 changed files with 21 additions and 3 deletions

View file

@ -225,10 +225,17 @@ export class BBox {
]
}
public asGeoJson<T>(properties: T): Feature<Polygon, T> {
public asGeojsonCached() {
if (this["geojsonCache"] === undefined) {
this["geojsonCache"] = this.asGeoJson({})
}
return this["geojsonCache"]
}
public asGeoJson<T = {}>(properties?: T): Feature<Polygon, T> {
return {
type: "Feature",
properties,
properties: properties,
geometry: this.asGeometry(),
}
}

View file

@ -25,11 +25,22 @@ export default class GeoIndexedStore implements FeatureSource {
*/
public GetFeaturesWithin(bbox: BBox): Feature[] {
// TODO optimize
const bboxFeature = bbox.asGeoJson({})
const bboxFeature = bbox.asGeojsonCached()
return this.features.data.filter((f) => {
if (f.geometry.type === "Point") {
return bbox.contains(<[number, number]>f.geometry.coordinates)
}
if (f.geometry.type === "LineString") {
const intersection = GeoOperations.intersect(
BBox.get(f).asGeojsonCached(),
bboxFeature
)
return intersection !== undefined
}
if (f.geometry.type === "Polygon" || f.geometry.type === "MultiPolygon") {
return GeoOperations.intersect(f, bboxFeature) !== undefined
}
console.log("Calculating intersection between", bboxFeature, "and", f)
return GeoOperations.intersect(f, bboxFeature) !== undefined
})
}