@panoramax/web-viewer 4.0.1-develop-35288366 → 4.0.1-develop-6b70d6bf
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/CHANGELOG.md +1 -0
- package/build/index.js +17 -17
- package/build/index.js.map +1 -1
- package/docs/09_Develop.md +4 -0
- package/package.json +1 -1
- package/src/components/ui/widgets/OSMEditors.js +2 -2
- package/src/utils/geocoder.js +5 -3
- package/src/utils/index.js +2 -1
- package/src/utils/services.js +57 -0
- package/src/utils/utils.js +5 -5
package/docs/09_Develop.md
CHANGED
|
@@ -54,6 +54,10 @@ This allows a flexible way to interact with viewer for users. Prioritization of
|
|
|
54
54
|
|
|
55
55
|
This means that, when developing, if you want to check if your attributes are well-defined, you may want to get rid of URL search parameters, as well as remove the `pnx-map-parameters` local storage item. Otherwise, they may not be read as they are lower priority than others.
|
|
56
56
|
|
|
57
|
+
### Third-party services URL
|
|
58
|
+
|
|
59
|
+
All third-party services URL (like geocoding API, OSM iD editor) are grouped into a dedicated `src/utils/services.js` file. You can easily change them to deploy a custom version of the viewer.
|
|
60
|
+
|
|
57
61
|
## Testing
|
|
58
62
|
|
|
59
63
|
We're trying to make Panoramax as reliable and secure as possible. To ensure this, we rely heavily on code testing. A variety of testing tools is made available:
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LitElement, html, nothing, css } from "lit";
|
|
2
2
|
import { fa } from "../../../utils/widgets";
|
|
3
3
|
import { josmBboxParameters } from "../../../utils/utils";
|
|
4
|
+
import { IdEditorURL } from "../../../utils/services";
|
|
4
5
|
import { faLocationDot } from "@fortawesome/free-solid-svg-icons/faLocationDot";
|
|
5
6
|
import { faSatelliteDish } from "@fortawesome/free-solid-svg-icons/faSatelliteDish";
|
|
6
7
|
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons/faExternalLinkAlt";
|
|
7
8
|
|
|
8
9
|
const JOSM_REMOTE_URL = "http://127.0.0.1:8111";
|
|
9
|
-
const ID_URL = "https://www.openstreetmap.org/edit?editor=id";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* OSM Editors component offers direct links to OpenStreetMap's iD and JOSM editors.
|
|
@@ -126,7 +126,7 @@ export default class OSMEditors extends LitElement {
|
|
|
126
126
|
"photo_overlay": "panoramax",
|
|
127
127
|
"photo": `panoramax/${this._pic.id}`,
|
|
128
128
|
};
|
|
129
|
-
const idUrl = idOpts && `${
|
|
129
|
+
const idUrl = idOpts && `${IdEditorURL()}#${new URLSearchParams(idOpts).toString()}`;
|
|
130
130
|
|
|
131
131
|
return html`
|
|
132
132
|
<pnx-link-button
|
package/src/utils/geocoder.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// DO NOT REMOVE THE "!": bundled builds breaks otherwise !!!
|
|
2
2
|
import maplibregl from "!maplibre-gl";
|
|
3
3
|
|
|
4
|
+
import { NominatimBaseUrl, AdresseDataGouvBaseURL } from "./services";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Transforms a set of parameters into an URL-ready string
|
|
6
8
|
* It also removes null/undefined values
|
|
@@ -94,7 +96,7 @@ export function forwardGeocodingNominatim(config) {
|
|
|
94
96
|
viewbox: config.bbox,
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
return fetch(
|
|
99
|
+
return fetch(`${NominatimBaseUrl()}/search?${geocoderParamsToURLString(params)}&format=geojson&polygon_geojson=1&addressdetails=1`)
|
|
98
100
|
.then(res => res.json())
|
|
99
101
|
.then(res => {
|
|
100
102
|
const finalRes = { features: [] };
|
|
@@ -115,7 +117,7 @@ export function forwardGeocodingNominatim(config) {
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
export function reverseGeocodingNominatim(lat, lon) {
|
|
118
|
-
return fetch(
|
|
120
|
+
return fetch(`${NominatimBaseUrl()}/reverse?lat=${lat}&lon=${lon}&zoom=18&format=jsonv2`)
|
|
119
121
|
.then(res => res.json())
|
|
120
122
|
.then(res => nominatimAddressToPlaceName(res?.address));
|
|
121
123
|
}
|
|
@@ -138,7 +140,7 @@ export function forwardGeocodingBAN(config) {
|
|
|
138
140
|
const toPlaceName = p => [p.name, p.district, p.city].filter(v => v).join(", ");
|
|
139
141
|
const placeTypeToZoom = { "housenumber": 20, "street": 18, "locality": 15, "municipality": 12 };
|
|
140
142
|
|
|
141
|
-
return fetch(
|
|
143
|
+
return fetch(`${AdresseDataGouvBaseURL()}/search/?${geocoderParamsToURLString(params)}`)
|
|
142
144
|
.then(res => res.json())
|
|
143
145
|
.then(res => {
|
|
144
146
|
res.features = res.features.map(f => ({
|
package/src/utils/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import * as geocoder from "./geocoder";
|
|
|
2
2
|
import * as i18n from "./i18n";
|
|
3
3
|
import * as map from "./map";
|
|
4
4
|
import * as picture from "./picture";
|
|
5
|
+
import * as services from "./services";
|
|
5
6
|
import * as utils from "./utils";
|
|
6
7
|
import * as widgets from "./widgets";
|
|
7
8
|
|
|
8
|
-
export { geocoder, i18n, map, picture, utils, widgets };
|
|
9
|
+
export { geocoder, i18n, map, picture, services, utils, widgets };
|
|
9
10
|
export {default as API} from "./API";
|
|
10
11
|
export {default as PhotoAdapter} from "./PhotoAdapter";
|
|
11
12
|
export {default as URLHandler} from "./URLHandler";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Settings that may be useful to change for special cases (e.g. offline implementation).
|
|
3
|
+
* Most users will be fine with the defaults.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* OpenStreetMap iD editor URL
|
|
9
|
+
* @returns {string} The editor URL
|
|
10
|
+
*/
|
|
11
|
+
export function IdEditorURL() {
|
|
12
|
+
return "https://www.openstreetmap.org/edit?editor=id";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/* -----------------------------------------------------
|
|
17
|
+
* Internet speed tests
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the threshold fast internet speed value.
|
|
22
|
+
*
|
|
23
|
+
* @returns {number} the minimum speed in MBps for internet to be considered "fast"
|
|
24
|
+
*/
|
|
25
|
+
export function InternetFastThreshold() {
|
|
26
|
+
return 10;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the fast internet speed test file.
|
|
31
|
+
*
|
|
32
|
+
* @returns {string} URL for the file to use for internet speed testing.
|
|
33
|
+
*/
|
|
34
|
+
export function InternetFastTestFile() {
|
|
35
|
+
return "https://panoramax.openstreetmap.fr/images/05/ca/2c/98/0111-4baf-b6f3-587bb8847d2e.jpg";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/* -----------------------------------------------------
|
|
40
|
+
* Geocoding-related settings
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the Adresse Data Gouv FR base URL for geocoding API.
|
|
45
|
+
* @returns {string} The Adresse Data Gouv URL (must support /search calls).
|
|
46
|
+
*/
|
|
47
|
+
export function AdresseDataGouvBaseURL() {
|
|
48
|
+
return "https://api-adresse.data.gouv.fr";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the Nominatim base URL for geocoding API.
|
|
53
|
+
* @returns {string} The Nominatim URL (must support /search & /reverse calls).
|
|
54
|
+
*/
|
|
55
|
+
export function NominatimBaseUrl() {
|
|
56
|
+
return "https://nominatim.openstreetmap.org";
|
|
57
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InternetFastTestFile, InternetFastThreshold } from "./services";
|
|
2
|
+
|
|
1
3
|
export const BASE_PANORAMA_ID = "geovisio-fake-id-0";
|
|
2
4
|
|
|
3
5
|
export const COLORS = {
|
|
@@ -245,9 +247,7 @@ export function isInIframe() {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
|
|
248
|
-
const INTERNET_FAST_THRESHOLD = 10; // MBit/s
|
|
249
250
|
const INTERNET_FAST_STORAGE = "pnx-internet-fast";
|
|
250
|
-
const INTERNET_FAST_TESTFILE = "https://panoramax.openstreetmap.fr/images/05/ca/2c/98/0111-4baf-b6f3-587bb8847d2e.jpg";
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
253
|
* Check if Internet connection is high-speed or not.
|
|
@@ -258,7 +258,7 @@ export function isInternetFast() {
|
|
|
258
258
|
// Check if downlink property is available
|
|
259
259
|
try {
|
|
260
260
|
const speed = navigator.connection.downlink; // MBit/s
|
|
261
|
-
return Promise.resolve(speed >=
|
|
261
|
+
return Promise.resolve(speed >= InternetFastThreshold());
|
|
262
262
|
}
|
|
263
263
|
// Fallback for other browsers
|
|
264
264
|
catch(e) {
|
|
@@ -271,14 +271,14 @@ export function isInternetFast() {
|
|
|
271
271
|
|
|
272
272
|
// Run download testing
|
|
273
273
|
const startTime = (new Date()).getTime();
|
|
274
|
-
return fetch(
|
|
274
|
+
return fetch(`${InternetFastTestFile()}?nocache=${startTime}`)
|
|
275
275
|
.then(async res => [res, await res.blob()])
|
|
276
276
|
.then(([res, blob]) => {
|
|
277
277
|
const size = parseInt(res.headers.get("Content-Length") || blob.size); // Bytes
|
|
278
278
|
const endTime = (new Date()).getTime();
|
|
279
279
|
const duration = (endTime - startTime) / 1000; // Transfer time in seconds
|
|
280
280
|
const speed = (size * 8 / 1024 / 1024) / duration; // MBits/s
|
|
281
|
-
const isFast = speed >=
|
|
281
|
+
const isFast = speed >= InternetFastThreshold();
|
|
282
282
|
sessionStorage.setItem(INTERNET_FAST_STORAGE, isFast ? "true" : "false");
|
|
283
283
|
return isFast;
|
|
284
284
|
})
|