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
</p>
22
<details>
23
<summary>Delete</summary>
24
<a href="/picture/{{ resource.id }}/delete">Delete</a>
25
</details>
26
<div id="annotation-zone">
27
<img id="annotation-image" src="/raw/picture/{{ resource.id }}" alt="{{ resource.title }}">
28
{% for region in resource.regions %}
29
{% if region.json.type == "bbox" %}
30
<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}">
31
<rect x="{{ region.json.shape.x * size[0] }}"
32
y="{{ region.json.shape.y * size[1] }}"
33
width="{{ region.json.shape.w * size[0] }}"
34
height="{{ region.json.shape.h * size[1] }}"
35
fill="none" class="shape-bbox shape"
36
></rect>
37
{% set centre_x = region.json.shape.x + region.json.shape.w / 2 %}
38
{% set centre_y = region.json.shape.y + region.json.shape.h / 2 %}
39
</svg>
40
{% elif region.json.type == "polygon" %}
41
<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}">
42
<polygon points="{% for point in region.json.shape %}{{ point.x * size[0] }},{{ point.y * size[1] }} {% endfor %}" fill="none" class="shape-polygon shape"></polygon>
43
{% set top = region.json.shape | sort(attribute='y') | last %}
44
{% set left = region.json.shape | sort(attribute='x') | first %}
45
{% set bottom = region.json.shape | sort(attribute='y') | first %}
46
{% set right = region.json.shape | sort(attribute='x') | last %}
47
{% set centre_x = (left.x + right.x) / 2 %}
48
{% set centre_y = (top.y + bottom.y) / 2 %}
49
</svg>
50
{% elif region.json.type == "polyline" %}
51
<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}">
52
<polyline points="{% for point in region.json.shape %}{{ point.x * size[0] }},{{ point.y * size[1] }} {% endfor %}" fill="none" class="shape-polyline shape"></polyline>
53
{# Median point #}
54
{% set centre_x = region.json.shape | map(attribute="x") | median %}
55
{% set centre_y = region.json.shape | map(attribute="y") | median %}
56
</svg>
57
{% elif region.json.type == "point" %}
58
<svg class="shape-container-viewonly" viewBox="0 0 {{ size[0] }} {{ size[1] }}">
59
<circle cx="{{ region.json.shape.x * size[0] }}" cy="{{ region.json.shape.y * size[1] }}" r="0" fill="none" class="shape-point shape"></circle>
60
</svg>
61
{% endif %}
62
{{ shape_label(centre_x, centre_y, region.object_id) }}
63
{% endfor %}
64
</div>
65
<x-buttonbox>
66
<label>
67
<input type="checkbox" id="show-shapes" checked>
68
Show shapes
69
</label>
70
<label>
71
<input type="checkbox" id="show-objects" checked>
72
Show objects
73
</label>
74
</x-buttonbox>
75
{% set licences = resource.licences | map(attribute="licence") | list %}
76
{% set contains = resource.regions | map(attribute="object_id") | set | select | sort | list %}
77
<x-vbox>
78
<div class="icon-explainer">
79
<span>Type</span>
80
<span>{{ resource.nature.id }}</span>
81
<span>File format</span>
82
<span>{{ resource.file_format }}</span>
83
<span>Size</span>
84
<span>{{ size[0] }}×{{ size[1] }}</span>
85
<span>Number of regions</span>
86
<span>{{ resource.regions | length }}</span>
87
<span>Number of labelled regions</span>
88
<span>{{ resource.regions | selectattr("object_id") | list | length }}</span>
89
<span>Date uploaded</span>
90
<span>{{ resource.timestamp }}</span>
91
</div>
92
Contains objects: {{ contains | join(", ") }}
93
<x-hbox style="justify-content: space-between">
94
<small class="picture-licensing-info">
95
Available under:
96
{% for licence in licences %}
97
<a href="{{ licence.info_url }}" target="_blank">
98
{{ licence.title }}
99
</a>
100
{% if not loop.last %}, {% endif %}
101
{% endfor %}
102
</small>
103
<x-vbox class="picture-licence-logos">
104
{% for licence in licences %}
105
{% if licence.logo_url %}
106
{% if licence.info_url %}
107
<a href="{{ licence.info_url }}" target="_blank" tabindex="-1">
108
{# An equivalent link already exists, only one is focusable #}
109
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
110
</a>
111
{% else %}
112
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
113
{% endif %}
114
{% endif %}
115
{% endfor %}
116
</x-vbox>
117
</x-hbox>
118
</x-vbox>
119
</x-frame>
120
{% endblock %}