#!/bin/bash # Parse Tellico database to BioOSM index.htm # $1 = tellico .tc file # $2 = "" terminal stderr (default) # = "html" html marked stderr (for web bioosm) # # Print result to /jsonrss/*.json # # find ./ -type f -name '*.jpg' -newermt "2023-09-03" -exec mogrify -verbose -layers Dispose -resize 1600\>x1600\> -quality 90% {} + # echo "14.7345 48.7145" | gdallocationinfo -wgs84 ./cesko_big.tiff # gdal_translate -of GTiff -a_srs WGS84 -a_ullr 11.6863 50.9745 19.9876 48.3729 ./source.tif ./result.tif # https://data.geus.dk/egdi/#baslay=baseMapGEUS&extent=3953440,2399890,4757540,2763830&layers=igme5000 #bnds=new OpenLayers.Bounds(11.6863000,48.3729000 ,19.9876000,50.9745000); #var geoimg = new OpenLayers.Layer.Image("geo","https://brmlab.s0c4.net/bioosm/eusr5000_600dpi_cesko.png", bnds,bnds.getSize(),{numZoomLevels: 20,isBaseLayer:false}); #map.addLayer(geoimg); # # # // vectorLayer.removeFeatures(atol) # // map.removeLayer(vectorLayer) # # # Creates: # (to stdout) HTML file with the map and static entries # ./det/ID.htm details of each and every entry # ./bioosm.json JSON of all entries # ./bioosm.rss updated RSS feed # ./plainlog.htm sorted entries for easy human/alg # rm -rfv "./det/*" mkdir -p "./det" ICON_animalia="animalia.png" ICON_bacteria="bacteria.png" ICON_fungi="fungi.png" ICON_chromista="chromista.png" ICON_plantae="plantae.svg" ICON_plostenkoid="plostenkoid.png" ICON_protista="protista.png" ICON_biohazard="biohazard.svg" json="" geojson="" rss=$'\n' rss+=$'\n' rss+=$'\n' rss+=$'Brmlab BioOSM RSS feed\n' rss+=$'New entries in the BioOSM database\n' rss+=$'https://bioosm.s0c4.net\n' rss+=$'\n' rss+=$'\n' rss+=$'86400\n' errhtml="$2" # paticka (co, rok, odkaz) function obioosm () { r="

Welcome to BioOSM! This site is owned and maintained by members of the hackerspace brmlab. See our wiki page for further details
License: CC BY-NC-ND. In case you have any questions, suggestions, please let us know at bioosms0c4.net.

To cite any material (including images) in your publication, please use following format:
Plskova, K., Sacha, M., brmlab. BioOSM" if [[ "$1" != "" ]]; then r+=" - $1" fi r+=". " if [[ "$2" != "" ]]; then r+="$2. " else r+="2023. " fi if [[ "$3" != "" ]]; then r+="$3" else r+="https://bioosm.s0c4.net" fi r+="

" echo "$r" } # HTML fajl per project function genhtml() { o=$(obioosm "$1" "" "" | sed -e 's/\//\\\//g') # make "\/" from "/" so sed below is OK h=$(cat "./__BIOVZOR__.htm" | sed -e "s/__BIOVZOR_TIT__/$1/g" | sed -e "s/__BIOVZOR_CPRT__/$o/g" | sed -e "s/__BIOVZOR_J__/$1/g") echo "$h" > "./jsonrss/$1.htm" echo "*** $1 done ***" } # Return icon by Regnum function geticon () { case "$1" in "Animalia") echo "$ICON_animalia";; "Bacteria") echo "$ICON_bacteria";; "Fungi") echo "$ICON_fungi";; "Chromista") echo "$ICON_chromista";; "Plantae") echo "$ICON_plantae";; "Protista") echo "$ICON_protista";; *) echo "$ICON_biohazard";; esac } function safehtml () { echo "$1" | sed -e 's/#/%23/g' -e "s/'/\'/g" -e 's/"/\"/g' -e 's//\>/g' -e 's/^[ ]*//g' -e 's/[ ]*$//g' } function getgeo () { #g=$(echo "$1 $2" | gdallocationinfo -wgs84 ./geo/eusr5000_600dpi_cesko_8b_geo.tif | grep -v 255 | grep -oPe '[0-9]+$') g=$(echo "$1 $2" | gdallocationinfo -wgs84 ./geo/eusr5000_600dpi_cesko_8b_geo.tif | grep -v 255 | grep -oE '[0-9]+$') case "$g" in "1") echo "Fluvial deposits, sediments";; "128") echo "Weathering residues of different rocks, loess";; "130") echo "Volcanic rocks";; "133") echo "Igneous and metamorphic rocks, Palaeozoic sedimentary rocks, loess";; "143") echo "Loess, igneous and metamorphic rocks";; "144") echo "Loess, Cretaceous sandstone and marl";; "147") echo "Igneous, metamorphic and Palaeozoic sedimentary rocks, loess";; "148") echo "Igneous and metamorphic rocks, loess";; "149") echo "Igneous and metamorphic rocks, Palaeozoic sedimentary rocks, loess";; # asi fakt stejny jako 133 omg "150") echo "Igneous and metamorphic rocks, palaeozoic sedimentary rocks";; "153") echo "Sandy and loamy loess, Tertiary sediments, fluvial deposits";; "205") echo "Cretaceous and Tertiary flysch, marl, sandstone, limestone";; *) echo "";; esac } i=1 # GLOBAL increment must persist multiple spagety() calls; incremented to infinity # Core function generating entries matching selection criteria (ie Kingdom) # !!! BEZ ODSAZENI !!! # $1 = list of entries # $2 = layer name = JSON filename without suffix # $3 = icon of the points function spagety () { if [[ "$errhtml" == "" ]]; then >&2 echo "===== $2 =====" else >&2 echo "

$2

" fi bylo="" # Minula pozice sam="" # HTML samostatneho zaznamu osam="" # predchozi $sam spoj="" # HTML had z popisu stejnych pozic ospoj="" # Predchozi $spoj ox="" # Old X oy="" # Old Y datelog="" # Entries sorted by date for plaintext log json="var data='{\"version\":\"$(date --rfc-3339=seconds)\",\"fund\":\"$2\",\"arma\":[" geojson='{"type":"FeatureCollection","version":"BIOOSM_' geojson+="$(date --rfc-3339=seconds)" geojson+='","features":[' while IFS='' read -r radek || [[ -n "$radek" ]]; do if [[ "$radek" = "" ]]; then continue; fi entryid=$(echo "$radek" | sed -E 's/^.*.*$/\1/g;t;d') co=$(echo "$radek" | sed -E 's/^.*(.*)<\/title>.*$/\1/g;t;d') co=$(safehtml "$co") obr=$(echo "$radek" | sed -E 's/^.*<image>(.*)<\/image>.*$/\1/g;t;d' | sed -E 's/^.*\///g') kde=$(echo "$radek" | sed -E 's/^.*<locality>(.*)<\/locality>.*$/\1/g;t;d') kde=$(safehtml "$kde") kdex=$(echo "$kde" | sed -E 's/^[0-9]+\.[0-9]+[, ]*//g;t;d') # keep second part kdey=$(echo "$kde" | sed -E 's/[, ]*[0-9]+\.[0-9]+$//g;t;d') # keep first part kdy=$(echo "$radek" | sed -E 's/^.*<taken-date>(.*)<\/taken-date>.*$/\1/g;t;d' | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]{4})/\3-\2-\1/g' | sed -E 's/-([0-9])-/-0\1-/g' | sed -E 's/-([0-9])$/-0\1/g') kdy=$(safehtml "$kdy") skop_typ=$(echo "$radek" | sed -E 's/^.*<new-field-1>(.*)<\/new-field-1>.*$/\1/g;t;d') skop_typ=$(safehtml "$skop_typ") skop=$(echo "$radek" | sed -E 's/^.*<microscope>(.*)<\/microscope>.*$/\1/g;t;d') skop=$(safehtml "$skop") imp=$(echo "$radek" | sed -E 's/^.*<new-field-3>(.*)<\/new-field-3>.*$/\1/g;t;d') imp=$(safehtml "$imp") reg=$(echo "$radek" | sed -E 's/^.*<new-field-4>(.*)<\/new-field-4>.*$/\1/g;t;d') reg=$(safehtml "$reg") phy=$(echo "$radek" | sed -E 's/^.*<phylum>(.*)<\/phylum>.*$/\1/g;t;d') phy=$(safehtml "$phy") cla=$(echo "$radek" | sed -E 's/^.*<class>(.*)<\/class>.*$/\1/g;t;d') cla=$(safehtml "$cla") ord=$(echo "$radek" | sed -E 's/^.*<order>(.*)<\/order>.*$/\1/g;t;d') ord=$(safehtml "$ord") fam=$(echo "$radek" | sed -E 's/^.*<family>(.*)<\/family>.*$/\1/g;t;d') fam=$(safehtml "$fam") gen=$(echo "$radek" | sed -E 's/^.*<genus>(.*)<\/genus>.*$/\1/g;t;d') gen=$(safehtml "$gen") spe=$(echo "$radek" | sed -E 's/^.*<species>(.*)<\/species>.*$/\1/g;t;d') spe=$(safehtml "$spe") loc=$(echo "$radek" | sed -E 's/^.*<locality---plaintext>(.*)<\/locality---plaintext>.*$/\1/g;t;d') loc=$(safehtml "$loc") des=$(echo "$radek" | sed -E 's/^.*<description>(.*)<\/description>.*$/\1/g;t;d') des=$(safehtml "$des") vid=$(echo "$radek" | sed -E 's/^.*<videolink>(.*)<\/videolink>.*$/\1/g;t;d') vid=$(safehtml "$vid") bio=$(echo "$radek" | sed -E 's/^.*<biotope>(.*)<\/biotope>.*$/\1/g;t;d') bio=$(safehtml "$bio") eng=$(echo "$radek" | sed -E 's/^.*<enlargement>(.*)<\/enlargement>.*$/\1/g;t;d') eng=$(safehtml "$eng") obs=$(echo "$radek" | sed -E 's/^.*<observer>(.*)<\/observer>.*$/\1/g;t;d') obs=$(safehtml "$obs") lnk=$(echo "$radek" | sed -E 's/^.*<localitylink>(.*)<\/localitylink>.*$/\1/g;t;d') lnk=$(safehtml "$lnk") har=$(echo "$radek" | sed -E 's/^.*<harvesting-method>(.*)<\/harvesting-method>.*$/\1/g;t;d') den=$(echo "$radek" | sed -E 's/^.*<population-density>(.*)<\/population-density>.*$/\1/g;t;d') dur=$(echo "$radek" | sed -E 's/^.*<min>(.*)<\/min>.*$/\1/g;t;d') lor=$(echo "$radek" | sed -E 's/^.*<locality-reference>(.*)<\/locality-reference>.*$/\1/g;t;d') lrl=$(echo "$radek" | sed -E 's/^.*<locality-reference---link>(.*)<\/locality-reference---link>.*$/\1/g;t;d') lov=$(echo "$radek" | sed -E 's/^.*<locality---vobrazek>(.*)<\/locality---vobrazek>.*$/\1/g;t;d' | sed -E 's/^.*\///g') lov=$(safehtml "$lov") cls=$(echo "$radek" | sed -E 's/^.*<cluster>([0-9]*)<\/cluster>.*$/\1/g;t;d') mpi=$(echo "$radek" | grep -oe ' <mainpic>yep</mainpic> ') elv=$(echo "$kdex $kdey" | gdallocationinfo -wgs84 ./elev/cesko_big.tiff | grep "Value" | grep -oe '[0-9]+$') geo=$(getgeo "$kdex" "$kdey") gra=$(echo "$radek" | sed -E 's/^.*<grant>(.*)<\/grant>.*$/\1/g;t;d') tem=$(echo "$radek" | sed -E 's/^.*<temperature>(.*)<\/temperature>.*$/\1/g;t;d') cnd=$(echo "$radek" | sed -E 's/^.*<conductivity>(.*)<\/conductivity>.*$/\1/g;t;d') ph=$(echo "$radek" | sed -E 's/^.*<ph>(.*)<\/ph>.*$/\1/g;t;d') kar=$(echo "$radek" | sed -E 's/^.*<karyotype>(.*)<\/karyotype>.*$/\1/g;t;d') lid=$(echo "$radek" | sed -E 's/^.*<localityid>(.*)<\/localityid>.*$/\1/g;t;d') # if [[ "$errhtml" == "" ]]; then # >&2 echo "$co - $har - $den - $dur - $lor - $lrl - $lov - $elv" # else # >&2 echo "<span class='nok'>$co - $har - $den - $dur - $lor - $lrl - $lov - $elv</span><br>" # fi # continue; detid=$(echo "brmlab$co$obr$kde$kdy" | md5sum | grep -oe '[a-zA-Z0-9]*') if [[ "$kdex" = "" ]]; then if [[ "$errhtml" == "" ]]; then >&2 echo -e "\033[31m $lid KDEX '$kde' '$co' \033[0m" >&2 echo -e "\033[31m $lid RADEK '$radek' \033[0m" else >&2 echo "<span class='nok'>$lid KDEX '$kde' '$co'</span><br>" >&2 echo "<span class='nok'><pre>$radek</pre></span>" fi fi zkurvenetellico=$(echo "$obr" | grep -oe '\.[a-zA-Z]*$') odkurvenyobr=$(echo "$obr" | sed -e 's/%23/#/g') #if [[ "$zkurvenetellico" = ".jpeg" ]]; then if [[ ! -f "./img/$odkurvenyobr" ]]; then if [[ "$gen" != "negative" ]]; then if [[ "$errhtml" == "" ]]; then >&2 echo -e "\033[31m $lid OBR $odkurvenyobr $co\033[0m" else >&2 echo "<span class='nok'>$lid OBR $odkurvenyobr $co</span>" fi continue; fi fi obr=$(safehtml "$obr") if [[ "$spe" = "sp." ]]; then wikisp="https://en.wikipedia.org/wiki/$gen" else wikisp="https://en.wikipedia.org/wiki/$gen $spe" fi povr="" povs="" pov="" if [[ "$phy" = "Platyhelminthes" ]]; then povr=$(cat "./povodi_r.json" | ./povodi.py "$kdey" "$kdex") #povrf=$(echo "$povr" | grep -oPe '^[^ ]*' | tr 'e' 'E') povrf=$(echo "$povr" | sed -e 's/ .*$//g' | tr 'e' 'E') povrn=$(echo "$povr" | sed -e 's/^[^ ]* //g') povs=$(cat "./povodi_s.json" | ./povodi.py "$kdey" "$kdex") #povsf=$(echo "$povs" | grep -oPe '^[^ ]*' | tr 'e' 'E') povsf=$(echo "$povs" | sed -e 's/ .*$//g' | tr 'e' 'E') povsn=$(echo "$povs" | sed -e 's/^[^ ]* //g') if (( $(echo "$povsf < $povrf" | bc -l) )) ; then pov="$povsn - $povrn" else pov="$povrn" fi fi if [[ "$cls" = "" ]]; then cls=0 fi if [[ "$mpi" = "" ]]; then mpi="" else mpi="y" fi Tjson="{" Tjson+=" \"title\":\"$co\"," # qualis Tjson+=" \"imperium\":\"$imp\"," Tjson+=" \"regnum\":\"$reg\"," Tjson+=" \"phylum\":\"$phy\"," Tjson+=" \"classis\":\"$cla\"," Tjson+=" \"ordo\":\"$ord\"," Tjson+=" \"familia\":\"$fam\"," Tjson+=" \"genus\":\"$gen\"," Tjson+=" \"specie\":\"$spe\"," Tjson+=" \"locality\":\"$kde\"," # locus Tjson+=" \"x\":\"$kdex\"," Tjson+=" \"y\":\"$kdey\"," Tjson+=" \"locplain\":\"$loc\"," Tjson+=" \"description\":\"$des\"," # depictio Tjson+=" \"takendate\":\"$kdy\"," # quando Tjson+=" \"obr\":\"$obr\"," Tjson+=" \"micro\":\"$skop\"," Tjson+=" \"microtyp\":\"$skop_typ\"," Tjson+=" \"videolink\":\"$vid\"," # vid Tjson+=" \"biotope\":\"$bio\"," # bio Tjson+=" \"enlargement\":\"$eng\"," # amp Tjson+=" \"observer\":\"$obs\"," # spec Tjson+=" \"detid\":\"$detid\"," Tjson+=" \"harvestingmethod\":\"$har\"," # har Tjson+=" \"populationdensity\":\"$den\"," # den Tjson+=" \"min\":\"$dur\"," # dur Tjson+=" \"localityreference\":\"$lor\"," # lor Tjson+=" \"localityreferencelink\":\"$lrl\"," #lrl Tjson+=" \"localityvobrazek\":\"$lov\"," # lov Tjson+=" \"localitylink\":\"$lnk\"," # lnk Tjson+=" \"cluster\":$cls," # cls Tjson+=" \"mainpic\":\"$mpi\"," # mpi Tjson+=" \"pov\":\"$pov\"," Tjson+=" \"elv\":\"$elv\"," Tjson+=" \"geo\":\"$geo\"," Tjson+=" \"temperature\":\"$tem\"," # tem Tjson+=" \"conductivity\":\"$cnd\"," # cnd Tjson+=" \"ph\":\"$ph\"," Tjson+=" \"karyotype\":\"$kar\"" # kar # Last without ',' Tjson+="}" json+="$Tjson," geojson+='{"type":"Feature","geometry":{"type":"point","coordinates":[' geojson+="$kdex,$kdey" geojson+=']},"properties":' geojson+="$Tjson}," rss+=$'<item>\n' rss+=$' <title>'"$co"$'\n' rss+=$' '"$des"$'\n' rss+=$' http://brmlab.s0c4.net/bioosm/det/'"$detid"$'.htm\n' rss+=$' '"$detid"$'\n' rss+=$' '"$kdy"$'\n' rss+=$'\n' # Generate detail page detid=$(echo "brmlab$co$obr$kde$kdy" | md5sum | grep -oe '[a-zA-Z0-9]*') detpg="" detpg+="" detpg+="" detpg+="Brmlab - BioOSM $co $kde" detpg+="" detpg+="" detpg+="" detpg+="" detpg+="" detpg+="" detpg+="" detpg+="" detpg+="" if [[ "$cls" != "0" ]]; then detpg+="" detpg+="" fi detpg+="" detpg+="" detpg+="

$co (wiki)

" detpg+="
" if [[ "$imp" != "" ]]; then detpg+="Domain: $imp
" fi if [[ "$reg" != "" ]]; then detpg+="Kingdom: $reg
" fi if [[ "$phy" != "" ]]; then detpg+="Phylum: $phy
" fi if [[ "$cla" != "" ]]; then detpg+="Class: $cla
" fi if [[ "$ord" != "" ]]; then detpg+="Order: $ord
" fi if [[ "$fam" != "" ]]; then detpg+="Family: $fam
" fi if [[ "$gen" != "" ]]; then detpg+="Genus: $gen
" fi if [[ "$spe" != "" ]]; then detpg+="Species: $spe
" fi if [[ "$kar" != "" ]]; then detpg+="Karyotype: $kar
" fi detpg+="
" if [[ "$kdy" != "" ]]; then detpg+="Date: $kdy
" fi if [[ "$lnk" != "" ]]; then loc="$loc" # Yes, escaped " fi detpg+="Place: $kde ($loc)
" if [[ "$elv" != "" ]]; then detpg+="Elevation: $elv m
" fi if [[ "$obs" != "" ]]; then detpg+="Observer: $obs
" fi if [[ "$bio" != "" ]]; then detpg+="Biotope: $bio
" fi if [[ "$pov" != "" ]]; then detpg+="River: $pov
" fi if [[ "$geo" != "" ]]; then detpg+="Bedrock: $geo
" fi if [[ "$tem" != "" ]]; then detpg+="Temperature: $tem °C
" fi if [[ "$cnd" != "" ]]; then detpg+="Conductivity: $cnd mSv
" fi if [[ "$ph" != "" ]]; then detpg+="pH: $ph
" fi detpg+="" if [[ "$skop" != "" ]]; then detpg+="Microscope: $skop ($skop_typ)
" fi detpg+="
" detpg+="" if [[ "$eng" != "" ]]; then detpg+="Amplification: $eng
" fi detpg+="
" if [[ "$vid" != "" ]]; then detpg+="Video: $vid
" fi if [[ "$har" != "" ]]; then detpg+="Collecting method: $har
" fi if [[ "$den" != "" ]]; then detpg+="Individuals found: $den
" fi if [[ "$dur" != "" ]]; then detpg+="Duration on stage: $dur
" fi if [[ "$lrl" != "" ]]; then detpg+="Locality reference: $lor
" elif [[ "$lor" != "" ]]; then detpg+="Locality reference: $lor
" fi detpg+="" if [[ "$des" != "" ]]; then detpg+="Description: $des
" fi detpg+="
" detpg+="
More on BioOSM map
" detpg+="
" lhx=$(echo "$kdex-0.022" | bc) lhy=$(echo "$kdey-0.010" | bc) pdx=$(echo "$kdex+0.022" | bc) pdy=$(echo "$kdey+0.010" | bc) detpg+="" detpg+="
" if [[ "$obr" != "" ]]; then detpg+="
\"$co\"
" detpg+="
" else if [[ "$vid" != "" ]]; then detyt=$(echo "$vid" | sed -e 's/youtube.com\/watch?v=/youtube.com\/embed\//g') detpg+="" else if [[ "$gen" == "negative" ]]; then detpg+="\"Negative" else detpg+="\"video\"" fi fi fi if [[ "$lov" != "" ]]; then detpg+="\"Locality
" fi detpg+="
" detpg+=$(obioosm "$co" "$quando" "https://brmlab.s0c4.net/bioosm/det/$detid.htm") detpg+="" echo "$detpg" > "./det/$detid.htm" # Plain log of entries datelog+="$kdy $kde $co
\n" if [[ "$errhtml" == "" ]]; then >&2 echo -e "\033[32m$lid $co $obs\033[0m" else >&2 echo "$lid $co $obs" fi ox="$kdex" oy="$kdey" i=$(($i+1)) done <<< $(echo "$1") # Zere parametr spaget, nikoli $1 scriptu !!! echo -e "$json{}]}" | sed -e "s/^var data='//g" > "./jsonrss/$2.json" # echo -e "$json{}]}'" echo -e "$geojson{}]}" > "./jsonrss/geo_$2.geojson" rss+=$'
\n' rss+=$'
\n' echo "$rss" > "./jsonrss/$2.rss" } # KONEC FCE SPAGETY # Sorted unique Kingdoms (to be passed as selection criteria) #kingdoms=$(unzip -p "$1" tellico.xml | grep -oe '.*' | sed -E 's/( )*<(\/)?new-field-4>( )*//g' | sort | uniq) kingdoms=$(unzip -p "$1" tellico.xml | sed -E 's/^.*(.*)<\/new-field-4>.*$/\1/g;t;d' | sort | uniq) #echo '' #echo '' #echo '' #echo ' ' #echo ' brmlab - BioOSM' #echo ' ' #echo ' ' #echo ' ' #echo '' #echo '' ## Generate select #echo "
RSS feed
Quick news log
" ##echo "

BioOSM - arma biologica in tuis vicinia

" #echo "

BioOSM - creatures around us

" # #ksel="" #echo "Kingdom: $ksel " #echo "Phylum: " #echo "Class: " #echo "Order: " #echo "Family: " #echo "Genus: " #echo "Species: " # #echo "
" #echo "" ##echo "" #echo "
" #echo "

" #echo $(obioosm "" "" "") #echo "" # #echo "' #echo '' # Must be after JSON #echo "" # Create plaintext log dateloghtm="" dateloghtm+="" dateloghtm+="" dateloghtm+="Brmlab - BioOSM plaintext log" dateloghtm+="" datelogsort=$(echo -e "$datelog" | sort -r | uniq) dateloghtm+="$datelogsort" dateloghtm+="" echo "$dateloghtm" > "./plainlog.htm"