@abi-software/flatmap-viewer 2.7.2 → 2.7.3-a.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index.css +1 -0
- package/dist/index.js +80577 -0
- package/dist/lib/index.d.ts +4 -0
- package/package.json +10 -7
- package/lib/index.ts +0 -10
- package/src/contextmenu.js +0 -97
- package/src/controls/annotation.js +0 -302
- package/src/controls/controls.js +0 -645
- package/src/controls/flightpaths.js +0 -95
- package/src/controls/info.js +0 -291
- package/src/controls/minimap.js +0 -442
- package/src/controls/paths.js +0 -143
- package/src/controls/search.js +0 -113
- package/src/controls/systems.js +0 -75
- package/src/controls/taxons.js +0 -73
- package/src/flatmap-viewer.js +0 -1789
- package/src/images.js +0 -66
- package/src/interactions.js +0 -1569
- package/src/layers/cluster.js +0 -177
- package/src/layers/filter.js +0 -310
- package/src/layers/flightpaths.js +0 -383
- package/src/layers/index.js +0 -478
- package/src/layers/styling.js +0 -1077
- package/src/main.js +0 -272
- package/src/mapserver.js +0 -64
- package/src/mathjax.js +0 -100
- package/src/pathways.js +0 -427
- package/src/search.js +0 -137
- package/src/systems.js +0 -146
- package/src/utils.js +0 -152
- package/static/css/flatmap-viewer.css +0 -238
- package/static/icons/favicon.ico +0 -0
- package/static/images/active.png +0 -0
- package/static/images/inactive.png +0 -0
- package/static/images/reset-map-active.png +0 -0
- package/static/images/reset-map-button.png +0 -0
- package/static/images/rounded-background.png +0 -0
- package/static/images/zoom-in-active.png +0 -0
- package/static/images/zoom-in-button.png +0 -0
- package/static/images/zoom-out-active.png +0 -0
- package/static/images/zoom-out-button.png +0 -0
- package/thirdParty/maplibre-gl-svg/CHANGELOG.md +0 -13
- package/thirdParty/maplibre-gl-svg/LICENSE +0 -21
- package/thirdParty/maplibre-gl-svg/LICENSE.md +0 -21
- package/thirdParty/maplibre-gl-svg/README.md +0 -24
- package/thirdParty/maplibre-gl-svg/assets/Add custom SVG template to template manager.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as HTML markers.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as symbols.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Fill polygon with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with Custom SVG Template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Line layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Load SVG from URL.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/SVG template options.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Smiley_face_changed.svg +0 -37
- package/thirdParty/maplibre-gl-svg/assets/Symbol layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up-thin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/car.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker-rotated.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles-spaced.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/dots.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag-triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-arrow.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-ball-pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-circle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-flat.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin-round.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-stripes.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-left.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/x-fill.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag-vertical.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag.png +0 -0
- package/thirdParty/maplibre-gl-svg/build/build.js +0 -210
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.js +0 -339
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.min.js +0 -4
- package/thirdParty/maplibre-gl-svg/docs/docs.md +0 -375
- package/thirdParty/maplibre-gl-svg/examples/Add custom SVG template to template manager.html +0 -101
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as HTML markers.html +0 -82
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as symbols.html +0 -124
- package/thirdParty/maplibre-gl-svg/examples/Fill polygon with built-in SVG template.html +0 -94
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with Custom SVG Template.html +0 -86
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with built-in SVG template.html +0 -83
- package/thirdParty/maplibre-gl-svg/examples/Line layer with built-in SVG template.html +0 -129
- package/thirdParty/maplibre-gl-svg/examples/Load SVG from URL.html +0 -96
- package/thirdParty/maplibre-gl-svg/examples/SVG template options.html +0 -264
- package/thirdParty/maplibre-gl-svg/examples/Symbol layer with built-in SVG template.html +0 -93
- package/thirdParty/maplibre-gl-svg/index.html +0 -151
- package/thirdParty/maplibre-gl-svg/package-lock.json +0 -5882
- package/thirdParty/maplibre-gl-svg/package.json +0 -49
- package/thirdParty/maplibre-gl-svg/src/SvgManager.ts +0 -186
- package/thirdParty/maplibre-gl-svg/src/SvgTemplateManager.ts +0 -144
- package/thirdParty/maplibre-gl-svg/src/index.ts +0 -4
- package/thirdParty/maplibre-gl-svg/tsconfig.json +0 -31
- package/thirdParty/maplibre-gl-svg/typings/index.d.ts +0 -111
package/src/main.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 - 2024 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
******************************************************************************/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
//==============================================================================
|
|
24
|
-
|
|
25
|
-
import { MapManager } from './flatmap-viewer';
|
|
26
|
-
export { MapManager };
|
|
27
|
-
|
|
28
|
-
const ALL_MARKERS = [
|
|
29
|
-
// Most of these are around the heart
|
|
30
|
-
'UBERON:0003382',
|
|
31
|
-
'UBERON:0002348',
|
|
32
|
-
'UBERON:0002349',
|
|
33
|
-
'UBERON:0003379',
|
|
34
|
-
'UBERON:0001986',
|
|
35
|
-
'UBERON:0001074',
|
|
36
|
-
'UBERON:0003381',
|
|
37
|
-
'UBERON:0002165',
|
|
38
|
-
'UBERON:0002080',
|
|
39
|
-
'UBERON:0000948',
|
|
40
|
-
'UBERON:0002084',
|
|
41
|
-
'UBERON:0002078',
|
|
42
|
-
'UBERON:0002079',
|
|
43
|
-
'UBERON:0002349',
|
|
44
|
-
'UBERON:0002408',
|
|
45
|
-
'UBERON:0007240',
|
|
46
|
-
'UBERON:0002359',
|
|
47
|
-
|
|
48
|
-
'UBERON:0001508',
|
|
49
|
-
'UBERON:0037094',
|
|
50
|
-
'ILX:0738305',
|
|
51
|
-
|
|
52
|
-
'UBERON:0000948', // {className: 'heart-marker'}); // Heart
|
|
53
|
-
'UBERON:0002048', // Lung
|
|
54
|
-
'UBERON:0000945', // Stomach
|
|
55
|
-
'UBERON:0001155', // Colon
|
|
56
|
-
'UBERON:0001255', // Bladder
|
|
57
|
-
'UBERON:0001759', // Vagus
|
|
58
|
-
]
|
|
59
|
-
|
|
60
|
-
//==============================================================================
|
|
61
|
-
|
|
62
|
-
class DrawControl
|
|
63
|
-
{
|
|
64
|
-
constructor(flatmap)
|
|
65
|
-
{
|
|
66
|
-
this._flatmap = flatmap
|
|
67
|
-
this._lastEvent = null
|
|
68
|
-
this._idField = document.getElementById('drawing-id')
|
|
69
|
-
|
|
70
|
-
this._okBtn = document.getElementById('drawing-ok')
|
|
71
|
-
if (this._okBtn) {
|
|
72
|
-
this._okBtn.addEventListener('click', e => {
|
|
73
|
-
if (this._lastEvent) {
|
|
74
|
-
const feature = this._flatmap.refreshAnnotationFeatureGeometry(this._lastEvent.feature)
|
|
75
|
-
this._flatmap.commitAnnotationEvent(this._lastEvent)
|
|
76
|
-
this._idField.innerText = ''
|
|
77
|
-
this._lastEvent = null
|
|
78
|
-
// Send `feature`, along with user comments, to the annotation service
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this._cancelBtn = document.getElementById('drawing-cancel')
|
|
84
|
-
if (this._cancelBtn) {
|
|
85
|
-
this._cancelBtn.addEventListener('click', e => {
|
|
86
|
-
if (this._lastEvent) {
|
|
87
|
-
this._flatmap.rollbackAnnotationEvent(this._lastEvent)
|
|
88
|
-
this._idField.innerText = ''
|
|
89
|
-
this._lastEvent = null
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
handleEvent(event)
|
|
96
|
-
//================
|
|
97
|
-
{
|
|
98
|
-
console.log(event)
|
|
99
|
-
if (this._idField && event.type !== 'modeChanged' && event.type !== 'selectionChanged') {
|
|
100
|
-
this._idField.innerText = `Annotation ${event.type}, Id: ${event.feature.id}`
|
|
101
|
-
this._lastEvent = event
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
//==============================================================================
|
|
107
|
-
|
|
108
|
-
export async function standaloneViewer(map_endpoint=null, options={})
|
|
109
|
-
{
|
|
110
|
-
const requestUrl = new URL(window.location.href);
|
|
111
|
-
if (map_endpoint == null) {
|
|
112
|
-
const parts = requestUrl.pathname.split('/');
|
|
113
|
-
map_endpoint = requestUrl.origin + (parts.slice(0, (parts[parts.length - 1] === '') ? -2 : -1)
|
|
114
|
-
.concat([''])
|
|
115
|
-
.join('/'));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const mapManager = new MapManager(map_endpoint, {
|
|
119
|
-
images: [
|
|
120
|
-
{
|
|
121
|
-
id: 'label-background',
|
|
122
|
-
url: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAAmCAIAAADbSlUzAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAJOgAACToAYJjBRwAAACVSURBVFhH7dixDoJAEIThfXqMBcYKrTQ+jkYSStDYkVhZINxyEshJcZXJtC7FfNlmur9eyXb7Vqf6+bI9HUKyWkt5e4RlOF9ycerjsqbqpfefuKzNJawBWIOxBmMNxhqMNRhrMNZgrMFYg7EGYw3GGow1GGuw5dU07y4ua22nUlb3uKxd80IOx1Pjxp+f4P/P+ZButl+YrbXnPs+YmAAAAABJRU5ErkJggg==',
|
|
123
|
-
options: {
|
|
124
|
-
content: [21, 4, 28, 33],
|
|
125
|
-
stretchX: [[21, 28]],
|
|
126
|
-
stretchY: [[4, 33]]
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
let currentMap = null;
|
|
133
|
-
let drawControl = null;
|
|
134
|
-
let defaultBackground = localStorage.getItem('flatmap-background-colour') || 'black';
|
|
135
|
-
|
|
136
|
-
const mapOptions = Object.assign({
|
|
137
|
-
tooltips: true,
|
|
138
|
-
background: defaultBackground,
|
|
139
|
-
debug: false,
|
|
140
|
-
minimap: false,
|
|
141
|
-
showId: true,
|
|
142
|
-
showPosition: false,
|
|
143
|
-
standalone: true,
|
|
144
|
-
annotator: true,
|
|
145
|
-
flightPaths: true
|
|
146
|
-
}, options);
|
|
147
|
-
|
|
148
|
-
function loadMap(id, taxon, sex)
|
|
149
|
-
//==============================
|
|
150
|
-
{
|
|
151
|
-
if (currentMap !== null) {
|
|
152
|
-
currentMap.close();
|
|
153
|
-
}
|
|
154
|
-
if (id !== null) {
|
|
155
|
-
requestUrl.searchParams.set('id', id);
|
|
156
|
-
requestUrl.searchParams.delete('taxon');
|
|
157
|
-
requestUrl.searchParams.delete('sex');
|
|
158
|
-
} else if (taxon !== null) {
|
|
159
|
-
id = taxon;
|
|
160
|
-
requestUrl.searchParams.set('taxon', taxon);
|
|
161
|
-
if (sex !== null) {
|
|
162
|
-
requestUrl.searchParams.set('sex', sex);
|
|
163
|
-
}
|
|
164
|
-
requestUrl.searchParams.delete('id');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Update address bar URL to current map
|
|
168
|
-
window.history.pushState('data', document.title, requestUrl);
|
|
169
|
-
|
|
170
|
-
mapManager.loadMap(id, 'map-canvas', (eventType, ...args) => {
|
|
171
|
-
if (args[0].type === 'control' && args[0].control === 'background') {
|
|
172
|
-
mapOptions.background = args[0].value;
|
|
173
|
-
} else if (eventType === 'annotation') {
|
|
174
|
-
drawControl.handleEvent(...args)
|
|
175
|
-
}
|
|
176
|
-
}, mapOptions)
|
|
177
|
-
.then(map => {
|
|
178
|
-
/*
|
|
179
|
-
map.addMarker('UBERON:0000948', {className: 'heart-marker'}); // Heart
|
|
180
|
-
map.addMarker('UBERON:0002048'); // Lung
|
|
181
|
-
map.addMarker('UBERON:0000945'); // Stomach
|
|
182
|
-
map.addMarker('UBERON:0001155'); // Colon
|
|
183
|
-
map.addMarker('UBERON:0001255'); // Bladder
|
|
184
|
-
map.addMarker('UBERON:0001759'); // Vagus
|
|
185
|
-
*/
|
|
186
|
-
map.addMarkers(ALL_MARKERS, {cluster: true})
|
|
187
|
-
currentMap = map;
|
|
188
|
-
drawControl = new DrawControl(map)
|
|
189
|
-
})
|
|
190
|
-
.catch(error => {
|
|
191
|
-
console.log(error);
|
|
192
|
-
alert(error);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const viewMapId = requestUrl.searchParams.get('id');
|
|
197
|
-
const viewMapTaxon = requestUrl.searchParams.get('taxon');
|
|
198
|
-
const viewMapSex = requestUrl.searchParams.get('sex');
|
|
199
|
-
|
|
200
|
-
const latestMaps = new Map();
|
|
201
|
-
const maps = await mapManager.allMaps();
|
|
202
|
-
for (const map of Object.values(maps)) {
|
|
203
|
-
const text = [];
|
|
204
|
-
if ('describes' in map) {
|
|
205
|
-
text.push(map.describes);
|
|
206
|
-
}
|
|
207
|
-
if ('name' in map) {
|
|
208
|
-
text.push(map.name);
|
|
209
|
-
} else {
|
|
210
|
-
text.push(map.id);
|
|
211
|
-
}
|
|
212
|
-
const mapName = text.join(' -- ')
|
|
213
|
-
if (!latestMaps.has(mapName)) {
|
|
214
|
-
latestMaps.set(mapName, map);
|
|
215
|
-
} else if (latestMaps.get(mapName).created < map.created) {
|
|
216
|
-
latestMaps.set(mapName, map);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// Sort in created order with most recent first
|
|
220
|
-
const sortedMaps = new Map([...latestMaps].sort((a, b) => (a[1].created < b[1].created) ? 1
|
|
221
|
-
: (a[1].created > b[1].created) ? -1
|
|
222
|
-
: 0));
|
|
223
|
-
let mapId = null;
|
|
224
|
-
let mapTaxon = null;
|
|
225
|
-
let mapSex = null;
|
|
226
|
-
const mapList = [];
|
|
227
|
-
for (const [name, map] of sortedMaps.entries()) {
|
|
228
|
-
const text = [ name, map.created ];
|
|
229
|
-
let selected = '';
|
|
230
|
-
const id = ('uuid' in map) ? map.uuid : map.id;
|
|
231
|
-
if (mapId === null && id === viewMapId) {
|
|
232
|
-
mapId = id;
|
|
233
|
-
selected = 'selected';
|
|
234
|
-
} else if (mapId === null
|
|
235
|
-
&& mapTaxon === null
|
|
236
|
-
&& map.taxon === viewMapTaxon
|
|
237
|
-
&& !('biologicalSex' in map || map.biologicalSex === viewMapSex)) {
|
|
238
|
-
mapTaxon = viewMapTaxon;
|
|
239
|
-
mapSex = viewMapSex;
|
|
240
|
-
selected = 'selected';
|
|
241
|
-
}
|
|
242
|
-
mapList.push(`<option value="${id}" ${selected}>${text.join(' -- ')}</option>`);
|
|
243
|
-
}
|
|
244
|
-
mapList.splice(0, 0, '<option value="">Select flatmap...</option>');
|
|
245
|
-
|
|
246
|
-
const selector = document.getElementById('map-selector');
|
|
247
|
-
selector.innerHTML = mapList.join('');
|
|
248
|
-
selector.onchange = (e) => {
|
|
249
|
-
if (e.target.value !== '') {
|
|
250
|
-
loadMap(e.target.value);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (mapId === null) {
|
|
255
|
-
mapId = viewMapId;
|
|
256
|
-
}
|
|
257
|
-
if (mapTaxon === null) {
|
|
258
|
-
mapTaxon = viewMapTaxon;
|
|
259
|
-
}
|
|
260
|
-
if (mapSex === null) {
|
|
261
|
-
mapTaxon = viewMapSex;
|
|
262
|
-
}
|
|
263
|
-
if (mapId === null && mapTaxon == null) {
|
|
264
|
-
mapId = selector.options[1].value;
|
|
265
|
-
selector.options[1].selected = true;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
loadMap(mapId, mapTaxon, mapSex);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
//==============================================================================
|
|
272
|
-
|
package/src/mapserver.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
******************************************************************************/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
//==============================================================================
|
|
24
|
-
|
|
25
|
-
export async function loadJSON(url)
|
|
26
|
-
//=================================
|
|
27
|
-
{
|
|
28
|
-
const response = await fetch(url, {
|
|
29
|
-
method: 'GET',
|
|
30
|
-
headers: {
|
|
31
|
-
"Accept": "application/json; charset=utf-8",
|
|
32
|
-
"Cache-Control": "no-store"
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
throw new Error(`Cannot access ${url}`);
|
|
37
|
-
}
|
|
38
|
-
return response.json();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//==============================================================================
|
|
42
|
-
|
|
43
|
-
export class MapServer
|
|
44
|
-
{
|
|
45
|
-
constructor(url)
|
|
46
|
-
{
|
|
47
|
-
this._url = url;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
url(relativePath='')
|
|
51
|
-
//==================
|
|
52
|
-
{
|
|
53
|
-
const url = new URL(relativePath, this._url);
|
|
54
|
-
return url.href;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async loadJSON(relativePath)
|
|
58
|
-
//==========================
|
|
59
|
-
{
|
|
60
|
-
return loadJSON(this.url(relativePath));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//==============================================================================
|
package/src/mathjax.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/******************************************************************************
|
|
3
|
-
|
|
4
|
-
Flatmap viewer and annotation tool
|
|
5
|
-
|
|
6
|
-
Copyright (c) 2019-2023 David Brooks
|
|
7
|
-
|
|
8
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
you may not use this file except in compliance with the License.
|
|
10
|
-
You may obtain a copy of the License at
|
|
11
|
-
|
|
12
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
|
|
14
|
-
Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
See the License for the specific language governing permissions and
|
|
18
|
-
limitations under the License.
|
|
19
|
-
|
|
20
|
-
******************************************************************************/
|
|
21
|
-
|
|
22
|
-
/*************************************************************************
|
|
23
|
-
*
|
|
24
|
-
* direct/tex2svg
|
|
25
|
-
*
|
|
26
|
-
* Uses MathJax v3 to convert a TeX string to an SVG string.
|
|
27
|
-
*
|
|
28
|
-
* ----------------------------------------------------------------------
|
|
29
|
-
*
|
|
30
|
-
* Copyright (c) 2018 The MathJax Consortium
|
|
31
|
-
*
|
|
32
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
33
|
-
* you may not use this file except in compliance with the License.
|
|
34
|
-
* You may obtain a copy of the License at
|
|
35
|
-
*
|
|
36
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
37
|
-
*
|
|
38
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
39
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
40
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
41
|
-
* See the License for the specific language governing permissions and
|
|
42
|
-
* limitations under the License.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
//==============================================================================
|
|
46
|
-
|
|
47
|
-
const EM_SIZE = 16;
|
|
48
|
-
const EX_SIZE = 8;
|
|
49
|
-
|
|
50
|
-
//==============================================================================
|
|
51
|
-
|
|
52
|
-
// Load the packages needed for MathJax
|
|
53
|
-
import {mathjax} from 'mathjax-full/js/mathjax';
|
|
54
|
-
import {TeX} from 'mathjax-full/js/input/tex';
|
|
55
|
-
import {SVG} from 'mathjax-full/js/output/svg';
|
|
56
|
-
import {browserAdaptor} from 'mathjax-full/js/adaptors/browserAdaptor';
|
|
57
|
-
import {RegisterHTMLHandler} from 'mathjax-full/js/handlers/html';
|
|
58
|
-
import {AllPackages} from 'mathjax-full/js/input/tex/AllPackages'; // required to load `textmacros`
|
|
59
|
-
|
|
60
|
-
//==============================================================================
|
|
61
|
-
|
|
62
|
-
// Minimal CSS needed for stand-alone image
|
|
63
|
-
export const LatexStyleRules = [
|
|
64
|
-
'svg a{fill:blue;stroke:blue}',
|
|
65
|
-
// Round the corners of filled background rectangles
|
|
66
|
-
'[data-mml-node="mstyle"]>rect[data-bgcolor="true"]{rx: 8%; ry: 12%}',
|
|
67
|
-
'[data-mml-node="merror"]>g{fill:red;stroke:red}',
|
|
68
|
-
'[data-mml-node="merror"]>rect[data-background]{fill:yellow;stroke:none}',
|
|
69
|
-
'[data-frame],[data-line]{stroke-width:70px;fill:none}',
|
|
70
|
-
'.mjx-dashed{stroke-dasharray:140}',
|
|
71
|
-
'.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}',
|
|
72
|
-
'use[data-c]{stroke-width:3px}'
|
|
73
|
-
].join('');
|
|
74
|
-
|
|
75
|
-
//==============================================================================
|
|
76
|
-
|
|
77
|
-
// Create DOM adaptor and register it for HTML documents
|
|
78
|
-
const adaptor = browserAdaptor();
|
|
79
|
-
RegisterHTMLHandler(adaptor);
|
|
80
|
-
|
|
81
|
-
//==============================================================================
|
|
82
|
-
|
|
83
|
-
const tex = new TeX({packages: AllPackages}); // ['base', 'textmacros']});
|
|
84
|
-
const svg = new SVG({fontCache: 'local'});
|
|
85
|
-
const html = mathjax.document('', {InputJax: tex, OutputJax: svg});
|
|
86
|
-
|
|
87
|
-
//==============================================================================
|
|
88
|
-
|
|
89
|
-
export function latex2Svg(latex)
|
|
90
|
-
{
|
|
91
|
-
const node = html.convert(latex, {
|
|
92
|
-
display: false, // process as inline math
|
|
93
|
-
em: 2*EM_SIZE,
|
|
94
|
-
ex: 2*EX_SIZE,
|
|
95
|
-
});
|
|
96
|
-
let result = adaptor.innerHTML(node);
|
|
97
|
-
return result.replace(/<defs>/, `<defs><style>${LatexStyleRules}</style>`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//==============================================================================
|