-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.html
41 lines (31 loc) · 1.26 KB
/
test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OS Transform</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.7.0/proj4.js"></script>
<script src="os-transform.js"></script>
<script>
var request = new XMLHttpRequest();
request.onload = function() {
var arrayBuffer = request.response;
proj4.nadgrid('OSTN15_NTv2_OSGBtoETRS', arrayBuffer);
proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs +nadgrids=OSTN15_NTv2_OSGBtoETRS');
var p1 = { ea: 337297, no: 503695 };
var p2 = { lat: 54.42480998276385, lng: -2.96793742245737 };
console.log(os.Transform.toLatLng(p1));
console.log(os.Transform.toLatLng(p1, 14));
console.log(os.Transform.fromLatLng(p2));
console.log(os.Transform.toGridRef(p1));
console.log(os.Transform.toGridRef(os.Transform.fromLatLng(p2)));
console.log(os.Transform.fromGridRef("NY 37297 03695"));
};
request.open('GET', 'OSTN15_NTv2_OSGBtoETRS.gsb');
request.responseType = 'arraybuffer';
request.send();
</script>
</body>
</html>