NodeBuilder helps to create OSM nodes
Name | Type | Argument | Description |
---|---|---|---|
ds |
DataSet |
<optional> |
the dataset which created objects are added to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import {NodeBuilder} from 'josm/builder'
const DataSet = Java.type('org.openstreetmap.josm.data.osm.DataSet')
const ds = new DataSet()
// create a node builder without and underlying dataset ...
let nbuilder = new NodeBuilder()
// ... with an underlying dataset ....
nbuilder = new NodeBuilder(ds)
// ... or using this factory method
nbuilder = NodeBuilder.forDataSet(ds)
// create a new local node at position (0,0) without tags
const n1 = NodeBuilder.create()
// create a new global node at a specific position with tags
const n2 = NodeBuilder.withPosition(1,1).withTags({name: 'test'}).create(1)
// create a new proxy for a global node
// (an 'incomplete' node in JOSM terminology)
const n3 = NodeBuilder.createProxy(2)
Creates a new Node
Name | Type | Argument | Description |
---|---|---|---|
id |
number |
<optional> |
a global node id. If missing and
not set before using withId(..) , creates a new local id. |
options |
module:josm/builder/node~NodeBuilder.NodeBuilderOptions |
<optional> |
additional options for creating the node |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import { NodeBuilder } from 'josm/builder'
// create a new local node at position [0,0]
const n1 = NodeBuilder.create()
// create a new global node with id 1111 at position [0,0]
const n2 = NodeBuilder.create(1111)
// create a new global node with version 3 at a specific position
// and with some tags
const n3 = NodeBuilder.create(2222, {
version: 3,
lat: 23.45,
lon: 87.23,
tags: {amenity: 'restaurant'}
})
Name | Type | Description |
---|---|---|
id |
number | the node id (not null, number > 0 expected) |
Creates a new NodeBuilder for a specific DataSet.
ds
.
Name | Type | Description |
---|---|---|
ds |
DataSet | the dataset which created objects are added to |
1 2 3 4 5 6 7 8 9 10
import { NodeBuilder } from 'josm/builder'
// create a new node builder building to a data set
const DataSet = Java.type('org.openstreetmap.josm.data.osm.DataSet')
const ds = new DataSet()
// ... using a static method ...
const nb1 = NodeBuilder.forDataSet(ds)
// ... or the instance method
const nb2 = new NodeBuilder.forDataSet(ds)
Name | Type | Argument | Default | Description |
---|---|---|---|---|
id |
number | the global node id. A number > 0. | ||
version |
number |
<optional> |
1 | optional the global node version. If present, a number > 0. |
Name | Type | Description |
---|---|---|
lat |
Number | the latitude. A number in the range [-90..90]. |
lon |
Number | the longitude. A number in the range [-180..180]. |
Name | Type | Argument | Description |
---|---|---|---|
tags |
object |
<optional> |
the tags |
1 2 3 4 5 6 7 8 9 10 11 12
import { NodeBuilder } from 'josm/builder'
// a new global node with the global id 1111 and tags name=test and
// highway=road
const n1 = NodeBuilder.withTags({'name':'test', 'highway':'road'}).create(1111)
// a new local node with tags name=test and highway=road
const tags = {
'name' : 'test',
'highway' : 'road'
}
const n2 = NodeBuilder.withTags(tags).create()
Name | Type | Argument | Default | Description |
---|---|---|---|---|
version |
number |
<optional> |
1 | the version (> 0) of the node. Default: 1. |
lat |
number |
<optional> |
0.0 | a valide latitude (number in the range [-90,90]. Default: 0.0 |
lon |
number |
<optional> |
0.0 | a valide longitude (number in the range[-180,180]. Default: 0.0 |
pos |
Array.<number> | Object |
<optional> |
null | a position, either an array with two numbers or as an object |
tags |
object |
<optional> |
an object with tags. Null values and undefined values are ignored. Any other value is converted to a string. Leading and trailing white space in keys is removed. |