-
Notifications
You must be signed in to change notification settings - Fork 0
/
emergencymapview.html
225 lines (211 loc) · 10.1 KB
/
emergencymapview.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<html>
<head><title>Emergency Cases Mapview based on Linked Data</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="wicket.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="rdfstore_min.js"></script>
<script>
var relmap={
"http://www.wikidata.org/wiki/Property:P512":"academic degree",
"http://www.wikidata.org/wiki/Property:P1416":"affiliation",
"http://www.wikidata.org/wiki/Property:P69":"alma mater",
"http://www.wikidata.org/wiki/Property:P66":"ancestral home",
"http://www.wikidata.org/wiki/Property:P450":"astronaut mission",
"http://www.wikidata.org/wiki/Property:P166":"award received",
"http://www.wikidata.org/wiki/Property:P3150":"birthday",
"http://www.wikidata.org/wiki/Property:P1477":"birth name",
"http://www.wikidata.org/wiki/Property:P509":"cause of death",
"http://www.wikidata.org/wiki/Property:P40":"child",
"http://www.wikidata.org/wiki/Property:P237":"coat of arms",
"http://www.wikidata.org/wiki/Property:P1399":"convicted of",
"http://www.wikidata.org/wiki/Property:P27":"country of citizenship",
"http://www.wikidata.org/wiki/Property:P569":"date of birth",
"http://www.wikidata.org/wiki/Property:P570":"date of death",
"http://xmlns.com/foaf/0.1/depiction":"depiction",
"http://www.wikidata.org/wiki/Property:P184":"doctoral advisor",
"http://www.wikidata.org/wiki/Property:P185":"doctoral student",
"http://www.wikidata.org/wiki/Property:P551":"dwelling",
"http://www.wikidata.org/wiki/Property:P69":"educated at",
"http://www.wikidata.org/wiki/Property:P108":"employer",
"http://www.wikidata.org/wiki/Property:P582":"end time",
"http://www.wikidata.org/wiki/Property:P172":"ethnic group",
"http://www.wikidata.org/wiki/Property:P1340":"eye color",
"http://www.wikidata.org/wiki/Property:P734":"family name",
"http://www.wikidata.org/wiki/Property:P22":"father",
"http://www.wikidata.org/wiki/Property:P101":"field of work",
"http://www.wikidata.org/wiki/Property:P103":"first language",
"http://www.wikidata.org/wiki/Property:P735":"given name",
"http://www.wikidata.org/wiki/Property:P1290":"godparent",
"http://www.wikidata.org/wiki/Property:P119":"grave location",
"http://www.wikidata.org/wiki/Property:P1429":"has pet",
"http://xmlns.com/foaf/0.1/homepage":"homepage",
"http://www.wikidata.org/wiki/Property:P109":"image of persons signature",
"http://xmlns.com/foaf/0.1/knows":"knows",
"https://www.wikidata.org/wiki/Property:P1412":"languages written, spoken or signed",
"http://www.wikidata.org/wiki/Property:P39":"mandate",
"http://www.wikidata.org/wiki/Property:P1196":"manner of death",
"http://www.wikidata.org/wiki/Property:P463":"member of",
"http://www.wikidata.org/wiki/Property:P25":"mother",
"http://www.wikidata.org/wiki/Property:P157":"murderer",
"http://www.wikidata.org/wiki/Property:P1559":"name of the person in their native language",
"http://www.wikidata.org/wiki/Property:P97":"noble title",
"http://www.wikidata.org/wiki/Property:P1411":"nominated for",
"http://www.wikidata.org/wiki/Property:P1971":"number of children",
"http://www.wikidata.org/wiki/Property:P263":"official residence",
"http://www.wikidata.org/wiki/Property:P106":"occupation",
"http://www.wikidata.org/wiki/Property:P1344":"participant of",
"http://www.wikidata.org/wiki/Property:P451":"partner",
"http://www.wikidata.org/wiki/Property:P1442":"picture of the grave",
"http://www.wikidata.org/wiki/Property:P19":"place of birth",
"http://www.wikidata.org/wiki/Property:P20":"place of death",
"http://www.wikidata.org/wiki/Property:P1303":"plays instrument",
"http://www.wikidata.org/wiki/Property:P102":"political party",
"http://www.wikidata.org/wiki/Property:P742":"pseudonym",
"http://xmlns.com/foaf/0.1/publications":"publication",
"http://www.wikidata.org/wiki/Property:P1038":"relative",
"http://www.wikidata.org/wiki/Property:P140":"religion",
"http://www.wikidata.org/wiki/Property:P551":"residence",
"http://www.wikidata.org/wiki/Property:P91":"sexual orientation",
"http://www.wikidata.org/wiki/Property:P21":"sex or gender",
"http://www.wikidata.org/wiki/Property:P3373":"sibling",
"http://www.wikidata.org/wiki/Property:P26":"spouse",
"http://www.wikidata.org/wiki/Property:P580":"start time",
"http://www.wikidata.org/wiki/Property:P3448":"stepparent",
"http://www.wikidata.org/wiki/Property:P1066":"student of",
"http://www.wikidata.org/wiki/Property:P1066":"teacher",
"http://www.wikidata.org/wiki/Property:P793":"witnessed significant event",
"http://www.wikidata.org/wiki/Property:P800":"work and magnum opus",
"http://www.wikidata.org/wiki/Property:P412":"voice type",
"http://www.wikidata.org/wiki/Property:P553":"website account on"
}
var prefixList="PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX geo: <http://www.opengis.net/ont/geosparql#> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX xml: <http://www.w3.org/XML/1998/namespace> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX symbol: <http://semgis.de/disastermanagement/symbols#> PREFIX semgis: <http://semgis.de/disastermanagement#> PREFIX emergel: <http://purl.org/emergel#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
var currdfstore=null;
var wkt = new Wkt.Wkt();
$( function() {
document.getElementById('file-input')
.addEventListener('change', readRDFFile, false);
});
function readSingleFile(e) {
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
displayContents(contents);
};
reader.readAsText(file);
}
function readRDFFile(e){
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
rdfstore.create(function(err, store) {
currdfstore=store;
store.load('text/turtle', contents, function(s,d){
console.log(s,d);
displayGeometricObjects()
});
});
};
reader.readAsText(file);
}
function outputSPARQLResults(results) {
for (row in results) {
printedLine = ''
for (column in results[row]) {
printedLine = printedLine + results[row][column].value + ' '
}
console.log(printedLine)
}
}
function findLastNonAlpha(input){
if(input.includes("^^")){
return input.length
}
for(i=input.length-2;i>0;i--){
if(!input.substring(i,i+1).match("[A-z0-9-,;.^]"))
return i+1;
}
}
function displayGeometricObjects(){
personToWKT={}
currdfstore.execute(prefixList+" SELECT ?e ?wkt WHERE { ?ecls rdfs:subClassOf semgis:ActorTask . ?e rdf:type ?ecls . ?e symbol:hasSymbol ?icon . ?e semgis:adresses ?disaster . ?disaster geosparql:hasGeometry ?g. ?g geosparql:asWKT ?wkt. }", function(success,results){
for(res in results){
console.log(results[res]["wkt"]["value"])
wkt.read(results[res]["wkt"]["value"]);
personToWKT[results[res]["e"]["value"]]=wkt.toJson()["coordinates"];
}
});
console.log(personToWKT)
//OPTIONAL{?disaster rdf:type ?t. ?t rdfs:subClassOf semgis:Disaster.}
currdfstore.execute(prefixList+"SELECT ?e ?img ?adresses ?address ?numberOfAffectedPeople ?responsible ?actorAddress ?actorPhoneNumber WHERE { ?ecls rdfs:subClassOf semgis:ActorTask . ?e rdf:type ?ecls . ?e symbol:hasSymbol ?icon . ?icon symbol:hasImage ?img . ?e semgis:adresses ?adresses . ?adresses semgis:hasAddresse ?address . ?adresses semgis:numberOfAffectedPeople ?numberOfAffectedPeople . ?e semgis:hasResponsible ?responsible . ?responsible semgis:hasAddresse ?actorAddress . ?responsible foaf:phone ?pa. ?pa semgis:hasValue ?actorPhoneNumber . }", function(success,results){
console.log(success,results)
persons={}
for(res in results){
if(!(results[res]["e"]["value"] in persons)){
persons[results[res]["e"]["value"]]={}
}
for(resultvar in results[res]){
if(resultvar!="e"){
persons[results[res]["e"]["value"]][resultvar]=results[res][resultvar]["value"]
}
}
console.log(persons)
}
console.log(JSON.stringify(persons))
for(pers in persons){
markerIconPath=""
tooltip="<html><b><a href=\""+pers+"\" target=\"_blank\">"+pers.substring(pers.indexOf("#")+1)+"</a></b><ul>"
for(rel in persons[pers]){
console.log(rel)
console.log(persons[pers][rel])
if(rel=="actorAddress" || rel=="actorPhoneNumber"){
tooltip+="<ul>"
}
if(rel=="img"){
markerIconPath=persons[pers][rel]
}else{
tooltip+="<li><a href=\""+rel+"\" target=\"_blank\">"+(rel in relmap?relmap[rel]:rel.substring(rel.lastIndexOf("#")+1))+"</a> - "
tooltip+="<a href=\""+persons[pers][rel]+"\" target=\"_blank\">"+(persons[pers][rel].includes('#')?persons[pers][rel].substring(persons[pers][rel].indexOf('#')+1):persons[pers][rel])+"</a></li> "
}
if(rel=="actorAddress" || rel=="actorPhoneNumber"){
tooltip+="</ul>"
}
}
tooltip+="</ul></html>"
var markerIcon = L.icon({
iconUrl: markerIconPath,
iconSize: [38, 95], // size of the icon
});
//console.log(tooltip)
var marker = new L.marker(personToWKT[pers],{icon:markerIcon}); //opacity may be set to zero
marker.bindPopup(tooltip, {maxWidth : 560});
marker.addTo(mymap);
}
mymap.setView([50.933730, 6.982728], 13);
});
}
</script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<h2 align="center">Emergency Cases Mapview based on Linked Data</h2>
<div id="mapid" style="height:80%">
<script>
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
var layer=L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);
</script>
</div>
RDF File Upload:<input type="file" id="file-input" />
</body>
</html>