-
Notifications
You must be signed in to change notification settings - Fork 25
/
compositor.json
143 lines (143 loc) · 21 KB
/
compositor.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
{
"name": "digidem/osm-p2p-db",
"version": "0.1.4",
"libraries": {
"xv": "^1.1.25"
},
"title": "",
"branch": "",
"style": {
"name": "Default",
"componentSet": {
"nav": "nav/BasicNav",
"header": "header/BannerHeader",
"article": "article/BasicArticle",
"footer": "footer/BasicFooter"
},
"fontFamily": "-apple-system, BlinkMacSystemFont, sans-serif",
"fontWeight": 400,
"bold": 600,
"lineHeight": 1.5,
"typeScale": [
72,
48,
24,
20,
16,
14,
12
],
"monospace": "Menlo, monospace",
"heading": {
"fontFamily": null,
"fontStyle": null,
"fontWeight": 600,
"lineHeight": 1.25,
"textTransform": null,
"letterSpacing": null
},
"h0": {},
"h1": {},
"h2": {},
"h3": {},
"h4": {},
"h5": {},
"h6": {},
"alternativeText": {},
"space": [
0,
8,
16,
32,
48,
64,
96
],
"layout": {
"maxWidth": 1024,
"centered": false
},
"colors": {
"text": "#111",
"background": "#fff",
"primary": "#08e",
"secondary": "#059",
"highlight": "#e08",
"border": "#ddd",
"muted": "#eee"
},
"border": {
"width": 1,
"radius": 2
},
"link": {},
"button": {
"hover": {
"boxShadow": "inset 0 0 0 999px rgba(0, 0, 0, .125)"
}
},
"input": {},
"body": {
"margin": 0
},
"breakpoints": {
"xs": "@media screen and (max-width:40em)",
"sm": "@media screen and (min-width:40em)",
"md": "@media screen and (min-width:52em)",
"lg": "@media screen and (min-width:64em)"
}
},
"content": [
{
"component": "nav",
"links": [
{
"href": "https://github.com/digidem/osm-p2p-db",
"text": "GitHub"
},
{
"href": "https://npmjs.com/package/osm-p2p-db",
"text": "npm"
}
]
},
{
"component": "header",
"heading": "osm-p2p-db",
"subhead": "Peer-to-peer database for OpenStreetMap data",
"children": [
{
"component": "ui/TweetButton",
"text": "osm-p2p-db: Peer-to-peer database for OpenStreetMap data",
"url": ""
},
{
"component": "ui/GithubButton",
"user": "digidem",
"repo": "osm-p2p-db"
}
],
"text": "v4.2.4"
},
{
"component": "article",
"metadata": {
"source": "github.readme"
},
"html": "\n<p><a href=\"https://travis-ci.org/digidem/osm-p2p-db\"><img src=\"https://img.shields.io/travis/digidem/osm-p2p-db.svg\"></a>\n<a href=\"http://standardjs.com/\"><img src=\"https://img.shields.io/badge/code%20style-standard-brightgreen.svg?maxAge=2592000\"></a>\n<a href=\"https://www.npmjs.com/package/osm-p2p-db\"><img src=\"https://img.shields.io/npm/v/osm-p2p-db.svg?maxAge=2592000\"></a></p>\n<blockquote>\n<p>p2p database for open street map data</p>\n</blockquote>\n<h2>Table of Contents</h2>\n<ul>\n<li><a href=\"#install\">Install</a></li>\n<li><a href=\"#usage\">Usage</a></li>\n<li><a href=\"#api\">API</a><ul>\n<li><a href=\"#var-osm--osmdbopts\">var osm = osmdb(opts)</a></li>\n<li><a href=\"#osmcreatedoc-opts-cb\">osm.create(doc, opts={}, cb)</a></li>\n<li><a href=\"#osmputid-doc-opts-cb\">osm.put(id, doc, opts={}, cb)</a></li>\n<li><a href=\"#osmdelid-opts-cb\">osm.del(id, opts={}, cb)</a></li>\n<li><a href=\"#osmbatchrows-opts-cb\">osm.batch(rows, opts={}, cb)</a></li>\n<li><a href=\"#osmgetid-opts-cb\">osm.get(id, opts={}, cb)</a></li>\n<li><a href=\"#osmqueryq-opts-cb\">osm.query(q, opts, cb)</a></li>\n<li><a href=\"#osmreadycb\">osm.ready(cb)</a></li>\n<li><a href=\"#osmclosecb\">osm.close(cb)</a></li>\n<li><a href=\"#var-rstream--osmquerystreamq-opts\">var rstream = osm.queryStream(q, opts)</a></li>\n<li><a href=\"#var-rstream--osmgetchangesid-cb\">var rstream = osm.getChanges(changeset, cb)</a></li>\n<li><a href=\"#osmonerror-function-err-\">osm.on('error', function (err) {})</a></li>\n<li><a href=\"#osmkv\">osm.kv</a></li>\n<li><a href=\"#osmlog\">osm.log</a></li>\n</ul>\n</li>\n<li><a href=\"#browser\">Browser</a></li>\n<li><a href=\"#replication\">Replication</a></li>\n<li><a href=\"#architecture\">Architecture</a></li>\n<li><a href=\"#contribute\">Contribute</a></li>\n<li><a href=\"#license\">License</a></li>\n</ul>\n<h2>Install</h2>\n<pre>npm <span class=\"hljs-keyword\">install</span> osm-p2p-db</pre><h2>Usage</h2>\n<pre><span class=\"hljs-keyword\">var</span> hyperlog = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'hyperlog'</span>)\n\n<span class=\"hljs-keyword\">var</span> level = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'level'</span>)\n<span class=\"hljs-keyword\">var</span> db = {\n <span class=\"hljs-attr\">log</span>: level(<span class=\"hljs-string\">'/tmp/osm-p2p/log'</span>),\n <span class=\"hljs-attr\">index</span>: level(<span class=\"hljs-string\">'/tmp/osm-p2p/index'</span>)\n}\n<span class=\"hljs-keyword\">var</span> fdstore = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'fd-chunk-store'</span>)\n<span class=\"hljs-keyword\">var</span> storefile = <span class=\"hljs-string\">'/tmp/osm-p2p/kdb'</span>\n\n<span class=\"hljs-keyword\">var</span> osmdb = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'osm-p2p-db'</span>)\n<span class=\"hljs-keyword\">var</span> osm = osmdb({\n <span class=\"hljs-attr\">log</span>: hyperlog(db.log, { <span class=\"hljs-attr\">valueEncoding</span>: <span class=\"hljs-string\">'json'</span> }),\n <span class=\"hljs-attr\">db</span>: db.index,\n <span class=\"hljs-attr\">store</span>: fdstore(<span class=\"hljs-number\">4096</span>, storefile)\n})\n\n<span class=\"hljs-keyword\">if</span> (process.argv[<span class=\"hljs-number\">2</span>] === <span class=\"hljs-string\">'create'</span>) {\n <span class=\"hljs-keyword\">var</span> value = <span class=\"hljs-built_in\">JSON</span>.parse(process.argv[<span class=\"hljs-number\">3</span>])\n osm.create(value, <span class=\"hljs-function\"><span class=\"hljs-keyword\">function</span> (<span class=\"hljs-params\">err, key, node</span>) </span>{\n <span class=\"hljs-keyword\">if</span> (err) <span class=\"hljs-built_in\">console</span>.error(err)\n <span class=\"hljs-keyword\">else</span> <span class=\"hljs-built_in\">console</span>.log(key)\n })\n} <span class=\"hljs-keyword\">else</span> <span class=\"hljs-keyword\">if</span> (process.argv[<span class=\"hljs-number\">2</span>] === <span class=\"hljs-string\">'query'</span>) {\n <span class=\"hljs-keyword\">var</span> q = process.argv.slice(<span class=\"hljs-number\">3</span>).map(csplit)\n osm.query(q, <span class=\"hljs-function\"><span class=\"hljs-keyword\">function</span> (<span class=\"hljs-params\">err, pts</span>) </span>{\n <span class=\"hljs-keyword\">if</span> (err) <span class=\"hljs-built_in\">console</span>.error(err)\n <span class=\"hljs-keyword\">else</span> pts.forEach(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function</span> (<span class=\"hljs-params\">pt</span>) </span>{\n <span class=\"hljs-built_in\">console</span>.log(pt)\n })\n })\n}\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function</span> <span class=\"hljs-title\">csplit</span> (<span class=\"hljs-params\">x</span>) </span>{ <span class=\"hljs-keyword\">return</span> x.split(<span class=\"hljs-string\">','</span>).map(<span class=\"hljs-built_in\">Number</span>) }</pre><p>Now we can create a few nodes and search with a bounding box query:</p>\n<pre>$ mkdir /tmp/osm-p2p\n$ <span class=\"hljs-keyword\">node</span> <span class=\"hljs-title\">db</span>.js create '{<span class=\"hljs-string\">"type"</span>:<span class=\"hljs-string\">"node"</span>,<span class=\"hljs-string\">"lat"</span>:<span class=\"hljs-number\">64.6</span>,<span class=\"hljs-string\">"lon"</span>:-<span class=\"hljs-number\">147.8</span>}'\n<span class=\"hljs-number\">11892499690884077339</span>\n$ <span class=\"hljs-keyword\">node</span> <span class=\"hljs-title\">db</span>.js create '{<span class=\"hljs-string\">"type"</span>:<span class=\"hljs-string\">"node"</span>,<span class=\"hljs-string\">"lat"</span>:<span class=\"hljs-number\">64.3</span>,<span class=\"hljs-string\">"lon"</span>:-<span class=\"hljs-number\">148.2</span>}'\n<span class=\"hljs-number\">1982521011513780909</span>\n$ <span class=\"hljs-keyword\">node</span> <span class=\"hljs-title\">db</span>.js create '{<span class=\"hljs-string\">"type"</span>:<span class=\"hljs-string\">"node"</span>,<span class=\"hljs-string\">"lat"</span>:<span class=\"hljs-number\">64.5</span>,<span class=\"hljs-string\">"lon"</span>:-<span class=\"hljs-number\">147.3</span>}'\n<span class=\"hljs-number\">14062704270722785878</span>\n$ <span class=\"hljs-keyword\">node</span> <span class=\"hljs-title\">db</span>.js query <span class=\"hljs-number\">64.1</span>,<span class=\"hljs-number\">64.6</span> -<span class=\"hljs-number\">148</span>,-<span class=\"hljs-number\">147</span>\n{ <span class=\"hljs-keyword\">type</span>: '<span class=\"hljs-keyword\">node</span><span class=\"hljs-title\">',\n lat</span>: <span class=\"hljs-number\">64.5</span>,\n lon: -<span class=\"hljs-number\">147.3</span>,\n id: '<span class=\"hljs-number\">14062704270722785878</span>',\n <span class=\"hljs-keyword\">version</span>: 'e635d07b9fc0a9d048cdd5d9e97a44a19ba3a0b2a51830d1e3e0fadcb80935fc' }</pre><p>We can make a <code>way</code> document that refers to a list of <code>node</code> documents:</p>\n<pre>$ <span class=\"hljs-keyword\">node</span> <span class=\"hljs-title\">db</span>.js create '{<span class=\"hljs-string\">"type"</span>:<span class=\"hljs-string\">"way"</span>,<span class=\"hljs-string\">"refs"</span>:\n[<span class=\"hljs-string\">"11892499690884077339"</span>,<span class=\"hljs-string\">"1982521011513780909"</span>,<span class=\"hljs-string\">"14062704270722785878"</span>]}'\n<span class=\"hljs-number\">14666931246975765366</span></pre><p>When we query, any <code>ways</code> that have one or more nodes within the bounding box\nwill turn up in the results:</p>\n<pre>$ node db.js query <span class=\"hljs-number\">64.1</span>,<span class=\"hljs-number\">64.6</span> -<span class=\"hljs-number\">148</span>,-<span class=\"hljs-number\">147</span>\n{ <span class=\"hljs-built_in\">type</span>: <span class=\"hljs-string\">'node'</span>,\n <span class=\"hljs-keyword\">la</span><span class=\"hljs-variable\">t:</span> <span class=\"hljs-number\">64.5</span>,\n lon: -<span class=\"hljs-number\">147.3</span>,\n id: <span class=\"hljs-string\">'14062704270722785878'</span>,\n <span class=\"hljs-keyword\">version</span>: <span class=\"hljs-string\">'e635d07b9fc0a9d048cdd5d9e97a44a19ba3a0b2a51830d1e3e0fadcb80935fc'</span> }\n{ <span class=\"hljs-built_in\">type</span>: <span class=\"hljs-string\">'way'</span>,\n ref<span class=\"hljs-variable\">s:</span> [ <span class=\"hljs-string\">'11892499690884077339'</span>, <span class=\"hljs-string\">'1982521011513780909'</span>, <span class=\"hljs-string\">'14062704270722785878'</span> ],\n id: <span class=\"hljs-string\">'14666931246975765366'</span>,\n <span class=\"hljs-keyword\">version</span>: <span class=\"hljs-string\">'f4fc0045e298ca4f9373fab78dee4f0561b4056dcd7975eb92f21d0a05e0eede'</span> }</pre><h2>Terminology</h2>\n<ul>\n<li><em>document</em>: a map element, such a a <code>node</code> or <code>way</code>.</li>\n<li><em>document id</em>, <em>osm id</em>: an identifier of a document at its latest known\nversion.</li>\n<li><em>version</em>, <em>version id</em>: an identifier of a document <em>at a specific point in\ntime</em>.</li>\n</ul>\n<h2>API</h2>\n<pre><span class=\"hljs-keyword\">var</span> osmdb = <span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">'osm-p2p-db'</span>)</pre><h3>var osm = osmdb(opts)</h3>\n<p>Create a new <code>osm</code> instance with:</p>\n<ul>\n<li><code>opts.log</code> - a <a href=\"https://npmjs.com/package/hyperlog\">hyperlog</a> with a valueEncoding of <code>json</code></li>\n<li><code>opts.db</code> - a <a href=\"https://npmjs.com/package/levelup\">levelup</a> instance to store index data</li>\n<li><code>opts.store</code> - an <a href=\"https://npmjs.com/package/abstract-chunk-store\">abstract-chunk-store</a> instance</li>\n</ul>\n<p>You may optionally pass in a <a href=\"https://npmjs.com/package/hyperkv\">hyperkv</a> instance as <code>opts.kv</code>, but otherwise\none will be created from the <code>opts.log</code> and <code>opts.db</code>.</p>\n<p>You may safely delete the index database whenever you like. The index data is\nautomatically regenerated. This is very useful if there are breaking changes to\nthe index code or if the data becomes corrupted. The hyperlog contains the\nsource of truth.</p>\n<h3>osm.create(doc, opts={}, cb)</h3>\n<p>Store a new document from <code>doc</code>. <code>cb(err, id, node)</code> fires with the generated\nOSM <code>id</code> and the <code>node</code> from the underlying hyperlog.</p>\n<p>Elements are <code>node</code>, <code>way</code>, and <code>relation</code>. Each element should have a <code>type</code>\nproperty that contains the element type as a string.</p>\n<ul>\n<li>Nodes should have <code>doc.lat</code> and <code>doc.lon</code> coordinates.</li>\n<li>Ways should have an array of OSM keys as <code>doc.refs</code>.</li>\n<li>Relations should have an array member objects as <code>doc.members</code>.\nEach member object has a <code>member.type</code> of the document pointed at by\n<code>member.ref</code> and optionally a <a href=\"http://wiki.openstreetmap.org/wiki/Relation#Roles\"><code>member.role</code></a>.</li>\n</ul>\n<p>Another type of document is a <code>changeset</code>.\nEach element should have a <code>changeset</code> property that refers to the id of a\n<code>changeset</code> document.</p>\n<p>It is recommended to use <code>tags.comment</code> to store free-form text describing the\nchangeset.</p>\n<h3>osm.put(id, doc, opts={}, cb)</h3>\n<p>Replace a document at <code>id</code> with <code>doc</code>.</p>\n<p>If the document didn't exist previously, it will be created.</p>\n<p>The options <code>opts</code> are passed to the underlying <a href=\"https://npmjs.com/package/hyperkv\">hyperkv</a> instance.</p>\n<p>By default, hyperkv will merge the most recent known forks into a single fork.\nTo add modifications to a fork without merging the changes into other forks,\nset <code>opts.links</code> to an array of only the single key you want to update.</p>\n<h3>osm.del(id, opts={}, cb)</h3>\n<p>Delete a document at <code>id</code>.</p>\n<p>The options <code>opts</code> are passed to the underlying <a href=\"https://npmjs.com/package/hyperkv\">hyperkv</a> instance.</p>\n<p><code>cb(err, node)</code> fires with the underlying <code>node</code> in the hyperlog.</p>\n<h3>osm.batch(rows, opts={}, cb)</h3>\n<p>Atomically insert an array of documents <code>rows</code>.</p>\n<p>Each <code>row</code> in <code>rows</code> should have:</p>\n<ul>\n<li><code>row.type</code> - <code>'put'</code> or <code>'del'</code></li>\n<li><code>row.key</code> or <code>row.id</code> - the id of the document (generated if not specified)</li>\n<li><code>row.links</code> - array of links to ancestor keys</li>\n<li><code>row.value</code> - for puts, the value to store</li>\n</ul>\n<h3>osm.get(id, opts={}, cb)</h3>\n<p>Get a document as <code>cb(err, docs)</code> by its OSM <code>id</code>.</p>\n<p><code>docs</code> is an object mapping hyperlog hashes to current document values. If a\ndocument has been deleted, it will only have the properties <code>{ id: <osm-id>,\nversion: <osm-version>, deleted: true}</code>.</p>\n<h3>osm.query(q, opts, cb)</h3>\n<p>Query for all nodes, ways, and relations in the query given by the array <code>q</code>.\nQueries are arrays of <code>[[minLat,maxLat],[minLon,maxLon]]</code> specifying a bounding\nbox.</p>\n<p><code>cb(err, res)</code> fires with an array of results <code>res</code>. Each result is the document\naugmented with an <code>id</code> property and a <code>version</code> property that is the hash key\nfrom the underlying hyperlog. If a document has been deleted, it will only have\nthe properties <code>{ id: <osm-id>, version: <osm-version>, deleted: true}</code>.</p>\n<p>Optionally:</p>\n<ul>\n<li><code>opts.order</code> - set to <code>'type'</code> to order by type: node, way, relation</li>\n</ul>\n<h3>osm.ready(cb)</h3>\n<p>Runs the callback <code>cb</code> once all of <code>osm</code>'s internal indexes are caught up to the latest data. <code>cb</code> is called exactly once.</p>\n<h3>osm.close(cb)</h3>\n<p>Closes the Level and chunk-store backends associated with the database. <code>cb</code> is\ncalled upon completion.</p>\n<h3>var rstream = osm.queryStream(q, opts)</h3>\n<p>Return a readable object stream <code>rstream</code> of query results contained in the\nquery <code>q</code>. Queries are arrays of <code>[[minLat,maxLat],[minLon,maxLon]]</code> specifying\na bounding box.</p>\n<p>Each object in the stream is a document augmented with an <code>id</code> property and a\n<code>version</code> property that is the hash key from the underlying hyperlog.</p>\n<p>Optionally:</p>\n<ul>\n<li><code>opts.order</code> - set to <code>'type'</code> to order by type: node, way, relation</li>\n</ul>\n<h3>var rstream = osm.getChanges(changeset, [cb])</h3>\n<p>Get the list of document version ids in a changeset by a changeset id\n<code>changeset</code>.</p>\n<p>If a callback is provided, the version ids are returned as <code>cb(err, versions)</code>.\nWithout callback, the versions are provided by the returned readable object\nstream <code>rstream</code>.</p>\n<h3>osm.on('error', function (err) {})</h3>\n<p>Handle errors from the underlying indexes with the <code>'error'</code> event.</p>\n<h3>osm.kv</h3>\n<p>You can get at the <a href=\"https://npmjs.com/package/hyperkv\">hyperkv</a> instance directly to perform more operations\nusing <code>osm.kv</code>.</p>\n<p>For example, you can use <code>osm.kv.createReadStream()</code> to list all the id/value\npairs in the database.</p>\n<h3>osm.log</h3>\n<p>The <a href=\"https://npmjs.com/package/hyperlog\">hyperlog</a> instance is available as the <code>opts.log</code> property if you need\nto get at it directly later.</p>\n<h2>Browser</h2>\n<p>To use this module in the browser, use <a href=\"https://npmjs.com/package/level-browserify\">level-browserify</a> to provide the\n<code>opts.db</code> instance and <a href=\"https://www.npmjs.com/package/idb-chunk-store\">idb-chunk-store</a> as the <code>opts.store</code>. Each of these\nis backed by IndexedDB, a native browser storage interface.</p>\n<h2>Replication</h2>\n<p>If you have two hyperlogs <code>log0</code> and <code>log1</code>, pipe them together and back again\nto replicate:</p>\n<pre>var r<span class=\"hljs-number\">0</span> = lo<span class=\"hljs-name\">g0.</span>replicate<span class=\"hljs-comment\">()</span>\nvar r<span class=\"hljs-number\">1</span> = lo<span class=\"hljs-name\">g1.</span>replicate<span class=\"hljs-comment\">()</span>\nr<span class=\"hljs-number\">0.</span>pipe<span class=\"hljs-comment\">(r1)</span>.pipe<span class=\"hljs-comment\">(r0)</span></pre><p>Insert additional streams as necessary for network transports if the logs live\nin different processes or machines.</p>\n<p>If both logs have made edits to the same IDs, multiple records will appear for\nthe same ID in the results. To merge these "conflicts" back into a single value,\nuse <code>osm.put(id, doc, cb)</code> to store the desired document value.</p>\n<h2>Architecture</h2>\n<p><a href=\"doc/architecture.markdown\">Read about the internal architecture</a>.</p>\n<h2>Contribute</h2>\n<p>If you would like to support our work, or if you have ideas about how to use and\nadapt osm-p2p for your own project, then please dive in. Open <a href=\"https://github.com/digidem/osm-p2p-db/issues\">an\nissue</a> with a bug report or\nfeature request, or send us a <a href=\"https://github.com/digidem/osm-p2p-db/pulls\">pull\nrequest</a> with a bug-fix or new\nfeature.</p>\n<p>We need help right now adding tests and fixing edge-cases with\n<a href=\"https://github.com/digidem/osm-p2p-server\">osm-p2p-server</a> and increasing\ncompatibility with other OSM tools such as\n<a href=\"https://josm.openstreetmap.de/\">JOSM</a>.</p>\n<h2>License</h2>\n<p>BSD (c) 2016, Digital Democracy.</p>\n"
},
{
"component": "footer",
"links": [
{
"href": "https://github.com/digidem/osm-p2p-db",
"text": "GitHub"
},
{
"href": "https://github.com/digidem",
"text": "digidem"
}
]
}
]
}