-
create( [id] [, options])
-
Creates a new way.
Can be used in an instance or in a static context.
Parameters:
- Source:
-
Returns:
the created way
-
Type
-
Way
Example
import {WayBuilder, NodeBuilder} from 'josm/builder'
// create a new local way
const w1 = WayBuilder.create()
// create a new global way
const w2 = WayBuilder.create(1111)
// create a new global way with version 3 with some nodes and with
// some tags
const w3 = WayBuilder.create(2222, {
version: 3,
tags: {higway: 'primary'},
nodes: [
NodeBuilder.withPosition(1,1).create(),
NodeBuilder.withPosition(2,2).create(),
NodeBuilder.withPosition(3,3).create()
]
})
-
createProxy(id)
-
Creates a new proxy way. A proxy way is a way for which we
only know its global id. In order to know more details (nodes, tags, etc.),
we would have to download it from the OSM server.
The method can be used in a static and in an instance context.
Parameters:
Name |
Type |
Description |
id |
number
|
the id. A number > 0 |
- Source:
-
Returns:
the new proxy way
-
Type
-
Way
Example
import {WayBuilder} from 'josm/builder'
// a new proxy way for the global way with id 1111
const w1 = WayBuilder.createProxy(1111)
-
forDataSet(ds)
-
Creates or configures a WayBuilder which will add created nodes
to the dataset ds
.
Parameters:
Name |
Type |
Description |
ds |
DataSet
|
the dataset to which
created objects are added |
- Source:
-
Returns:
the way builder
-
Type
-
module:josm/builder/way~WayBuilder
Example
import {DataSet, WayBuilder} from 'josm/builder'
// create a new way builder which builds to a data set
const ds = new DataSet()
let wb = WayBuilder.forDataSet(ds)
-
withId(id [, version])
-
Declares the global way id and the global way version.
The method can be used in a static and in an instance context.
Parameters:
Name |
Type |
Argument |
Description |
id |
number
|
|
(mandatory) the global way id. A number > 0. |
version |
number
|
<optional>
|
the global way version. If present,
a number > 0. If missing, the version 1 is assumed. |
- Source:
-
Returns:
the way builder (for method chaining)
-
Type
-
module:josm/builder/way~WayBuilder
Example
import {WayBuilder} from 'josm/builder'
// creates a global way with id 1111 an version 22
const way = WayBuilder.withId(1111, 22).create()
-
withNodes( [nodes])
-
Declares the nodes of the way.
Accepts either a vararg list of
Node,
an array of
Nodes or a Java list
of
Nodes. At least
two
non-identical nodes have to be supplied.
The same node can occure more than once in the list, but a consecutive
sequence of the same node is collapsed to one node.
The method can be used in a static and in an instance context.
Parameters:
Name |
Type |
Argument |
Description |
nodes |
Node
|
List
|
Node[]
|
<optional>
|
the list of nodes.
See description and examples. |
- Source:
-
Returns:
the way builder (for method chaining)
-
Type
-
module:josm/builder/way~WayBuilder
Example
import {WayBuilder, NodeBuilder} from 'josm/builder'
// creates a new local way with two local nodes
const way = WayBuilder.withNodes(
NodeBuilder.create(),
NodeBuilder.create()
).create()
-
-
Declares the tags to be assigned to the new way.
The method can be used in a static and in an instance context.
Parameters:
Name |
Type |
Argument |
Description |
tags |
object
|
<optional>
|
the tags |
- Source:
-
Returns:
the way builder (for method chaining)
-
Type
-
module:josm/builder/way~WayBuilder
Example
import {WayBuilder} from 'josm/builder'
// a new global way with the global id 1111 and tags name='Laubeggstrasse'
// and highway=residential
const w1 = WayBuilder.withTags({name:'Laubeggstrasse', highway:'residential'})
.create(1111)
// a new local way with tags name=test and highway=road
const tags = {
name : 'Laubeggstrasse',
highway : 'residential'
}
const w2 = WayBuilder.withTags(tags).create()