-
Notifications
You must be signed in to change notification settings - Fork 112
/
index.html
202 lines (185 loc) · 6.38 KB
/
index.html
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!--
demo page / introduction for osmtogeojson
https://tyrasd.github.io/osmtogeojson
https://github.com/tyrasd/osmtogeojson
this page is based on https://github.com/aaronlidman/osm-and-geojson (c)Aaron Lidman, WTFPL
-->
<html>
<head>
<title>osmtogeojson</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="osmtogeojson.js"></script>
<script type="text/javascript">
function toGeo(e) {
e.preventDefault();
var data = document.getElementById('osmxml').value || "<osm></osm>",
geojson;
try {
data = $.parseXML(data);
} catch(e) {
data = JSON.parse(data);
}
geojson = osmtogeojson(data);
document.getElementById('geojson').value = JSON.stringify(geojson, null, 4);
console.log(geojson);
}
$(function() {
$("#toGeo").click(toGeo);
});
</script>
<style type="text/css">
body {
font-size: 18px;
background: white;
font-family: "Helvetica Neue", Helvetica, sans-serif;
width: 960px;
margin: 50px auto;
color: #222;
line-height: 1.7em
}
a { color: black; }
li {
line-height: 1.7em;
text-align: left;
list-style: none;
}
textarea, input { outline: none; }
#left {
width: 49%;
float: left;
text-align: center;
}
#osmxml, #geojson {
width: 100%;
background: white;
border: 1px solid #ccc;
height: 320px;
overflow: auto;
margin-bottom: 20px;
}
#right {
width: 49%;
float: right;
text-align: center;
}
.button {
display: inline-block;
text-shadow: 0px 0px 1px black;
border-radius: 3px;
color: white;
background: #A33;
padding: 10px 15px;
font-weight: bold;
text-decoration: none;
}
.button:hover {
background: #833;
}
.button:active {
box-shadow: inset 0 0 10px rgba(0,0,0,0.75);
}
textarea {
font-size: 13px;
line-height: 1.5em;
padding: 7px 10px;
}
#top {
font-size: 22px;
text-align: center;
margin-bottom: 25px;
}
#name {
font-size: 44px;
letter-spacing: -1px;
font-weight: bold;
margin-right: 5px;
}
#example {
clear: both;
width: 100%;
height: 500px;
text-align: center;
}
#about {
width: 720px;
margin: 0 auto;
}
#download {
margin: 50px auto 0 auto;
text-align: center;
}
#dl {
background: #569834;
padding: 7px 10px;
border-radius: 3px;
color: white;
font-weight: bold;
font-size: 32px;
}
.disc { list-style: disc; }
</style>
</head>
<body>
<a href="https://github.com/tyrasd/osmtogeojson"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<div id="top">
<span id="name">osmtogeojson</span> converts OSM data to GeoJSON.
</div>
<div id="example">
<div id="left">
<h3>OSM data</h3>
<textarea id="osmxml" contenteditable="true"></textarea>
</div>
<div id="right">
<h3>GeoJSON</h3>
<textarea id="geojson" contenteditable="true"></textarea>
</div>
<a class="button" href="" id="toGeo">convert to GeoJSON →</a>
</div>
<div id="about">
<p>osmtogeojson is a Javascript module for converting OSM data (OSM XML or Overpass JSON) to GeoJSON. It works in the browser, nodejs and can also be used as a command line tool. This OSM conversion code was written for and is maintained by the <a href="https://github.com/tyrasd/overpass-turbo">overpass-turbo</a> project.</p>
<span style="font-weight: bold;">Usage: </span>
<ul>
<li>In the browser:
<ul>
<li><code>
<script src='osmtogeojson.js'></script>
</code></li>
<li><code>
osmtogeojson(osm_data);
</code></li>
</ul>
</li>
<li>As a nodejs library:
<ul>
<li><code>
$ npm install osmtogeojson
</code></li>
<li><code>
var osmtogeojson = require('osmtogeojson');<br>
osmtogeojson(xml_data);
</code></li>
</ul>
</li>
<li>As a command line tool:
<ul>
<li><code>
$ npm install -g osmtogeojson
</code></li>
<li><code>
$ osmtogeojson file.osm > file.geojson
</code></li>
</ul>
</li>
</ul>
Read more about the API in the official <a href="https://github.com/tyrasd/osmtogeojson#usage">documentation</a>.
<div id="download">
<p><a class="button" href="https://github.com/tyrasd/osmtogeojson/raw/gh-pages/osmtogeojson.js">download osmtogeojson.js</a><br/><br/>
github: <a href="https://github.com/tyrasd/osmtogeojson">tyrasd/osmtogeojson</a><br/>
npm: <a href="https://npmjs.org/package/osmtogeojson">osmtogeojson</a><br/>
license: <a href="https://github.com/tyrasd/osmtogeojson/blob/gh-pages/LICENSE">MIT</a><br/>
</p>
</div>
</div>
</table>
</body>
</html>