Ticket #2240: vistiles.sh

File vistiles.sh, 1.2 KB (added by Dimitar Misev, 5 years ago)
Line 
1#!/bin/bash
2
3coll="$1"
4
5r='rasql --user rasadmin --passwd rasadmin'
6colors=(White Silver Grey Orange Brown Maroon Green Olive Purple DarkBlue \
7LightBlue Bisque BurlyWood CadetBlue Chocolate Coral Crimson DarkCyan DarkGray \
8DarkMagenta DarkSlateGreen DarkTurquoise Green HotPink Indigo Lavender MidnightBlue \
9Peru RosyBrown SaddleBrown Sienna Teal Yellow)
10
11get_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}
19get_color() {
20 colorno=$((${#colors[@]} - 1))
21 idx=$(shuf -i 0-$colorno -n 1)
22 color=${colors[$idx]}
23}
24decompose_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
30decompose_sdom
31
32echo "<svg width='$w' height='$h'>"
33
34for 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>"
39done
40
41echo "</svg>"