-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-converter.html
executable file
·144 lines (121 loc) · 4.52 KB
/
test-converter.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.0.1/ol.css" type="text/css">
<style>
.progress, .alert {
margin: 15px;
display: none;
}
.alert {
display: none;
}
#downloading {
display: none;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://rawgit.com/nodeca/pako/master/dist/pako.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.0.1/ol.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js'></script>
<script src='https://rawgit.com/enricofer/geojson_viewer/master/epsg.js'></script>
<script type="text/javascript">
var spreadsheet_id = gup('spreadsheet_id');
//var sheet_id = gup('sheet_id');
//var epsg_id = gup('epsg');
var layer_projection, view_projection = 'EPSG:3857'
ol.proj.setProj4(proj4);
window.googleDocCallback = function () { return true; };
//var public_html_url = 'https://docs.google.com/spreadsheets/d/'+ spreadsheet_id +'/pubhtml?gid='+ sheet_id +'&single=true';
var public_html_url = 'https://docs.google.com/spreadsheets/d/'+ spreadsheet_id +'/pubhtml?callback=googleDocCallback';
console.log (public_html_url);
function registerEPSGId(epsg_id){
if (epsg_id != 'EPSG:3858' && epsg_id != 'EPSG:4326'){
var layer_projection = epsg_id
var newProjection = new ol.proj.Projection({
code: layer_projection
});
ol.proj.addProjection(newProjection);
}
}
function init() {
$('#downloading').css('display', 'block');
Tabletop.init( { key: public_html_url,
callback: showInfo,
simpleSheet: false } )
}
function getTransformationOptions(){
return {
dataProjection: layer_projection,
featureProjection:view_projection
}
}
function decompress(b64_zipped){
// Decode base64 (convert ascii to binary)
var strData = atob(b64_zipped);
// Convert binary string to character-number array
var charData = strData.split('').map(function(x){return x.charCodeAt(0);});
// Turn number array into byte-array
var binData = new Uint8Array(charData);
// Pako magic
var inflated = pako.inflate(binData);
// Convert gunzipped byteArray back to ascii string:
return String.fromCharCode.apply(null, new Uint16Array(inflated));
}
function showInfo(data, tabletop) {
//alert('Successfully processed!')
$('#downloading').css('display', 'none');
$('.progress').css('display', 'block');
console.log(tabletop);
console.log(data);
$('.progress').css('display', 'none');
$('#completed').css('display', 'block');
}
window.addEventListener('DOMContentLoaded', init)
function gup(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
function ol_init(){
googis_map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults().extend([
new ol.control.MousePosition(),
new ol.control.OverviewMap()
]),
target: 'map',
/*
view: new ol.View({
projection:view_projection,
center: [11,45],
zoom: 3
})
*/
});
init()
}
</script>
</head>
<body onload="ol_init()">
<div style="width:100%;height:600px" id="map"></div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>
</div>
<div id="downloading" class="alert alert-success" role="alert">Downloading</div>
<div id="completed" class="alert alert-success" role="alert">Loading completed!</div>
</body>
</html>