forked from MapComplete/MapComplete
refactoring
This commit is contained in:
parent
b94a8f5745
commit
5d0fe31c41
114 changed files with 2412 additions and 2958 deletions
|
@ -2,12 +2,12 @@ import { OsmCreateAction } from "./OsmChangeAction"
|
|||
import { Tag } from "../../Tags/Tag"
|
||||
import { Changes } from "../Changes"
|
||||
import { ChangeDescription } from "./ChangeDescription"
|
||||
import FeaturePipelineState from "../../State/FeaturePipelineState"
|
||||
import FeatureSource from "../../FeatureSource/FeatureSource"
|
||||
import CreateNewWayAction from "./CreateNewWayAction"
|
||||
import CreateWayWithPointReuseAction, { MergePointConfig } from "./CreateWayWithPointReuseAction"
|
||||
import { And } from "../../Tags/And"
|
||||
import { TagUtils } from "../../Tags/TagUtils"
|
||||
import { SpecialVisualizationState } from "../../../UI/SpecialVisualization"
|
||||
import FeatureSource from "../../FeatureSource/FeatureSource"
|
||||
|
||||
/**
|
||||
* More or less the same as 'CreateNewWay', except that it'll try to reuse already existing points
|
||||
|
@ -26,14 +26,14 @@ export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAct
|
|||
tags: Tag[],
|
||||
outerRingCoordinates: [number, number][],
|
||||
innerRingsCoordinates: [number, number][][],
|
||||
state: FeaturePipelineState,
|
||||
state: SpecialVisualizationState,
|
||||
config: MergePointConfig[],
|
||||
changeType: "import" | "create" | string
|
||||
) {
|
||||
super(null, true)
|
||||
this._tags = [...tags, new Tag("type", "multipolygon")]
|
||||
this.changeType = changeType
|
||||
this.theme = state?.layoutToUse?.id ?? ""
|
||||
this.theme = state?.layout?.id ?? ""
|
||||
this.createOuterWay = new CreateWayWithPointReuseAction(
|
||||
[],
|
||||
outerRingCoordinates,
|
||||
|
@ -45,7 +45,7 @@ export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAct
|
|||
new CreateNewWayAction(
|
||||
[],
|
||||
ringCoordinates.map(([lon, lat]) => ({ lat, lon })),
|
||||
{ theme: state?.layoutToUse?.id }
|
||||
{ theme: state?.layout?.id }
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -59,6 +59,10 @@ export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAct
|
|||
}
|
||||
}
|
||||
|
||||
public async getPreview(): Promise<FeatureSource> {
|
||||
return undefined
|
||||
}
|
||||
|
||||
protected async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {
|
||||
console.log("Running CMPWPRA")
|
||||
const descriptions: ChangeDescription[] = []
|
||||
|
|
|
@ -2,7 +2,6 @@ import { OsmCreateAction } from "./OsmChangeAction"
|
|||
import { Tag } from "../../Tags/Tag"
|
||||
import { Changes } from "../Changes"
|
||||
import { ChangeDescription } from "./ChangeDescription"
|
||||
import FeaturePipelineState from "../../State/FeaturePipelineState"
|
||||
import { BBox } from "../../BBox"
|
||||
import { TagsFilter } from "../../Tags/TagsFilter"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
|
@ -10,6 +9,7 @@ import FeatureSource from "../../FeatureSource/FeatureSource"
|
|||
import StaticFeatureSource from "../../FeatureSource/Sources/StaticFeatureSource"
|
||||
import CreateNewNodeAction from "./CreateNewNodeAction"
|
||||
import CreateNewWayAction from "./CreateNewWayAction"
|
||||
import { SpecialVisualizationState } from "../../../UI/SpecialVisualization"
|
||||
|
||||
export interface MergePointConfig {
|
||||
withinRangeOfM: number
|
||||
|
@ -62,14 +62,14 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction {
|
|||
* lngLat-coordinates
|
||||
* @private
|
||||
*/
|
||||
private _coordinateInfo: CoordinateInfo[]
|
||||
private _state: FeaturePipelineState
|
||||
private _config: MergePointConfig[]
|
||||
private readonly _coordinateInfo: CoordinateInfo[]
|
||||
private readonly _state: SpecialVisualizationState
|
||||
private readonly _config: MergePointConfig[]
|
||||
|
||||
constructor(
|
||||
tags: Tag[],
|
||||
coordinates: [number, number][],
|
||||
state: FeaturePipelineState,
|
||||
state: SpecialVisualizationState,
|
||||
config: MergePointConfig[]
|
||||
) {
|
||||
super(null, true)
|
||||
|
@ -188,7 +188,7 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction {
|
|||
}
|
||||
|
||||
public async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {
|
||||
const theme = this._state?.layoutToUse?.id
|
||||
const theme = this._state?.layout?.id
|
||||
const allChanges: ChangeDescription[] = []
|
||||
const nodeIdsToUse: { lat: number; lon: number; nodeId?: number }[] = []
|
||||
for (let i = 0; i < this._coordinateInfo.length; i++) {
|
||||
|
@ -252,9 +252,7 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction {
|
|||
private CalculateClosebyNodes(coordinates: [number, number][]): CoordinateInfo[] {
|
||||
const bbox = new BBox(coordinates)
|
||||
const state = this._state
|
||||
const allNodes = [].concat(
|
||||
...(state?.featurePipeline?.GetFeaturesWithin("type_node", bbox.pad(1.2)) ?? [])
|
||||
)
|
||||
const allNodes =state.fullNodeDatabase?.getNodesWithin(bbox.pad(1.2))
|
||||
const maxDistance = Math.max(...this._config.map((c) => c.withinRangeOfM))
|
||||
|
||||
// Init coordianteinfo with undefined but the same length as coordinates
|
||||
|
|
|
@ -12,8 +12,8 @@ import { And } from "../../Tags/And"
|
|||
import { Utils } from "../../../Utils"
|
||||
import { OsmConnection } from "../OsmConnection"
|
||||
import { Feature } from "@turf/turf"
|
||||
import FeaturePipeline from "../../FeatureSource/FeaturePipeline"
|
||||
import { Geometry, LineString, Point, Polygon } from "geojson"
|
||||
import { Geometry, LineString, Point } from "geojson"
|
||||
import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
|
||||
|
||||
export default class ReplaceGeometryAction extends OsmChangeAction {
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
|||
private readonly feature: any
|
||||
private readonly state: {
|
||||
osmConnection: OsmConnection
|
||||
featurePipeline: FeaturePipeline
|
||||
fullNodeDatabase?: FullNodeDatabaseSource
|
||||
}
|
||||
private readonly wayToReplaceId: string
|
||||
private readonly theme: string
|
||||
|
@ -41,7 +41,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
|||
constructor(
|
||||
state: {
|
||||
osmConnection: OsmConnection
|
||||
featurePipeline: FeaturePipeline
|
||||
fullNodeDatabase?: FullNodeDatabaseSource
|
||||
},
|
||||
feature: any,
|
||||
wayToReplaceId: string,
|
||||
|
@ -195,7 +195,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
|||
}> {
|
||||
// TODO FIXME: if a new point has to be created, snap to already existing ways
|
||||
|
||||
const nodeDb = this.state.featurePipeline.fullNodeDatabase
|
||||
const nodeDb = this.state.fullNodeDatabase
|
||||
if (nodeDb === undefined) {
|
||||
throw "PANIC: replaceGeometryAction needs the FullNodeDatabase, which is undefined. This should be initialized by having the 'type_node'-layer enabled in your theme. (NB: the replacebutton has type_node as dependency)"
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
|||
}
|
||||
|
||||
protected async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {
|
||||
const nodeDb = this.state.featurePipeline.fullNodeDatabase
|
||||
const nodeDb = this.state.fullNodeDatabase
|
||||
if (nodeDb === undefined) {
|
||||
throw "PANIC: replaceGeometryAction needs the FullNodeDatabase, which is undefined. This should be initialized by having the 'type_node'-layer enabled in your theme. (NB: the replacebutton has type_node as dependency)"
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@ export interface GeoCodeResult {
|
|||
display_name: string
|
||||
lat: number
|
||||
lon: number
|
||||
/**
|
||||
* Format:
|
||||
* [lat, lat, lon, lon]
|
||||
*/
|
||||
boundingbox: number[]
|
||||
osm_type: "node" | "way" | "relation"
|
||||
osm_id: string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue