-
Notifications
You must be signed in to change notification settings - Fork 1
/
geonode_get_layers.sh
executable file
·61 lines (41 loc) · 1.42 KB
/
geonode_get_layers.sh
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
#!/bin/bash
#cd /srv/www/htdocs/monitor/
json=$1
file="getcapabilities_1.3.0.xml"
curl "https://geonode.salahumanitaria.co/geoserver/wms?request=GetCapabilities&service=WMS&version=1.3" -o $file
i=0
r=""
while read line ; do
#line=${l//$'\n'/}
if [ $i -gt 0 ]; then
if [[ $line == \<Name* ]] || [[ $line == \<Title* ]] || [[ $line == \<Abstract* ]]; then
if [ $i -eq 1 ]; then
name=$(awk -F "[><]" '/Name/{print $3}' <<< $line)
elif [ $i -eq 2 ]; then
title=$(awk -F "[><]" '/Title/{print $3}' <<< $line)
elif [ $i -eq 3 ]; then
abstract=$(awk -F "[><]" '/Abstract/{print $3}' <<< $line)
if [ $json -eq 0 ]; then
r+="<li><div class='left chk'><input type='checkbox' value='$name' /></div><div class='left'> <h3>$title</h3><p class='nota'>$abstract</p></div><div class='clear'></div> </li>"
else
if [[ $title == *vereda* ]] || [[ $title == *Vereda* ]]; then
if [ "$r" != "" ]; then
r+=","
fi
r+="{\"nombre\":\"$title\",\"wms\":\"$name\"}"
fi
fi
i=0
fi
let i=$i+1
fi
fi
if [ $i -eq 0 ]; then
let i=$i+1
fi
done < <( echo "cat //Layer/Layer/Name|//Layer/Layer/Title|//Layer/Layer/Abstract" | xmllint --shell $file )
#done < <( echo "cat //Layer/Layer[position()>2]/Name|//Layer/Layer[position()>2]/Title|//Layer/Layer[position()>2]/Abstract" | xmllint --shell $file )
if [ $json -eq 1 ]; then
r="[$r]"
fi
echo "$r"