picture.html
HTML document, ASCII text
1{% extends "default.html" %} 2{% block title %}Picture | gigadata{% endblock %} 3{% macro shape_label(x, y, text) %} 4{% if text %} 5<foreignObject height="100%" width="100%" x="{{ x * size[0] }}" y="{{ y * size[1] }}"> 6<div class="shape-label"> 7{{ text }} 8</div> 9</foreignObject> 10{% endif %} 11{% endmacro %} 12{% block content %} 13<x-frame style="--width: 768px"> 14<h1>{{ resource.title }}</h1> 15<p>{{ resource.description }}</p> 16<p> 17<a href="{{ resource.origin_url }}">Original source</a> | 18<a href="/raw/picture/{{ resource.id }}">View</a> | 19<a href="/raw/picture/{{ resource.id }}" download="GigadataPicture_{{ resource.id }}{{ file_extension }}">Download</a> | 20<a href="/picture/{{ resource.id }}/annotate">Annotate</a> 21</p> 22<div id="annotation-zone"> 23<img id="annotation-image" src="/raw/picture/{{ resource.id }}" alt="{{ resource.title }}"> 24{% for region in resource.regions %} 25{% if region.json.type == "bbox" %} 26<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}"> 27<rect x="{{ region.json.shape.x * size[0] }}" 28y="{{ region.json.shape.y * size[1] }}" 29width="{{ region.json.shape.w * size[0] }}" 30height="{{ region.json.shape.h * size[1] }}" 31fill="none" class="shape-bbox shape" 32></rect> 33{% set centre_x = region.json.shape.x + region.json.shape.w / 2 %} 34{% set centre_y = region.json.shape.y + region.json.shape.h / 2 %} 35{{ shape_label(centre_x, centre_y, region.object_id) }} 36</svg> 37{% elif region.json.type == "polygon" %} 38<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}"> 39<polygon points="{% for point in region.json.shape %}{{ point.x * size[0] }},{{ point.y * size[1] }} {% endfor %}" fill="none" class="shape-polygon shape"></polygon> 40{% set top = region.json.shape | sort(attribute='y') | last %} 41{% set left = region.json.shape | sort(attribute='x') | first %} 42{% set bottom = region.json.shape | sort(attribute='y') | first %} 43{% set right = region.json.shape | sort(attribute='x') | last %} 44{% set centre_x = (left.x + right.x) / 2 %} 45{% set centre_y = (top.y + bottom.y) / 2 %} 46{{ shape_label(centre_x, centre_y, region.object_id) }} 47</svg> 48{% elif region.json.type == "polyline" %} 49<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}"> 50<polyline points="{% for point in region.json.shape %}{{ point.x * size[0] }},{{ point.y * size[1] }} {% endfor %}" fill="none" class="shape-polyline shape"></polyline> 51{# Median point #} 52{% set centre_x = region.json.shape | map(attribute="x") | median %} 53{% set centre_y = region.json.shape | map(attribute="y") | median %} 54{{ shape_label(centre_x, centre_y, region.object_id) }} 55</svg> 56{% elif region.json.type == "point" %} 57<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}"> 58<circle cx="{{ region.json.shape.x * size[0] }}" cy="{{ region.json.shape.y * size[1] }}" r="0" fill="none" class="shape-point shape"></circle> 59{{ shape_label(region.json.shape.x, region.json.shape.y, region.object_id) }} 60</svg> 61{% endif %} 62{% endfor %} 63</div> 64<x-buttonbox> 65<label> 66<input type="checkbox" id="show-shapes" checked> 67Show shapes 68</label> 69<label> 70<input type="checkbox" id="show-objects" checked> 71Show objects 72</label> 73</x-buttonbox> 74<div class="icon-explainer"> 75<span>Type:</span> 76<span>{{ resource.nature.id }}</span> 77<span>File format:</span> 78<span>{{ resource.file_format }}</span> 79<span>Size:</span> 80<span>{{ size[0] }}×{{ size[1] }}</span> 81</div> 82{% set licences = resource.licences | map(attribute="licence") | list %} 83<x-hbox> 84<small class="picture-licensing-info"> 85Available under: 86{% for licence in licences %} 87<a href="{{ licence.url }}" target="_blank"> 88{{ licence.title }} 89</a> 90{% if not loop.last %}, {% endif %} 91{% endfor %} 92</small> 93<x-vbox class="picture-licence-logos"> 94{% for licence in licences %} 95{% if licence.logo_url %} 96<a href="{{ licence.url }}" target="_blank" tabindex="-1"> 97{# An equivalent link already exists, only one is focusable #} 98<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo"> 99</a> 100{% endif %} 101{% endfor %} 102</x-vbox> 103</x-hbox> 104</x-frame> 105{% endblock %}