UNPKG

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