-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathhexify.html
148 lines (134 loc) · 5.15 KB
/
hexify.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hexify</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="https://open-innovations.org/resources/images/logos/oi-square-10.svg" />
<meta charset="utf-8" />
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@OpenInnovates">
<meta name="twitter:url" property="og:url" content="https://open-innovations.org/projects/hexmaps/builder">
<meta name="twitter:title" property="og:title" content="Hex map builder">
<meta name="twitter:description" property="og:description" content="Create your own point-topped hex map from a data file.">
<meta name="twitter:image" property="og:image" content="https://open-innovations.org/projects/hexmaps/hexmap.png">
<link rel="StyleSheet" href="resources/style.css" type="text/css" />
<script type="text/javascript" src="resources/stuquery.js"></script>
<script type="text/javascript" src="resources/stuquery.svg.js"></script>
<script src="resources/d3.v5.min.js"></script>
<script src="resources/stuquery.hexmap.js"></script>
<!--<script type="text/javascript" src="resources/builder.js"></script>-->
<!--<script src="https://cdn.jsdelivr.net/npm/d3-delaunay@6"></script>-->
<script src="resources/hexify.js"></script>
<script>
var hexify;
S(document).ready(function(){
//builder = new Builder('hexmap',1080,1220,2);
hexify = new Hexify('hexify');
S('#restart').on('click',function(e){
hexify.start();
});
S('#jiggle').on('click',function(e){
hexify.start(true);
});
S('#gridify').on('click',function(e){
hexify.stop();
hexify.gridify();
hexify.draw();
S('#hexjson').html(hexify.makeHexJSON())
});
S('#save').on('click',function(e){
json = hexify.makeHexJSON();
hexify.save(json);
});
S('.example').on('click',function(e){
console.log('click')
S().ajax("https://mapper.odileeds.org/layers/imd-leeds.geojson",{
'type':'json',
'this': hexify,
'success':function(d){
this.data = JSON.parse(d);
this.loaded();
}
})
});
});
</script>
<style>
.dropzone {
border: 2px dashed #999999;
border-radius: 5px;
color: #333333;
padding: 25px;
text-align: center;
position: relative;
}
.dropzone.loaded {
border: 2px solid #333333;
color: #333333;
}
.dropzone.loaded .helpertext {
display: none;
}
.dropzone.drop {
background-color: #ddd;
}
.dropzone input {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
opacity: 0;
}
#hexify, #hexmap { width: 100%; height: 200px; }
#d3 { width: 100%; height: 800px; }
select,input { line-height: 2em; height: 2em; font-size: 1em; }
</style>
</head>
<body>
<div id="main">
<header>
<div class="b1-bg">
<div class="holder" style="text-align:center;">
<a href="https://open-innovations.org/"><img src="https://open-innovations.org/resources/images/logos/oi-square-10.svg" width="100px" /></a>
<h1>Hexify</h1>
</div>
</div>
</header>
<div class="holder">
<p>Create <a href="hexjson.html">HexJSON</a> layouts from GeoJSON Polygons/Multipolygons. See <a href="#notes">notes below</a>. Try an <a href="#" class="example">example for Leeds LSOAs</a>.</p>
<div id="drop_zone" class="dropzone block">
<div class="helpertext">
Drop a GeoJSON file here (or click to browse files)<br />
<input id="standard_files" class="fileselect" type="file" title="browse" name="files[]" multiple="multiple" accept=".geojson">
</div>
</div>
</div>
<div class="holder">
<p>The geographic points:</p>
<div id="hexify"></div>
<p>The gridded points:</p>
<div id="d3"><canvas style="width:100%;height:100%"></canvas></div>
<div style="text-align:center;">
<label for="colour-by">Colour-by:</label><select id="colour-by"><option value="">Distance</option></select>
<button id="restart" class="c1-bg">Collapse</button>
<button id="jiggle" class="c1-bg">Jiggle</button>
<button id="gridify" class="c1-bg">Gridify</button>
<button id="save" class="c10-bg">Save hexes as <span class="line">H</span>exJSON</button>
</div>
</div>
</div>
<footer class="b1-bg">
<div class="holder">
<h2 id="notes">Notes</h2>
<p>This will read a GeoJSON file containing Polygons or Multipolygons. If your GeoJSON contains Points you could load them into a tool such as QGIS and create Voronoi polygons then export the output to use in this tool. It parses the Polygons, finds neighbours and centres, then uses D3 to bring them together. Use the collapse/jiggle buttons below to adjust the objects. Use the gridify button to force the objects to sit on a hexagonal grid. Then save the output. Once you have saved your HexJSON you might want to tidy it up in our <a href="builder.html">HexBuilder</a>.</p>
<h2>Credits</h2>
© 2017-2022 <a href="https://open-innovations.org/">Open Innovations</a>. Released under an MIT license. <a href="https://github.com/odileeds/hexmaps">Source on Github</a>.
</div>
</footer>
<script src="https://open-innovations.org/resources/oi.log.js"></script>
<script>
OI.log.setup({'id':'odileeds','target':['open-innovations.org','odileeds.github.io']}).add('action=view');
</script>
</body>
</html>