forked from MapComplete/MapComplete
Fix typings
This commit is contained in:
parent
728f526b61
commit
28fc81c96f
4 changed files with 12 additions and 9 deletions
|
@ -84,8 +84,8 @@ export class NewGeometryFromChangesFeatureSource implements FeatureSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const tags: OsmTags = {
|
const tags: OsmTags & {id: OsmId & string} = {
|
||||||
id: <OsmId>(change.type + "/" + change.id),
|
id: <OsmId & string>(change.type + "/" + change.id),
|
||||||
}
|
}
|
||||||
for (const kv of change.tags) {
|
for (const kv of change.tags) {
|
||||||
tags[kv.k] = kv.v
|
tags[kv.k] = kv.v
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { Utils } from "../../../Utils"
|
||||||
import { OsmConnection } from "../OsmConnection"
|
import { OsmConnection } from "../OsmConnection"
|
||||||
import { Feature } from "@turf/turf"
|
import { Feature } from "@turf/turf"
|
||||||
import FeaturePipeline from "../../FeatureSource/FeaturePipeline"
|
import FeaturePipeline from "../../FeatureSource/FeaturePipeline"
|
||||||
|
import {Geometry, LineString, Point, Polygon} from "geojson";
|
||||||
|
|
||||||
export default class ReplaceGeometryAction extends OsmChangeAction {
|
export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +85,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||||
public async getPreview(): Promise<FeatureSource> {
|
public async getPreview(): Promise<FeatureSource> {
|
||||||
const { closestIds, allNodesById, detachedNodes, reprojectedNodes } =
|
const { closestIds, allNodesById, detachedNodes, reprojectedNodes } =
|
||||||
await this.GetClosestIds()
|
await this.GetClosestIds()
|
||||||
const preview: Feature[] = closestIds.map((newId, i) => {
|
const preview: Feature<Geometry> [] = closestIds.map((newId, i) => {
|
||||||
if (this.identicalTo[i] !== undefined) {
|
if (this.identicalTo[i] !== undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||||
|
|
||||||
reprojectedNodes.forEach(({ newLat, newLon, nodeId }) => {
|
reprojectedNodes.forEach(({ newLat, newLon, nodeId }) => {
|
||||||
const origNode = allNodesById.get(nodeId)
|
const origNode = allNodesById.get(nodeId)
|
||||||
const feature: Feature = {
|
const feature: Feature<LineString> = {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: {
|
properties: {
|
||||||
move: "yes",
|
move: "yes",
|
||||||
|
@ -143,7 +144,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||||
|
|
||||||
detachedNodes.forEach(({ reason }, id) => {
|
detachedNodes.forEach(({ reason }, id) => {
|
||||||
const origNode = allNodesById.get(id)
|
const origNode = allNodesById.get(id)
|
||||||
const feature: Feature = {
|
const feature: Feature<Point> = {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: {
|
properties: {
|
||||||
detach: "yes",
|
detach: "yes",
|
||||||
|
@ -389,7 +390,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||||
const node = allNodesById.get(id)
|
const node = allNodesById.get(id)
|
||||||
|
|
||||||
// Project the node onto the target way to calculate the new coordinates
|
// Project the node onto the target way to calculate the new coordinates
|
||||||
const way = {
|
const way = <Feature<LineString>> {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: {},
|
properties: {},
|
||||||
geometry: {
|
geometry: {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import BaseLayer from "../../Models/BaseLayer"
|
||||||
import Loading from "../Base/Loading"
|
import Loading from "../Base/Loading"
|
||||||
import Hash from "../../Logic/Web/Hash"
|
import Hash from "../../Logic/Web/Hash"
|
||||||
import { GlobalFilter } from "../../Logic/State/MapState"
|
import { GlobalFilter } from "../../Logic/State/MapState"
|
||||||
|
import {WayId} from "../../Models/OsmFeature";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The SimpleAddUI is a single panel, which can have multiple states:
|
* The SimpleAddUI is a single panel, which can have multiple states:
|
||||||
|
@ -123,13 +124,13 @@ export default class SimpleAddUI extends Toggle {
|
||||||
function confirm(
|
function confirm(
|
||||||
tags: any[],
|
tags: any[],
|
||||||
location: { lat: number; lon: number },
|
location: { lat: number; lon: number },
|
||||||
snapOntoWayId?: string
|
snapOntoWayId?: WayId
|
||||||
) {
|
) {
|
||||||
if (snapOntoWayId === undefined) {
|
if (snapOntoWayId === undefined) {
|
||||||
createNewPoint(tags, location, undefined)
|
createNewPoint(tags, location, undefined)
|
||||||
} else {
|
} else {
|
||||||
OsmObject.DownloadObject(snapOntoWayId).addCallbackAndRunD((way) => {
|
OsmObject.DownloadObject(snapOntoWayId).addCallbackAndRunD((way) => {
|
||||||
createNewPoint(tags, location, <OsmWay>way)
|
createNewPoint(tags, location, way)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Title from "../Base/Title"
|
||||||
import { GlobalFilter } from "../../Logic/State/MapState"
|
import { GlobalFilter } from "../../Logic/State/MapState"
|
||||||
import { VariableUiElement } from "../Base/VariableUIElement"
|
import { VariableUiElement } from "../Base/VariableUIElement"
|
||||||
import { Tag } from "../../Logic/Tags/Tag"
|
import { Tag } from "../../Logic/Tags/Tag"
|
||||||
|
import {WayId} from "../../Models/OsmFeature";
|
||||||
|
|
||||||
export default class ConfirmLocationOfPoint extends Combine {
|
export default class ConfirmLocationOfPoint extends Combine {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -35,7 +36,7 @@ export default class ConfirmLocationOfPoint extends Combine {
|
||||||
confirm: (
|
confirm: (
|
||||||
tags: any[],
|
tags: any[],
|
||||||
location: { lat: number; lon: number },
|
location: { lat: number; lon: number },
|
||||||
snapOntoWayId: string
|
snapOntoWayId: WayId | undefined
|
||||||
) => void,
|
) => void,
|
||||||
cancel: () => void,
|
cancel: () => void,
|
||||||
closePopup: () => void
|
closePopup: () => void
|
||||||
|
|
Loading…
Reference in a new issue