blob: 932f91f13afdbf2a3b82da9c08a492f3e066ce10 (
plain) (
blame)
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
|
exports.urlToXpathObj = function urlToXpathObj(url){
// FIXMEresult.shift(): more validaiton
// filter stars in keys
// filter no enough arguments
var parseKeyList = function(string){
console.log("input f1: " + string);
result = /([^\|]*)/g.exec(string);
console.log(result);
result.shift();
return result;
}
var parseBboxList = function(string){
console.log("input: " + string);
result = /(.+),(.+),(.+),(.+)/.exec(string);
console.log(result);
if(result.length != 4){
throw "error";
}
result.shift();
return {
'left' : result[0],
'bottom' : result[1],
'right' : result[2],
'top' : result[3]
}
}
var xp = {};
result = url.match(/\/(\*|node|way|relation)\[(.*)=(.*)\]*/);
console.log("OUTER: " + result);
xp.object=result[1];
for(i=2;i<=result.length;i++){
if(result[i]==="bbox" && result[i]){
xp.bbox = parseBboxList(result[i+1]);
} else {
if(result[i]){
xp.tag ={};
xp.tag.keys = parseKeyList(result[i]);
xp.tag.values = parseKeyList(result[i+1]);
}
}
i++;
}
console.log(xp);
return(xp);
}
|