Reformat all files with prettier

This commit is contained in:
Pieter Vander Vennet 2022-09-08 21:40:48 +02:00
parent e22d189376
commit b541d3eab4
382 changed files with 50893 additions and 35566 deletions

View file

@ -1,46 +1,56 @@
/// Given a feature source, calculates a list of OSM-contributors who mapped the latest versions
import {Store, UIEventSource} from "./UIEventSource";
import FeaturePipeline from "./FeatureSource/FeaturePipeline";
import Loc from "../Models/Loc";
import {BBox} from "./BBox";
import { Store, UIEventSource } from "./UIEventSource"
import FeaturePipeline from "./FeatureSource/FeaturePipeline"
import Loc from "../Models/Loc"
import { BBox } from "./BBox"
export default class ContributorCount {
public readonly Contributors: UIEventSource<Map<string, number>> = new UIEventSource<
Map<string, number>
>(new Map<string, number>())
private readonly state: {
featurePipeline: FeaturePipeline
currentBounds: Store<BBox>
locationControl: Store<Loc>
}
private lastUpdate: Date = undefined
public readonly Contributors: UIEventSource<Map<string, number>> = new UIEventSource<Map<string, number>>(new Map<string, number>());
private readonly state: { featurePipeline: FeaturePipeline, currentBounds: Store<BBox>, locationControl: Store<Loc> };
private lastUpdate: Date = undefined;
constructor(state: { featurePipeline: FeaturePipeline, currentBounds: Store<BBox>, locationControl: Store<Loc> }) {
this.state = state;
const self = this;
state.currentBounds.map(bbox => {
constructor(state: {
featurePipeline: FeaturePipeline
currentBounds: Store<BBox>
locationControl: Store<Loc>
}) {
this.state = state
const self = this
state.currentBounds.map((bbox) => {
self.update(bbox)
})
state.featurePipeline.runningQuery.addCallbackAndRun(
_ => self.update(state.currentBounds.data)
state.featurePipeline.runningQuery.addCallbackAndRun((_) =>
self.update(state.currentBounds.data)
)
}
private update(bbox: BBox) {
if (bbox === undefined) {
return;
return
}
const now = new Date();
if (this.lastUpdate !== undefined && ((now.getTime() - this.lastUpdate.getTime()) < 1000 * 60)) {
return;
const now = new Date()
if (
this.lastUpdate !== undefined &&
now.getTime() - this.lastUpdate.getTime() < 1000 * 60
) {
return
}
this.lastUpdate = now;
this.lastUpdate = now
const featuresList = this.state.featurePipeline.GetAllFeaturesWithin(bbox)
const hist = new Map<string, number>();
const hist = new Map<string, number>()
for (const list of featuresList) {
for (const feature of list) {
const contributor = feature.properties["_last_edit:contributor"]
const count = hist.get(contributor) ?? 0;
const count = hist.get(contributor) ?? 0
hist.set(contributor, count + 1)
}
}
this.Contributors.setData(hist)
}
}
}