From f9db0d9b5c11df3f2251f2fed0cf9bfc7c62d90f Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Sun, 22 Sep 2024 10:29:58 +0800 Subject: [PATCH 01/16] Add PMTiles vector support * add PMTiles mode to source editing dialog * App.tsx detects PMTiles sources for fetching vector_layers (inspect does not yet work) --- package-lock.json | 26 ++++++++++++ package.json | 1 + src/components/App.tsx | 52 ++++++++++++++--------- src/components/MapMaplibreGl.tsx | 3 ++ src/components/ModalSources.tsx | 6 +++ src/components/ModalSourcesTypeEditor.tsx | 29 ++++++++++++- 6 files changed, 95 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index b68c2bd1..047f1543 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", + "pmtiles": "^3.1.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", @@ -2132,6 +2133,15 @@ "integrity": "sha512-131wOmuwDg8ypYCSQ437bGdP+K2lJ8GJUu+ng4iQQxAc3irRnb7mGHbexsPChBcKWLctTR9V5LJdX5A8WWk44A==", "dev": true }, + "node_modules/@types/leaflet": { + "version": "1.9.12", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.12.tgz", + "integrity": "sha512-BK7XS+NyRI291HIo0HCfE18Lp8oA30H1gpi1tf0mF3TgiCEzanQjOqNZ4x126SXzzi2oNSZhZ5axJp1k0iM6jg==", + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/lodash": { "version": "4.17.0", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz", @@ -5177,6 +5187,12 @@ "pend": "~1.2.0" } }, + "node_modules/fflate": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", + "license": "MIT" + }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -8844,6 +8860,16 @@ "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.3.tgz", "integrity": "sha512-VJK1SRmXBpjwsB4YOHYSturx48rLKMzHgCqDH2ZDa6ZbMS/N5huoNqyQdK5Fj/xayu3fqbXckn5SeCS1EbMDZg==" }, + "node_modules/pmtiles": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.1.0.tgz", + "integrity": "sha512-6JvgAQ8gElP1Ilg6ILM4KqleeKS+QcwpW8PXqhPWjRFmqF42yyUJ8sP3dZHQXm+G0HYXuw1kGlMTdVEs583pCQ==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/leaflet": "^1.9.8", + "fflate": "^0.8.0" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", diff --git a/package.json b/package.json index 592f3cc7..b00b1907 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", + "pmtiles": "^3.1.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", diff --git a/src/components/App.tsx b/src/components/App.tsx index 86a94de2..7444ea04 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -8,6 +8,7 @@ import get from 'lodash.get' import {unset} from 'lodash' import {arrayMoveMutable} from 'array-move' import hash from "string-hash"; +import { PMTiles } from "pmtiles"; import {Map, LayerSpecification, StyleSpecification, ValidationError, SourceSpecification} from 'maplibre-gl' import {latest, validateStyleMin} from '@maplibre/maplibre-gl-style-spec' @@ -641,33 +642,42 @@ export default class App extends React.Component { console.warn("Failed to setFetchAccessToken: ", err); } - fetch(url!, { - mode: 'cors', - }) - .then(response => response.json()) - .then(json => { + const setVectorLayers = (json:any) => { + if(!Object.prototype.hasOwnProperty.call(json, "vector_layers")) { + return; + } - if(!Object.prototype.hasOwnProperty.call(json, "vector_layers")) { - return; - } + // Create new objects before setState + const sources = Object.assign({}, { + [key]: this.state.sources[key], + }); - // Create new objects before setState - const sources = Object.assign({}, { - [key]: this.state.sources[key], - }); + for(const layer of json.vector_layers) { + (sources[key] as any).layers.push(layer.id) + } - for(const layer of json.vector_layers) { - (sources[key] as any).layers.push(layer.id) - } + console.debug("Updating source: "+key); + this.setState({ + sources: sources + }); + }; - console.debug("Updating source: "+key); - this.setState({ - sources: sources + if (url!.startsWith("pmtiles://")) { + (new PMTiles(url!.substr(10))).getTileJson("") + .then(json => setVectorLayers(json)) + .catch(err => { + console.error("Failed to process sources for '%s'", url, err); }); + } else { + fetch(url!, { + mode: 'cors', }) - .catch(err => { - console.error("Failed to process sources for '%s'", url, err); - }); + .then(response => response.json()) + .then(json => setVectorLayers(json)) + .catch(err => { + console.error("Failed to process sources for '%s'", url, err); + }); + } } else { sourceList[key] = this.state.sources[key] || this.state.mapStyle.sources[key]; diff --git a/src/components/MapMaplibreGl.tsx b/src/components/MapMaplibreGl.tsx index 87a2ad23..96b73b2c 100644 --- a/src/components/MapMaplibreGl.tsx +++ b/src/components/MapMaplibreGl.tsx @@ -15,6 +15,7 @@ import MaplibreGeocoder, { MaplibreGeocoderApi, MaplibreGeocoderApiConfig } from import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css'; import { withTranslation, WithTranslation } from 'react-i18next' import i18next from 'i18next' +import { Protocol } from "pmtiles"; function renderPopup(popup: JSX.Element, mountNode: ReactDOM.Container): HTMLElement { ReactDOM.render(popup, mountNode); @@ -148,6 +149,8 @@ class MapMaplibreGlInternal extends React.Component { diff --git a/src/components/ModalSources.tsx b/src/components/ModalSources.tsx index eabb5a8b..7ec8c873 100644 --- a/src/components/ModalSources.tsx +++ b/src/components/ModalSources.tsx @@ -51,6 +51,7 @@ function editorMode(source: SourceSpecification) { } if(source.type === 'vector') { if(source.tiles) return 'tile_vector' + if(source.url!.startsWith("pmtiles://")) return 'pmtiles_vector' return 'tilejson_vector' } if(source.type === 'geojson') { @@ -129,6 +130,10 @@ class AddSource extends React.Component { const {protocol} = window.location; switch(mode) { + case 'pmtiles_vector': return { + type: 'vector', + url: `${protocol}//localhost:3000/file.pmtiles` + } case 'geojson_url': return { type: 'geojson', data: `${protocol}//localhost:3000/geojson.json` @@ -240,6 +245,7 @@ class AddSource extends React.Component { ['tile_raster', t('Raster (Tile URLs)')], ['tilejson_raster-dem', t('Raster DEM (TileJSON URL)')], ['tilexyz_raster-dem', t('Raster DEM (XYZ URLs)')], + ['pmtiles_vector', 'Vector (PMTiles)'], ['image', t('Image')], ['video', t('Video')], ]} diff --git a/src/components/ModalSourcesTypeEditor.tsx b/src/components/ModalSourcesTypeEditor.tsx index da4f7a3c..d5b8794b 100644 --- a/src/components/ModalSourcesTypeEditor.tsx +++ b/src/components/ModalSourcesTypeEditor.tsx @@ -11,7 +11,7 @@ import FieldCheckbox from './FieldCheckbox' import { WithTranslation, withTranslation } from 'react-i18next'; import { TFunction } from 'i18next' -export type EditorMode = "video" | "image" | "tilejson_vector" | "tile_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "tile_vector" | "geojson_url" | "geojson_json" | null; +export type EditorMode = "video" | "image" | "tilejson_vector" | "tile_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "pmtiles_vector" | "tile_vector" | "geojson_url" | "geojson_json" | null; type TileJSONSourceEditorProps = { source: { @@ -286,6 +286,32 @@ class GeoJSONSourceFieldJsonEditor extends React.Component { + render() { + const t = this.props.t; + return
+ this.props.onChange({ + ...this.props.source, + url: `pmtiles://${url}` + })} + /> + {this.props.children} +
+ } +} + type ModalSourcesTypeEditorInternalProps = { mode: EditorMode source: any @@ -343,6 +369,7 @@ class ModalSourcesTypeEditorInternal extends React.Component + case 'pmtiles_vector': return case 'image': return case 'video': return default: return null From 498b7d76de91409dc07a5d3382efca94582e65b7 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Sun, 22 Sep 2024 19:16:24 +0800 Subject: [PATCH 02/16] update to pmtiles 3.2.0 to make inspector work. --- package-lock.json | 8 ++++---- package.json | 2 +- src/components/MapMaplibreGl.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 047f1543..afc698e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", - "pmtiles": "^3.1.0", + "pmtiles": "^3.2.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", @@ -8861,9 +8861,9 @@ "integrity": "sha512-VJK1SRmXBpjwsB4YOHYSturx48rLKMzHgCqDH2ZDa6ZbMS/N5huoNqyQdK5Fj/xayu3fqbXckn5SeCS1EbMDZg==" }, "node_modules/pmtiles": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.1.0.tgz", - "integrity": "sha512-6JvgAQ8gElP1Ilg6ILM4KqleeKS+QcwpW8PXqhPWjRFmqF42yyUJ8sP3dZHQXm+G0HYXuw1kGlMTdVEs583pCQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.2.0.tgz", + "integrity": "sha512-4v3Nw5xeMxaUReLZQTz3PyM4VM/Lx/Xp/rc2GGEWMl0nqAmcb+gjyi+eOTwfPu8LnB0ash36hz0dV76uYvih5A==", "license": "BSD-3-Clause", "dependencies": { "@types/leaflet": "^1.9.8", diff --git a/package.json b/package.json index b00b1907..ddf25d03 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", - "pmtiles": "^3.1.0", + "pmtiles": "^3.2.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", diff --git a/src/components/MapMaplibreGl.tsx b/src/components/MapMaplibreGl.tsx index 96b73b2c..833aace3 100644 --- a/src/components/MapMaplibreGl.tsx +++ b/src/components/MapMaplibreGl.tsx @@ -149,7 +149,7 @@ class MapMaplibreGlInternal extends React.Component Date: Wed, 25 Sep 2024 22:36:51 +0200 Subject: [PATCH 03/16] Fix Cypress shortcut d test --- src/components/ModalSources.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ModalSources.tsx b/src/components/ModalSources.tsx index 7ec8c873..05a5c09d 100644 --- a/src/components/ModalSources.tsx +++ b/src/components/ModalSources.tsx @@ -51,7 +51,7 @@ function editorMode(source: SourceSpecification) { } if(source.type === 'vector') { if(source.tiles) return 'tile_vector' - if(source.url!.startsWith("pmtiles://")) return 'pmtiles_vector' + if(source.url && source.url.startsWith("pmtiles://")) return 'pmtiles_vector' return 'tilejson_vector' } if(source.type === 'geojson') { From de670771d89a9a280a3161fdc1d4ef4e3bfb9dea Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 26 Dec 2024 22:37:34 +0100 Subject: [PATCH 04/16] fix editing pmtiles URLs --- src/components/ModalSourcesTypeEditor.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ModalSourcesTypeEditor.tsx b/src/components/ModalSourcesTypeEditor.tsx index d5b8794b..2c9a1492 100644 --- a/src/components/ModalSourcesTypeEditor.tsx +++ b/src/components/ModalSourcesTypeEditor.tsx @@ -302,9 +302,9 @@ class PMTilesSourceEditor extends React.Component { label={t("PMTiles URL")} fieldSpec={latest.source_vector.url} value={this.props.source.url} - onChange={url => this.props.onChange({ + onChange={(url: string) => this.props.onChange({ ...this.props.source, - url: `pmtiles://${url}` + url: url.startsWith("pmtiles://") ? url : `pmtiles://${url}` })} /> {this.props.children} From 6e8488f36029cf1353c597508900ac3b49321de7 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 26 Dec 2024 22:42:08 +0100 Subject: [PATCH 05/16] bump pmtiles to latest npm version --- package-lock.json | 20 +++++--------------- package.json | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index afc698e7..4ed925e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", - "pmtiles": "^3.2.0", + "pmtiles": "^4.1.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", @@ -2133,15 +2133,6 @@ "integrity": "sha512-131wOmuwDg8ypYCSQ437bGdP+K2lJ8GJUu+ng4iQQxAc3irRnb7mGHbexsPChBcKWLctTR9V5LJdX5A8WWk44A==", "dev": true }, - "node_modules/@types/leaflet": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.12.tgz", - "integrity": "sha512-BK7XS+NyRI291HIo0HCfE18Lp8oA30H1gpi1tf0mF3TgiCEzanQjOqNZ4x126SXzzi2oNSZhZ5axJp1k0iM6jg==", - "license": "MIT", - "dependencies": { - "@types/geojson": "*" - } - }, "node_modules/@types/lodash": { "version": "4.17.0", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz", @@ -8861,13 +8852,12 @@ "integrity": "sha512-VJK1SRmXBpjwsB4YOHYSturx48rLKMzHgCqDH2ZDa6ZbMS/N5huoNqyQdK5Fj/xayu3fqbXckn5SeCS1EbMDZg==" }, "node_modules/pmtiles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.2.0.tgz", - "integrity": "sha512-4v3Nw5xeMxaUReLZQTz3PyM4VM/Lx/Xp/rc2GGEWMl0nqAmcb+gjyi+eOTwfPu8LnB0ash36hz0dV76uYvih5A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-4.1.0.tgz", + "integrity": "sha512-wymKYI61y3yI/iTzYHW18l6ViYBnF7TXbFnXb9q7RcWqkQ2EfgQVDzEIc5lImd3aAVkxu2tuWaoYhokov6N9VA==", "license": "BSD-3-Clause", "dependencies": { - "@types/leaflet": "^1.9.8", - "fflate": "^0.8.0" + "fflate": "^0.8.2" } }, "node_modules/possible-typed-array-names": { diff --git a/package.json b/package.json index ddf25d03..c6fb3118 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "maputnik-design": "github:maputnik/design#172b06c", "ol": "^6.14.1", "ol-mapbox-style": "^7.1.1", - "pmtiles": "^3.2.0", + "pmtiles": "^4.1.0", "prop-types": "^15.8.1", "react": "^18.2.0", "react-accessible-accordion": "^5.0.0", From 4087353219d2c42a561d32d149d405a5986818cb Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Sun, 29 Dec 2024 00:03:55 +0100 Subject: [PATCH 06/16] Add pmtiles source test --- cypress/e2e/modals.cy.ts | 15 +++++++++++++++ src/components/ModalSourcesTypeEditor.tsx | 1 + 2 files changed, 16 insertions(+) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index aade75fe..9f5bfcb7 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -83,6 +83,21 @@ describe("modals", () => { }); }); + it("add new pmtiles source", () => { + let sourceId = "pmtilestest"; + when.setValue("modal:sources.add.source_id", sourceId); + when.select("modal:sources.add.source_type", "pmtiles_vector"); + when.setValue("modal:sources.add.source_url", "https://data.source.coop/protomaps/openstreetmap/v4.pmtiles"); + when.click("modal:sources.add.add_source"); + when.wait(200); + then( + get.styleFromLocalStorage().then((style) => style.sources[sourceId]) + ).shouldInclude({ + type: "vector", + // url: "pmtiles://https://data.source.coop/protomaps/openstreetmap/v4.pmtiles", + }); + }); + it("add new raster source", () => { let sourceId = "rastertest"; when.setValue("modal:sources.add.source_id", sourceId); diff --git a/src/components/ModalSourcesTypeEditor.tsx b/src/components/ModalSourcesTypeEditor.tsx index 2c9a1492..20fd9fa6 100644 --- a/src/components/ModalSourcesTypeEditor.tsx +++ b/src/components/ModalSourcesTypeEditor.tsx @@ -302,6 +302,7 @@ class PMTilesSourceEditor extends React.Component { label={t("PMTiles URL")} fieldSpec={latest.source_vector.url} value={this.props.source.url} + data-wd-key="modal:sources.add.source_url" onChange={(url: string) => this.props.onChange({ ...this.props.source, url: url.startsWith("pmtiles://") ? url : `pmtiles://${url}` From 189c34e0a2fee4446b62497bdd11e69e5e66a5e7 Mon Sep 17 00:00:00 2001 From: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:27:45 +0200 Subject: [PATCH 07/16] Fix failing test --- cypress/e2e/modals.cy.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index 9f5bfcb7..3de61dde 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -88,13 +88,15 @@ describe("modals", () => { when.setValue("modal:sources.add.source_id", sourceId); when.select("modal:sources.add.source_type", "pmtiles_vector"); when.setValue("modal:sources.add.source_url", "https://data.source.coop/protomaps/openstreetmap/v4.pmtiles"); - when.click("modal:sources.add.add_source"); + when.realClick("modal:sources.add.add_source"); when.wait(200); - then( - get.styleFromLocalStorage().then((style) => style.sources[sourceId]) - ).shouldInclude({ - type: "vector", - // url: "pmtiles://https://data.source.coop/protomaps/openstreetmap/v4.pmtiles", + then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ + sources: { + pmtilestest: { + type: "vector", + url: "pmtiles://https://data.source.coop/protomaps/openstreetmap/v4.pmtiles", + }, + }, }); }); From 292666a294bd8708b116c453d3eb60b77fef03df Mon Sep 17 00:00:00 2001 From: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:47:01 +0200 Subject: [PATCH 08/16] fix tests for firefox --- cypress/e2e/modals.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index 3de61dde..b36d7c9a 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -88,7 +88,8 @@ describe("modals", () => { when.setValue("modal:sources.add.source_id", sourceId); when.select("modal:sources.add.source_type", "pmtiles_vector"); when.setValue("modal:sources.add.source_url", "https://data.source.coop/protomaps/openstreetmap/v4.pmtiles"); - when.realClick("modal:sources.add.add_source"); + when.blur("modal:sources.add.source_url"); + when.click("modal:sources.add.add_source"); when.wait(200); then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ sources: { From 616c9aa24a6b87967186b49393cea5d19893e1d5 Mon Sep 17 00:00:00 2001 From: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com> Date: Tue, 7 Jan 2025 06:13:47 +0200 Subject: [PATCH 09/16] if at first you don't succeed, try, try again --- cypress/e2e/modals.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index b36d7c9a..5139f8a9 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -88,7 +88,7 @@ describe("modals", () => { when.setValue("modal:sources.add.source_id", sourceId); when.select("modal:sources.add.source_type", "pmtiles_vector"); when.setValue("modal:sources.add.source_url", "https://data.source.coop/protomaps/openstreetmap/v4.pmtiles"); - when.blur("modal:sources.add.source_url"); + when.focus("modal:sources.add.add_source"); when.click("modal:sources.add.add_source"); when.wait(200); then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ From 6199b808d0ff54ae69616226d09b9e339429dc9c Mon Sep 17 00:00:00 2001 From: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:32:59 +0200 Subject: [PATCH 10/16] Try to fix tests --- cypress/e2e/modals.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index 5139f8a9..a9dcb9a5 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -88,7 +88,7 @@ describe("modals", () => { when.setValue("modal:sources.add.source_id", sourceId); when.select("modal:sources.add.source_type", "pmtiles_vector"); when.setValue("modal:sources.add.source_url", "https://data.source.coop/protomaps/openstreetmap/v4.pmtiles"); - when.focus("modal:sources.add.add_source"); + when.click("modal:sources.add.add_source"); when.click("modal:sources.add.add_source"); when.wait(200); then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ From 0dba0721ed94b95c22c19c57ee810f87183dd699 Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Sat, 11 Jan 2025 22:58:57 +0100 Subject: [PATCH 11/16] Make PMTiles source entry translatable --- src/components/App.tsx | 1 - src/components/ModalSources.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 7444ea04..31e2cf57 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -656,7 +656,6 @@ export default class App extends React.Component { (sources[key] as any).layers.push(layer.id) } - console.debug("Updating source: "+key); this.setState({ sources: sources }); diff --git a/src/components/ModalSources.tsx b/src/components/ModalSources.tsx index 05a5c09d..3db41bad 100644 --- a/src/components/ModalSources.tsx +++ b/src/components/ModalSources.tsx @@ -245,7 +245,7 @@ class AddSource extends React.Component { ['tile_raster', t('Raster (Tile URLs)')], ['tilejson_raster-dem', t('Raster DEM (TileJSON URL)')], ['tilexyz_raster-dem', t('Raster DEM (XYZ URLs)')], - ['pmtiles_vector', 'Vector (PMTiles)'], + ['pmtiles_vector', t('Vector (PMTiles)')], ['image', t('Image')], ['video', t('Video')], ]} From df4c417b3b6a2562ae9498913b56ce383f2431e8 Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Sun, 12 Jan 2025 14:13:23 +0100 Subject: [PATCH 12/16] npm run i18n:refresh --- src/locales/de/translation.json | 3 +++ src/locales/fr/translation.json | 3 +++ src/locales/he/translation.json | 3 +++ src/locales/ja/translation.json | 3 +++ src/locales/zh/translation.json | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json index 75072939..550bbf52 100644 --- a/src/locales/de/translation.json +++ b/src/locales/de/translation.json @@ -81,6 +81,7 @@ "Close modal": "Modale Fenster schließen", "Debug": "Debug", "Options": "Optionen", + "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "Stil Speichern", "Save the JSON style to your computer.": "Speichere den JSON Stil auf deinem Computer.", "Save as": "Speichern unter", @@ -149,6 +150,7 @@ "Raster (Tile URLs)": "Raster (Tile URLs)", "Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)", "Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)", + "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", "Image": "Bild", "Video": "Video", "Add Source": "Quelle hinzufügen", @@ -170,6 +172,7 @@ "GeoJSON URL": "GeoJSON URL", "GeoJSON": "GeoJSON", "Cluster": "Cluster", + "PMTiles URL": "__STRING_NOT_TRANSLATED__", "Tile Size": "Kachelgröße", "Encoding": "Kodierung", "Error:": "Fehler:", diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index e4957469..336a73e4 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -81,6 +81,7 @@ "Close modal": "Fermer la fenêtre modale", "Debug": "Déboguer", "Options": "Options", + "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "Enregistrer le style", "Save the JSON style to your computer.": "Enregistrer le style JSON sur votre ordinateur.", "Save as": "Enregistrer sous", @@ -149,6 +150,7 @@ "Raster (Tile URLs)": "Raster (URLs Tile)", "Raster DEM (TileJSON URL)": "Raster DEM (URL TileJSON)", "Raster DEM (XYZ URLs)": "Raster DEM (URLs XYZ)", + "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", "Image": "Image", "Video": "Vidéo", "Add Source": "Ajouter une source", @@ -170,6 +172,7 @@ "GeoJSON URL": "URL GeoJSON", "GeoJSON": "GeoJSON", "Cluster": "Cluster", + "PMTiles URL": "__STRING_NOT_TRANSLATED__", "Tile Size": "Dimension d'une tuile", "Encoding": "Encodage", "Error:": "Erreur :", diff --git a/src/locales/he/translation.json b/src/locales/he/translation.json index 5ed72d4d..36d17a24 100644 --- a/src/locales/he/translation.json +++ b/src/locales/he/translation.json @@ -81,6 +81,7 @@ "Close modal": "סגירת חלונית", "Debug": "דיבאג", "Options": "אפשרויות", + "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "שמירת הסטייל", "Save the JSON style to your computer.": "שמירת הסטייל JSON במחשב שלך.", "Save as": "שמירה בשם", @@ -149,6 +150,7 @@ "Raster (Tile URLs)": "Raster (Tile URLs)", "Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)", "Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)", + "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", "Image": "תמונה", "Video": "וידאו", "Add Source": "הוספת מקור", @@ -170,6 +172,7 @@ "GeoJSON URL": "כתובת GeoJSON", "GeoJSON": "GeoJSON", "Cluster": "קיבוץ", + "PMTiles URL": "__STRING_NOT_TRANSLATED__", "Tile Size": "גודל אריח", "Encoding": "קידוד", "Error:": "שגיאה", diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json index ba380259..ceb6b077 100644 --- a/src/locales/ja/translation.json +++ b/src/locales/ja/translation.json @@ -81,6 +81,7 @@ "Close modal": "モーダルを閉じる", "Debug": "デバッグ", "Options": "設定", + "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "スタイルを保存", "Save the JSON style to your computer.": "JSONスタイルをコンピュータに保存します。", "Save as": "名前を付けて保存", @@ -149,6 +150,7 @@ "Raster (Tile URLs)": "ラスタ (Tile URLs)", "Raster DEM (TileJSON URL)": "ラスタ DEM (TileJSON URL)", "Raster DEM (XYZ URLs)": "ラスタ DEM (XYZ URL)", + "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", "Image": "画像", "Video": "動画", "Add Source": "ソースを追加", @@ -170,6 +172,7 @@ "GeoJSON URL": "GeoJSON URL", "GeoJSON": "GeoJSON", "Cluster": "クラスタ", + "PMTiles URL": "__STRING_NOT_TRANSLATED__", "Tile Size": "タイルサイズ", "Encoding": "エンコーディング", "Error:": "エラー:", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index 63a76063..4c25d2ca 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -81,6 +81,7 @@ "Close modal": "关闭模态框", "Debug": "调试", "Options": "选项", + "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "保存样式", "Save the JSON style to your computer.": "将JSON样式保存到您的计算机。", "Save as": "另存为", @@ -149,6 +150,7 @@ "Raster (Tile URLs)": "栅格数据 (Tile URLs)", "Raster DEM (TileJSON URL)": "栅格高程数据 (TileJSON URL)", "Raster DEM (XYZ URLs)": "栅格高程数据 (XYZ URLs)", + "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", "Image": "图像", "Video": "视频", "Add Source": "添加源", @@ -170,6 +172,7 @@ "GeoJSON URL": "GeoJSON URL", "GeoJSON": "GeoJSON", "Cluster": "聚合", + "PMTiles URL": "__STRING_NOT_TRANSLATED__", "Tile Size": "__STRING_NOT_TRANSLATED__", "Encoding": "编码", "Error:": "错误:", From cf423c39dabedd0c59f8f0032c790aab2abc1408 Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Sun, 12 Jan 2025 14:15:50 +0100 Subject: [PATCH 13/16] Update german and french translations --- src/locales/de/translation.json | 4 ++-- src/locales/fr/translation.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json index 550bbf52..bf27d68b 100644 --- a/src/locales/de/translation.json +++ b/src/locales/de/translation.json @@ -150,7 +150,7 @@ "Raster (Tile URLs)": "Raster (Tile URLs)", "Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)", "Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)", - "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", + "Vector (PMTiles)": "Vektor (PMTiles)", "Image": "Bild", "Video": "Video", "Add Source": "Quelle hinzufügen", @@ -172,7 +172,7 @@ "GeoJSON URL": "GeoJSON URL", "GeoJSON": "GeoJSON", "Cluster": "Cluster", - "PMTiles URL": "__STRING_NOT_TRANSLATED__", + "PMTiles URL": "PMTiles URL", "Tile Size": "Kachelgröße", "Encoding": "Kodierung", "Error:": "Fehler:", diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index 336a73e4..a7c91075 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -150,7 +150,7 @@ "Raster (Tile URLs)": "Raster (URLs Tile)", "Raster DEM (TileJSON URL)": "Raster DEM (URL TileJSON)", "Raster DEM (XYZ URLs)": "Raster DEM (URLs XYZ)", - "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", + "Vector (PMTiles)": "Vecteur (PMTiles)", "Image": "Image", "Video": "Vidéo", "Add Source": "Ajouter une source", @@ -172,7 +172,7 @@ "GeoJSON URL": "URL GeoJSON", "GeoJSON": "GeoJSON", "Cluster": "Cluster", - "PMTiles URL": "__STRING_NOT_TRANSLATED__", + "PMTiles URL": "URL PMTiles", "Tile Size": "Dimension d'une tuile", "Encoding": "Encodage", "Error:": "Erreur :", From 51c5bb7f7f1675401d61aed87fefd77832a8e123 Mon Sep 17 00:00:00 2001 From: Harel M Date: Sun, 12 Jan 2025 16:03:18 +0200 Subject: [PATCH 14/16] Update src/locales/he/translation.json --- src/locales/he/translation.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/locales/he/translation.json b/src/locales/he/translation.json index 36d17a24..2df81cd2 100644 --- a/src/locales/he/translation.json +++ b/src/locales/he/translation.json @@ -81,7 +81,6 @@ "Close modal": "סגירת חלונית", "Debug": "דיבאג", "Options": "אפשרויות", - "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "שמירת הסטייל", "Save the JSON style to your computer.": "שמירת הסטייל JSON במחשב שלך.", "Save as": "שמירה בשם", From 6fbc79c5f573f50d5ea17ce0566ae373d5ae8195 Mon Sep 17 00:00:00 2001 From: Harel M Date: Sun, 12 Jan 2025 16:04:20 +0200 Subject: [PATCH 15/16] Apply suggestions from code review --- src/locales/he/translation.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/he/translation.json b/src/locales/he/translation.json index 2df81cd2..7be17f2b 100644 --- a/src/locales/he/translation.json +++ b/src/locales/he/translation.json @@ -149,7 +149,7 @@ "Raster (Tile URLs)": "Raster (Tile URLs)", "Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)", "Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)", - "Vector (PMTiles)": "__STRING_NOT_TRANSLATED__", + "Vector (PMTiles)": "Vector (PMTiles)", "Image": "תמונה", "Video": "וידאו", "Add Source": "הוספת מקור", @@ -171,7 +171,7 @@ "GeoJSON URL": "כתובת GeoJSON", "GeoJSON": "GeoJSON", "Cluster": "קיבוץ", - "PMTiles URL": "__STRING_NOT_TRANSLATED__", + "PMTiles URL": "כתובת PMTiles", "Tile Size": "גודל אריח", "Encoding": "קידוד", "Error:": "שגיאה", From 65cf85ccc7a1f822b35a9b34e5d932a83e34a1ab Mon Sep 17 00:00:00 2001 From: Harel M Date: Sun, 12 Jan 2025 16:05:57 +0200 Subject: [PATCH 16/16] Remove unwanted translation key --- src/locales/de/translation.json | 1 - src/locales/fr/translation.json | 1 - src/locales/ja/translation.json | 1 - src/locales/zh/translation.json | 1 - 4 files changed, 4 deletions(-) diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json index bf27d68b..435d9b04 100644 --- a/src/locales/de/translation.json +++ b/src/locales/de/translation.json @@ -81,7 +81,6 @@ "Close modal": "Modale Fenster schließen", "Debug": "Debug", "Options": "Optionen", - "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "Stil Speichern", "Save the JSON style to your computer.": "Speichere den JSON Stil auf deinem Computer.", "Save as": "Speichern unter", diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index a7c91075..3460a8c3 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -81,7 +81,6 @@ "Close modal": "Fermer la fenêtre modale", "Debug": "Déboguer", "Options": "Options", - "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "Enregistrer le style", "Save the JSON style to your computer.": "Enregistrer le style JSON sur votre ordinateur.", "Save as": "Enregistrer sous", diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json index ceb6b077..df84cacc 100644 --- a/src/locales/ja/translation.json +++ b/src/locales/ja/translation.json @@ -81,7 +81,6 @@ "Close modal": "モーダルを閉じる", "Debug": "デバッグ", "Options": "設定", - "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "スタイルを保存", "Save the JSON style to your computer.": "JSONスタイルをコンピュータに保存します。", "Save as": "名前を付けて保存", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index 4c25d2ca..c892585a 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -81,7 +81,6 @@ "Close modal": "关闭模态框", "Debug": "调试", "Options": "选项", - "<0>Open in OSM — Opens the current view on openstreetmap.org": "__STRING_NOT_TRANSLATED__", "Save Style": "保存样式", "Save the JSON style to your computer.": "将JSON样式保存到您的计算机。", "Save as": "另存为",