CesiumGS / CesiumGS/cesium

TimeInterval default value for `stop` should not be zero

Open
#9,490 2 comments 0 reactions 0 assignees View on GitHub
type - enhancement
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

The [docs for TimeInterval](https://cesium.com/docs/cesiumjs-ref-doc/TimeInterval.html) say that the `start` and `stop` properties are both optional. For `start` this makes a kind of sense, because it uses `new JulianDate()` as a default value, which is earlier than 4000 BCE -- close enough to an open-ended interval for most users. However, `stop` also defaults to `new JulianDate()`. This will never produce a useful or well-formed interval. (`isEmpty` will always return true.)

It should default to something like `new JulianDate(Number.MAX_VALUE)`, or Infinity, etc.

I found this out because I was adding two intervals, basically providing "before and after" positions, akin to

```js
prop.intervals.addInterval({stop: someDate, stopIncluded: false, data: pos});
prop.intervals.addInterval({start: someDate, data: pos});
```

I had assumed, before reading the docs, that providing `start` with no `stop` made an open-ended interval bounded on the "left". In actual fact, the second call silently does nothing, because empty intervals are ignored -- which, like I said, is always the case for undefined `stop`. (It might also be nice if there were some way to tell that your `addInteval` call didn't do anything...)

Contributor guide

Open the contributing guide

Research direction

Start by locating the TimeInterval implementation and its tests, then inspect how omitted stop values are initialized and how addInterval handles empty intervals. Confirm the intended open-ended interval behavior against the linked TimeInterval documentation and the two addInterval examples. Done means an omitted stop no longer makes the interval empty and the relevant tests cover that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.