1 | #!/bin/bash
|
---|
2 |
|
---|
3 | coll="$1"
|
---|
4 |
|
---|
5 | r='rasql --user rasadmin --passwd rasadmin'
|
---|
6 | colors=(White Silver Grey Orange Brown Maroon Green Olive Purple DarkBlue \
|
---|
7 | LightBlue Bisque BurlyWood CadetBlue Chocolate Coral Crimson DarkCyan DarkGray \
|
---|
8 | DarkMagenta DarkSlateGreen DarkTurquoise Green HotPink Indigo Lavender MidnightBlue \
|
---|
9 | Peru RosyBrown SaddleBrown Sienna Teal Yellow)
|
---|
10 |
|
---|
11 | get_bounds() {
|
---|
12 | lo1=${sdom[0]}
|
---|
13 | hi1=${sdom[1]}
|
---|
14 | lo2=${sdom[2]}
|
---|
15 | hi2=${sdom[3]}
|
---|
16 | w=$(($hi1 - $lo1 + 1))
|
---|
17 | h=$(($hi2 - $lo2 + 1))
|
---|
18 | }
|
---|
19 | get_color() {
|
---|
20 | colorno=$((${#colors[@]} - 1))
|
---|
21 | idx=$(shuf -i 0-$colorno -n 1)
|
---|
22 | color=${colors[$idx]}
|
---|
23 | }
|
---|
24 | decompose_sdom() {
|
---|
25 | sdom=($($r -q "select sdom(c) from $coll as c" --out string | grep Result | \
|
---|
26 | sed 's/.*\[//' | sed 's/[,:\]]*/ /g' | tr -d ']'))
|
---|
27 | get_bounds
|
---|
28 | }
|
---|
29 |
|
---|
30 | decompose_sdom
|
---|
31 |
|
---|
32 | echo "<svg width='$w' height='$h'>"
|
---|
33 |
|
---|
34 | for s in $($r -q "select dbinfo(c, \"printtiles=1\") from $coll as c" --out string | strings | grep $'\t\t"\[' | tr -d $'\t' | sed 's/,$//g'); do
|
---|
35 | sdom=($(echo "$s" | tr -d '"' | tr -d ']' | tr -d '[' | sed 's/[:,]/ /g'))
|
---|
36 | get_bounds
|
---|
37 | get_color
|
---|
38 | echo "<rect x=\"$lo1\" y=\"$lo2\" width=\"$w\" height=\"$h\" fill=\"$color\" stroke=\"black\"></rect>"
|
---|
39 | done
|
---|
40 |
|
---|
41 | echo "</svg>"
|
---|