From fa6a54d830cd3b99b28e396b2094c84833083971 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Fri, 26 Apr 2024 16:35:26 -0400 Subject: [PATCH] Stop using and instead use the old param specifier, even for wkt strings. --- modules/core/UrlHashSystem.js | 4 ++-- modules/pixi/PixiLayerCustomData.js | 29 +++++++++-------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/modules/core/UrlHashSystem.js b/modules/core/UrlHashSystem.js index cdb1c2eb8..4421d7332 100644 --- a/modules/core/UrlHashSystem.js +++ b/modules/core/UrlHashSystem.js @@ -48,7 +48,8 @@ export class UrlHashSystem extends AbstractSystem { * * Responsive (user can change) * __`background`__ - Imagery sourceID for the background imagery layer -* __`data`__ - A custom data URL for loading a gpx track or connecting to a vector data source +* __`data`__ - A custom data URL for loading a gpx track, vector data source, +* or well-known POLYGON or MULTIPOLYGON text string to render as custom data. * __`gpx`__ - Same as `data`, it's just the legacy name for the same thing * __`datasets`__ - A comma-separated list of Rapid/Esri datasetIDs to enable * __`disable_features`__ - Disables features in the list. @@ -61,7 +62,6 @@ export class UrlHashSystem extends AbstractSystem { * __`id`__ - An OSM ID to select. * __`map`__ - A slash-separated `zoom/lat/lon/rot`. * __`offset`__ - Background imagery alignment offset in meters, formatted as `east,north`. -* __`wktPoly`__ - Well-known POLYGON or MULTIPOLYGON text string to render as custom data. **/ diff --git a/modules/pixi/PixiLayerCustomData.js b/modules/pixi/PixiLayerCustomData.js index 5b5ccc68e..2cec0a01a 100644 --- a/modules/pixi/PixiLayerCustomData.js +++ b/modules/pixi/PixiLayerCustomData.js @@ -111,7 +111,7 @@ export class PixiLayerCustomData extends AbstractLayer { /** * createWktPolys - * creates WKT Polys from a raw string supplied on the url (if specified) from param 'wktPoly'. + * creates WKT Polys from a raw string supplied by the data url param'. * * @param wktString - the poly or multipoly string(s) in wkt format * i.e. 'POLYGON((-2.2 1.9, -2.3 1.7, -0.8 1.7, -0.8 1.9, -2.2 1.9))' @@ -126,7 +126,6 @@ export class PixiLayerCustomData extends AbstractLayer { let poly = {}; // If it couldn't be parsed, or if it isn't a poly/multipoly, we can't render it. Issue an error. if (!parsedWkt || (parsedWkt.type !== 'Polygon' && parsedWkt.type !== 'MultiPolygon')) { - console.error("Unable to parse wkt Poly string"); return poly; } @@ -381,17 +380,6 @@ export class PixiLayerCustomData extends AbstractLayer { return !!(this._template || this._geojson); } - /** - * hasWkt - * Return true if there is custom data to display - * @return {boolean} `true` if there is a vector tile template or geojson to display - */ - hasWkt() { - const urlhash = this.context.systems.urlhash; - const hasWkt = urlhash.getParam('wktPoly'); - return !!hasWkt; - } - /** * dataUsed * @return {Array} Array of single element for the data layer currently enabled @@ -689,15 +677,16 @@ export class PixiLayerCustomData extends AbstractLayer { const newData = currParams.get('data') || currParams.get('gpx'); const oldData = prevParams.get('data') || prevParams.get('gpx'); if (newData !== oldData) { - this.setUrl(newData); - } - const newWkt = currParams.get('wktPoly'); + //First attempt to parse the data string as a WKT. + const wktPolys = this.createWktPolys(newData); - if (newWkt) { - this.scene.enableLayers(this.layerID); - const wktPolys = this.createWktPolys(newWkt); - this._setFile(wktPolys, '.geojson'); + // If it is, treat it as such. If not, treat it as a URL. + if (wktPolys) { + this._setFile(wktPolys, '.geojson'); + } else { + this.setUrl(newData); + } } }