[[BioOSM]]
 

BioOSM

Biologicke zbrane ve vasem okoli
bioosm.jpg
founder: sachy
depends on:
interested: sumie-dh
software license: CC-BY-SA
hardware license: N/A

BioOSM je mapa vyskytu mikroorganismu (ras, bakterii, plostenek, …) a do budoucna i dalsich prirodnin (mineralu, …).

K cemu to je

  • interaktivni mapa vhodna k zobrazovani vetsiho mnozstvi fotek, brmlabi wiki, sluzby typu phtagr a soup se zdaly nevhodne k publikaci tohoto typu obsahu, wiki by byla prilis obludna, na beznych sdilecich obrazkovych sluzbach se neda nic pohodlne dohledavat a davat tam biologicky smysluplne a prehledne popisky
  • monitoring zivocichu a rostlin podle zajmu prispevovatelu
  • snadne klikaci katalogovani nalezu skrze Tellico nevyzadujici coding skills
  • TODO - jednoduche selekce zajmoveho okruhu subjektu [napr. podle rodu, biotopu, datumu] na mape
  • procvicovani temne magie commandu grep, sed a regexpu

Jak to funguje

Podklad jsou OSM, ktere maji API OpenLayers jez umoznuje pridavat do mapy vlastni body, vrstvy…

Jednotliva pozorovani jsou v databazi Tellico. Udelal jsem script parse_tellico.sh, ktery z .tc databaze (je to vlastne ZIP s XML uvnitr) vyparsuje jednotlive polozky a vygeneruje HTML soubor s mapou a podadresar “det” s HTML strankami s detaily jednotlivych pozorovani.

Obrazky v plnem rozliseni jsou v podadresari “img”, nahledy v “simg”. Videa jsou nahrana na YT a misto nahledu maji generickou ikonu.

Pozorovani ktera se v mape zobrazi lze filtrovat dle prislusnosti k radu (bakterie, zvirata, rostliny,…) pripadne cimkoli co lze grepnout z Tellico XML.

Tellico sample database

Az se mi ho podari nekam nahrat tak nekde bude. Nebo mozna nejaky webxicht…

Kusy zdrojaku k nezapomenuti

Extrakce polozek z Tellico databaze

  1. ziskani tellico.xml
  2. radkovani dle polozek
  3. pouze verejne (strcit-do-mapy = yep)
  4. preneseni lokality na zacatek radku s informacemi o polozce
  5. seskupeni dle lokality
praseTC=$(unzip -p "$1" tellico.xml | tr -d '\n' | sed -e $'s/<entry id="/\\\n<entry id="/g' -e $'s/<\/entry>/<\/entry>\\\n/g' | grep -Pe '^<entry id="' | grep "<strcit-do-mapy>yep</strcit-do-mapy>" | sed -E 's/(^.*)(<locality>.*<\/locality>)(.*$)/\2\1\3/' | sort)

Prepinani vrstev

Nazvy vrstev musi byt v JS poli kvuli ovladacimu API (skryti/zobrazeni)

var laycon = [vectorLayer,ALL];
...
laycon.push(vrstva);
var controls = {
  selector: new OpenLayers.Control.SelectFeature(laycon,{onSelect: createPopup, onUnselect: destroyPopup})
};
map.addControl(controls['selector']);
controls['selector'].activate();

Prepnuti viditelnych vrstev

function kinchange() {
  kinsel=document.getElementById('kin');
  kinopt=kinsel.options[kinsel.selectedIndex].text;
  for (var i = map.layers.length - 1; i >= 1; i--) {
    map.removeLayer(map.layers[i]);
  }
  map.addLayer(window[kinopt])
}

Nastaveni brmlabu do paticky map

OpenLayers.Layer.Vector('Overlay',{attribution:'<a href="http://brmlab.cz">Brmlab</a>'});

Umisteni copyrightu

OSM maji defaultne copyright nesmyslne odsazeny od spodniho okraje mapy, CSS zmena na nejaky rozumny offset:

.olControlAttribution
{
  bottom:0.5em;
}

parse_tellico.sh

parse_tellico.sh
#!/bin/bash
# Parse Tellico database to BioOSM index.htm
# $1 = tellico .tc file
# Print result to stdout
#
# find ./ -type f -exec mogrify -verbose -layers Dispose -resize 128\>x128\> -quality 100% {} +
#
# // vectorLayer.removeFeatures(atol)
# // map.removeLayer(vectorLayer)
#
#
# Creates:
#   (to stdout) index.htm file with the map and static entries
#   ./det/ID.htm details of each and every entry
#
 
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"
 
# 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
}
 
 
rm -rfv "./det/*"
mkdir -p "./det"
#cat "./index_head.htm"
 
# Parse Tellico file to list of entries
praseTC=$(unzip -p "$1" tellico.xml | tr -d '\n' | sed -e $'s/<entry id="/\\\n<entry id="/g' -e $'s/<\/entry>/<\/entry>\\\n/g' | grep -Pe '^<entry id="' | grep "<strcit-do-mapy>yep</strcit-do-mapy>" | sed -E 's/(^.*)(<locality>.*<\/locality>)(.*$)/\2\1\3/' | sort)
 
# Sorted unique Kingdoms (to be passed as selection criteria)
kingdoms=$(echo "$praseTC" | grep -oe ' <new-field-4>.*</new-field-4> ' | sed -E 's/( )*<(\/)?new-field-4>( )*//g' | sort | uniq)
 
 
echo '<!DOCTYPE html>'
echo '<html>'
echo '<head>'
echo '	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
echo '	<title>brmlab - BioOSM</title>'
echo '	<link rel="stylesheet" href="./style.css" type="text/css">'
echo '	<link rel="favicon" href="./'$ICON_biohazard'">'
echo '	<script src="./OpenLayers.js"></script>'
echo '</head>'
 
echo "<body>"
	echo "<div style='position:absolute;top:0;right:0;margin:1em'><b><a href='./plainlog.htm'>Plaintext log</a></b></div>"
	echo "<h1 id='title'>BioOSM - arma biologica in tuis vicinia</h1>"
 
	# Generate select
	ksel="<select id='kin' onChange='kinchange()'>"
	ksel="$ksel<option value='ALL' selected>ALL</option>"
	while IFS='' read -r king || [[ -n "$king" ]]; do
		ksel="$ksel<option value='"$king"'>$king</option>"
	done <<< $(echo "$kingdoms")
	ksel="$ksel</select>"
	echo "Regnum: $ksel | "
	echo "<input type='button' value='Plostenkoidy' onClick='plostenkoid()'><br><br>"
 
  echo "<div id='map' class='smallmap'></div>"
echo "</body>"
 
echo '<script>'
 
echo 'map = new OpenLayers.Map("map");'
echo 'map.addLayer(new OpenLayers.Layer.OSM());'
echo 'epsg4326 =  new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection'
echo 'projectTo = map.getProjectionObject(); //The map projection (Spherical Mercator)'
echo 'var lonLat = new OpenLayers.LonLat(15.478, 49.817).transform(epsg4326, projectTo);'
echo 'var zoom=8;'
echo 'map.setCenter (lonLat, zoom);'
 
echo 'var vectorLayer = new OpenLayers.Layer.Vector("Overlay",{attribution:"<a href=\"http://brmlab.cz\">Brmlab</a>"});'
 
echo '// Define markers as "features" of the vector layer:'
 
echo 'var atol = new OpenLayers.Feature.Vector('
echo '	new OpenLayers.Geometry.Point(14.41876, 50.10554).transform(epsg4326, projectTo),'
echo '		{description:"Atomovy atol Brmkini"} ,'
echo '		{externalGraphic: "./biohazard.svg", graphicHeight:24, graphicWidth:24, graphicXOffset:-12, graphicYOffset:-12},'
echo ');'
echo 'vectorLayer.addFeatures(atol);'
# Sem prijdou dalsi staticke ficury
echo "map.addLayer(vectorLayer);"
 
 
 
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
# $3 = icon of the points
function spagety () {
 
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
 
 
while IFS='' read -r radek || [[ -n "$radek" ]]; do
 
	co=$(echo "$radek" | grep -oe ' <title>.*</title> ' | sed -E 's/( )*<(\/)?title>( )*//g')
	obr=$(echo "$radek" | grep -oe ' <image>.*</image> ' | sed -E 's/( )*<(\/)?image>( )*//g' | grep -oPe '[^/]*$')
	kde=$(echo "$radek" | grep -oe '<locality>.*</locality>' | grep -oPe '[0-9]{2}\.[0-9]{1,10}[, ]*[0-9]{2}\.[0-9]{1,10}')
	kdex=$(echo "$kde" | grep -oPe '[0-9]{2}\.[0-9]{1,10}$')
	kdey=$(echo "$kde" | grep -oPe '^[0-9]{2}\.[0-9]{1,10}')
	kdy=$(echo "$radek" | grep -oe ' <taken-date>.*</taken-date> ' | sed -E 's/( )*<(\/)?taken-date>( )*//g' | 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')
	skop_typ=$(echo "$radek" | grep -oe ' <new-field-1>.*</new-field-1> ' | sed -E 's/( )*<(\/)?new-field-1>( )*//g')
	skop=$(echo "$radek" | grep -oe ' <microscope>.*</microscope> ' | sed -E 's/( )*<(\/)?microscope>( )*//g')
	imp=$(echo "$radek" | grep -oe ' <new-field-3>.*</new-field-3> ' | sed -E 's/( )*<(\/)?new-field-3>( )*//g')
	reg=$(echo "$radek" | grep -oe ' <new-field-4>.*</new-field-4> ' | sed -E 's/( )*<(\/)?new-field-4>( )*//g')
	phy=$(echo "$radek" | grep -oe ' <phylum>.*</phylum> ' | sed -E 's/( )*<(\/)?phylum>( )*//g')
	cla=$(echo "$radek" | grep -oe ' <class>.*</class> ' | sed -E 's/( )*<(\/)?class>( )*//g')
	ord=$(echo "$radek" | grep -oe ' <order>.*</order> ' | sed -E 's/( )*<(\/)?order>( )*//g')
	fam=$(echo "$radek" | grep -oe ' <family>.*</family> ' | sed -E 's/( )*<(\/)?family>( )*//g')
	gen=$(echo "$radek" | grep -oe ' <genus>.*</genus> ' | sed -E 's/( )*<(\/)?genus( )*>//g')
	spe=$(echo "$radek" | grep -oe ' <species>.*</species> ' | sed -E 's/( )*<(\/)?species>( )*//g')
	loc=$(echo "$radek" | grep -oe ' <locality---plaintext>.*</locality---plaintext> ' | sed -E 's/( )*<(\/)?locality---plaintext>( )*//g')
	des=$(echo "$radek" | grep -oe ' <description>.*</description> ' | sed -E 's/( )*<(\/)?description>( )*//g')
	vid=$(echo "$radek" | grep -oe ' <videolink>.*</videolink> ' | sed -E 's/( )*<(\/)?videolink>( )*//g')
	bio=$(echo "$radek" | grep -oe ' <biotope>.*</biotope> ' | sed -E 's/( )*<(\/)?biotope>( )*//g')
	eng=$(echo "$radek" | grep -oe ' <enlargement>.*</enlargement> ' | sed -E 's/( )*<(\/)?enlargement>( )*//g')
	obs=$(echo "$radek" | grep -oe ' <observer>.*</observer> ' | sed -E 's/( )*<(\/)?observer>( )*//g')
 
 
	if [[ "$kdex" = "" ]]; then
		>&2 echo $(echo "$radek" | grep -oe '<locality>.*</locality>') " $co"
		continue;
	fi
	zkurvenetellico=$(echo "$obr" | grep -oe '\.[a-zA-Z]*$')
	if [[ "$zkurvenetellico" = ".jpeg" ]]; then
		>&2 echo "$obr $co"
		continue;
	fi
 
 
	# Generate detail page
	detid=$(echo "brmlab$co$obr$kde$kdy" | md5sum | grep -oe '[a-zA-Z0-9]*')
	detpg="<html><head>"
	detpg="$detpg<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
	detpg="$detpg<link rel='stylesheet' href='../style.css' type='text/css'>"
	detpg="$detpg<title>Brmlab - BioOSM $co $kde</title>"
	detpg="$detpg</head><body>"
	detpg="$detpg<table class='dettbl'><tr>"
	detpg="$detpg<td><h1>$co (<a href='https://en.wikipedia.org/wiki/$co' target='_blank'>wiki</a>)</h1>"
	if [[ "$imp" != "" ]]; then
		detpg="$detpg<b>Imperium:</b> <a href='https://en.wikipedia.org/wiki/$imp' target='_blank'>$imp</a><br>"
	fi
	if [[ "$reg" != "" ]]; then
		detpg="$detpg<b>Regnum:</b> <a href='https://en.wikipedia.org/wiki/$reg' target='_blank'>$reg</a><br>"
	fi
	if [[ "$phy" != "" ]]; then
		detpg="$detpg<b>Phylum:</b> <a href='https://en.wikipedia.org/wiki/$phy' target='_blank'>$phy</a><br>"
	fi
	if [[ "$cla" != "" ]]; then
		detpg="$detpg<b>Classis:</b> <a href='https://en.wikipedia.org/wiki/$cla' target='_blank'>$cla</a><br>"
	fi
	if [[ "$ord" != "" ]]; then
		detpg="$detpg<b>Ordo:</b> <a href='https://en.wikipedia.org/wiki/$ord' target='_blank'>$ord</a><br>"
	fi
	if [[ "$fam" != "" ]]; then
		detpg="$detpg<b>Familia:</b> <a href='https://en.wikipedia.org/wiki/$fam' target='_blank'>$fam</a><br>"
	fi
	if [[ "$gen" != "" ]]; then
		detpg="$detpg<b>Genus:</b> <a href='https://en.wikipedia.org/wiki/$gen' target='_blank'>$gen</a><br>"
	fi
	if [[ "$spe" != "" ]]; then
		detpg="$detpg<b>Specie:</b> $spe<br>"
	fi
	detpg="$detpg<br>"
	if [[ "$kdy" != "" ]]; then
		detpg="$detpg<b>Quando:</b> $kdy<br>"
	fi
	detpg="$detpg<b>Locus:</b> $kde ($loc)<br>"
	if [[ "$obs" != "" ]]; then
		detpg="$detpg<b>Spectator:</b> $obs<br>"
	fi
	if [[ "$bio" != "" ]]; then
		detpg="$detpg<b>Biotope:</b> $bio<br>"
	fi
	detpg="$detpg<br>"
	if [[ "$skop" != "" ]]; then
		detpg="$detpg<b>Microscopium:</b> $skop ($skop_typ)<br>"
	fi
	if [[ "$eng" != "" ]]; then
		detpg="$detpg<b>Amplificatio:</b> $eng<br>"
	fi
	detpg="$detpg<br>"
	if [[ "$des" != "" ]]; then
		detpg="$detpg<b>Depictio:</b> $des<br>"
	fi
	if [[ "$vid" != "" ]]; then
		detpg="$detpg<b>Video:</b> <a href=\"$vid\" target=\"_blank\">$vid</a><br>"
	fi
	detpg="$detpg</td><td style='min-width:66%'>"
	if [[ "$obr" != "" ]]; then
		detpg="$detpg<a href=\"../img/$obr\"><img src=\"../img/$obr\" alt=\"$co\" class='detimg'></a>"
	else
		if [[ "$vid" != "" ]]; then
			detyt=$(echo "$vid" | sed -e 's/youtube.com\/watch?v=/youtube.com\/embed\//g')
			detpg="$detpg<iframe class='detvid' src='$detyt' frameborder='0' allow='encrypted-media' allowfullscreen></iframe>"
		else
			detpg="$detpg<img src=\"../$3\" alt=\"video\" class='detimg'>"
		fi
	fi
	detpg="$detpg</td></tr></table>"
	detpg="$detpg</body></html>"
	echo "$detpg" > "./det/$detid.htm"
 
	# Plain log of entries
	datelog="$datelog $kdy $kde <a href='./det/$detid.htm' target='_blank'>$co</a><br>\n"
 
	# Pokracujem v hadovi
	if [[ "$kde" = "$bylo" ]]; then
		sam="";
		spoj="$spoj<tr><td><a href=\"./det/$detid.htm\" target=\"_blank\">"
		if [[ "$obr" != "" ]]; then
			spoj="$spoj<img src=\"./simg/$obr\" class=\"hadimg\"></a></td>"
		else
			spoj="$spoj<img src=\"./$3\" class=\"hadimg\"></a></td>"
		fi
		spoj="$spoj<td>$co<br>$kdy</td>"
		spoj="$spoj<!-- $reg -->" # Metadata
		spoj="$spoj</tr>"
		ox="$kdex"
		oy="$kdey"
		continue;
	fi
 
	# Bud prvni zaznam, nebo zmena pozice
 
	# Predchozi pozice jen 1 zaznam?
	if [[ "$sam" != "" ]]; then
		samicon=$(geticon $(echo "$sam" | grep -oPe "<b>Regnum:</b> <[^>]*>[a-zA-Z0-9]*" | grep -oPe "[a-zA-Z0-9]*$"))
		# >&2 echo "$samicon"
 
		echo "var n$i = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point($ox,$oy).transform(epsg4326,projectTo),{description:'"$sam"'},{externalGraphic:'./$samicon',graphicHeight:24,graphicWidth:24,graphicXOffset:-12,graphicYOffset:-12});"
		echo "$2.addFeatures(n$i);"
		spoj=""
		sam=""
	fi # ELSE vytvori prazdny radek
	# Predchozi pozice vic zaznamu?
	if [[ "$spoj" != "" ]]; then
		muchicons=$(echo "$spoj" | grep -oPe "<!-- [a-zA-Z0-9]* -->" | grep -oPe "[a-zA-Z0-9]*" | sort | uniq | wc -l)
		#>&2 echo "*** $muchicons"
		if [[ "$muchicons" == "1" ]]; then
			spojicon=$(geticon $(echo "$spoj" | grep -oPe "<!-- [a-zA-Z0-9]* -->" | grep -oPe "[a-zA-Z0-9]*" | sort | uniq))
			#>&2 echo "*** $spojicon"
		else
			spojicon="$ICON_biohazard"
		fi
		echo "var n$i = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point($ox,$oy).transform(epsg4326,projectTo),{description:'<table class=\"hadtbl\">"$spoj"</table>'},{externalGraphic:'./$spojicon',graphicHeight:24,graphicWidth:24,graphicXOffset:-12,graphicYOffset:-12});"
    echo "$2.addFeatures(n$i);"
		spoj=""
		sam=""
	fi
 
	bylo="$kde"
	spoj="<tr><td><a href=\"./det/$detid.htm\" target=\"_blank\">"
	if [[ "$obr" != "" ]]; then
		spoj="$spoj<img src=\"./simg/$obr\" class=\"hadimg\"></a></td>"
	else
		spoj="$spoj<img src=\"./$3\" class=\"hadimg\"</a></td>"
	fi
	spoj="$spoj<td>$co<br>$kdy</td>"
	spoj="$spoj<!-- $reg -->" # Metadata pyco
	spoj="$spoj</tr>"
 
	sam="<a href=\"./det/$detid.htm\" target=\"_blank\"><img src=\"./simg/$obr\" alt=\"$co\" class=\"buttimg\"></a>"
	sam="$sam<br><span class=\"butttext\">"
	sam="$sam<b>Qualis:</b> <a href=\"https://en.wikipedia.org/wiki/$co\" target=\"_blank\">$co</a><br>"
	if [[ "$imp" != "" ]]; then
		sam="$sam<b>Imperium:</b> <a href=\"https://en.wikipedia.org/wiki/$imp\" target=\"_blank\">$imp</a><br>"
	fi
	if [[ "$reg" != "" ]]; then
		sam="$sam<b>Regnum:</b> <a href=\"https://en.wikipedia.org/wiki/$reg\" target=\"_blank\">$reg</a><br>"
	fi
	if [[ "$phy" != "" ]]; then
		sam="$sam<b>Phylum:</b> <a href=\"https://en.wikipedia.org/wiki/$phy\" target=\"_blank\">$phy</a><br>"
	fi
	if [[ "$cla" != "" ]]; then
		sam="$sam<b>Classis:</b> <a href=\"https://en.wikipedia.org/wiki/$cla\" target=\"_blank\">$cla</a><br>"
	fi
	if [[ "$ord" != "" ]]; then
		sam="$sam<b>Ordo:</b> <a href=\"https://en.wikipedia.org/wiki/$ord\" target=\"_blank\">$ord</a><br>"
	fi
	if [[ "$fam" != "" ]]; then
		sam="$sam<b>Familia:</b> <a href=\"https://en.wikipedia.org/wiki/$fam\" target=\"_blank\">$fam</a><br>"
	fi
	if [[ "$gen" != "" ]]; then
		sam="$sam<b>Genus:</b> <a href=\"https://en.wikipedia.org/wiki/$gen\" target=\"_blank\">$gen</a><br>"
	fi
	if [[ "$spe" != "" ]]; then
		sam="$sam<b>Specie:</b> $spe<br>"
	fi
	if [[ "$bio" != "" ]]; then
		sam="$sam<b>Biotope:</b> $bio<br>"
	fi
	if [[ "$kdy" != "" ]]; then
		sam="$sam<b>Quando:</b> $kdy<br>"
	fi
	sam="$sam<b>Locus:</b> $kde ($loc)<br>"
	if [[ "$obs" != "" ]]; then
		sam="$sam<b>Spectator:</b> $obs<br>"
	fi
	if [[ "$skop" != "" ]]; then
		sam="$sam<b>Microscopium:</b> $skop ($skop_typ)<br>"
	fi
	if [[ "$eng" != "" ]]; then
		sam="$sam<b>Amplificatio:</b> $eng<br>"
	fi
#	if [[ "$des" != "" ]]; then
#		sam="$sam<b>Depictio:</b> $des<br>"
#	fi
	if [[ "$vid" != "" ]]; then
		sam="$sam<b>Video:</b> <a href=\"$vid\" target=\"_blank\">$vid</a><br>"
	fi
	sam="$sam</span>"
 
	>&2 echo "$co $obs"
 
 
	ox="$kdex"
	oy="$kdey"
 
 
	i=$(($i+1))
 
	# Precti XML, vyfiltruj jen to co ma prijit do mapy a serad to dle umisteni
	#  Umisteni je razene kvuli vic vzorkum z jednoho mista
 
done <<< $(echo "$1") # Zere parametr spaget, nikoli $1 scriptu !!!
 
# Do not forget to print last line when WHILE ends!
if [[ "$sam" = "" ]]; then
	muchicons=$(echo "$spoj" | grep -oPe "<!-- [a-zA-Z0-9]* -->" | grep -oPe "[a-zA-Z0-9]*" | sort | uniq | wc -l)
	if [[ "$muchicons" == "1" ]]; then
		samicon=$(geticon $(echo "$spoj" | grep -oPe "<!-- [a-zA-Z0-9]* -->" | grep -oPe "[a-zA-Z0-9]*" | sort | uniq))
	else
		samicon="$ICON_biohazard"
	fi
	sam="<table style=\"hadtbl\">$spoj</table>"
else
	samicon=$(geticon $(echo "$sam" | grep -oPe "<b>Regnum:</b> [a-zA-Z0-9]*" | grep -oPe "[a-zA-Z0-9]*$"))
fi
echo "var n$i = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point($kdex,$kdey).transform(epsg4326,projectTo),{description:'"$sam"'},{externalGraphic:'./$samicon',graphicHeight:24,graphicWidth:24,graphicXOffset:-12,graphicYOffset:-12});"
echo "$2.addFeatures(n$i);"
 
} # KONEC FCE SPAGETY !!!
 
echo "var ALL = new OpenLayers.Layer.Vector('Overlay',{attribution:'<a href=\"http://brmlab.cz\">Brmlab</a>'});"
spagety "$praseTC" "ALL" "$ICON_biohazard"
echo "map.addLayer(ALL);"
 
# Create plaintext log JUST AFTER "spagety ALL"
dateloghtm="<html><head>"
dateloghtm="$dateloghtm<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
dateloghtm="$dateloghtm<link rel='stylesheet' href='./style.css' type='text/css'>"
dateloghtm="$dateloghtm<title>Brmlab - BioOSM plaintext log</title>"
dateloghtm="$dateloghtm</head><body>"
datelogsort=$(echo -e "$datelog" | sort -r | uniq)
dateloghtm="$dateloghtm $datelogsort"
dateloghtm="$dateloghtm</body></html>"
echo "$dateloghtm" > "./plainlog.htm"
 
echo "var laycon = [vectorLayer,ALL];" # Layer controls JS array
while IFS='' read -r spag || [[ -n "$spag" ]]; do
	echo "var $spag = new OpenLayers.Layer.Vector('Overlay',{attribution:'<a href=\"http://brmlab.cz\">Brmlab</a>'});"
	spg=$(echo "$praseTC" | grep "<new-field-4>$spag</new-field-4>")
	icon=$(geticon "$spag")
	spagety "$spg" "$spag" "$icon"
	echo "laycon.push($spag);"
done <<< $(echo "$kingdoms")
 
# Plostenky
spg=$(echo "$praseTC" | grep "<phylum>Platyhelminthes</phylum>")
echo "var Platyhelminthes = new OpenLayers.Layer.Vector('Overlay',{attribution:'<a href=\"http://brmlab.cz\">Brmlab</a>'});"
spagety "$spg" "Platyhelminthes" "$ICON_plostenkoid"
echo "laycon.push(Platyhelminthes)"
 
 
echo "var controls = {"
echo "	selector: new OpenLayers.Control.SelectFeature(laycon, { onSelect: createPopup, onUnselect: destroyPopup })"
echo "};"
echo "map.addControl(controls['selector']);"
echo "controls['selector'].activate();"
 
 
 
 
 
echo "function createPopup(feature) {"
	echo "	feature.popup = new OpenLayers.Popup.FramedCloud('pop',"
		echo "		feature.geometry.getBounds().getCenterLonLat(),"
		echo "		null,"
		echo "		'<div class=\"markerContent\">'+feature.attributes.description+'</div>',"
		echo "		null,"
		echo "		false,"
		echo "		function() { controls['selector'].unselectAll(); }"
	echo "	);"
	echo "	//feature.popup.closeOnMove = true;"
	echo "	map.addPopup(feature.popup);"
echo "}"
 
echo "function destroyPopup(feature) {"
	echo "	feature.popup.destroy();"
	echo "	feature.popup = null;"
echo "}"
 
 
echo "function kinchange() {"
	echo "	kinsel=document.getElementById('kin');"
	echo "	kinopt=kinsel.options[kinsel.selectedIndex].text;"
	echo "	for (var i = map.layers.length - 1; i >= 1; i--) {"
	echo "		map.removeLayer(map.layers[i]);"
	echo "	}"
	echo "	map.addLayer(window[kinopt])"
echo "}"
 
echo "function plostenkoid() {"
	echo "	for (var i=map.layers.length-1;i>=1;i--) {"
	echo "		map.removeLayer(map.layers[i]);"
	echo "	}"
	echo "	map.addLayer(Platyhelminthes)"
echo "}"
 
 
echo "</script>"
echo "</html>"
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki