From defbef017c13e019d0dfe784daf6da67f4e81b20 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Thu, 18 May 2023 12:27:46 -0400 Subject: [PATCH 01/17] change default cs from pcrs to gcrs --- src/map-feature.js | 4 ++-- src/mapml/layers/FeatureLayer.js | 2 +- src/mapml/layers/TemplatedFeaturesLayer.js | 2 +- test/e2e/mapml-viewer/customTCRS.test.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/map-feature.js b/src/map-feature.js index 416886b8f..5779f441f 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -310,7 +310,7 @@ export class MapFeature extends HTMLElement { if (this._extentEl.querySelector('map-link[rel=query]')) { // for query, fallback zoom is the current map zoom level that the query is returned nativeZoom = this._map.getZoom(); - nativeCS = 'pcrs'; + nativeCS = 'gcrs'; } else if (this._extentEl.querySelector('map-link[rel=features]')) { // for templated feature, read fallback from the fetched mapml's map-meta[name=zoom / cs] nativeZoom = this._extentEl._nativeZoom; @@ -340,7 +340,7 @@ export class MapFeature extends HTMLElement { csLength = csMeta?.length; nativeCS = csLength ? csMeta[csLength - 1].getAttribute('content') - : 'pcrs'; + : 'gcrs'; return { zoom: nativeZoom, cs: nativeCS }; } } diff --git a/src/mapml/layers/FeatureLayer.js b/src/mapml/layers/FeatureLayer.js index 8fee20358..c62ebf492 100644 --- a/src/mapml/layers/FeatureLayer.js +++ b/src/mapml/layers/FeatureLayer.js @@ -130,7 +130,7 @@ export var FeatureLayer = L.FeatureGroup.extend({ M._metaContentToObject( mapml.querySelector('map-meta[name=cs]').getAttribute('content') ).content) || - 'PCRS'; + 'GCRS'; return { zoom: nativeZoom, cs: nativeCS }; }, diff --git a/src/mapml/layers/TemplatedFeaturesLayer.js b/src/mapml/layers/TemplatedFeaturesLayer.js index 54e160ee2..2f2e3c3c1 100644 --- a/src/mapml/layers/TemplatedFeaturesLayer.js +++ b/src/mapml/layers/TemplatedFeaturesLayer.js @@ -159,7 +159,7 @@ export var TemplatedFeaturesLayer = L.Layer.extend({ .querySelector('map-meta[name=cs]') .getAttribute('content') ).content) || - 'PCRS'); + 'GCRS'); features.addData(mapml, nativeCS, nativeZoom); // "migrate" to extent's shadow // make a clone, prevent the elements from being removed from mapml file diff --git a/test/e2e/mapml-viewer/customTCRS.test.js b/test/e2e/mapml-viewer/customTCRS.test.js index d8059d206..731e68a92 100644 --- a/test/e2e/mapml-viewer/customTCRS.test.js +++ b/test/e2e/mapml-viewer/customTCRS.test.js @@ -71,7 +71,7 @@ test.describe('Playwright Custom TCRS Tests', () => { expect(featureThree).toEqual('M382 -28L809 -28L809 399L382 399z'); expect(featureFour).toEqual( - 'M55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231L55 231z' + 'M150 429L171 426L175 438L181 457L183 461L185 463L185 465L187 465L185 468L185 470L184 472L186 477L186 481L188 485L182 486L154 490L154 492L157 494L157 497L158 498L156 501L154 501L151 499L150 495L149 495L148 498L148 501L144 501L141 477L141 448L141 431L139 430L150 429z' ); expect(staticFeatures).toEqual(false); From 2cf9a2400f738d702a182f9dd0dba5440fe8638c Mon Sep 17 00:00:00 2001 From: AliyanH Date: Thu, 18 May 2023 12:31:43 -0400 Subject: [PATCH 02/17] update index to use default cs --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ddfa9d00d..094a18eae 100644 --- a/index.html +++ b/index.html @@ -117,7 +117,7 @@ - + -75.705278 45.397778 From e1bfd0c9099e838be67386efa3b0d022e8b4e99d Mon Sep 17 00:00:00 2001 From: AliyanH Date: Wed, 31 May 2023 14:47:47 -0400 Subject: [PATCH 03/17] default layer projection to map's projection when map-meta projection not present for layer --- index.html | 1 - src/mapml/layers/MapMLLayer.js | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 094a18eae..320c86c74 100644 --- a/index.html +++ b/index.html @@ -76,7 +76,6 @@ A pleasing map of Canada - diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index 91f06539a..0eef0891e 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -1428,6 +1428,15 @@ export var MapMLLayer = L.Layer.extend({ projectionMatch = projection && projection === layer.options.mapprojection; } + } else { + // default projection set to parent projection when no map-meta projection element present + projection = layer.options.mapprojection; + projectionMatch = true; + serverMeta = projection; + console.log( + `A projection was not assigned to the '${this._layerEl.label}' Layer. Please specify a projection for that layer using a map-meta element. See more here - https://maps4html.org/web-map-doc/docs/elements/meta/` + ); + // TODO: Add a more obvious warning. } var metaExtent = mapml.querySelector('map-meta[name=extent]'), @@ -1496,7 +1505,13 @@ export var MapMLLayer = L.Layer.extend({ } } } else { - layer._extent = serverMeta; + if (typeof serverMeta === 'string') { + // when map-meta projection not present for layer + layer._extent = { serverMeta }; + } else { + // when map-meta projection present for layer + layer._extent = serverMeta; + } } layer._parseLicenseAndLegend(mapml, layer, projection); @@ -1728,7 +1743,7 @@ export var MapMLLayer = L.Layer.extend({ let extent = this._extent._mapExtents ? this._extent._mapExtents[0] : this._extent; // the projections for each extent eould be the same (as) validated in _validProjection, so can use mapExtents[0] - if (!extent) return FALLBACK_PROJECTION; + if (extent.serverMeta) return extent.serverMeta; switch (extent.tagName.toUpperCase()) { case 'MAP-EXTENT': if (extent.hasAttribute('units')) From 1d6dd6518d0538bdc8c83d794a9e298505d88c8a Mon Sep 17 00:00:00 2001 From: AliyanH Date: Fri, 2 Jun 2023 15:55:23 -0400 Subject: [PATCH 04/17] Add test to ensure a layer without any map-meta gets rendered --- test/e2e/core/metaDefault.html | 9 +++++++++ test/e2e/core/metaDefault.test.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/test/e2e/core/metaDefault.html b/test/e2e/core/metaDefault.html index fdd7a9e85..51f36f87a 100644 --- a/test/e2e/core/metaDefault.html +++ b/test/e2e/core/metaDefault.html @@ -34,6 +34,15 @@ tref="http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" > + + + + + -79.477626 43.764814 + + + + diff --git a/test/e2e/core/metaDefault.test.js b/test/e2e/core/metaDefault.test.js index 5f89c8d84..ebf37c836 100644 --- a/test/e2e/core/metaDefault.test.js +++ b/test/e2e/core/metaDefault.test.js @@ -90,4 +90,8 @@ test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () => expectedGCRSSecondLayer.bottomRight ); }); + test("Layer with no map-meta's is rendered on map", async () => { + let vector = await page.locator('.mapml-vector-container > svg'); + await expect(vector).toHaveCount(1); + }); }); From 64f240410d6a0a1e602960d39a89310fe304b95c Mon Sep 17 00:00:00 2001 From: AliyanH Date: Wed, 14 Jun 2023 15:29:24 -0400 Subject: [PATCH 05/17] update _getnativeVariables to support query inputs --- src/mapml/layers/FeatureLayer.js | 59 ++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/src/mapml/layers/FeatureLayer.js b/src/mapml/layers/FeatureLayer.js index c62ebf492..76adeedb4 100644 --- a/src/mapml/layers/FeatureLayer.js +++ b/src/mapml/layers/FeatureLayer.js @@ -116,21 +116,52 @@ export var FeatureLayer = L.FeatureGroup.extend({ } }, + // _getNativeVariables" returns an object with the native zoom and CS, + // based on the map-metas that are available within + // the layer or the fallback default values. + // _getNativeVariables: mapml-||layer-||null||[map-feature,...] -> {zoom: _, val: _} + // mapml can be a mapml- element, layer- element, null, or an array of map-features _getNativeVariables: function (mapml) { - let nativeZoom = - (mapml.querySelector && - mapml.querySelector('map-meta[name=zoom]') && - +M._metaContentToObject( - mapml.querySelector('map-meta[name=zoom]').getAttribute('content') - ).value) || - 0; - let nativeCS = - (mapml.querySelector && - mapml.querySelector('map-meta[name=cs]') && - M._metaContentToObject( - mapml.querySelector('map-meta[name=cs]').getAttribute('content') - ).content) || - 'GCRS'; + let nativeZoom, nativeCS; + // when mapml is an array of features provided by the query + if ( + mapml.length && + mapml[0].parentElement.parentElement && + mapml[0].parentElement.parentElement.tagName === 'mapml-' + ) { + let mapmlEl = mapml[0].parentElement.parentElement; + console.log(mapmlEl); + nativeZoom = + (mapmlEl.querySelector && + mapmlEl.querySelector('map-meta[name=zoom]') && + +M._metaContentToObject( + mapmlEl.querySelector('map-meta[name=zoom]').getAttribute('content') + ).value) || + 0; + nativeCS = + (mapmlEl.querySelector && + mapmlEl.querySelector('map-meta[name=cs]') && + M._metaContentToObject( + mapmlEl.querySelector('map-meta[name=cs]').getAttribute('content') + ).content) || + 'GCRS'; + } else { + // when mapml is null or a layer-/mapml- element + nativeZoom = + (mapml.querySelector && + mapml.querySelector('map-meta[name=zoom]') && + +M._metaContentToObject( + mapml.querySelector('map-meta[name=zoom]').getAttribute('content') + ).value) || + 0; + nativeCS = + (mapml.querySelector && + mapml.querySelector('map-meta[name=cs]') && + M._metaContentToObject( + mapml.querySelector('map-meta[name=cs]').getAttribute('content') + ).content) || + 'GCRS'; + } return { zoom: nativeZoom, cs: nativeCS }; }, From 330e7d8fadb092750f9c8a7d1feac5f168f1abdd Mon Sep 17 00:00:00 2001 From: AliyanH Date: Fri, 16 Jun 2023 14:05:12 -0400 Subject: [PATCH 06/17] Provide map-meta in map-extent shadowRoots to give respect to mapml document' metadata + fix zoom to here link for query --- src/map-feature.js | 26 +++++++++++++++++++++++--- src/mapml/handlers/QueryHandler.js | 8 +++++++- src/mapml/layers/FeatureLayer.js | 14 ++++++++++---- test/e2e/layers/queryLink.test.js | 3 ++- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/map-feature.js b/src/map-feature.js index 5779f441f..823cfcc04 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -303,14 +303,32 @@ export class MapFeature extends HTMLElement { _getNativeZoomAndCS(content) { // content: referred to if the has inline , or // referred to remote mapml if the has a src attribute, and the fetched mapml contains + // referred to [map-meta, ...] if it is query // referred to null otherwise (i.e. has fetched in shadow, the attaches to 's shadow) let nativeZoom, nativeCS; if (this._extentEl) { // feature attaches to extent's shadow if (this._extentEl.querySelector('map-link[rel=query]')) { // for query, fallback zoom is the current map zoom level that the query is returned - nativeZoom = this._map.getZoom(); - nativeCS = 'gcrs'; + let metaZoom, metaCS; + if (content) { + metaZoom = M._metaContentToObject( + Array.prototype.filter + .call(content, function (elem) { + return elem.matches('map-meta[name=zoom]'); + })[0] + ?.getAttribute('content') + ).content; + metaCS = M._metaContentToObject( + Array.prototype.filter + .call(content, function (elem) { + return elem.matches('map-meta[name=cs]'); + })[0] + ?.getAttribute('content') + ).content; + } + nativeZoom = metaZoom || this._map.getZoom(); + nativeCS = metaCS || 'gcrs'; } else if (this._extentEl.querySelector('map-link[rel=features]')) { // for templated feature, read fallback from the fetched mapml's map-meta[name=zoom / cs] nativeZoom = this._extentEl._nativeZoom; @@ -361,7 +379,9 @@ export class MapFeature extends HTMLElement { // calculate feature extent let map = this._map, geometry = this.querySelector('map-geometry'), - native = this._getNativeZoomAndCS(this._layer._content), + native = this._getNativeZoomAndCS( + this._layer._content || this._layer.metas + ), cs = geometry.getAttribute('cs') || native.cs, // zoom level that the feature rendered at zoom = this.zoom || native.zoom, diff --git a/src/mapml/handlers/QueryHandler.js b/src/mapml/handlers/QueryHandler.js index 666a563c5..45040008f 100644 --- a/src/mapml/handlers/QueryHandler.js +++ b/src/mapml/handlers/QueryHandler.js @@ -109,6 +109,12 @@ export var QueryHandler = L.Handler.extend({ features = Array.prototype.slice.call( mapmldoc.querySelectorAll('map-feature') ); + // elements + layer.metas = Array.prototype.slice.call( + mapmldoc.querySelectorAll( + 'map-meta[name=cs], map-meta[name=zoom], map-meta[name=projection]' + ) + ); if (features.length) layer._mapmlFeatures = layer._mapmlFeatures.concat(features); } else { @@ -279,7 +285,7 @@ export var QueryHandler = L.Handler.extend({ layer.on('popupclose', function () { map.removeLayer(f); }); - f.showPaginationFeature({ i: 0, popup: layer._popup }); + f.showPaginationFeature({ i: 0, popup: layer._popup, meta: layer.metas }); } } }); diff --git a/src/mapml/layers/FeatureLayer.js b/src/mapml/layers/FeatureLayer.js index 76adeedb4..dc96483a1 100644 --- a/src/mapml/layers/FeatureLayer.js +++ b/src/mapml/layers/FeatureLayer.js @@ -88,14 +88,21 @@ export var FeatureLayer = L.FeatureGroup.extend({ showPaginationFeature: function (e) { if (this.options.query && this._mapmlFeatures[e.i]) { let feature = this._mapmlFeatures[e.i]; - // remove the prev / next one from shadow if there is any - feature._extentEl.shadowRoot.firstChild?.remove(); + // empty the map-extent shadowRoot + // remove the prev / next one and 's from shadow if there is any + feature._extentEl.shadowRoot.replaceChildren(); this.clearLayers(); feature._featureGroup = this.addData( feature, this.options.nativeCS, this.options.nativeZoom ); + // append all map-meta from mapml document + if (e.meta) { + for (let i = 0; i < e.meta.length; i++) { + feature._extentEl.shadowRoot.appendChild(e.meta[i]); + } + } feature._extentEl.shadowRoot.appendChild(feature); e.popup._navigationBar.querySelector('p').innerText = e.i + 1 + '/' + this.options._leafletLayer._totalFeatureCount; @@ -116,7 +123,7 @@ export var FeatureLayer = L.FeatureGroup.extend({ } }, - // _getNativeVariables" returns an object with the native zoom and CS, + // _getNativeVariables: returns an object with the native zoom and CS, // based on the map-metas that are available within // the layer or the fallback default values. // _getNativeVariables: mapml-||layer-||null||[map-feature,...] -> {zoom: _, val: _} @@ -130,7 +137,6 @@ export var FeatureLayer = L.FeatureGroup.extend({ mapml[0].parentElement.parentElement.tagName === 'mapml-' ) { let mapmlEl = mapml[0].parentElement.parentElement; - console.log(mapmlEl); nativeZoom = (mapmlEl.querySelector && mapmlEl.querySelector('map-meta[name=zoom]') && diff --git a/test/e2e/layers/queryLink.test.js b/test/e2e/layers/queryLink.test.js index 51b16fa3d..d0b1420c4 100644 --- a/test/e2e/layers/queryLink.test.js +++ b/test/e2e/layers/queryLink.test.js @@ -130,7 +130,8 @@ test.describe('Playwright Query Link Tests', () => { const featureCount = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.children.length` ); - expect(featureCount).toEqual(1); + // shadowRoot contains 1 map-feature and 3 map-meta (cs, zoom, projection) + expect(featureCount).toEqual(4); const property = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.querySelector('map-properties').innerText.trim()` ); From 0f408b7824aadba702a6e92193b4097afa071811 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Mon, 19 Jun 2023 10:05:57 -0400 Subject: [PATCH 07/17] Add bug fix for empty getFeatureInfo --- src/mapml/handlers/QueryHandler.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mapml/handlers/QueryHandler.js b/src/mapml/handlers/QueryHandler.js index 45040008f..b0a494503 100644 --- a/src/mapml/handlers/QueryHandler.js +++ b/src/mapml/handlers/QueryHandler.js @@ -252,6 +252,7 @@ export var QueryHandler = L.Handler.extend({ } } function displayFeaturesPopup(features, loc) { + if (features.length === 0) return; let f = M.featureLayer(features, { // pass the vector layer a renderer of its own, otherwise leaflet // puts everything into the overlayPane From 41f373e5d382caf84dc9544692c4ca565f484a6d Mon Sep 17 00:00:00 2001 From: prushfor Date: Mon, 19 Jun 2023 16:11:32 -0400 Subject: [PATCH 08/17] Add map-feature._groupEl._feature property, which will allow code to navigate from focused on-screen element in shadow root to custom element (_groupEl already allows code navigation to SD-rendered content) Add test leveraging ._feature property to verify rendering of default coordinate system geometries. --- src/map-feature.js | 1 + test/e2e/core/metaDefault.html | 9 +++++++++ test/e2e/core/metaDefault.test.js | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/map-feature.js b/src/map-feature.js index 823cfcc04..33a23dc76 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -246,6 +246,7 @@ export class MapFeature extends HTMLElement { this._layer = parentEl._layer; _attachedToMap(); } + this._groupEl._feature = this; } _updateFeature() { diff --git a/test/e2e/core/metaDefault.html b/test/e2e/core/metaDefault.html index 51f36f87a..6cb3628ed 100644 --- a/test/e2e/core/metaDefault.html +++ b/test/e2e/core/metaDefault.html @@ -36,12 +36,21 @@ + gcrs location -79.477626 43.764814 + + pcrs location + + + 1515460 -157975 + + + diff --git a/test/e2e/core/metaDefault.test.js b/test/e2e/core/metaDefault.test.js index ebf37c836..6285837d2 100644 --- a/test/e2e/core/metaDefault.test.js +++ b/test/e2e/core/metaDefault.test.js @@ -94,4 +94,24 @@ test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () => let vector = await page.locator('.mapml-vector-container > svg'); await expect(vector).toHaveCount(1); }); + test('cs defaults / falls back to gcrs; priority is cs attribute, then map-meta, then fallback (gcrs)', async () => { + await page.click('body'); + await page.keyboard.press('Tab'); + await page.keyboard.press('Tab'); + const f1 = await page.evaluate( + () => + document.activeElement.shadowRoot.activeElement._feature.querySelector( + 'map-coordinates' + ).textContent + ); + expect(f1).toBe('1515460 -157975'); + await page.keyboard.press('ArrowRight'); + const f2 = await page.evaluate( + () => + document.activeElement.shadowRoot.activeElement._feature.querySelector( + 'map-coordinates' + ).textContent + ); + expect(f2).toBe('-79.477626 43.764814'); + }); }); From 3be3684c9ea7b638779be73077c82682972589b2 Mon Sep 17 00:00:00 2001 From: prushfor Date: Mon, 19 Jun 2023 16:27:36 -0400 Subject: [PATCH 09/17] Remove cs="gcrs" and because they are the defaults / fallback values when not explicitly marked up. --- test/e2e/geojson/mapml2geojson.html | 881 ++++++++++++++-------------- 1 file changed, 435 insertions(+), 446 deletions(-) diff --git a/test/e2e/geojson/mapml2geojson.html b/test/e2e/geojson/mapml2geojson.html index b5bc08458..91e199a04 100644 --- a/test/e2e/geojson/mapml2geojson.html +++ b/test/e2e/geojson/mapml2geojson.html @@ -1,447 +1,436 @@ - - - - - MapML 2 geoJSON - - - - - - - - - - - - - - Point - - - - -75.6916809 45.4186964 - - -

This is a Point

-
-
- - - - - Line - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a Line

-
-
- - - - - Polygon - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - -75.6596588 45.4211062 -75.6338958 45.4254436 -75.6277127 45.4066458 -75.6572542 45.4097792 -75.6596588 45.4211062 - - -

This is a Polygon

-
-
- - - - - MultiPoint - - - - -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 - - -

This is a multipoint

-
-
- - - - - MultiLineString - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a MultiLineString

-
-
- - - - - MultiPolygon - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - - - -

This is a MultiPolygon

-
-
- - - - - - - - - - Polygon - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - -
Property nameProperty value
id24e21a60be4811d892e2080020a0f4c9
label_frQuébec
label_enQuébec
label_abQuébec
type_frCITY-Ville
type_enCITY-City
-
- - - Line - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a Line

-
- - - Point - - - - -75.6916809 45.4186964 - - -

This is a Point

-
- - - MultiPoint - - - - -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 - - -

This is a multipoint

-
- - - MultiLineString - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a MultiLineString

-
- - - MultiPolygon - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - - - -

This is a MultiPolygon

-
- - - Polygon with holes - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - -75.6467062 45.4215881 -75.6889363 45.4049585 -75.6693647 45.3767494 -75.6270640 45.3924229 -75.6467062 45.4215881 - - -

This is a Polygon with holes

-
-
- - - - - - - - - - -75.5859375 45.465669 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.753479 45.3294614 -75.5831909 45.3815724 -75.602417 45.4273712 -75.5673981 45.4639834 -75.5859375 45.465669 - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - - -75.6916809 45.4186964 - - - - - - - - - - - - - - - - - -
Property nameProperty value
prop0This is a Geometry Collection
-
-
-
- - - - - - Point - - - - -75.6916809 45.4186964 - - - -

This is
bolded and emphasized
.

-
-
-
- - - - - - Point - - - - -75.6916809 45.4186964 - - - - - - - - - - - - - - - - -
Property nameProperty value
prop0This is a Point
-
-
-
- - - - - - -

Test

- - - - - 9 10 10 10 10 11 9 11 9 10 - - - - 10.5 11 - - - - - -
- - Geometry Collection - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 - -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 - 45.4639834 -75.5859375 45.4656690 - - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 - 45.377714 - - - - -75.6916809 45.4186964 - - - - - - -

This is a Geometry Collection

-
-
- - - - -

-

-

-

-

-

-

-

-

-

-

- -
- - -

-

-

-

-

-

-

-

-

-

-

- - - - - + + + + + MapML 2 geoJSON + + + + + + + + + + + + + Point + + + + -75.6916809 45.4186964 + + +

This is a Point

+
+
+ + + + Line + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a Line

+
+
+ + + + Polygon + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + -75.6596588 45.4211062 -75.6338958 45.4254436 -75.6277127 45.4066458 -75.6572542 45.4097792 -75.6596588 45.4211062 + + +

This is a Polygon

+
+
+ + + + MultiPoint + + + + -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 + + +

This is a multipoint

+
+
+ + + + MultiLineString + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a MultiLineString

+
+
+ + + + MultiPolygon + + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + + + +

This is a MultiPolygon

+
+
+ + + + + + + + + Polygon + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + +
Property nameProperty value
id24e21a60be4811d892e2080020a0f4c9
label_frQuébec
label_enQuébec
label_abQuébec
type_frCITY-Ville
type_enCITY-City
+
+ + + Line + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a Line

+
+ + + Point + + + + -75.6916809 45.4186964 + + +

This is a Point

+
+ + + MultiPoint + + + + -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 + + +

This is a multipoint

+
+ + + MultiLineString + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a MultiLineString

+
+ + + MultiPolygon + + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + + + +

This is a MultiPolygon

+
+ + + Polygon with holes + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + -75.6467062 45.4215881 -75.6889363 45.4049585 -75.6693647 45.3767494 -75.6270640 45.3924229 -75.6467062 45.4215881 + + +

This is a Polygon with holes

+
+
+ + + + + + + + + -75.5859375 45.465669 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.753479 45.3294614 -75.5831909 45.3815724 -75.602417 45.4273712 -75.5673981 45.4639834 -75.5859375 45.465669 + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + + -75.6916809 45.4186964 + + + + + + + + + + + + + + + + + +
Property nameProperty value
prop0This is a Geometry Collection
+
+
+
+ + + + + Point + + + + -75.6916809 45.4186964 + + + +

This is
bolded and emphasized
.

+
+
+
+ + + + + Point + + + + -75.6916809 45.4186964 + + + + + + + + + + + + + + + + +
Property nameProperty value
prop0This is a Point
+
+
+
+ + + + + +

Test

+ + + + + 9 10 10 10 10 11 9 11 9 10 + + + + 10.5 11 + + + + + +
+ + Geometry Collection + + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 + -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 + 45.4639834 -75.5859375 45.4656690 + + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 + 45.377714 + + + + -75.6916809 45.4186964 + + + + + + +

This is a Geometry Collection

+
+
+ +
+ + +

+

+

+

+

+

+

+

+

+

+

+ +
+ + +

+

+

+

+

+

+

+

+

+

+

+ + + + + \ No newline at end of file From 5fb03f92c5fa6aa122123db4ed89d98048f07de9 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Tue, 20 Jun 2023 07:43:43 -0400 Subject: [PATCH 10/17] update test to use default projection and CS, remove cs="gcrs", map-meta name="cs" content="gcrs" and map-meta name="projection" content="OSMTILE" Revert "Remove cs="gcrs" and " This reverts commit 3be3684c9ea7b638779be73077c82682972589b2. update test to use default projection and CS --- test/e2e/geojson/mapml2geojson.html | 854 ++++++++++++++-------------- 1 file changed, 418 insertions(+), 436 deletions(-) diff --git a/test/e2e/geojson/mapml2geojson.html b/test/e2e/geojson/mapml2geojson.html index 91e199a04..8de57da49 100644 --- a/test/e2e/geojson/mapml2geojson.html +++ b/test/e2e/geojson/mapml2geojson.html @@ -1,436 +1,418 @@ - - - - - MapML 2 geoJSON - - - - - - - - - - - - - Point - - - - -75.6916809 45.4186964 - - -

This is a Point

-
-
- - - - Line - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a Line

-
-
- - - - Polygon - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - -75.6596588 45.4211062 -75.6338958 45.4254436 -75.6277127 45.4066458 -75.6572542 45.4097792 -75.6596588 45.4211062 - - -

This is a Polygon

-
-
- - - - MultiPoint - - - - -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 - - -

This is a multipoint

-
-
- - - - MultiLineString - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a MultiLineString

-
-
- - - - MultiPolygon - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - - - -

This is a MultiPolygon

-
-
- - - - - - - - - Polygon - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - -
Property nameProperty value
id24e21a60be4811d892e2080020a0f4c9
label_frQuébec
label_enQuébec
label_abQuébec
type_frCITY-Ville
type_enCITY-City
-
- - - Line - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a Line

-
- - - Point - - - - -75.6916809 45.4186964 - - -

This is a Point

-
- - - MultiPoint - - - - -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 - - -

This is a multipoint

-
- - - MultiLineString - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - -

This is a MultiLineString

-
- - - MultiPolygon - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - - - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 - - - -

This is a MultiPolygon

-
- - - Polygon with holes - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 - -75.6467062 45.4215881 -75.6889363 45.4049585 -75.6693647 45.3767494 -75.6270640 45.3924229 -75.6467062 45.4215881 - - -

This is a Polygon with holes

-
-
- - - - - - - - - -75.5859375 45.465669 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.753479 45.3294614 -75.5831909 45.3815724 -75.602417 45.4273712 -75.5673981 45.4639834 -75.5859375 45.465669 - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 - - - -75.6916809 45.4186964 - - - - - - - - - - - - - - - - - -
Property nameProperty value
prop0This is a Geometry Collection
-
-
-
- - - - - Point - - - - -75.6916809 45.4186964 - - - -

This is
bolded and emphasized
.

-
-
-
- - - - - Point - - - - -75.6916809 45.4186964 - - - - - - - - - - - - - - - - -
Property nameProperty value
prop0This is a Point
-
-
-
- - - - - -

Test

- - - - - 9 10 10 10 10 11 9 11 9 10 - - - - 10.5 11 - - - - - -
- - Geometry Collection - - - - - -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 - -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 - 45.4639834 -75.5859375 45.4656690 - - - - - -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 - -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 - 45.377714 - - - - -75.6916809 45.4186964 - - - - - - -

This is a Geometry Collection

-
-
- -
- - -

-

-

-

-

-

-

-

-

-

-

- -
- - -

-

-

-

-

-

-

-

-

-

-

- - - - - - \ No newline at end of file + + + + + MapML 2 geoJSON + + + + + + + + + + + + + Point + + + -75.6916809 45.4186964 + + +

This is a Point

+
+
+ + + + Line + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a Line

+
+
+ + + + Polygon + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + -75.6596588 45.4211062 -75.6338958 45.4254436 -75.6277127 45.4066458 -75.6572542 45.4097792 -75.6596588 45.4211062 + + +

This is a Polygon

+
+
+ + + + MultiPoint + + + -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 + + +

This is a multipoint

+
+
+ + + + MultiLineString + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a MultiLineString

+
+
+ + + + MultiPolygon + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + + + +

This is a MultiPolygon

+
+
+ + + + + + + + + Polygon + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + +
Property nameProperty value
id24e21a60be4811d892e2080020a0f4c9
label_frQuébec
label_enQuébec
label_abQuébec
type_frCITY-Ville
type_enCITY-City
+
+ + + Line + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a Line

+
+ + + Point + + + -75.6916809 45.4186964 + + +

This is a Point

+
+ + + MultiPoint + + + -75.7016373 45.4391764 -75.7236099 45.4208652 -75.7833481 45.384225 + + +

This is a multipoint

+
+ + + MultiLineString + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + +

This is a MultiLineString

+
+ + + MultiPolygon + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + + + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + -75.6744295 45.4728920 -75.7053451 45.4439942 -75.7063756 45.4249616 -75.7489704 45.4177324 -75.7788555 45.4003785 -75.7943133 45.4321899 -75.6744295 45.4728920 + + + +

This is a MultiPolygon

+
+ + + Polygon with holes + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 45.4639834 -75.5859375 45.4656690 + -75.6467062 45.4215881 -75.6889363 45.4049585 -75.6693647 45.3767494 -75.6270640 45.3924229 -75.6467062 45.4215881 + + +

This is a Polygon with holes

+
+
+ + + + + + + + -75.5859375 45.465669 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 -75.7792282 45.3772317 -75.753479 45.3294614 -75.5831909 45.3815724 -75.602417 45.4273712 -75.5673981 45.4639834 -75.5859375 45.465669 + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 45.377714 + + + -75.6916809 45.4186964 + + + + + + + + + + + + + + + + + +
Property nameProperty value
prop0This is a Geometry Collection
+
+
+
+ + + + + Point + + + -75.6916809 45.4186964 + + + +

This is
bolded and emphasized
.

+
+
+
+ + + + + Point + + + -75.6916809 45.4186964 + + + + + + + + + + + + + + + + +
Property nameProperty value
prop0This is a Point
+
+
+
+ + + + +

Test

+ + + + + 9 10 10 10 10 11 9 11 9 10 + + + + 10.5 11 + + + + + +
+ + Geometry Collection + + + + -75.5859375 45.4656690 -75.6813812 45.4533876 -75.6961441 45.4239978 -75.7249832 45.4083331 + -75.7792282 45.3772317 -75.7534790 45.3294614 -75.5831909 45.3815724 -75.6024170 45.4273712 -75.5673981 + 45.4639834 -75.5859375 45.4656690 + + + + + -75.6168365 45.471929 -75.6855011 45.458445 -75.7016373 45.4391764 -75.7030106 45.4259255 + -75.7236099 45.4208652 -75.7565689 45.4117074 -75.7833481 45.384225 -75.8197403 45.3714435 -75.8516693 + 45.377714 + + + + -75.6916809 45.4186964 + + + + + + +

This is a Geometry Collection

+
+
+ +
+ + +

+

+

+

+

+

+

+

+

+

+

+ +
+ + +

+

+

+

+

+

+

+

+

+

+

+ + + + + + From 376e43a7712f8376a2399d62c8b8295bc7f9887b Mon Sep 17 00:00:00 2001 From: AliyanH Date: Sat, 24 Jun 2023 21:58:16 -0400 Subject: [PATCH 11/17] preserve map-metas in map-extent shadowroot when paginating --- src/mapml/layers/FeatureLayer.js | 11 ++++++++--- test/e2e/layers/queryLink.test.js | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mapml/layers/FeatureLayer.js b/src/mapml/layers/FeatureLayer.js index dc96483a1..2bb95bbae 100644 --- a/src/mapml/layers/FeatureLayer.js +++ b/src/mapml/layers/FeatureLayer.js @@ -88,9 +88,14 @@ export var FeatureLayer = L.FeatureGroup.extend({ showPaginationFeature: function (e) { if (this.options.query && this._mapmlFeatures[e.i]) { let feature = this._mapmlFeatures[e.i]; - // empty the map-extent shadowRoot - // remove the prev / next one and 's from shadow if there is any - feature._extentEl.shadowRoot.replaceChildren(); + if (e.type === 'featurepagination') { + // remove map-feature only (keep meta's) when paginating + feature._extentEl.shadowRoot.querySelector('map-feature').remove(); + } else { + // empty the map-extent shadowRoot + // remove the prev / next one and 's from shadow if there is any + feature._extentEl.shadowRoot.replaceChildren(); + } this.clearLayers(); feature._featureGroup = this.addData( feature, diff --git a/test/e2e/layers/queryLink.test.js b/test/e2e/layers/queryLink.test.js index d0b1420c4..73a688b99 100644 --- a/test/e2e/layers/queryLink.test.js +++ b/test/e2e/layers/queryLink.test.js @@ -164,7 +164,8 @@ test.describe('Playwright Query Link Tests', () => { const featureCount = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.children.length` ); - expect(featureCount).toEqual(1); + // shadowRoot contains 1 map-feature and 3 map-meta (cs, zoom, projection) + expect(featureCount).toEqual(4); const property = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.querySelector('map-properties').innerText.trim()` ); @@ -197,7 +198,8 @@ test.describe('Playwright Query Link Tests', () => { const featureCount = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.children.length` ); - expect(featureCount).toEqual(1); + // shadowRoot contains 1 map-feature and 3 map-meta (cs, zoom, projection) + expect(featureCount).toEqual(4); const property = await page.evaluate( `document.querySelector('mapml-viewer > layer- > map-extent').shadowRoot.querySelector('map-properties').innerText.trim()` ); From f11128f65234e0821560c336ecf784d0f77d60b0 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Sat, 24 Jun 2023 22:47:16 -0400 Subject: [PATCH 12/17] make statement fail-proof --- src/mapml/layers/FeatureLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapml/layers/FeatureLayer.js b/src/mapml/layers/FeatureLayer.js index 2bb95bbae..0a0956683 100644 --- a/src/mapml/layers/FeatureLayer.js +++ b/src/mapml/layers/FeatureLayer.js @@ -90,7 +90,7 @@ export var FeatureLayer = L.FeatureGroup.extend({ let feature = this._mapmlFeatures[e.i]; if (e.type === 'featurepagination') { // remove map-feature only (keep meta's) when paginating - feature._extentEl.shadowRoot.querySelector('map-feature').remove(); + feature._extentEl.shadowRoot.querySelector('map-feature')?.remove(); } else { // empty the map-extent shadowRoot // remove the prev / next one and 's from shadow if there is any From 958529111e144e7ac0b936a1941c98996e746d83 Mon Sep 17 00:00:00 2001 From: prushfor Date: Mon, 26 Jun 2023 15:45:29 -0400 Subject: [PATCH 13/17] Revert Add map-feature._groupEl._feature property. Will integrate (better) changes when we've resolved 'createmap' dilemma. --- src/map-feature.js | 1 - test/e2e/core/metaDefault.html | 9 --------- test/e2e/core/metaDefault.test.js | 20 -------------------- 3 files changed, 30 deletions(-) diff --git a/src/map-feature.js b/src/map-feature.js index 33a23dc76..823cfcc04 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -246,7 +246,6 @@ export class MapFeature extends HTMLElement { this._layer = parentEl._layer; _attachedToMap(); } - this._groupEl._feature = this; } _updateFeature() { diff --git a/test/e2e/core/metaDefault.html b/test/e2e/core/metaDefault.html index 6cb3628ed..51f36f87a 100644 --- a/test/e2e/core/metaDefault.html +++ b/test/e2e/core/metaDefault.html @@ -36,21 +36,12 @@ - gcrs location -79.477626 43.764814 - - pcrs location - - - 1515460 -157975 - - - diff --git a/test/e2e/core/metaDefault.test.js b/test/e2e/core/metaDefault.test.js index 6285837d2..ebf37c836 100644 --- a/test/e2e/core/metaDefault.test.js +++ b/test/e2e/core/metaDefault.test.js @@ -94,24 +94,4 @@ test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () => let vector = await page.locator('.mapml-vector-container > svg'); await expect(vector).toHaveCount(1); }); - test('cs defaults / falls back to gcrs; priority is cs attribute, then map-meta, then fallback (gcrs)', async () => { - await page.click('body'); - await page.keyboard.press('Tab'); - await page.keyboard.press('Tab'); - const f1 = await page.evaluate( - () => - document.activeElement.shadowRoot.activeElement._feature.querySelector( - 'map-coordinates' - ).textContent - ); - expect(f1).toBe('1515460 -157975'); - await page.keyboard.press('ArrowRight'); - const f2 = await page.evaluate( - () => - document.activeElement.shadowRoot.activeElement._feature.querySelector( - 'map-coordinates' - ).textContent - ); - expect(f2).toBe('-79.477626 43.764814'); - }); }); From ca9399d747cb305218b8dc5e86138c6ff56cef68 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Fri, 7 Jul 2023 10:22:46 -0400 Subject: [PATCH 14/17] Add default projection (OSMTILE) + remove use of 'createmap' events --- src/layer.js | 24 +++--------- src/map-extent.js | 12 +----- src/map-feature.js | 23 +++-------- src/mapml-viewer.js | 38 ++++++++++-------- src/mapml/handlers/AnnounceMovement.js | 10 ++++- src/mapml/layers/MapMLLayer.js | 6 ++- test/e2e/core/projectionDefault.html | 26 ++++++++++++ test/e2e/core/projectionDefault.test.js | 50 ++++++++++++++++++++++++ test/e2e/mapml-viewer/customTCRS.test.js | 18 ++++++--- 9 files changed, 134 insertions(+), 73 deletions(-) create mode 100644 test/e2e/core/projectionDefault.html create mode 100644 test/e2e/core/projectionDefault.test.js diff --git a/src/layer.js b/src/layer.js index 7f8d480ef..2222b0cdf 100644 --- a/src/layer.js +++ b/src/layer.js @@ -95,25 +95,11 @@ export class MapLayer extends HTMLElement { if (this.getAttribute('src') && !this.shadowRoot) { this.attachShadow({ mode: 'open' }); } - //creates listener that waits for createmap event, this allows for delayed builds of maps - //this allows a safeguard for the case where loading a custom TCRS takes longer than loading mapml-viewer.js/web-map.js - this.parentNode.addEventListener( - 'createmap', - () => { - this._ready(); - // if the map has been attached, set this layer up wrt Leaflet map - if (this.parentNode._map) { - this._attachedToMap(); - } - if (this._layerControl && !this.hidden) { - this._layerControl.addOrUpdateOverlay(this._layer, this.label); - } - }, - { once: true } - ); //listener stops listening after event occurs once - //if map is already created then dispatch createmap event, allowing layer to be built - if (this.parentNode._map) - this.parentNode.dispatchEvent(new CustomEvent('createmap')); + this._ready(); + this._attachedToMap(); + if (this._layerControl && !this.hidden) { + this._layerControl.addOrUpdateOverlay(this._layer, this.label); + } } adoptedCallback() { diff --git a/src/map-extent.js b/src/map-extent.js index bb81f376e..9b81dc2bb 100644 --- a/src/map-extent.js +++ b/src/map-extent.js @@ -78,17 +78,7 @@ export class MapExtent extends HTMLElement { this.parentNode.nodeName.toUpperCase() === 'LAYER-' ? this.parentNode : this.parentNode.host; - if (!parentLayer._layer) { - // for custom projection cases, the MapMLLayer has not yet created and binded with the layer- at this point, - // because the "createMap" event of mapml-viewer has not yet been dispatched, the map has not yet been created - // the event will be dispatched after defineCustomProjection > projection setter - // should wait until MapMLLayer is built - parentLayer.parentNode.addEventListener('createmap', (e) => { - this._layer = parentLayer._layer; - }); - } else { - this._layer = parentLayer._layer; - } + this._layer = parentLayer._layer; } disconnectedCallback() {} } diff --git a/src/map-feature.js b/src/map-feature.js index 823cfcc04..e0df27e46 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -229,23 +229,12 @@ export class MapFeature extends HTMLElement { } }; - if (!parentEl._layer) { - // for custom projection cases, the MapMLLayer has not yet created and binded with the layer- at this point, - // because the "createMap" event of mapml-viewer has not yet been dispatched, the map has not yet been created - // the event will be dispatched after defineCustomProjection > projection setter - // should wait until MapMLLayer is built - let parentLayer = - parentEl.nodeName.toUpperCase() === 'LAYER-' - ? parentEl - : parentEl.parentElement || parentEl.parentNode.host; - parentLayer.parentNode.addEventListener('createmap', (e) => { - this._layer = parentLayer._layer; - _attachedToMap(); - }); - } else { - this._layer = parentEl._layer; - _attachedToMap(); - } + let parentLayer = + parentEl.nodeName.toUpperCase() === 'LAYER-' + ? parentEl + : parentEl.parentElement || parentEl.parentNode.host; + this._layer = parentLayer._layer; + _attachedToMap(); } _updateFeature() { diff --git a/src/mapml-viewer.js b/src/mapml-viewer.js index 1210f4b72..599a1b42d 100644 --- a/src/mapml-viewer.js +++ b/src/mapml-viewer.js @@ -74,23 +74,13 @@ export class MapViewer extends HTMLElement { } } get projection() { - return this.hasAttribute('projection') + return this.hasAttribute('projection') && M[this.getAttribute('projection')] ? this.getAttribute('projection') - : ''; + : 'OSMTILE'; } set projection(val) { if (val && M[val]) { this.setAttribute('projection', val); - if (this._map && this._map.options.projection !== val) { - this._map.options.crs = M[val]; - this._map.options.projection = val; - for (let layer of this.querySelectorAll('layer-')) { - layer.removeAttribute('disabled'); - let reAttach = this.removeChild(layer); - this.appendChild(reAttach); - } - if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug(); - } else this.dispatchEvent(new CustomEvent('createmap')); } else throw new Error('Undefined Projection'); } get zoom() { @@ -176,7 +166,6 @@ export class MapViewer extends HTMLElement { // is because the mapml-viewer element has / can have a size of 0 up until after // something that happens between this point and the event handler executing // perhaps a browser rendering cycle?? - this.addEventListener('createmap', this._createMap); let custom = !['CBMTILE', 'APSTILE', 'OSMTILE', 'WGS84'].includes( this.projection @@ -185,9 +174,8 @@ export class MapViewer extends HTMLElement { // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent // In particular: // "All applicable event handlers are called and return before dispatchEvent() returns." - if (!custom) { - this.dispatchEvent(new CustomEvent('createmap')); - } + this._createMap(); + // https://github.com/Maps4HTML/Web-Map-Custom-Element/issues/274 this.setAttribute('role', 'application'); this._toggleStatic(); @@ -362,6 +350,22 @@ export class MapViewer extends HTMLElement { case 'static': this._toggleStatic(); break; + case 'projection': + if (newValue && M[newValue]) { + if (this._map && this._map.options.projection !== newValue) { + this._map.options.crs = M[newValue]; + this._map.options.projection = newValue; + for (let layer of this.querySelectorAll('layer-')) { + layer.removeAttribute('disabled'); + let reAttach = this.removeChild(layer); + this.appendChild(reAttach); + } + if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug(); + this.zoomTo(this.lat, this.lon, this.zoom); + //this.dispatchEvent(new CustomEvent('projectionchange')); + } + } + break; } } @@ -815,7 +819,7 @@ export class MapViewer extends HTMLElement { this._updateMapCenter(); this._addToHistory(); this.dispatchEvent( - new CustomEvent('moveend', { detail: { target: this } }) + new CustomEvent('map-moveend', { detail: { target: this } }) ); }, this diff --git a/src/mapml/handlers/AnnounceMovement.js b/src/mapml/handlers/AnnounceMovement.js index f0beef557..960efdd3a 100644 --- a/src/mapml/handlers/AnnounceMovement.js +++ b/src/mapml/handlers/AnnounceMovement.js @@ -5,7 +5,10 @@ export var AnnounceMovement = L.Handler.extend({ layerremove: this.totalBounds }); - this._map.options.mapEl.addEventListener('moveend', this.announceBounds); + this._map.options.mapEl.addEventListener( + 'map-moveend', + this.announceBounds + ); this._map.dragging._draggable.addEventListener('dragstart', this.dragged); this._map.options.mapEl.addEventListener( 'mapfocused', @@ -18,7 +21,10 @@ export var AnnounceMovement = L.Handler.extend({ layerremove: this.totalBounds }); - this._map.options.mapEl.removeEventListener('moveend', this.announceBounds); + this._map.options.mapEl.removeEventListener( + 'map-moveend', + this.announceBounds + ); this._map.dragging._draggable.removeEventListener( 'dragstart', this.dragged diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index 0eef0891e..a3f5e7477 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -1247,7 +1247,10 @@ export var MapMLLayer = L.Layer.extend({ cs ); } else { - extentFallback.bounds = M[projection].options.crs.pcrs.bounds; + // for custom projections, M[projection] may not be loaded, so uses M['OSMTILE'] as backup, this code will need to get rerun once projection is changed and M[projection] is available + // TODO: This is a temporary fix, _initTemplateVars (or processinitialextent) should not be called when projection of the layer and map do not match, this should be called/reinitialized once the layer projection matches with the map projection + let fallbackProjection = M[projection] || M.OSMTILE; + extentFallback.bounds = fallbackProjection.options.crs.pcrs.bounds; } for (var i = 0; i < tlist.length; i++) { @@ -1468,6 +1471,7 @@ export var MapMLLayer = L.Layer.extend({ ); return; } else if ( + // when there is only one layer with different projection from the map, change's map's projection to match layer !projectionMatch && layer._map && layer._map.options.mapEl.querySelectorAll('layer-').length === 1 diff --git a/test/e2e/core/projectionDefault.html b/test/e2e/core/projectionDefault.html new file mode 100644 index 000000000..e1edab2dc --- /dev/null +++ b/test/e2e/core/projectionDefault.html @@ -0,0 +1,26 @@ + + + + + + + + Default Projection + + + + + + Rectangle + + + -123.216259390223 55.90361621419453 -123.216259390223 -0.5886925650467134 78.15130158758717 -0.5886925650467134 78.15130158758717 55.90361621419453 -123.216259390223 55.90361621419453 + + + + Rectangle + + + + + \ No newline at end of file diff --git a/test/e2e/core/projectionDefault.test.js b/test/e2e/core/projectionDefault.test.js new file mode 100644 index 000000000..91ebcd856 --- /dev/null +++ b/test/e2e/core/projectionDefault.test.js @@ -0,0 +1,50 @@ +import { test, expect, chromium } from '@playwright/test'; + +test.describe('Playwright Viewer Default Projection', () => { + let page; + let context; + test.beforeAll(async () => { + context = await chromium.launchPersistentContext(''); + page = + context.pages().find((page) => page.url() === 'about:blank') || + (await context.newPage()); + await page.goto('projectionDefault.html'); + }); + + test.afterAll(async function () { + await context.close(); + }); + + test.describe('Viewer with no projection attribute', () => { + test('Viewer defaults to OSMTILE', async () => { + const mapProjection = await page.$eval( + 'body > mapml-viewer', + (map) => map.projection + ); + const leafletProjection = await page.$eval( + 'body > mapml-viewer', + (map) => map._map.options.projection + ); + const leafletProjection1 = await page.$eval( + 'body > mapml-viewer', + (map) => map._map.options.crs.code + ); + const projectionAttribute = await page.$eval( + 'body > mapml-viewer', + (map) => map.getAttribute('projection') + ); + expect(mapProjection).toEqual('OSMTILE'); + expect(leafletProjection).toEqual('OSMTILE'); + expect(leafletProjection1).toEqual('EPSG:3857'); + expect(projectionAttribute).toEqual(null); + }); + + test('layer renders', async () => { + const featureSVG = await page.$eval( + 'body > mapml-viewer > layer- > map-feature', + (feature) => feature._groupEl.firstChild.getAttribute('d') + ); + expect(featureSVG).toEqual('M62 27L62 75L206 75L206 27L62 27z'); + }); + }); +}); diff --git a/test/e2e/mapml-viewer/customTCRS.test.js b/test/e2e/mapml-viewer/customTCRS.test.js index 731e68a92..cf0d4a06c 100644 --- a/test/e2e/mapml-viewer/customTCRS.test.js +++ b/test/e2e/mapml-viewer/customTCRS.test.js @@ -18,8 +18,13 @@ test.describe('Playwright Custom TCRS Tests', () => { test('Simple Custom TCRS, tiles load, mismatched layer disabled', async () => { const misMatchedLayerDisabled = await page.$eval( - 'body > mapml-viewer:nth-child(1) > layer-:nth-child(1)', - (layer) => layer.hasAttribute('disabled') + 'body > mapml-viewer:nth-child(1)', + (map) => map.querySelectorAll('layer-')[0].hasAttribute('disabled') + ); + + const matchedLayerEnabled = await page.$eval( + 'body > mapml-viewer:nth-child(1)', + (map) => map.querySelectorAll('layer-')[1].hasAttribute('disabled') ); const tilesLoaded = await page.$eval( @@ -29,6 +34,7 @@ test.describe('Playwright Custom TCRS Tests', () => { expect(tilesLoaded).toEqual(2); expect(misMatchedLayerDisabled).toEqual(true); + expect(matchedLayerEnabled).toEqual(false); }); test('A projection name containing a colon is invalid', async () => { const message = await page.$eval( @@ -39,13 +45,13 @@ test.describe('Playwright Custom TCRS Tests', () => { }); test('Complex Custom TCRS, static features loaded, templated features loaded', async () => { const staticFeatures = await page.$eval( - 'body > mapml-viewer:nth-child(3) > layer-:nth-child(1)', - (layer) => layer.hasAttribute('disabled') + 'body > mapml-viewer:nth-child(3)', + (map) => map.querySelectorAll('layer-')[0].hasAttribute('disabled') ); const templatedFeatures = await page.$eval( - 'body > mapml-viewer:nth-child(3) > layer-:nth-child(2)', - (layer) => layer.hasAttribute('disabled') + 'body > mapml-viewer:nth-child(3)', + (map) => map.querySelectorAll('layer-')[1].hasAttribute('disabled') ); const featureOne = await page.$eval( From a3b4a0ba33ec2339caa65d90443a0bc822e2a237 Mon Sep 17 00:00:00 2001 From: Aliyan Haq <55751566+AliyanH@users.noreply.github.com> Date: Tue, 18 Jul 2023 11:49:25 -0400 Subject: [PATCH 15/17] Revert "Add default projection (OSMTILE) + remove use of 'createmap' events" This reverts commit ca9399d747cb305218b8dc5e86138c6ff56cef68. --- src/layer.js | 24 +++++++++--- src/map-extent.js | 12 +++++- src/map-feature.js | 23 ++++++++--- src/mapml-viewer.js | 38 ++++++++---------- src/mapml/handlers/AnnounceMovement.js | 10 +---- src/mapml/layers/MapMLLayer.js | 6 +-- test/e2e/core/projectionDefault.html | 26 ------------ test/e2e/core/projectionDefault.test.js | 50 ------------------------ test/e2e/mapml-viewer/customTCRS.test.js | 18 +++------ 9 files changed, 73 insertions(+), 134 deletions(-) delete mode 100644 test/e2e/core/projectionDefault.html delete mode 100644 test/e2e/core/projectionDefault.test.js diff --git a/src/layer.js b/src/layer.js index 2222b0cdf..7f8d480ef 100644 --- a/src/layer.js +++ b/src/layer.js @@ -95,11 +95,25 @@ export class MapLayer extends HTMLElement { if (this.getAttribute('src') && !this.shadowRoot) { this.attachShadow({ mode: 'open' }); } - this._ready(); - this._attachedToMap(); - if (this._layerControl && !this.hidden) { - this._layerControl.addOrUpdateOverlay(this._layer, this.label); - } + //creates listener that waits for createmap event, this allows for delayed builds of maps + //this allows a safeguard for the case where loading a custom TCRS takes longer than loading mapml-viewer.js/web-map.js + this.parentNode.addEventListener( + 'createmap', + () => { + this._ready(); + // if the map has been attached, set this layer up wrt Leaflet map + if (this.parentNode._map) { + this._attachedToMap(); + } + if (this._layerControl && !this.hidden) { + this._layerControl.addOrUpdateOverlay(this._layer, this.label); + } + }, + { once: true } + ); //listener stops listening after event occurs once + //if map is already created then dispatch createmap event, allowing layer to be built + if (this.parentNode._map) + this.parentNode.dispatchEvent(new CustomEvent('createmap')); } adoptedCallback() { diff --git a/src/map-extent.js b/src/map-extent.js index 9b81dc2bb..bb81f376e 100644 --- a/src/map-extent.js +++ b/src/map-extent.js @@ -78,7 +78,17 @@ export class MapExtent extends HTMLElement { this.parentNode.nodeName.toUpperCase() === 'LAYER-' ? this.parentNode : this.parentNode.host; - this._layer = parentLayer._layer; + if (!parentLayer._layer) { + // for custom projection cases, the MapMLLayer has not yet created and binded with the layer- at this point, + // because the "createMap" event of mapml-viewer has not yet been dispatched, the map has not yet been created + // the event will be dispatched after defineCustomProjection > projection setter + // should wait until MapMLLayer is built + parentLayer.parentNode.addEventListener('createmap', (e) => { + this._layer = parentLayer._layer; + }); + } else { + this._layer = parentLayer._layer; + } } disconnectedCallback() {} } diff --git a/src/map-feature.js b/src/map-feature.js index e0df27e46..823cfcc04 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -229,12 +229,23 @@ export class MapFeature extends HTMLElement { } }; - let parentLayer = - parentEl.nodeName.toUpperCase() === 'LAYER-' - ? parentEl - : parentEl.parentElement || parentEl.parentNode.host; - this._layer = parentLayer._layer; - _attachedToMap(); + if (!parentEl._layer) { + // for custom projection cases, the MapMLLayer has not yet created and binded with the layer- at this point, + // because the "createMap" event of mapml-viewer has not yet been dispatched, the map has not yet been created + // the event will be dispatched after defineCustomProjection > projection setter + // should wait until MapMLLayer is built + let parentLayer = + parentEl.nodeName.toUpperCase() === 'LAYER-' + ? parentEl + : parentEl.parentElement || parentEl.parentNode.host; + parentLayer.parentNode.addEventListener('createmap', (e) => { + this._layer = parentLayer._layer; + _attachedToMap(); + }); + } else { + this._layer = parentEl._layer; + _attachedToMap(); + } } _updateFeature() { diff --git a/src/mapml-viewer.js b/src/mapml-viewer.js index 599a1b42d..1210f4b72 100644 --- a/src/mapml-viewer.js +++ b/src/mapml-viewer.js @@ -74,13 +74,23 @@ export class MapViewer extends HTMLElement { } } get projection() { - return this.hasAttribute('projection') && M[this.getAttribute('projection')] + return this.hasAttribute('projection') ? this.getAttribute('projection') - : 'OSMTILE'; + : ''; } set projection(val) { if (val && M[val]) { this.setAttribute('projection', val); + if (this._map && this._map.options.projection !== val) { + this._map.options.crs = M[val]; + this._map.options.projection = val; + for (let layer of this.querySelectorAll('layer-')) { + layer.removeAttribute('disabled'); + let reAttach = this.removeChild(layer); + this.appendChild(reAttach); + } + if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug(); + } else this.dispatchEvent(new CustomEvent('createmap')); } else throw new Error('Undefined Projection'); } get zoom() { @@ -166,6 +176,7 @@ export class MapViewer extends HTMLElement { // is because the mapml-viewer element has / can have a size of 0 up until after // something that happens between this point and the event handler executing // perhaps a browser rendering cycle?? + this.addEventListener('createmap', this._createMap); let custom = !['CBMTILE', 'APSTILE', 'OSMTILE', 'WGS84'].includes( this.projection @@ -174,8 +185,9 @@ export class MapViewer extends HTMLElement { // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent // In particular: // "All applicable event handlers are called and return before dispatchEvent() returns." - this._createMap(); - + if (!custom) { + this.dispatchEvent(new CustomEvent('createmap')); + } // https://github.com/Maps4HTML/Web-Map-Custom-Element/issues/274 this.setAttribute('role', 'application'); this._toggleStatic(); @@ -350,22 +362,6 @@ export class MapViewer extends HTMLElement { case 'static': this._toggleStatic(); break; - case 'projection': - if (newValue && M[newValue]) { - if (this._map && this._map.options.projection !== newValue) { - this._map.options.crs = M[newValue]; - this._map.options.projection = newValue; - for (let layer of this.querySelectorAll('layer-')) { - layer.removeAttribute('disabled'); - let reAttach = this.removeChild(layer); - this.appendChild(reAttach); - } - if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug(); - this.zoomTo(this.lat, this.lon, this.zoom); - //this.dispatchEvent(new CustomEvent('projectionchange')); - } - } - break; } } @@ -819,7 +815,7 @@ export class MapViewer extends HTMLElement { this._updateMapCenter(); this._addToHistory(); this.dispatchEvent( - new CustomEvent('map-moveend', { detail: { target: this } }) + new CustomEvent('moveend', { detail: { target: this } }) ); }, this diff --git a/src/mapml/handlers/AnnounceMovement.js b/src/mapml/handlers/AnnounceMovement.js index 960efdd3a..f0beef557 100644 --- a/src/mapml/handlers/AnnounceMovement.js +++ b/src/mapml/handlers/AnnounceMovement.js @@ -5,10 +5,7 @@ export var AnnounceMovement = L.Handler.extend({ layerremove: this.totalBounds }); - this._map.options.mapEl.addEventListener( - 'map-moveend', - this.announceBounds - ); + this._map.options.mapEl.addEventListener('moveend', this.announceBounds); this._map.dragging._draggable.addEventListener('dragstart', this.dragged); this._map.options.mapEl.addEventListener( 'mapfocused', @@ -21,10 +18,7 @@ export var AnnounceMovement = L.Handler.extend({ layerremove: this.totalBounds }); - this._map.options.mapEl.removeEventListener( - 'map-moveend', - this.announceBounds - ); + this._map.options.mapEl.removeEventListener('moveend', this.announceBounds); this._map.dragging._draggable.removeEventListener( 'dragstart', this.dragged diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index a3f5e7477..0eef0891e 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -1247,10 +1247,7 @@ export var MapMLLayer = L.Layer.extend({ cs ); } else { - // for custom projections, M[projection] may not be loaded, so uses M['OSMTILE'] as backup, this code will need to get rerun once projection is changed and M[projection] is available - // TODO: This is a temporary fix, _initTemplateVars (or processinitialextent) should not be called when projection of the layer and map do not match, this should be called/reinitialized once the layer projection matches with the map projection - let fallbackProjection = M[projection] || M.OSMTILE; - extentFallback.bounds = fallbackProjection.options.crs.pcrs.bounds; + extentFallback.bounds = M[projection].options.crs.pcrs.bounds; } for (var i = 0; i < tlist.length; i++) { @@ -1471,7 +1468,6 @@ export var MapMLLayer = L.Layer.extend({ ); return; } else if ( - // when there is only one layer with different projection from the map, change's map's projection to match layer !projectionMatch && layer._map && layer._map.options.mapEl.querySelectorAll('layer-').length === 1 diff --git a/test/e2e/core/projectionDefault.html b/test/e2e/core/projectionDefault.html deleted file mode 100644 index e1edab2dc..000000000 --- a/test/e2e/core/projectionDefault.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - Default Projection - - - - - - Rectangle - - - -123.216259390223 55.90361621419453 -123.216259390223 -0.5886925650467134 78.15130158758717 -0.5886925650467134 78.15130158758717 55.90361621419453 -123.216259390223 55.90361621419453 - - - - Rectangle - - - - - \ No newline at end of file diff --git a/test/e2e/core/projectionDefault.test.js b/test/e2e/core/projectionDefault.test.js deleted file mode 100644 index 91ebcd856..000000000 --- a/test/e2e/core/projectionDefault.test.js +++ /dev/null @@ -1,50 +0,0 @@ -import { test, expect, chromium } from '@playwright/test'; - -test.describe('Playwright Viewer Default Projection', () => { - let page; - let context; - test.beforeAll(async () => { - context = await chromium.launchPersistentContext(''); - page = - context.pages().find((page) => page.url() === 'about:blank') || - (await context.newPage()); - await page.goto('projectionDefault.html'); - }); - - test.afterAll(async function () { - await context.close(); - }); - - test.describe('Viewer with no projection attribute', () => { - test('Viewer defaults to OSMTILE', async () => { - const mapProjection = await page.$eval( - 'body > mapml-viewer', - (map) => map.projection - ); - const leafletProjection = await page.$eval( - 'body > mapml-viewer', - (map) => map._map.options.projection - ); - const leafletProjection1 = await page.$eval( - 'body > mapml-viewer', - (map) => map._map.options.crs.code - ); - const projectionAttribute = await page.$eval( - 'body > mapml-viewer', - (map) => map.getAttribute('projection') - ); - expect(mapProjection).toEqual('OSMTILE'); - expect(leafletProjection).toEqual('OSMTILE'); - expect(leafletProjection1).toEqual('EPSG:3857'); - expect(projectionAttribute).toEqual(null); - }); - - test('layer renders', async () => { - const featureSVG = await page.$eval( - 'body > mapml-viewer > layer- > map-feature', - (feature) => feature._groupEl.firstChild.getAttribute('d') - ); - expect(featureSVG).toEqual('M62 27L62 75L206 75L206 27L62 27z'); - }); - }); -}); diff --git a/test/e2e/mapml-viewer/customTCRS.test.js b/test/e2e/mapml-viewer/customTCRS.test.js index cf0d4a06c..731e68a92 100644 --- a/test/e2e/mapml-viewer/customTCRS.test.js +++ b/test/e2e/mapml-viewer/customTCRS.test.js @@ -18,13 +18,8 @@ test.describe('Playwright Custom TCRS Tests', () => { test('Simple Custom TCRS, tiles load, mismatched layer disabled', async () => { const misMatchedLayerDisabled = await page.$eval( - 'body > mapml-viewer:nth-child(1)', - (map) => map.querySelectorAll('layer-')[0].hasAttribute('disabled') - ); - - const matchedLayerEnabled = await page.$eval( - 'body > mapml-viewer:nth-child(1)', - (map) => map.querySelectorAll('layer-')[1].hasAttribute('disabled') + 'body > mapml-viewer:nth-child(1) > layer-:nth-child(1)', + (layer) => layer.hasAttribute('disabled') ); const tilesLoaded = await page.$eval( @@ -34,7 +29,6 @@ test.describe('Playwright Custom TCRS Tests', () => { expect(tilesLoaded).toEqual(2); expect(misMatchedLayerDisabled).toEqual(true); - expect(matchedLayerEnabled).toEqual(false); }); test('A projection name containing a colon is invalid', async () => { const message = await page.$eval( @@ -45,13 +39,13 @@ test.describe('Playwright Custom TCRS Tests', () => { }); test('Complex Custom TCRS, static features loaded, templated features loaded', async () => { const staticFeatures = await page.$eval( - 'body > mapml-viewer:nth-child(3)', - (map) => map.querySelectorAll('layer-')[0].hasAttribute('disabled') + 'body > mapml-viewer:nth-child(3) > layer-:nth-child(1)', + (layer) => layer.hasAttribute('disabled') ); const templatedFeatures = await page.$eval( - 'body > mapml-viewer:nth-child(3)', - (map) => map.querySelectorAll('layer-')[1].hasAttribute('disabled') + 'body > mapml-viewer:nth-child(3) > layer-:nth-child(2)', + (layer) => layer.hasAttribute('disabled') ); const featureOne = await page.$eval( From b8b529e29c500273c036f4711b13b5998184b602 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Wed, 19 Jul 2023 13:18:03 -0400 Subject: [PATCH 16/17] fix small bug with remote layer with no map-metas + Add tests --- src/mapml/layers/MapMLLayer.js | 16 ++++++++------ test/e2e/core/metaDefault.html | 1 + test/e2e/core/metaDefault.test.js | 36 +++++++++++++++++++++++++++++-- test/e2e/data/noMapMeta.mapml | 18 ++++++++++++++++ test/server.js | 11 ++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 test/e2e/data/noMapMeta.mapml diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index 0eef0891e..026e5b03a 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -1388,11 +1388,20 @@ export var MapMLLayer = L.Layer.extend({ layer._content = mapml; if (!this.responseXML && this.responseText) mapml = new DOMParser().parseFromString(this.responseText, 'text/xml'); + + // if everything is ok, continue with the processing if ( this.readyState === this.DONE && mapml.querySelector && !mapml.querySelector('parsererror') ) { + // Get layer's title/label + if (mapml.querySelector('map-title')) { + layer._title = mapml.querySelector('map-title').textContent.trim(); + } else if (mapml instanceof Element && mapml.hasAttribute('label')) { + layer._title = mapml.getAttribute('label').trim(); + } + var serverExtent = mapml.querySelectorAll('map-extent'), projection, projectionMatch, @@ -1434,7 +1443,7 @@ export var MapMLLayer = L.Layer.extend({ projectionMatch = true; serverMeta = projection; console.log( - `A projection was not assigned to the '${this._layerEl.label}' Layer. Please specify a projection for that layer using a map-meta element. See more here - https://maps4html.org/web-map-doc/docs/elements/meta/` + `A projection was not assigned to the '${layer._title}' Layer. Please specify a projection for that layer using a map-meta element. See more here - https://maps4html.org/web-map-doc/docs/elements/meta/` ); // TODO: Add a more obvious warning. } @@ -1628,11 +1637,6 @@ export var MapMLLayer = L.Layer.extend({ layer._styles = stylesControl; } - if (mapml.querySelector('map-title')) { - layer._title = mapml.querySelector('map-title').textContent.trim(); - } else if (mapml instanceof Element && mapml.hasAttribute('label')) { - layer._title = mapml.getAttribute('label').trim(); - } if (layer._map) { layer._validateExtent(); // if the layer is checked in the layer control, force the addition diff --git a/test/e2e/core/metaDefault.html b/test/e2e/core/metaDefault.html index 51f36f87a..93f507d5d 100644 --- a/test/e2e/core/metaDefault.html +++ b/test/e2e/core/metaDefault.html @@ -43,6 +43,7 @@
+ diff --git a/test/e2e/core/metaDefault.test.js b/test/e2e/core/metaDefault.test.js index ebf37c836..7a74ff10b 100644 --- a/test/e2e/core/metaDefault.test.js +++ b/test/e2e/core/metaDefault.test.js @@ -91,7 +91,39 @@ test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () => ); }); test("Layer with no map-meta's is rendered on map", async () => { - let vector = await page.locator('.mapml-vector-container > svg'); - await expect(vector).toHaveCount(1); + const viewer = await page.evaluateHandle(() => + document.querySelector('mapml-viewer') + ); + const layerSVG = await ( + await page.evaluateHandle( + (map) => + map.shadowRoot + .querySelectorAll('.mapml-layer')[2] + .querySelector('path') + .getAttribute('d'), + viewer + ) + ).jsonValue(); + expect(layerSVG).toEqual( + 'M190 311 L177.5 281 C177.5 261, 202.5 261, 202.5 281 L190 311z' + ); + }); + test("Fetched layer with no map-meta's is rendered on map", async () => { + const viewer = await page.evaluateHandle(() => + document.querySelector('mapml-viewer') + ); + const layerSVG = await ( + await page.evaluateHandle( + (map) => + map.shadowRoot + .querySelectorAll('.mapml-layer')[3] + .querySelector('path') + .getAttribute('d'), + viewer + ) + ).jsonValue(); + expect(layerSVG).toEqual( + 'M243 255 L230.5 225 C230.5 205, 255.5 205, 255.5 225 L243 255z' + ); }); }); diff --git a/test/e2e/data/noMapMeta.mapml b/test/e2e/data/noMapMeta.mapml new file mode 100644 index 000000000..cf3551f97 --- /dev/null +++ b/test/e2e/data/noMapMeta.mapml @@ -0,0 +1,18 @@ + + + Capital of Canada + + + + + + Ottawa +

Ottawa

+ + + -75.715027 45.424721 + + +
+
+
diff --git a/test/server.js b/test/server.js index df2359a93..88bfd261d 100644 --- a/test/server.js +++ b/test/server.js @@ -59,6 +59,17 @@ app.get('/data/query/DouglasFir', (req, res, next) => { } ); }); +app.get('/data/noMapMeta', (req, res, next) => { + res.sendFile( + __dirname + '/e2e/data/noMapMeta.mapml', + { headers: { 'Content-Type': 'text/mapml' } }, + (err) => { + if (err) { + res.status(403).send('Error.'); + } + } + ); +}); app.use('/data', express.static(path.join(__dirname, 'e2e/data/tiles/cbmt'))); app.use('/data', express.static(path.join(__dirname, 'e2e/data/tiles/wgs84'))); From fafca0e1036cac5fb4271010a4e4e86a3bf62a24 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Wed, 19 Jul 2023 14:24:34 -0400 Subject: [PATCH 17/17] bug fix after merging upstream --- src/mapml/layers/MapMLLayer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index 44c358d7a..48cfaa398 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -1411,6 +1411,7 @@ export var MapMLLayer = L.Layer.extend({ // Get layer's title/label if (mapml.querySelector('map-title')) { layer._title = mapml.querySelector('map-title').textContent.trim(); + layer._titleIsReadOnly = true; } else if (mapml instanceof Element && mapml.hasAttribute('label')) { layer._title = mapml.getAttribute('label').trim(); }