forked from bertspaan/buildings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
246 lines (210 loc) · 9.84 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
---
---
<!DOCTYPE html>
<html>
<head>
<title>All buildings in the Netherlands, shaded by year of construction</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="{{ site.baseurl}}/style.css" />
<link rel="stylesheet" href="{{ site.baseurl}}/leaflet/leaflet.css" />
<script src="{{ site.baseurl}}/d3.v3.min.js"></script>
<script src="{{ site.baseurl}}/leaflet/leaflet.js"></script>
</head>
<body>
<div class="map" id="map"></div>
<span id="close" class="close"></span>
<div id="box">
<div>
<div id="info">
<h2>Info</h2>
<p>All 9,866,539 <a href="http://www.kadaster.nl/web/file?uuid=25da4675-fc9c-47a6-8039-1af04c142965&owner=23cbe925-35ce-4a72-ac8c-a33a0c19ae1e&contentid=2585">buildings</a> in the Netherlands, shaded according to year of construction. Data from <a href="http://www.kadaster.nl/bag">BAG</a> (January 2015), via <a href="http://citysdk.waag.org/">CitySDK LD API</a>. Map made with <a href="http://www.mapbox.com/tilemill/">TileMill</a> by <b><a href="https://twitter.com/bertspaan">Bert Spaan</a>, <a href="http://waag.org/">Waag Society</a></b>, inspired by <a href="http://bklynr.com/block-by-block-brooklyns-past-and-present/">BKLYNR</a>. Map errors can be reported on the <a href="http://www.kadaster.nl/web/Themas/Registraties/BAG/BAGartikelen/BAG-terugmelden.htm">Kadaster's website</a>.</p>
<p>The source code and TileMill project can be found on <a href="https://github.com/waagsociety/buildings">GitHub</a>. High-res prints are available in <a href="http://waagsociety.werkaandemuur.nl/">our web shop</a>.</p>
</div>
<div id="legend">
<h2>Legend</h2>
<table>
<tr><td class="key color1"></td><td class="value first">< 1800</td> <td class="key color7"></td><td class="value">1960 - 1975</td></tr>
<tr><td class="key color2"></td><td class="value first">1800 - 1850</td> <td class="key color8"></td><td class="value">1975 - 1985</td></tr>
<tr><td class="key color3"></td><td class="value first">1850 - 1900</td> <td class="key color9"></td><td class="value">1985 - 1995</td></tr>
<tr><td class="key color4"></td><td class="value first">1900 - 1930</td> <td class="key color10"></td><td class="value">1995 - 2005</td></tr>
<tr><td class="key color5"></td><td class="value first">1930 - 1945</td> <td class="key color11"></td><td class="value">> 2005</td></tr>
<tr><td class="key color6"></td><td class="value first">1945 - 1960</td> <td></td><td></td></tr>
</table>
</div>
<div id="data">
<h2>Data</h2>
<table class="data-table">
<tr><td><h3>City</h3></td><td><span class="help" id="gemeente-help">(click on building for data)</span></td></tr>
<tr><td class="key">Name:</td><td class="value" id="admr-naam"></td></tr>
<tr><td class="key">Population:</td><td class="value" id="cbs-inwoners"></td></tr>
<tr><td class="key">Area:</td><td class="value" id="cbs-oppervlakte"></td></tr>
<tr><td><h3>Building</h3></td><td></td></tr>
<tr><td class="key">Constructed:</td><td class="value" id="pand-bouwjaar"></td></tr>
<tr><td class="key">Address:</td><td class="value" id="vbo-adres"></td></tr>
<tr><td class="key"></td><td class="value" id="vbo-postcode"></td></tr>
<tr><td class="key"></td><td class="value" id="vbo-plaats"></td></tr>
<tr><td class="key">Area:</td><td class="value" id="vbo-oppervlakte"></td></tr>
<tr><td class="key">Function:</td><td class="value" id="vbo-gebruiksdoel"></td></tr>
</table>
</div>
<div id="waag">
<a href="#52.3732,4.9003,16"><img src="{{ site.baseurl}}/images/waag.png" /></a>
</div>
</div>
<div>
<script>
var disableHashChange = false,
map = L.map('map'),
tileUrl = "http://tiles.waag.org/v2/buildings/{z}/{x}/{y}.png";
L.tileLayer(tileUrl, {
attributionControl: false,
minZoom: 8,
maxZoom: 16
}).addTo(map);
map.setMaxBounds([
[48, 0],
[57, 10]
]);
map.setView([52.3674, 4.915], 11);
map.on('moveend', function(e) {
var lat = roundLatLon(map.getCenter().lat);
var lon = roundLatLon(map.getCenter().lng);
var zoom = map.getZoom();
disableHashChange = true;
window.location.hash = [lat, lon, zoom].join(",");
});
map.on('click', function(e) {
var lat = e.latlng.lat,
lon = e.latlng.lng;
var buildingUrl = "{{ site.api }}layers/bag.pand/objects?lat=" + lat.toFixed(4)
+ "&lon=" + lon.toFixed(4) + "&per_page=1&radius=" + {{ site.radius }};
d3.json(buildingUrl, function(geojson) {
// Reset data:
d3.select("#admr-naam").html("");
d3.select("#cbs-oppervlakte").html("");
d3.select("#cbs-inwoners").html("");
d3.select("#pand-bouwjaar").html("");
d3.select("#vbo-adres").html("");
d3.select("#vbo-postcode").html("");
d3.select("#vbo-plaats").html("");
d3.select("#vbo-oppervlakte").html("");
d3.select("#vbo-gebruiksdoel").html("");
if (geojson && geojson.features && geojson.features.length > 0) {
var buildingData = geojson.features[0].properties.layers["bag.pand"].data;
d3.select("#pand-bouwjaar").html(buildingData.bouwjaar);
var admrUrl = "{{ site.api }}layers/admr/objects?contains=bag.pand." + buildingData.id
+ "&admr::admn_level=3&geom=false&layer=cbs";
d3.json(admrUrl, function(geojson) {
if (geojson && geojson.features && geojson.features.length > 0) {
var admrData = geojson.features[0].properties.layers["admr"].data,
cbsData = geojson.features[0].properties.layers["cbs"].data;
d3.select("#admr-naam").html(admrData.gemeentenaam);
d3.select("#cbs-oppervlakte").html(formatNumber(cbsData.opp_tot / 100) + " km²");
d3.select("#cbs-inwoners").html(formatNumber(cbsData.aant_inw));
}
});
var addressUrl = "{{ site.api }}layers/bag.vbo/objects?bag.vbo::pand_ids=" + buildingData.id;
d3.json(addressUrl, function(geojson) {
if (geojson && geojson.features && geojson.features.length > 0) {
var addressData = geojson.features[0].properties.layers["bag.vbo"].data;
var purpose = "";
switch (addressData.gebruiksdoel) {
case "woonfunctie":
purpose = "House";
break;
case "gezondheidszorgfunctie":
purpose = "Healthcare";
break;
case "logiesfunctie":
purpose = "Hotel";
break;
case "industriefunctie":
purpose = "Industry";
break;
case "onderwijsfunctie":
purpose = "Education";
break;
case "sportfunctie":
purpose = "Sport";
break;
case "kantoorfunctie":
purpose = "Office";
break;
case "celfunctie":
purpose = "Detention";
break;
case "bijeenkomstfunctie":
purpose = "Public";
break;
case "winkelfunctie":
purpose = "Retail";
break;
case "overige gebruiksfunctie":
purpose = "Other";
break;
}
var addess = addressData.straat + " " + addressData.huisnummer
if (addressData.toevoeging) {
address += addressData.toevoeging;
}
d3.select("#vbo-adres").html(addess);
d3.select("#vbo-postcode").html(addressData.postcode);
d3.select("#vbo-plaats").html(addressData.woonplaats);
d3.select("#vbo-oppervlakte").html(formatNumber(addressData.oppervlakte) + " m²");
d3.select("#vbo-gebruiksdoel").html(purpose);
}
});
}
});
});
d3.select("#close").on("click", function() {
var closed = d3.select(this).classed("closed");
d3.select("#box")
.classed("hidden", closed)
.transition()
.duration(150)
.style("opacity", closed ? 1 : 0)
.each("end", function() { d3.select(this).classed("hidden", !closed); });
d3.select(this).classed("closed", !closed);
});
window.onhashchange = function() {
if (!disableHashChange) {
var hash = window.location.hash.split(",");;
if (hash.length == 3) {
var lat = parseFloat(hash[0].substring(1)), // Remove "#"
lon = parseFloat(hash[1]),
zoom = parseInt(hash[2]);
map.setView([lat, lon], zoom);
}
}
disableHashChange = false;
}
window.onhashchange();
function roundLatLon(l) {
return Math.round(l * 10000) / 10000;
}
function formatNumber(x) {
x = x.toString();
var pattern = /(-?\d+)(\d{3})/;
while (pattern.test(x))
x = x.replace(pattern, "$1,$2");
return x;
}
</script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//194.145.201.185/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 2]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//194.145.201.185/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>