-
Notifications
You must be signed in to change notification settings - Fork 6
/
transfer.html
131 lines (118 loc) · 3.18 KB
/
transfer.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
<!DOCTYPE html>
<html>
<head>
<title>GP Clustering</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type = "text/javascript" language = "javascript">
var map;
var markers = [];
var count = 0;
function initialize() {
var centerPoint = new google.maps.LatLng(-35.351057, 149.055559);
var mapOptions = {
zoom: 12,
center: centerPoint,
// mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
loadLocations();
var marker = new google.maps.Marker({
position: centerPoint,
map: map
});
// markers.push(marker);
// setAllMap(map);
}
function loadLocations(){
alert("loading data..");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile("C:\\Users\\Titicaca\\Documents\\GitHub\\GP-Clustering\\dataset\\school.txt",1);
var s = "";
count = 0;
// alert(count);
skiprows(1, file);
while(!file.AtEndOfStream){
count++;
// alert(count);
s = file.ReadLine();
// alert(s);
var items = s.split(/[\s]+/);
// var items = s.split("\t");
// alert(items[1] + "," + items[0]);
// var x = parseFloat(items[6]) + parseFloat(items[7])/100;
// var y = - (parseFloat(items[8]) + parseFloat(items[9])/100);
var x = parseFloat(items[1])
var y = parseFloat(items[0])
// alert(x + "," + y);
var location = new google.maps.LatLng(x,y);
var marker = new google.maps.Marker({
position: location,
map: map
});
markers.push(marker);
}
alert("data loaded..\n" + "Count:" + count);
}
function skiprows(numRows, file){
for (var i = 0; i < numRows; i ++){
if(!file.AtEndOfStream)
file.ReadLine();
}
}
// Sets the map on all markers in the array.
function setAllMap(map) {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
}
function showMarkers() {
alert("The number of points:" + markers.length);
setAllMap(map);
}
function showClusters() {
setAllMap(map);
}
function clearMarkers() {
setAllMap(null);
}
function exportPixels() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Users\\Titicaca\\Documents\\GitHub\\GP-Clustering\\dataset\\school_pixels.txt", true);
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
s.Close();
alert("File Export Finished!");
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<input onclick="showMarkers();" type=button value="Show All Markers">
<input onclick="showClusters();" type=button value="GPClustering">
<input onclick="clearMarkers();" type=button value="Clear Markers">
<input onclick="exportPixels();" type=button value="export Pixels">
</div>
<div id="map-canvas"></div>
<p>Click on the map to add markers.</p>
</body>
</html>