A collection of functions to create commands which can be applied, undone
and redone on
OsmDataLayers.
- Source:
-
Example
import {
buildAddCommand,
buildChangeCommand,
buildDeleteCommand
} from 'josm/command'
-
<static> buildAddCommand(obj)
-
Creates a command to add a collection of objects to a data layer.
Signatures
add(obj, obj, ...)
obj
are Nodes,
Ways, or
Relationss. Or javascript array
or Java collections thereof.
Parameters:
- Source:
-
Returns:
the command object
-
Type
-
module:josm/command.AddCommand
Example
import {buildAddCommand} from 'josm/command'
import layers from 'josm/layer'
import {NodeBuilder} from 'josm/builder'
const layer = layers.get('Data Layer 1')
// add two nodes
buildAddCommand(
NodeBuilder.create(),
NodeBuilder.create()
).applyTo(layer)
-
<static> buildChangeCommand(objs, change)
-
Creates a command to change a collection of objects in a data layer.
The mandatory last argument is an object with named parameters.
Parameters:
- Source:
-
Returns:
the change command object
-
Type
-
module:josm/command.ChangeCommand
Example
import {buildChangeCommand} from 'josm/command'
import layers from 'josm/layers'
const layer = layers.get("Data Layer 1")
// change the position of a node
buildChangeCommand(n1, {lat: 123.45, lon: 44.234}).applyTo(layer)
// change the tags of a collection of primitives
buildChangeCommand(n1, n3, w1, r1, {
tags: {'mycustomtag': 'value'}
}).applyTo(layer)
-
<static> buildDeleteCommand(obj)
-
Creates a command to delete a collection of objects in a data layer.
Parameters:
- Source:
-
Returns:
the command object
-
Type
-
module:josm/command.DeleteCommand
Example
import {buildDeleteCommand} from 'josm/command'
import layers from 'josm/layer'
import {NodeBuilder} from 'josm/builder'
const layer = layers.get('Data Layer 1')
// delete two nodes
buildDeleteCommand(NodeBuilder.create(),NodeBuilder.create()).applyTo(layer)
*
-
<static> combineSelectedWays()
Combines the currently selected ways.
-
Combines the currently selected ways in the active layer into one resulting
way.
Returns without effect if
- there is no active layer
- the active layer is not a data layer
- there are less than two selected ways in the active layer
Reuses the logic behind the JOSM standard menu entry Tools->Combine Ways.
If invoked from a script, this may trigger modal dialogs which are presented
to the user, in particular if the direction of the ways has to be reversed
because otherwise they could not be combined.
- Source:
-
Example
import {combineSelectedWays} from 'josm/command'
import layers from 'josm/layer'
const ds = layers.activeLayer.data
combineSelectedWays(ways)
-
<static> combineWays(ways, ways)
Combines two or more ways into one resulting way.
-
Combines two or more ways into one resulting way.
Reuses the logic behind the JOSM standard menu entry Tools->Combine Ways.
If invoked from a script, this may trigger modal dialogs which are presented
to the user, in particular if the direction of the ways has to be reversed
because otherwise they could not be combined.
Parameters:
Name |
Type |
Description |
ways |
|
the ways to be combined |
ways |
Way
|
array
|
the ways to be combined |
- Source:
-
Example
import {combineWays} from 'josm/command'
import layers from 'josm/layer'
const ds = layers.activeLayer.data
const ways = [ds.way(1), ds.way(2), ds.way(3)]
// pass in an array ...
combineWays(ways)
// ... or the individual ways ...
combineWays(ds.way(1), ds.way(2), ds.way(3))
// ... or any combination thereof.