Skip to content

Commit 6089cde

Browse files
authored
Add scheme type options for vector/raster tile (#943)
## Launch Checklist <!-- Thanks for the PR! Feel free to add or remove items from the checklist. --> - [x] Briefly describe the changes in this PR. - [ ] Link to related issues. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [ ] Write tests for all new functionality. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. ![image](https://github.com/user-attachments/assets/39c275dc-b526-426b-9d46-db1f1635d7ee)
1 parent 25cf61a commit 6089cde

9 files changed

+61
-22
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### ✨ Features and improvements
44
- Add german translation
55
- Use same version number for web and desktop versions
6+
- Add scheme type options for vector/raster tile
67
- _...Add new stuff here..._
78

89
### 🐞 Bug fixes

cypress/e2e/modals.cy.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,27 @@ describe("modals", () => {
6161
});
6262

6363
describe("sources", () => {
64+
beforeEach(() => {
65+
when.setStyle("layer");
66+
when.click("nav:sources");
67+
});
68+
6469
it("active sources");
6570
it("public source");
66-
it("add new source");
71+
72+
it("add new source", () => {
73+
let sourceId = "n1z2v3r";
74+
when.setValue("modal:sources.add.source_id", sourceId);
75+
when.select("modal:sources.add.source_type", "tile_vector");
76+
when.select("modal:sources.add.scheme_type", "tms");
77+
when.click("modal:sources.add.add_source");
78+
when.wait(200);
79+
then(
80+
get.styleFromLocalStorage().then((style) => style.sources[sourceId])
81+
).shouldInclude({
82+
scheme: "tms",
83+
});
84+
});
6785
});
6886

6987
describe("inspect", () => {

src/components/ModalSources.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class PublicSource extends React.Component<PublicSourceProps> {
4242

4343
function editorMode(source: SourceSpecification) {
4444
if(source.type === 'raster') {
45-
if(source.tiles) return 'tilexyz_raster'
45+
if(source.tiles) return 'tile_raster'
4646
return 'tilejson_raster'
4747
}
4848
if(source.type === 'raster-dem') {
4949
if(source.tiles) return 'tilexyz_raster-dem'
5050
return 'tilejson_raster-dem'
5151
}
5252
if(source.type === 'vector') {
53-
if(source.tiles) return 'tilexyz_vector'
53+
if(source.tiles) return 'tile_vector'
5454
return 'tilejson_vector'
5555
}
5656
if(source.type === 'geojson') {
@@ -142,21 +142,23 @@ class AddSource extends React.Component<AddSourceProps, AddSourceState> {
142142
type: 'vector',
143143
url: (source as VectorSourceSpecification).url || `${protocol}//localhost:3000/tilejson.json`
144144
}
145-
case 'tilexyz_vector': return {
145+
case 'tile_vector': return {
146146
type: 'vector',
147147
tiles: (source as VectorSourceSpecification).tiles || [`${protocol}//localhost:3000/{x}/{y}/{z}.pbf`],
148148
minzoom: (source as VectorSourceSpecification).minzoom || 0,
149-
maxzoom: (source as VectorSourceSpecification).maxzoom || 14
149+
maxzoom: (source as VectorSourceSpecification).maxzoom || 14,
150+
scheme: (source as VectorSourceSpecification).scheme || 'xyz'
150151
}
151152
case 'tilejson_raster': return {
152153
type: 'raster',
153154
url: (source as RasterSourceSpecification).url || `${protocol}//localhost:3000/tilejson.json`
154155
}
155-
case 'tilexyz_raster': return {
156+
case 'tile_raster': return {
156157
type: 'raster',
157158
tiles: (source as RasterSourceSpecification).tiles || [`${protocol}//localhost:3000/{x}/{y}/{z}.pbf`],
158159
minzoom: (source as RasterSourceSpecification).minzoom || 0,
159-
maxzoom: (source as RasterSourceSpecification).maxzoom || 14
160+
maxzoom: (source as RasterSourceSpecification).maxzoom || 14,
161+
scheme: (source as RasterSourceSpecification).scheme || 'xyz'
160162
}
161163
case 'tilejson_raster-dem': return {
162164
type: 'raster-dem',
@@ -222,6 +224,7 @@ class AddSource extends React.Component<AddSourceProps, AddSourceState> {
222224
fieldSpec={{doc: t("Unique ID that identifies the source and is used in the layer to reference the source.")}}
223225
value={this.state.sourceId}
224226
onChange={(v: string) => this.setState({ sourceId: v})}
227+
data-wd-key="modal:sources.add.source_id"
225228
/>
226229
<FieldSelect
227230
label={t("Source Type")}
@@ -230,16 +233,17 @@ class AddSource extends React.Component<AddSourceProps, AddSourceState> {
230233
['geojson_json', t('GeoJSON (JSON)')],
231234
['geojson_url', t('GeoJSON (URL)')],
232235
['tilejson_vector', t('Vector (TileJSON URL)')],
233-
['tilexyz_vector', t('Vector (XYZ URLs)')],
236+
['tile_vector', t('Vector (Tile URLs)')],
234237
['tilejson_raster', t('Raster (TileJSON URL)')],
235-
['tilexyz_raster', t('Raster (XYZ URL)')],
238+
['tile_raster', t('Raster (Tile URLs)')],
236239
['tilejson_raster-dem', t('Raster DEM (TileJSON URL)')],
237240
['tilexyz_raster-dem', t('Raster DEM (XYZ URLs)')],
238241
['image', t('Image')],
239242
['video', t('Video')],
240243
]}
241244
onChange={mode => this.setState({mode: mode as EditorMode, source: this.defaultSource(mode as EditorMode)})}
242245
value={this.state.mode as string}
246+
data-wd-key="modal:sources.add.source_type"
243247
/>
244248
<ModalSourcesTypeEditor
245249
onChange={this.onChangeSource}
@@ -249,6 +253,7 @@ class AddSource extends React.Component<AddSourceProps, AddSourceState> {
249253
<InputButton
250254
className="maputnik-add-source-button"
251255
onClick={this.onAdd}
256+
data-wd-key="modal:sources.add.add_source"
252257
>
253258
{t("Add Source")}
254259
</InputButton>

src/components/ModalSourcesTypeEditor.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import FieldCheckbox from './FieldCheckbox'
1111
import { WithTranslation, withTranslation } from 'react-i18next';
1212
import { TFunction } from 'i18next'
1313

14-
export type EditorMode = "video" | "image" | "tilejson_vector" | "tilexyz_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "tilexyz_vector" | "geojson_url" | "geojson_json" | null;
14+
export type EditorMode = "video" | "image" | "tilejson_vector" | "tile_raster" | "tilejson_raster" | "tilexyz_raster-dem" | "tilejson_raster-dem" | "tile_vector" | "geojson_url" | "geojson_json" | null;
1515

1616
type TileJSONSourceEditorProps = {
1717
source: {
@@ -45,6 +45,7 @@ type TileURLSourceEditorProps = {
4545
tiles: string[]
4646
minzoom: number
4747
maxzoom: number
48+
scheme: 'xyz' | 'tms'
4849
}
4950
onChange(...args: unknown[]): unknown
5051
children?: React.ReactNode
@@ -73,6 +74,20 @@ class TileURLSourceEditor extends React.Component<TileURLSourceEditorProps> {
7374
const t = this.props.t;
7475
return <div>
7576
{this.renderTileUrls()}
77+
<FieldSelect
78+
label={t("Scheme Type")}
79+
fieldSpec={latest.source_vector.scheme}
80+
options={[
81+
['xyz', 'xyz (Slippy map tilenames scheme)'],
82+
['tms', 'tms (OSGeo spec scheme)'],
83+
]}
84+
onChange={scheme => this.props.onChange({
85+
...this.props.source,
86+
scheme
87+
})}
88+
value={this.props.source.scheme}
89+
data-wd-key="modal:sources.add.scheme_type"
90+
/>
7691
<FieldNumber
7792
label={t("Min Zoom")}
7893
fieldSpec={latest.source_vector.minzoom}
@@ -291,9 +306,9 @@ class ModalSourcesTypeEditorInternal extends React.Component<ModalSourcesTypeEdi
291306
case 'geojson_url': return <GeoJSONSourceUrlEditor {...commonProps} />
292307
case 'geojson_json': return <GeoJSONSourceFieldJsonEditor {...commonProps} />
293308
case 'tilejson_vector': return <TileJSONSourceEditor {...commonProps} />
294-
case 'tilexyz_vector': return <TileURLSourceEditor {...commonProps} />
309+
case 'tile_vector': return <TileURLSourceEditor {...commonProps} />
295310
case 'tilejson_raster': return <TileJSONSourceEditor {...commonProps} />
296-
case 'tilexyz_raster': return <TileURLSourceEditor {...commonProps} />
311+
case 'tile_raster': return <TileURLSourceEditor {...commonProps} />
297312
case 'tilejson_raster-dem': return <TileJSONSourceEditor {...commonProps} />
298313
case 'tilexyz_raster-dem': return <TileURLSourceEditor {...commonProps}>
299314
<FieldSelect

src/locales/de/translation.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@
147147
"GeoJSON (JSON)": "GeoJSON (JSON)",
148148
"GeoJSON (URL)": "GeoJSON (URL)",
149149
"Vector (TileJSON URL)": "Vektor (TileJSON URL)",
150-
"Vector (XYZ URLs)": "Vektor (XYZ URLs)",
150+
"Vector (Tile URLs)": "Vektor (Tile URLs)",
151151
"Raster (TileJSON URL)": "Raster (TileJSON URL)",
152-
"Raster (XYZ URL)": "Raster (XYZ URL)",
152+
"Raster (Tile URLs)": "Raster (Tile URLs)",
153153
"Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)",
154154
"Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)",
155155
"Image": "Bild",

src/locales/fr/translation.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@
147147
"GeoJSON (JSON)": "GeoJSON (JSON)",
148148
"GeoJSON (URL)": "GeoJSON (URL)",
149149
"Vector (TileJSON URL)": "Vecteur (URL TileJSON)",
150-
"Vector (XYZ URLs)": "Vecteur (URLs XYZ)",
150+
"Vector (Tile URLs)": "Vecteur (URLs Tile)",
151151
"Raster (TileJSON URL)": "Raster (URL TileJSON)",
152-
"Raster (XYZ URL)": "Raster (URL XYZ)",
152+
"Raster (Tile URLs)": "Raster (URLs Tile)",
153153
"Raster DEM (TileJSON URL)": "Raster DEM (URL TileJSON)",
154154
"Raster DEM (XYZ URLs)": "Raster DEM (URLs XYZ)",
155155
"Image": "Image",

src/locales/he/translation.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@
146146
"GeoJSON (JSON)": "GeoJSON (JSON)",
147147
"GeoJSON (URL)": "GeoJSON (URL)",
148148
"Vector (TileJSON URL)": "Vector (TileJSON URL)",
149-
"Vector (XYZ URLs)": "Vector (XYZ URLs)",
149+
"Vector (Tile URLs)": "Vector (Tile URLs)",
150150
"Raster (TileJSON URL)": "Raster (TileJSON URL)",
151-
"Raster (XYZ URL)": "Raster (XYZ URL)",
151+
"Raster (Tile URLs)": "Raster (Tile URLs)",
152152
"Raster DEM (TileJSON URL)": "Raster DEM (TileJSON URL)",
153153
"Raster DEM (XYZ URLs)": "Raster DEM (XYZ URLs)",
154154
"Image": "תמונה",

src/locales/ja/translation.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@
146146
"GeoJSON (JSON)": "GeoJSON (JSON)",
147147
"GeoJSON (URL)": "GeoJSON (URL)",
148148
"Vector (TileJSON URL)": "ベクトル (TileJSON URL)",
149-
"Vector (XYZ URLs)": "ベクトル (XYZ URL)",
149+
"Vector (Tile URLs)": "ベクトル (Tile URLs)",
150150
"Raster (TileJSON URL)": "ラスタ (TileJSON URL)",
151-
"Raster (XYZ URL)": "ラスタ (XYZ URL)",
151+
"Raster (Tile URLs)": "ラスタ (Tile URLs)",
152152
"Raster DEM (TileJSON URL)": "ラスタ DEM (TileJSON URL)",
153153
"Raster DEM (XYZ URLs)": "ラスタ DEM (XYZ URL)",
154154
"Image": "画像",

src/locales/zh/translation.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@
146146
"GeoJSON (JSON)": "GeoJSON (JSON格式)",
147147
"GeoJSON (URL)": "GeoJSON (URL格式)",
148148
"Vector (TileJSON URL)": "矢量数据 (TileJSON URL)",
149-
"Vector (XYZ URLs)": "矢量数据 (XYZ URLs)",
149+
"Vector (Tile URLs)": "矢量数据 (Tile URLs)",
150150
"Raster (TileJSON URL)": "栅格数据 (TileJSON URL)",
151-
"Raster (XYZ URL)": "栅格数据 (XYZ URL)",
151+
"Raster (Tile URLs)": "栅格数据 (Tile URLs)",
152152
"Raster DEM (TileJSON URL)": "栅格高程数据 (TileJSON URL)",
153153
"Raster DEM (XYZ URLs)": "栅格高程数据 (XYZ URLs)",
154154
"Image": "图像",

0 commit comments

Comments
 (0)