UNPKG

2.51 kBJavaScriptView Raw
1import moment from 'moment';
2import { config } from './config';
3import React from 'react';
4export function query(changesetID) {
5 var url = config.osmBase + 'changeset/' + changesetID;
6 var options = {
7 'Response-Type': 'document'
8 };
9 return fetch(url, options)
10 .then(r => r.text())
11 .then(r => {
12 const parser = new DOMParser();
13 let xml;
14 try {
15 xml = parser.parseFromString(r, 'text/xml');
16 } catch (e) {
17 throw e;
18 }
19 var csFeature = xml.getElementsByTagName('changeset')[0];
20 var cs = csFeature.attributes;
21 var uid = cs.uid.textContent;
22 var user = cs.user.textContent;
23 var from = moment(cs.created_at.textContent, 'YYYY-MM-DDTHH:mm:ss\\Z')
24 .subtract(1, 'seconds')
25 .format('YYYY-MM-DDTHH:mm:ss\\Z');
26 var to = cs.closed_at ? cs.closed_at.textContent : null;
27 var left = cs.min_lon ? cs.min_lon.textContent : -180;
28 var bottom = cs.min_lat ? cs.min_lat.textContent : -90;
29 var right = cs.max_lon ? cs.max_lon.textContent : 180;
30 var top = cs.max_lat ? cs.max_lat.textContent : 90;
31 return {
32 id: changesetID,
33 uid: uid,
34 user: user,
35 from: from,
36 to: to,
37 bbox: {
38 left: left,
39 bottom: bottom,
40 right: right,
41 top: top
42 }
43 };
44 });
45}
46
47var x = (
48 <section className="cmap-filter-type-section">
49 <h6 className="cmap-heading">Filter by type</h6>
50 <ul className="cmap-hlist">
51 <li>
52 <label className="cmap-hlist-item cmap-noselect cmap-pointer">
53 <className
54 type="checkbox"
55 value="nodes"
56 checked="true"
57 id="cmap-type-selector-nodes"
58 />
59 <span className="cmap-label-text">Nodes</span>
60 </label>
61 </li>
62 <li>
63 <label className="cmap-hlist-item cmap-noselect cmap-pointer">
64 <className
65 type="checkbox"
66 value="ways"
67 checked="true"
68 id="cmap-type-selector-ways"
69 />
70 <span className="cmap-label-text">Ways</span>
71 </label>
72 </li>
73 <li>
74 <label className="cmap-hlist-item cmap-noselect cmap-pointer">
75 <className
76 type="checkbox"
77 value="relations"
78 checked="true"
79 id="cmap-type-selector-relations"
80 />
81 <span className="cmap-label-text">Relations</span>
82 </label>
83 </li>
84 </ul>
85 </section>
86);