Fix typing and build

This commit is contained in:
Pieter Vander Vennet 2022-11-07 23:35:17 +01:00
parent 336ebc4ea9
commit 5f1a7892c1
6 changed files with 20 additions and 19 deletions

View file

@ -3,11 +3,11 @@
*/ */
import { UIEventSource } from "./UIEventSource" import { UIEventSource } from "./UIEventSource"
import { GeoJSONObject } from "@turf/turf" import { GeoJSONObject } from "@turf/turf"
import {Feature, Point} from "geojson"; import {Feature, Geometry, Point} from "geojson";
import {OsmTags} from "../Models/OsmFeature"; import {OsmTags} from "../Models/OsmFeature";
export class ElementStorage { export class ElementStorage {
public ContainingFeatures = new Map<string, Feature<Point, OsmTags >>() public ContainingFeatures = new Map<string, Feature<Geometry, OsmTags >>()
private _elements = new Map<string, UIEventSource<any>>() private _elements = new Map<string, UIEventSource<any>>()
constructor() {} constructor() {}

View file

@ -27,7 +27,7 @@ class MetatagUpdater {
const self = this const self = this
this.params = { this.params = {
getFeatureById(id) { getFeatureById(id) {
return state.allElements.ContainingFeatures.get(id) return <any> state.allElements.ContainingFeatures.get(id)
}, },
getFeaturesWithin(layerId, bbox) { getFeaturesWithin(layerId, bbox) {
// We keep track of the BBOX that this source needs // We keep track of the BBOX that this source needs

View file

@ -10,7 +10,7 @@ import {
MultiPolygon, MultiPolygon,
Polygon, Polygon,
} from "@turf/turf" } from "@turf/turf"
import { LineString, Point } from "geojson" import {GeoJSON, LineString, Point} from "geojson"
import togpx from "togpx" import togpx from "togpx"
import Constants from "../Models/Constants" import Constants from "../Models/Constants"
@ -37,8 +37,8 @@ export class GeoOperations {
* Returns [lon,lat] coordinates * Returns [lon,lat] coordinates
* @param feature * @param feature
*/ */
static centerpointCoordinates(feature: AllGeoJSON): [number, number] { static centerpointCoordinates(feature: AllGeoJSON | GeoJSON): [number, number] {
return <[number, number]>turf.center(feature).geometry.coordinates return <[number, number]>turf.center(<any> feature).geometry.coordinates
} }
/** /**

View file

@ -1,18 +1,17 @@
import { OsmNode, OsmObject, OsmRelation, OsmWay } from "./OsmObject" import {OsmNode, OsmObject, OsmRelation, OsmWay} from "./OsmObject"
import { UIEventSource } from "../UIEventSource" import {UIEventSource} from "../UIEventSource"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
import OsmChangeAction from "./Actions/OsmChangeAction" import OsmChangeAction from "./Actions/OsmChangeAction"
import { ChangeDescription, ChangeDescriptionTools } from "./Actions/ChangeDescription" import {ChangeDescription, ChangeDescriptionTools} from "./Actions/ChangeDescription"
import { Utils } from "../../Utils" import {Utils} from "../../Utils"
import { LocalStorageSource } from "../Web/LocalStorageSource" import {LocalStorageSource} from "../Web/LocalStorageSource"
import SimpleMetaTagger from "../SimpleMetaTagger" import SimpleMetaTagger from "../SimpleMetaTagger"
import CreateNewNodeAction from "./Actions/CreateNewNodeAction"
import FeatureSource from "../FeatureSource/FeatureSource" import FeatureSource from "../FeatureSource/FeatureSource"
import { ElementStorage } from "../ElementStorage" import {ElementStorage} from "../ElementStorage"
import { GeoLocationPointProperties } from "../Actors/GeoLocationHandler" import {GeoLocationPointProperties} from "../Actors/GeoLocationHandler"
import { GeoOperations } from "../GeoOperations" import {GeoOperations} from "../GeoOperations"
import { ChangesetHandler, ChangesetTag } from "./ChangesetHandler" import {ChangesetHandler, ChangesetTag} from "./ChangesetHandler"
import { OsmConnection } from "./OsmConnection" import {OsmConnection} from "./OsmConnection"
/** /**
* Handles all changes made to OSM. * Handles all changes made to OSM.

View file

@ -22,6 +22,8 @@ import { TiledStaticFeatureSource } from "../FeatureSource/Sources/StaticFeature
import { Translation, TypedTranslation } from "../../UI/i18n/Translation" import { Translation, TypedTranslation } from "../../UI/i18n/Translation"
import { Tag } from "../Tags/Tag" import { Tag } from "../Tags/Tag"
import { OsmConnection } from "../Osm/OsmConnection" import { OsmConnection } from "../Osm/OsmConnection"
import {Feature, GeoJSON, LineString} from "geojson";
import {OsmTags} from "../../Models/OsmFeature";
export interface GlobalFilter { export interface GlobalFilter {
filter: FilterState filter: FilterState
@ -320,7 +322,7 @@ export default class MapState extends UserRelatedState {
return [] return []
} }
const feature = { const feature : Feature<LineString, OsmTags> = {
type: "Feature", type: "Feature",
properties: { properties: {
id: "location_track", id: "location_track",

View file

@ -121,7 +121,7 @@ export default class SplitRoadWizard extends Toggle {
} }
// Get nearest point on the road // Get nearest point on the road
const pointOnRoad = GeoOperations.nearestPoint(roadElement, coordinates) // pointOnRoad is a geojson const pointOnRoad = GeoOperations.nearestPoint(<any> roadElement, coordinates) // pointOnRoad is a geojson
// Update point properties to let it match the layer // Update point properties to let it match the layer
pointOnRoad.properties["_split_point"] = "yes" pointOnRoad.properties["_split_point"] = "yes"