Skip to content

Commit

Permalink
Merge branch 'main' into minmax-exceed-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
nf-s authored Nov 13, 2023
2 parents 244e43b + ba0a0e8 commit d0f09b2
Show file tree
Hide file tree
Showing 18 changed files with 1,529 additions and 619 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/find-region-mapping-alias-duplicates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Find region mapping alias duplicates

# Run when regionMapping.json file or is updated
on:
push:
paths:
- "wwwroot/data/regionMapping.json"
- "buildprocess/find-region-mapping-alias-duplicates.js"
pull_request:
paths:
- "wwwroot/data/regionMapping.json"
- "buildprocess/find-region-mapping-alias-duplicates.js"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job
find-alias-duplicates:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Check out only 2 files
# Use without cone mode as no git operations are executed past checkout
- uses: actions/checkout@v4
with:
sparse-checkout: |
wwwroot/data/regionMapping.json
buildprocess/find-region-mapping-alias-duplicates.js
sparse-checkout-cone-mode: false

- name: Check aliases
run: |
node buildprocess/find-region-mapping-alias-duplicates.js
12 changes: 11 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

#### next release (8.3.8)

- [The next improvement]
- Fix maximum call stack size exceeded on Math.min/max when creating Charts
- Fix boolean flag in `MyDataTab` displaying number
- Remove `jsx-control-statements` dependency
- Fix WMS nested group IDs - nested groups with the same name were not being created
- WMS `isEsri` default value will now check for case-insensitive `mapserver/wmsserver` (instead of `MapServer/WMSServer`)
- Tweak ArcGis MapServer WMS `GetFeatureInfo` default behaviour
- Add `application/geo+json` and `application/vnd.geo+json` default `GetFeatureInfo` (after `application/json` in priority list)
- Add `application/xml` default `GetFeatureInfo`. (if `isEsri` is true, then this will be used before `text/html`)
- Added many remaining ASGS 2021 region types to region mapping (STE_2021,ILOC_2021,IARE_2021,IREG_2021,RA_2021,SAL_2021,ADD_2021,DZN_2021,LGA_2022,LGA_2023,SED_2021,SED_2022,
CED_2021,POA_2021,TR_2021,SUA_2021,UCL_2021,SOS_2021,SOSR_2021).
- See [ASGS 2021](https://www.abs.gov.au/statistics/standards/australian-statistical-geography-standard-asgs-edition-3/jul2021-jun2026/access-and-downloads/digital-boundary-files)
- Added [Melbourne CLUE blocks](https://data.melbourne.vic.gov.au/pages/clue/) to region mapping.
- Fix WMS `GetMap`/`GetFeatureInfo` requests not having `styles` parameter (will use empty string instead of `undefined`)
- [The next improvement]

#### 8.3.7 - 2023-10-26

Expand Down
22 changes: 22 additions & 0 deletions buildprocess/find-region-mapping-alias-duplicates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require("fs");
const regions = JSON.parse(
fs.readFileSync("wwwroot/data/regionMapping.json")
).regionWmsMap;

const aliasToType = new Map();
for (const [regType, regDef] of Object.entries(regions)) {
for (const alias of regDef.aliases ?? []) {
aliasToType.set(alias, [...(aliasToType.get(alias) ?? []), regType]);
}
}

let issues = 0;
for (const [alias, regTypes] of aliasToType.entries()) {
if (regTypes.length > 1) {
console.error(
`Alias "${alias}" used in multiple types: ${regTypes.join(", ")}`
);
issues++;
}
}
process.exitCode = issues > 0 ? 1 : 0;
23 changes: 21 additions & 2 deletions lib/Models/Catalog/Ows/WebMapServiceCapabilitiesStratum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,9 @@ export default class WebMapServiceCapabilitiesStratum extends LoadableStratum(
@computed
get isEsri(): boolean {
if (this.catalogItem.url !== undefined)
return this.catalogItem.url.indexOf("MapServer/WMSServer") > -1;
return (
this.catalogItem.url.toLowerCase().indexOf("mapserver/wmsserver") > -1
);
return false;
}

Expand Down Expand Up @@ -831,9 +833,11 @@ export default class WebMapServiceCapabilitiesStratum extends LoadableStratum(
}

/** Prioritize format of GetFeatureInfo:
* - JSON
* - JSON/GeoJSON
* - If ESRI, then we prioritise XML next
* - HTML
* - GML
* - XML
* - Plain text
*
* If no matching format can be found in GetCapabilities, then Cesium will use defaults (see `WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats`)
Expand All @@ -852,10 +856,25 @@ export default class WebMapServiceCapabilitiesStratum extends LoadableStratum(

if (formatsArray.includes("application/json"))
return { format: "application/json", type: "json" };
if (formatsArray.includes("application/geo+json"))
return { format: "application/geo+json", type: "json" };
if (formatsArray.includes("application/vnd.geo+json"))
return { format: "application/vnd.geo+json", type: "json" };

// Special case for Esri WMS, use XML before HTML/GML
// as HTML includes <table> with rowbg that is hard to read
if (this.isEsri && formatsArray.includes("text/xml")) {
return { format: "text/xml", type: "xml" };
}
if (formatsArray.includes("text/html"))
return { format: "text/html", type: "html" };
if (formatsArray.includes("application/vnd.ogc.gml"))
return { format: "application/vnd.ogc.gml", type: "xml" };

// For non-Esri services, we use XML after HTML/GML
if (formatsArray.includes("text/xml")) {
return { format: "text/xml", type: "xml" };
}
if (formatsArray.includes("text/plain"))
return { format: "text/plain", type: "text" };
}
Expand Down
41 changes: 27 additions & 14 deletions lib/Models/Catalog/Ows/WebMapServiceCatalogGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class GetCapabilitiesStratum extends LoadableStratum(
}

@action
createMemberFromLayer(layer: CapabilitiesLayer) {
const layerId = this.getLayerId(layer);
createMemberFromLayer(layer: CapabilitiesLayer, parentLayerId?: string) {
const layerId = this.getLayerId(layer, parentLayerId);

if (!layerId) {
return;
Expand All @@ -185,7 +185,7 @@ class GetCapabilitiesStratum extends LoadableStratum(
members = [layer.Layer as CapabilitiesLayer];
}

members.forEach((member) => this.createMemberFromLayer(member));
members.forEach((member) => this.createMemberFromLayer(member, layerId));

// Create group
const existingModel = this.catalogGroup.terria.getModelById(
Expand All @@ -201,7 +201,7 @@ class GetCapabilitiesStratum extends LoadableStratum(
// At the moment we ignore duplicate layers
this.catalogGroup.terria.addModel(
model,
this.getLayerShareKeys(layer)
this.getLayerShareKeys(layer, layerId)
);
} catch (e) {
TerriaError.from(e, "Failed to add CatalogGroup").log();
Expand All @@ -215,7 +215,9 @@ class GetCapabilitiesStratum extends LoadableStratum(
model.setTrait(
CommonStrata.definition,
"members",
filterOutUndefined(members.map((member) => this.getLayerId(member)))
filterOutUndefined(
members.map((member) => this.getLayerId(member, layerId))
)
);

// Set group `info` trait if applicable
Expand Down Expand Up @@ -251,7 +253,10 @@ class GetCapabilitiesStratum extends LoadableStratum(
try {
// Sometimes WMS Layers have duplicate names
// At the moment we ignore duplicate layers
this.catalogGroup.terria.addModel(model, this.getLayerShareKeys(layer));
this.catalogGroup.terria.addModel(
model,
this.getLayerShareKeys(layer, layerId)
);
} catch (e) {
TerriaError.from(e, "Failed to add WebMapServiceCatalogItem").log();
return;
Expand Down Expand Up @@ -318,22 +323,30 @@ class GetCapabilitiesStratum extends LoadableStratum(
model.createGetCapabilitiesStratumFromParent(this.capabilities);
}

getLayerId(layer: CapabilitiesLayer) {
if (!isDefined(this.catalogGroup.uniqueId)) {
getLayerId(layer: CapabilitiesLayer, parentLayerId?: string) {
if (!isDefined(this.catalogGroup.uniqueId) && !isDefined(parentLayerId)) {
return;
}
return `${this.catalogGroup.uniqueId}/${layer.Name ?? layer.Title}`;
return `${parentLayerId ?? this.catalogGroup.uniqueId}/${
layer.Name ?? layer.Title
}`;
}

/** For backward-compatibility.
* If layer.Name is defined, we will use it to create layer autoID (see `this.getLayerId`).
* Previously we used layer.Title, so we now add it as a shareKey
* Previously we have used the following IDs
* - `WMS Group Catalog ID/WMS Layer Name` - regardless of nesting
* - `WMS Group Catalog ID/WMS Layer Title`
*/
getLayerShareKeys(layer: CapabilitiesLayer) {
getLayerShareKeys(layer: CapabilitiesLayer, layerId: string) {
const shareKeys: string[] = [];

if (layerId !== `${this.catalogGroup.uniqueId}/${layer.Name}`)
shareKeys.push(`${this.catalogGroup.uniqueId}/${layer.Name}`);

if (isDefined(layer.Name) && layer.Title !== layer.Name)
return [`${this.catalogGroup.uniqueId}/${layer.Title}`];
shareKeys.push(`${this.catalogGroup.uniqueId}/${layer.Title}`);

return [];
return shareKeys;
}
}

Expand Down
7 changes: 3 additions & 4 deletions lib/Models/Catalog/Ows/WebMapServiceCatalogItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,9 @@ class WebMapServiceCatalogItem
parameters.COLORSCALERANGE = this.colorScaleRange;
}

if (isDefined(this.styles)) {
parameters.styles = this.styles;
getFeatureInfoParameters.styles = this.styles;
}
// Styles parameter is mandatory (for GetMap and GetFeatureInfo requests), but can be empty string to use default style
parameters.styles = this.styles ?? "";
getFeatureInfoParameters.styles = this.styles ?? "";

Object.assign(parameters, diffModeParameters);

Expand Down
Loading

0 comments on commit d0f09b2

Please sign in to comment.