-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
202 lines (172 loc) · 6.3 KB
/
index.php
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
201
202
<?php
?>
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.divCenter {
position: absolute;
padding: 10px;
position: fixed;
top: 20%;
left: 40%;
border: 1px solid black;
}
.h1 {
position: absolute;
left: 50%;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
var selectedMeasure;
function rowValueChange()
{
classItem = [];
$.each( $('.snippetRow') , function(key, val){
var className = $(val).find('td:first').text();
var itemValue = $(val).find('select').val();
classItem.push('http://code.datacove.eu/codeList/'+ className +'/'+ itemValue);
});
console.log( "classItem PARAMETER START");
console.log( classItem );
console.log( "classItem PARAMETER END");
//return classItem;
};
function getGmlId(selectedMeasure)
{
// GET GML IDs FOR MEASURE PER COUNTRY AND YEAR
gmlID = [];
country = [];
var url = "http://bolegweb.geof.unizg.hr:2017/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&STOREDQUERY_ID=GetStatdistForMeasureYear&measure="+ selectedMeasure +"&year=2012-01-01&outputFormat=application/json";
var sendData = {};
$.getJSON(url, sendData, function(data){
$.each(data.features, function(){
gmlID.push(this.properties.gmlid);
var countryCode = this.properties.gmlid.split('_')[0];
country.push(countryCode);
});
console.log( "featureId PARAMETER START");
console.log( gmlID );
console.log( "featureId PARAMETER END");
});
}
function sendPdPhpFilter(){
var url = "http://bolegweb.geof.unizg.hr/danubehack2/pd-viewer/php/PD_Filter.php?classItem=http://code.datacove.eu/codeList/age/Y_1,http://code.datacove.eu/codeList/sex/F&featureId=AT_demo_r_mlifexp_sex_age_2012";
var sendData = {};
$.getJSON(url, sendData, function(data){
$.each(data.features, function(){
var gmlID = this.properties.gmlid;
console.log("GML ID:" +gmlID);
var country = gmlID.split('_')[0];
console.log("Country:" +country);
});
});
}
$( document ).ready(function(){
var geoserverURL = 'http://bolegweb.geof.unizg.hr:2017/geoserver';
var url = "http://bolegweb.geof.unizg.hr:2017/geoserver/pd-s/ows?service=WFS&version=2.0.0&request=GetFeature&typeNames=pd-s:sd_statdistmeasure_test&outputFormat=application/json"
var sendData = {};
$.getJSON(url, sendData, function(data){
$.each(data.features, function(){
$("#selectMeasure").append($("<option></option>").attr("value",this.properties.measure).text(this.properties.domain));
//console.log(this.properties.domain);
});
});
$("#selectMeasure").change(function(){
var zgrupnute = {};
var snippet;
var gmlID;
// remove old rows
$('.snippetRow').remove();
$('#addToMap').hide();
if ($("#selectMeasure option:selected").text() == 'No measure selected'){
$("#selectClass").parent().parent().hide();
$("#selectFeat").parent().parent().hide();
}
else {
$("#selectClass").find('option').remove();
selectedMeasure = $("#selectMeasure option:selected").val();
var url = "http://bolegweb.geof.unizg.hr:2017/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&STOREDQUERY_ID=GetStatdistclassitemForMeasureTest&measure="+ selectedMeasure +"&outputFormat=application/json";
sendData = {};
$.getJSON(url, sendData, function(res){
//console.log(res); // res.features[i].properties.itemclass
// prvy each na zgrupovanie
$.each(res.features, function(key, feature){
var itemClass = feature.properties.itemclass;
if( $.type( zgrupnute[itemClass] ) !== "array" )
{
zgrupnute[itemClass] = [];
}
zgrupnute[itemClass].push(feature);
});
//console.log(zgrupnute);
// druhy each prejde zgrupovanymi a vypise co treba
$.each(zgrupnute, function(key, group){
snippet = "";
snippet += '<tr class=snippetRow>';
snippet += '<td>'+key+'</td>';
snippet += '<td>';
snippet +='<select id="'+key+'" onchange="rowValueChange();getGmlId(selectedMeasure)">'
$.each(group, function(key, feature){
var item = feature.properties.item;
snippet += '<option value="'+item+'">'+item+'</option>';
});
snippet += '</select>';
snippet += '</td>';
snippet += '</tr>';
//snippet += '<button type="button">ADD FEATURES TO MAP</button>';
$('#queryDef').append(snippet);
$('#addToMap').show();
});
rowValueChange();
getGmlId(selectedMeasure);
});
}
});
});
</script>
</head>
<body>
<div class="divCenter">
<table id="queryDef">
<tr>
<td>
Select Measure:
</td>
<td>
<select id="selectMeasure">
<option value="noMeasure" selected="selected">No measure selected</option>
</select>
</td>
</tr>
<!--
<tr style="display: none">
<td>
Select Clasification:
</td>
<td>
<select id="selectClass">
<option value="noClass" selected="selected">No classification selected</option>
</select>
</td>
</tr>
<tr style="display: none">
<td>
Select Features:
</td>
<td>
<select id="selectFeat">
<option value="noFeat" selected="selected">No feature selected</option>
</select>
</td>
</tr>
-->
</table>
<button id="addToMap" style="display: none; float:right" type="button" onclick="myFunction()">ADD FEATURES TO MAP</button>
</div>
</body>
</html>