forked from MapComplete/MapComplete
Refactoring: move download functionality for OsmObjects into a new object
This commit is contained in:
parent
8eb2c68f79
commit
1f9aacfb29
23 changed files with 633 additions and 901 deletions
|
@ -5,6 +5,7 @@ import OsmChangeAction from "./OsmChangeAction"
|
|||
import { ChangeDescription } from "./ChangeDescription"
|
||||
import RelationSplitHandler from "./RelationSplitHandler"
|
||||
import { Feature, LineString } from "geojson"
|
||||
import OsmObjectDownloader from "../OsmObjectDownloader"
|
||||
|
||||
interface SplitInfo {
|
||||
originalIndex?: number // or negative for new elements
|
||||
|
@ -61,7 +62,9 @@ export default class SplitAction extends OsmChangeAction {
|
|||
}
|
||||
|
||||
async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {
|
||||
const originalElement = <OsmWay>await OsmObject.DownloadObjectAsync(this.wayId)
|
||||
const originalElement = <OsmWay>(
|
||||
await new OsmObjectDownloader(changes.backend, changes).DownloadObjectAsync(this.wayId)
|
||||
)
|
||||
const originalNodes = originalElement.nodes
|
||||
|
||||
// First, calculate the splitpoints and remove points close to one another
|
||||
|
@ -172,7 +175,8 @@ export default class SplitAction extends OsmChangeAction {
|
|||
|
||||
// At last, we still have to check that we aren't part of a relation...
|
||||
// At least, the order of the ways is identical, so we can keep the same roles
|
||||
const relations = await OsmObject.DownloadReferencingRelations(this.wayId)
|
||||
const downloader = new OsmObjectDownloader(changes.backend, changes)
|
||||
const relations = await downloader.DownloadReferencingRelations(this.wayId)
|
||||
for (const relation of relations) {
|
||||
const changDescrs = await new RelationSplitHandler(
|
||||
{
|
||||
|
@ -182,7 +186,8 @@ export default class SplitAction extends OsmChangeAction {
|
|||
allWaysNodesInOrder: allWaysNodesInOrder,
|
||||
originalWayId: originalElement.id,
|
||||
},
|
||||
this._meta.theme
|
||||
this._meta.theme,
|
||||
downloader
|
||||
).CreateChangeDescriptions(changes)
|
||||
changeDescription.push(...changDescrs)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue