Skip to content

Commit

Permalink
Stop using and instead use the old param specifier, even for wkt stri…
Browse files Browse the repository at this point in the history
…ngs.
  • Loading branch information
Benjamin Clark authored and bhousel committed Apr 30, 2024
1 parent f6e5bf9 commit fa6a54d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
4 changes: 2 additions & 2 deletions modules/core/UrlHashSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
**/

Expand Down
29 changes: 9 additions & 20 deletions modules/pixi/PixiLayerCustomData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))'
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit fa6a54d

Please sign in to comment.