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