Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kml-clamp-polyhon
Browse files Browse the repository at this point in the history
  • Loading branch information
nf-s committed Nov 10, 2023
2 parents 5f7b29a + 044831c commit 3c22fe3
Show file tree
Hide file tree
Showing 78 changed files with 2,740 additions and 1,741 deletions.
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
["@babel/typescript", { "allowNamespaces": true }]
],
"plugins": [
"babel-plugin-jsx-control-statements",
"@babel/plugin-transform-modules-commonjs",
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties",
Expand Down
9 changes: 2 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-control-statements/recommended"
],
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
Expand All @@ -19,7 +15,7 @@
"commonjs": true,
"es6": true
},
"plugins": ["react", "jsx-control-statements"],
"plugins": ["react"],
"globals": {
"process": true
},
Expand All @@ -29,7 +25,6 @@
}
},
"rules": {
"jsx-control-statements/jsx-use-if-tag": 0,
"react/jsx-no-undef": 0,

/*Possible Errors */
Expand Down
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
18 changes: 17 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Change Log

#### next release (8.3.7)
#### next release (8.3.8)

- 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.
- [The next improvement]

#### 8.3.7 - 2023-10-26

- Fix `WebMapServiceCatalogItem` `allowFeaturePicking`
- Allow translation of TableStylingWorkflow.
Expand All @@ -14,6 +28,8 @@
- Add `hideDefaultDescription` to `CatalogMemberTraits` - if true, then no generic default description will be shown when `description` is empty.
- Add `clampPolygonsToGround` to `KmlCatalogItemTraits` (defaults to true`)
- [The next improvement]
- Added on screen attribution and Google logo for Google Photorealistic 3D Tiles.
- Add `hideDefaultDescription` to `CatalogMemberTraits` - if true, then no generic default description will be shown when `description` is empty.

#### 8.3.6 - 2023-10-03

Expand Down
2 changes: 1 addition & 1 deletion architecture/0001-babel-and-ts-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ support for it covers everything we need to use it in terriajs, including
build times.

- Using _only_ ts-loader is out of the question, as we rely on tools inside the
babel ecosystem including jsx-control-statements & styled-components to name a
babel ecosystem including ~jsx-control-statements~ (removed 2023-10-16) & styled-components to name a
few.
- Using _only_ babel
- Using babel _with_ ts-loader in `transpileOnly` mode, if there are TypeScript
Expand Down
1 change: 0 additions & 1 deletion buildprocess/configureWebpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ function configureWebpack(
["@babel/typescript", { allowNamespaces: true }]
],
plugins: [
"babel-plugin-jsx-control-statements",
"@babel/plugin-transform-modules-commonjs",
["@babel/plugin-proposal-decorators", { legacy: true }],
"@babel/plugin-proposal-class-properties",
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;
2 changes: 0 additions & 2 deletions doc/contributing/frontend-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,3 @@ const BoxSpan: any = require("../../../Styled/Box").BoxSpan;

Components written in TypeScript will not need `PropTypes` defined on them, as
type errors on props will be caught at compilation rather than a runtime check.

All jsx-control-statements should be removed when migrating a .jsx file to .tsx.
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
Loading

0 comments on commit 3c22fe3

Please sign in to comment.