diff --git a/Logic/Actors/GeoLocationHandler.ts b/Logic/Actors/GeoLocationHandler.ts index f000095d8..c7ca5ae56 100644 --- a/Logic/Actors/GeoLocationHandler.ts +++ b/Logic/Actors/GeoLocationHandler.ts @@ -8,7 +8,7 @@ import {BBox} from "../BBox"; import Constants from "../../Models/Constants"; import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource"; -export interface GeoLocationPointProperties { +export interface GeoLocationPointProperties { id: "gps", "user:location": "yes", "date": string, diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index ce1c28198..92c3c9999 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -24,6 +24,7 @@ import FullNodeDatabaseSource from "./TiledFeatureSource/FullNodeDatabaseSource" import MapState from "../State/MapState"; import {ElementStorage} from "../ElementStorage"; import {Feature, Geometry} from "@turf/turf"; +import {OsmFeature} from "../../Models/OsmFeature"; /** @@ -338,15 +339,19 @@ export default class FeaturePipeline { } - public GetAllFeaturesWithin(bbox: BBox): Feature[][] { + public GetAllFeaturesWithin(bbox: BBox): OsmFeature[][] { const self = this - const tiles = [] + const tiles: OsmFeature[][] = [] Array.from(this.perLayerHierarchy.keys()) - .forEach(key => tiles.push(...self.GetFeaturesWithin(key, bbox))) + .forEach(key => { + const fetched : OsmFeature[][] = self.GetFeaturesWithin(key, bbox) + tiles.push(...fetched); + }) return tiles; } - public GetAllFeaturesAndMetaWithin(bbox: BBox, layerIdWhitelist?: Set): {features: any[], layer: string}[] { + public GetAllFeaturesAndMetaWithin(bbox: BBox, layerIdWhitelist?: Set): + {features: OsmFeature[], layer: string}[] { const self = this const tiles :{features: any[], layer: string}[]= [] Array.from(this.perLayerHierarchy.keys()) @@ -362,7 +367,11 @@ export default class FeaturePipeline { return tiles; } - public GetFeaturesWithin(layerId: string, bbox: BBox): any[][] { + /** + * Gets all the tiles which overlap with the given BBOX. + * This might imply that extra features might be shown + */ + public GetFeaturesWithin(layerId: string, bbox: BBox): OsmFeature[][] { if (layerId === "*") { return this.GetAllFeaturesWithin(bbox) } diff --git a/Logic/FeatureSource/FeatureSource.ts b/Logic/FeatureSource/FeatureSource.ts index a686377fc..f28d2cde9 100644 --- a/Logic/FeatureSource/FeatureSource.ts +++ b/Logic/FeatureSource/FeatureSource.ts @@ -1,9 +1,11 @@ import {Store, UIEventSource} from "../UIEventSource"; import FilteredLayer from "../../Models/FilteredLayer"; import {BBox} from "../BBox"; +import {Feature, Geometry} from "@turf/turf"; +import {OsmFeature} from "../../Models/OsmFeature"; export default interface FeatureSource { - features: Store<{ feature: any, freshness: Date }[]>; + features: Store<{ feature: OsmFeature, freshness: Date }[]>; /** * Mainly used for debuging */ @@ -28,12 +30,3 @@ export interface FeatureSourceForLayer extends FeatureSource { export interface IndexedFeatureSource extends FeatureSource { readonly containedIds: Store> } - -/** - * A feature source which has some extra data about it's state - */ -export interface FeatureSourceState { - readonly sufficientlyZoomed: Store; - readonly runningQuery: Store; - readonly timeout: Store; -} diff --git a/Logic/FeatureSource/TiledFeatureSource/TileHierarchy.ts b/Logic/FeatureSource/TiledFeatureSource/TileHierarchy.ts index f2e43069d..cd6b3dda7 100644 --- a/Logic/FeatureSource/TiledFeatureSource/TileHierarchy.ts +++ b/Logic/FeatureSource/TiledFeatureSource/TileHierarchy.ts @@ -13,7 +13,7 @@ export default interface TileHierarchy { export class TileHierarchyTools { public static getTiles(hierarchy: TileHierarchy, bbox: BBox): T[] { - const result = [] + const result: T[] = [] hierarchy.loadedTiles.forEach((tile) => { if (tile.bbox.overlapsWith(bbox)) { result.push(tile) diff --git a/Logic/GeoOperations.ts b/Logic/GeoOperations.ts index 240312a9b..e758d5546 100644 --- a/Logic/GeoOperations.ts +++ b/Logic/GeoOperations.ts @@ -3,7 +3,7 @@ import {BBox} from "./BBox"; import togpx from "togpx" import Constants from "../Models/Constants"; import LayerConfig from "../Models/ThemeConfig/LayerConfig"; -import {booleanWithin, Coord, Feature, Geometry, MultiPolygon, Polygon, Properties} from "@turf/turf"; +import {AllGeoJSON, booleanWithin, Coord, Feature, Geometry, MultiPolygon, Polygon, Properties} from "@turf/turf"; export class GeoOperations { @@ -29,7 +29,7 @@ export class GeoOperations { * Returns [lon,lat] coordinates * @param feature */ - static centerpointCoordinates(feature: any): [number, number] { + static centerpointCoordinates(feature: AllGeoJSON): [number, number] { return <[number, number]>turf.center(feature).geometry.coordinates; } diff --git a/Logic/Osm/Changes.ts b/Logic/Osm/Changes.ts index 0b887bdf7..ff0cde50b 100644 --- a/Logic/Osm/Changes.ts +++ b/Logic/Osm/Changes.ts @@ -159,7 +159,7 @@ export class Changes { const recentLocationPoints = locations.map(ff => ff.feature) .filter(feat => feat.geometry.type === "Point") .filter(feat => { - const visitTime = new Date((feat.properties).date) + const visitTime = new Date((feat.properties).date) // In seconds const diff = (now.getTime() - visitTime.getTime()) / 1000 return diff < Constants.nearbyVisitTime; diff --git a/Models/OsmFeature.ts b/Models/OsmFeature.ts new file mode 100644 index 000000000..4753287ca --- /dev/null +++ b/Models/OsmFeature.ts @@ -0,0 +1,4 @@ +import {Feature, Geometry} from "@turf/turf"; + +export type OsmTags = Record & {id: string} +export type OsmFeature = Feature \ No newline at end of file