-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
200 lines (183 loc) · 7.49 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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>WMTSメタデータ作成ツール</title>
<style>
body {padding: 0; margin: 0}
html, body {height: 100%; width: 100%;}
.scr {
font-size: 14px;
width: 100%;
height: 100%;
background-color: #fff;
}
.setumei {
margin:10px;
padding:10px;
}
</style>
</head>
<body>
<div class="scr" >
<div class="setumei">
<textarea name='tilecp' id='tilecp' cols="100" rows="50" readonly="readonly" onclick="this.select()">
</textarea>
</div>
</div>
<script>
var layerarray = ['https://maps.gsi.go.jp/layers_txt/layers1.txt',
'https://maps.gsi.go.jp/layers_txt/layers2.txt',
'https://maps.gsi.go.jp/layers_txt/layers3.txt',
'https://maps.gsi.go.jp/layers_txt/layers4.txt',
'https://maps.gsi.go.jp/layers_txt/layers5.txt',
'https://maps.gsi.go.jp/layers_txt/layers6.txt',
'https://maps.gsi.go.jp/layers_txt/layers7.txt'];
var outxml = '<?xml version="1.0" encoding="UTF-8"?>' + "\n";
outxml += '<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">' + "\n";;
outxml += '<Contents>' + "\n";
var outTileMatrix = [];
var ScaleDenominator ={
zoom0:559082264.0287178,
zoom1:279541132.0143589,
zoom2:139770566.0071794,
zoom3:69885283.00358972,
zoom4:34942641.50179486,
zoom5:17471320.75089743,
zoom6:8735660.375448715,
zoom7:4367830.187724357,
zoom8:2183915.093862179,
zoom9:1091957.546931089,
zoom10:545978.7734655447,
zoom11:272989.3867327723,
zoom12:136494.6933663862,
zoom13:68247.34668319309,
zoom14:34123.67334159654,
zoom15:17061.83667079827,
zoom16:8530.918335399136,
zoom17:4265.459167699568,
zoom18:2132.729583849784
};
var ljson = [
{title:"標準地図",id:"std",url:"https://maps.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",minZoom:2,maxNativeZoom:18},
{title:"淡色地図",id:"pale",url:"https://maps.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png",minZoom:2,maxNativeZoom:18},
{title:"白地図",id:"blank",url:"https://maps.gsi.go.jp/xyz/blank/{z}/{x}/{y}.png",minZoom:5,maxNativeZoom:14},
{title:"English",id:"english",url:"https://maps.gsi.go.jp/xyz/english/{z}/{x}/{y}.png",minZoom:5,maxNativeZoom:8},
{title:"写真",id:"ort",url:"https://maps.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg",minZoom:2,maxNativeZoom:18}
];
function layersearch(layerdata,parent){
if ( !layerdata ) return;
for ( var i=0; i<layerdata.length; i++ ){
if(parent){
layerdata[i].title = parent.title + "_" + layerdata[i].title;
}
if(layerdata[i].src){
if (layerdata[i].src.indexOf("//") < 0)
{
if ((layerdata[i].src.indexOf("./") == 0) && (layerdata[i].src.match(/\?|#/) == null)){
layerdata[i].src= "https://maps.gsi.go.jp/layers_txt/" + layerdata[i].src.substring(2);
}
else{
continue;
}
}
var xhr = new XMLHttpRequest();
xhr.open('GET', layerdata[i].src, false);
xhr.send(null);
var result = JSON.parse(xhr.responseText);
layersearch(result.layers,layerdata[i]);
}
if ( layerdata[i].type == "Layer"){
if ( (layerdata[i].id != "red") &&
(layerdata[i].id != "oosimared" ) &&
(layerdata[i].id != "miyakejimared" ) &&
(layerdata[i].id != "20180309_sekisyokurittai_kirishima") &&
(layerdata[i].id != "2018_sekisyokurittai_azumayama") &&
(layerdata[i].id != "tarumaered") &&
(layerdata[i].id != "20180130_kusatsushiranesan_sekishokurittai") &&
(layerdata[i].id != "20180906hokkaido_atsuma_sekishoku") &&
(layerdata[i].id != "kuchinoerabured") &&
(layerdata[i].id != "20190121_olsorittai_kusatsushiranesan") &&
(layerdata[i].id != "20190121_sekisyokurittai_kusatsushiranesan") &&
(layerdata[i].id != "20180130_kusatsushiranesan_sekishokurittai") &&
(layerdata[i].id != "gsi-compare-photo") &&
(( layerdata[i].url.match(/\{y\}\.jpg$/) || layerdata[i].url.match(/\{y\}\.png$/))) ){
if(!layerdata[i].maxNativeZoom){
if(!layerdata[i].maxZoom){
layerdata[i].maxNativeZoom = 18;
}else{
layerdata[i].maxNativeZoom = layerdata[i].maxZoom;
}
}
if(!layerdata[i].minZoom){
layerdata[i].minZoom = 2;
}
ljson[ljson.length ] = {title:layerdata[i].title,id:layerdata[i].id,url:layerdata[i].url,minZoom:layerdata[i].minZoom,maxNativeZoom:layerdata[i].maxNativeZoom};
}
}
layersearch(layerdata[i].entries,layerdata[i]);
}
}
function escapesp(src){
if (!src) return;
var mk = {
"<" : "<",
">" : ">",
"\"" : """,
"&" : "&"
};
return src.replace(/[<>]/g, function(mt){return mk[mt];});
}
for ( var ti=0; ti<layerarray.length; ti++ ){
var xhr = new XMLHttpRequest();
xhr.open('GET', layerarray[ti], false);
xhr.send(null);
var result = JSON.parse(xhr.responseText);
layersearch(result.layers,null);
}
for ( var i=0; i<ljson.length; i++ ){
var TileMatrixSet = ljson[i].minZoom + 'to' + ljson[i].maxNativeZoom;
if(outTileMatrix.indexOf(TileMatrixSet) == -1){outTileMatrix.push(TileMatrixSet);}
var tileext;
if(ljson[i].url.match(/\{y\}\.png$/)){tileext = 'image/png';}else{tileext = 'image/jpeg';}
ljson[i].url = ljson[i].url.replace('{z}/{x}/{y}', '{TileMatrix}/{TileCol}/{TileRow}');
outxml += '<Layer>' + "\n";
outxml += '<ows:Title>' + escapesp(ljson[i].title) + '</ows:Title>' + "\n";
outxml += '<ows:Identifier>' + ljson[i].id + '</ows:Identifier>' + "\n";
outxml += '<Style isDefault="true">' + "\n";
outxml += '<ows:Identifier>default</ows:Identifier>' + "\n";
outxml += '</Style>' + "\n";
outxml += '<Format>' + tileext + '</Format>' + "\n";
outxml += '<TileMatrixSetLink>' + "\n";
outxml += '<TileMatrixSet>z' + TileMatrixSet + '</TileMatrixSet>' + "\n";
outxml += '</TileMatrixSetLink>' + "\n";
outxml += '<ResourceURL format="' + tileext + '" resourceType="tile" template="' +ljson[i].url + '"/>' + "\n";
outxml += '</Layer>'+ "\n";
}
for ( var i=0; i<outTileMatrix.length; i++ ){
outxml += '<TileMatrixSet>'+ "\n";
outxml += '<ows:Identifier>z' + outTileMatrix[i] + '</ows:Identifier>'+ "\n";
outxml += '<ows:SupportedCRS>urn:ogc:def:crs:EPSG:6.18:3:3857</ows:SupportedCRS>'+ "\n";
var zoom = outTileMatrix[i].split('to');
var minz = parseInt(zoom[0], 10);
var maxz = parseInt(zoom[1], 10);
for ( var ii = minz; ii <= maxz; ii++ ){
var Matrixsize = Math.pow(2,ii);
outxml += '<TileMatrix>'+ "\n";
outxml += '<ows:Identifier>'+ii+'</ows:Identifier>'+ "\n";
outxml += '<ScaleDenominator>'+ScaleDenominator["zoom" + ii]+'</ScaleDenominator>'+ "\n";
outxml += '<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>'+ "\n";
outxml += '<TileWidth>256</TileWidth>'+ "\n";
outxml += '<TileHeight>256</TileHeight>'+ "\n";
outxml += '<MatrixWidth>'+Matrixsize+'</MatrixWidth>'+ "\n";
outxml += '<MatrixHeight>'+Matrixsize+'</MatrixHeight>'+ "\n";
outxml += '</TileMatrix>'+ "\n";
}
outxml += '</TileMatrixSet>'+ "\n";
}
outxml += '</Contents>' + "\n";
outxml += '</Capabilities>' + "\n";
tilecp.value = outxml;
</script>
</body>
</html>