Skip to content

Commit

Permalink
Merge branch 'main' into issue/7198
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneygijzen committed Oct 4, 2024
2 parents 36e6604 + dd2a2a5 commit 540ae60
Show file tree
Hide file tree
Showing 165 changed files with 1,822 additions and 1,084 deletions.
11 changes: 7 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
/* Variables */
"no-label-var": 1,
"no-unused-vars": [
1,
"warn",
{
"vars": "local",
"args": "none"
Expand Down Expand Up @@ -115,18 +115,21 @@
"rules": {
// @TODO: revise these rules
"@typescript-eslint/consistent-type-assertions": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-loss-of-precision": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"react-hooks/exhaustive-deps": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "error",
"react-hooks/exhaustive-deps": "error",
"react/prop-types": "warn"
}
}
Expand Down
15 changes: 13 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Change Log

#### next release (8.7.7)
#### next release (8.7.8)

- support URL parameters in a GetLegendGraphic request for a layer without a style configured
- [The next improvement]

#### 8.7.7 - 2024-10-01

- **Breaking changes:**

- Remove RollbarErrorServiceProvder
- Error services now instantiated externally to terriajs

- Fix remaining lint warnings
- Augment cesium types and start using import instead of require in ts files
- Update to sass 1.79.1
- Add option to import assets from Cesium ion through the Add data panel. Use map config parameter "cesiumIonOAuth2ApplicationID" to enable the feature.

#### 8.7.6 - 2024-08-22

- Add I3SCatalogItem
Expand All @@ -25,7 +37,6 @@
- Increase `maxRefreshIntervals` from 1000 to 10000 for `WebMapServiceCatalogItem` and `ArcGisMapServerCatalogItem`.
- Add `nextDiscreteJulianDate` helper computed value to `DiscretelyTimeVaryingMixin`
- Add `EPSG:7899` to `Proj4Definitions`
- [The next improvement]

#### 8.7.5 - 2024-06-26

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Please get involved in code review. It's a great way to expand your knowledge of
- Verify the code builds successfully and there are no lint warnings (run `gulp`).
- Check basic functionality of the map, such as enabling data sources in both 2D and 3D.
- Verify that all specs pass. If anything you did might be browser-dependent, you should run the specs in all the major supported browsers.
- Review the code itself for quality of implementation and consistency with coding conventions. Until we have our own coding conventions, we can [use Cesium's](https://github.com/AnalyticalGraphicsInc/cesium/wiki/JavaScript-Coding-Conventions).
- Review the code itself for quality of implementation and consistency with coding conventions. Until we have our own coding conventions, we use [Cesium's](https://github.com/CesiumGS/cesium/blob/master/Documentation/Contributors/CodingGuide/README.md).

Reviewers are welcome to make minor edits to a pull request (e.g. fixing typos) before merging it. If a reviewer makes larger changes, someone else - maybe the original author of the pull request - should take a look at the changes before the entire pull request is merged.

Expand Down
2 changes: 1 addition & 1 deletion architecture/0002-require-instead-of-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Date: 2020-08-07 recorded, decision made earlier

## Status

Accepted
Superseded by [0012-do-not-use-require-for-cesium-in-ts](./0012-do-not-use-require-for-cesium-in-ts.md) on 2024-09-28

## Context

Expand Down
2 changes: 1 addition & 1 deletion architecture/0010-never-support-ie11.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Date: 2022-05-12

## Status

Proposed
Accepted

## Context

Expand Down
2 changes: 1 addition & 1 deletion architecture/0011-configurable-search-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Date: 2021-01-19

## Status

Proposed
Accepted

## Context

Expand Down
34 changes: 34 additions & 0 deletions architecture/0012-do-not-use-require-for-cesium-in-ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 2. Using `imports` instead of `require` + type casting statements

Date: 2024-09-28

## Status

Proposed

## Context

A decision was made in [0002-require-instead-of-import](./0002-require-instead-of-import.md) to use non-exported terriajs-cesium features using `require` + type casting statements due to inability to augment namespace and enum imports.

Recently we found a new way to augment terriajs-cesium typescript definition in case of enums and namespaces. When we directly augment `terriajs-module` typescript will properly augment the namespaces and enums can be augmented as namespaces making everything works as should on type level.

```ts
declare module terriajs-cesium {
namespace FeatureDetection {
function isChrome(): boolean;
function isEdge(): boolean;
function isInternetExplorer(): boolean;
function isFirefox(): boolean;
function internetExplorerVersion(): number[];
function chromeVersion(): number[];
}

namespace Axis {
function fromName(name: string): number;
}
}
```

## Decission

Augment `terriajs-cesium` type definition
8 changes: 4 additions & 4 deletions doc/customizing/client-side-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ Configuration of items to appear in the search bar

### ErrorServiceOptions

| Name | Required | Type | Default | Description |
| ------------- | -------- | ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| provider | yes | **string** | `undefined` | A string identifying the error service provider to use. Currently only `rollbar` is supported. |
| configuration | no | **any** | `undefined` | The configuration object to pass as constructor parameters to the error service provider instance. See the [provider implementation](https://github.com/TerriaJS/terriajs/blob/main/lib/Models/ErrorServiceProviders/) for supported configuration parameters. |
| Name | Required | Type | Default | Description |
| ------------- | -------- | ---------- | ----------- | ---------------------------------------------------------------------- |
| provider | no | **string** | `undefined` | A string identifying the error service provider. |
| configuration | no | **any** | `undefined` | The configuration object to be used when initializing an ErrorService. |

**Example**

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gulp.task("lint", function (done) {
"--ignore-pattern",
"lib/ThirdParty",
"--max-warnings",
"238" // TODO: Bring this back to 0
"0"
]);

done();
Expand Down
14 changes: 7 additions & 7 deletions lib/Core/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
* The purpose of this module is to provide a standard way to perform actions after an animations ends.
* The advantage is that the code is more tightly coupled together and we don't have to guess when the animation ends.
* There is also a timeout fallback that will reject the Promise if the animation end event is not fired in time.
*
*
* Old code:
*
triggerSomeAnimation();
setTimeout(function() {
somePostAction();
}, 200);
*
* New code:
*
* New code:
animateEnd(this.elementRef.current).finally(somePostAction);
triggerAnimation();
*
*
*
*
*/

const ANIMATION_TIMEOUT = 500;
Expand All @@ -33,10 +33,10 @@ const transitionEnd = (element: Element | null) =>
});

const animationTimeout = (
timeoutID: ReturnType<typeof setTimeout> | undefined
_timeoutID: ReturnType<typeof setTimeout> | undefined
) =>
new Promise<void>((_, reject) => {
timeoutID = setTimeout(() => {
_timeoutID = setTimeout(() => {
reject("Animation timed out. Did you forget to animate the element?");
}, ANIMATION_TIMEOUT);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/autoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function autoUpdate(updater: (...args: any[]) => void) {
updater.call(args.context, args.value);
});
},
(disposer, value) => {
(disposer, _value) => {
console.log("cleanup");
if (disposer) {
disposer();
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/createColorForIdTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const usedColors: { [c: string]: number | undefined } = {};
*/
function createColorForIdTransformer() {
return createTransformer(
(id: string): string => {
(_id: string): string => {
const nextColor = leastUsedColor();
useColor(nextColor);
return nextColor;
Expand Down
29 changes: 16 additions & 13 deletions lib/Core/getDataType.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import i18next from "i18next";
import { action, observable } from "mobx";
import { type ComponentType } from "react";

interface DataType {
value: string;
name: string;
description?: string;
customComponent?: ComponentType;
}

export interface RemoteDataType extends DataType {}
Expand Down Expand Up @@ -193,39 +195,39 @@ const builtinLocalDataTypes: LocalDataType[] = [
];

/**
* Custom remote data types. Add to it by calling addRemoteDataType().
* Custom remote data types. Add to it by calling addOrReplaceRemoteFileUploadType().
*/
export const customRemoteDataTypes: Map<string, RemoteDataType> = observable(
new Map()
);

/**
* Custom local data types. Add by calling addLocalDataType().
* Custom local data types. Add by calling addOrReplaceLocalFileUploadType().
*/
export const customLocalDataTypes: Map<string, LocalDataType> = observable(
new Map()
);

export default function getDataTypes(): GetDataTypes {
const uniqueRemoteDataTypes: Map<string, RemoteDataType> = new Map([
...(builtinRemoteDataTypes.map((dtype) => [
dtype.value,
translateDataType(dtype)
]) as [string, RemoteDataType][]),
...(builtinRemoteDataTypes.map((dtype) => [dtype.value, dtype]) as [
string,
RemoteDataType
][]),
...customRemoteDataTypes.entries()
]);

const uniqueLocalDataTypes: Map<string, LocalDataType> = new Map([
...(builtinLocalDataTypes.map((dtype) => [
dtype.value,
translateDataType(dtype)
]) as [string, LocalDataType][]),
...(builtinLocalDataTypes.map((dtype) => [dtype.value, dtype]) as [
string,
LocalDataType
][]),
...customLocalDataTypes.entries()
]);

return {
remoteDataType: [...uniqueRemoteDataTypes.values()],
localDataType: [...uniqueLocalDataTypes.values()]
remoteDataType: [...uniqueRemoteDataTypes.values()].map(translateDataType),
localDataType: [...uniqueLocalDataTypes.values()].map(translateDataType)
};
}

Expand Down Expand Up @@ -264,6 +266,7 @@ function translateDataType<T extends DataType>(dataType: T): T {
name: i18next.t(dataType.name),
description: dataType.description
? i18next.t(dataType.description)
: undefined
: undefined,
customComponent: dataType.customComponent
};
}
3 changes: 1 addition & 2 deletions lib/Map/Cesium/CesiumRenderLoopPauser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import defined from "terriajs-cesium/Source/Core/defined";
import destroyObject from "terriajs-cesium/Source/Core/destroyObject";
import CesiumEvent from "terriajs-cesium/Source/Core/Event";
import getTimestamp from "terriajs-cesium/Source/Core/getTimestamp";
import JulianDate from "terriajs-cesium/Source/Core/JulianDate";
import Matrix4 from "terriajs-cesium/Source/Core/Matrix4";
import TaskProcessor from "terriajs-cesium/Source/Core/TaskProcessor";
import CesiumWidget from "terriajs-cesium/Source/Widget/CesiumWidget";
Expand Down Expand Up @@ -285,7 +284,7 @@ export default class CesiumRenderLoopPauser {
this.renderingIsPaused = false;
}

private postRender(date: JulianDate) {
private postRender() {
// We can safely stop rendering when:
// - the camera position hasn't changed in over a second,
// - there are no tiles waiting to load, and
Expand Down
4 changes: 2 additions & 2 deletions lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export default class ImageryProviderLeafletTileLayer extends L.TileLayer {
// an error event. We want to first raise an error event that optionally returns a promise and
// retries after the promise resolves.

const doRequest = (waitPromise?: any) => {
const _doRequest = (waitPromise?: any) => {
if (waitPromise) {
waitPromise
.then(function () {
doRequest();
_doRequest();
})
.catch((e: unknown) => {
// The tile has failed irrecoverably, so invoke Leaflet's standard
Expand Down
14 changes: 6 additions & 8 deletions lib/Map/Leaflet/LeafletDataSourceDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import L from "leaflet";
import BoundingSphere from "terriajs-cesium/Source/Core/BoundingSphere";
import EventHelper from "terriajs-cesium/Source/Core/EventHelper";
import JulianDate from "terriajs-cesium/Source/Core/JulianDate";
import createGuid from "terriajs-cesium/Source/Core/createGuid";
import defaultValue from "terriajs-cesium/Source/Core/defaultValue";
import destroyObject from "terriajs-cesium/Source/Core/destroyObject";
import BoundingSphereState from "terriajs-cesium/Source/DataSources/BoundingSphereState";
import CustomDataSource from "terriajs-cesium/Source/DataSources/CustomDataSource";
import DataSource from "terriajs-cesium/Source/DataSources/DataSource";
import DataSourceCollection from "terriajs-cesium/Source/DataSources/DataSourceCollection";
import defaultValue from "terriajs-cesium/Source/Core/defaultValue";
import Entity from "terriajs-cesium/Source/DataSources/Entity";
import EntityCluster from "terriajs-cesium/Source/DataSources/EntityCluster";
import EventHelper from "terriajs-cesium/Source/Core/EventHelper";
import isDefined from "../../Core/isDefined";
import JulianDate from "terriajs-cesium/Source/Core/JulianDate";
import L from "leaflet";
import LeafletScene from "./LeafletScene";

const createGuid = require("terriajs-cesium/Source/Core/createGuid").default;
const destroyObject =
require("terriajs-cesium/Source/Core/destroyObject").default;

interface Visualizer {
update(time: JulianDate): boolean;
destroy(): void;
Expand Down
13 changes: 3 additions & 10 deletions lib/Map/Leaflet/LeafletSelectionIndicator.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import L from "leaflet";
import Cartographic from "terriajs-cesium/Source/Core/Cartographic";
import CesiumMath from "terriajs-cesium/Source/Core/Math";
import EasingFunction from "terriajs-cesium/Source/Core/EasingFunction";
import Ellipsoid from "terriajs-cesium/Source/Core/Ellipsoid";
import L from "leaflet";
import CesiumMath from "terriajs-cesium/Source/Core/Math";
import TweenCollection from "terriajs-cesium/Source/Scene/TweenCollection";
import isDefined from "../../Core/isDefined";

import Leaflet from "../../Models/Leaflet";

const TweenCollection =
require("terriajs-cesium/Source/Scene/TweenCollection").default;
const selectionIndicatorUrl = require("../../../wwwroot/images/NM-LocationTarget.svg");

interface Tween {
cancelTween(): void;
}

interface TweenCollection {
length: number;
add(args: any): Tween;
update(): void;
}

const cartographicScratch = new Cartographic();

export default class LeafletSelectionIndicator {
Expand Down
Loading

0 comments on commit 540ae60

Please sign in to comment.