Skip to content

Commit

Permalink
#447 Deep Link shall also deep link to start and end times
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Oct 26, 2023
1 parent 71b4849 commit 50a03fd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 58 deletions.
15 changes: 8 additions & 7 deletions src/essence/Ancillary/QueryURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,6 @@ var QueryURL = {
var viewerImg = L_.Viewer_.getLastImageId()
var viewerLoc = L_.Viewer_.getLocation()

const timeEnabled =
L_.configData.time && L_.configData.time.enabled === true
var startTime = timeEnabled ? TimeControl.getStartTime() : null
var endTime = timeEnabled ? TimeControl.getEndTime() : null

//mission
var urlAppendage = '?mission=' + L_.mission

Expand Down Expand Up @@ -378,8 +373,14 @@ var QueryURL = {
if (urlTools !== false) urlAppendage += '&tools=' + urlTools

//time
if (L_.FUTURES.startTime) urlAppendage += '&startTime=' + startTime
if (L_.FUTURES.endTime) urlAppendage += '&endTime=' + endTime
if (L_.configData.time && L_.configData.time.enabled === true) {
// If the time UI is in the Range mode, then we have a start time
if (TimeControl.timeUI.modeIndex === 0)
if (TimeControl.startTime)
urlAppendage += '&startTime=' + TimeControl.startTime
if (TimeControl.endTime)
urlAppendage += '&endTime=' + TimeControl.endTime
}

var url = encodeURI(urlAppendage)

Expand Down
70 changes: 41 additions & 29 deletions src/essence/Ancillary/TimeUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const TimeUI = {
init: function (timeChange, enabled) {
TimeUI.timeChange = timeChange
TimeUI.enabled = enabled

// prettier-ignore
const markup = [
`<div id="mmgisTimeUI">`,
Expand Down Expand Up @@ -133,6 +134,11 @@ const TimeUI = {
},
getElement: function () {},
attachEvents: function (timeChange) {
let startingModeIndex = TimeUI.modeIndex
// Set modeIndex to 1/Point if a deeplink had an endtime but no starttime
if (L_.FUTURES.startTime == null && L_.FUTURES.endTime != null)
startingModeIndex = 1

// Timeline pan and zoom
// zoom
$('#mmgisTimeUITimelineInner').on('mousewheel', function (e) {
Expand Down Expand Up @@ -328,39 +334,12 @@ const TimeUI = {

// Mode dropdown
$('#mmgisTimeUIModeDropdown').html(
Dropy.construct(TimeUI.modes, 'Mode', TimeUI.modeIndex, {
Dropy.construct(TimeUI.modes, 'Mode', startingModeIndex, {
openUp: true,
dark: true,
})
)
Dropy.init($('#mmgisTimeUIModeDropdown'), function (idx) {
TimeUI.modeIndex = idx
if (TimeUI.modes[TimeUI.modeIndex] === 'Point') {
$('#mmgisTimeUIStartWrapper').css({ display: 'none' })
// Remove end date enforcement
TimeUI.endTempus.updateOptions({
restrictions: {
minDate: new Date(0).toISOString(),
},
})
} else {
$('#mmgisTimeUIStartWrapper').css({ display: 'inherit' })
// Reinforce min date
TimeUI.endTempus.updateOptions({
restrictions: {
minDate: TimeUI.startTempusSavedLastDate,
},
})
if (TimeUI._startTimestamp >= TimeUI._endTimestamp) {
const offsetStartDate = new Date(TimeUI._endTimestamp)
const parsedStart = TimeUI.startTempus.dates.parseInput(
new Date(offsetStartDate)
)
TimeUI.startTempus.dates.setValue(parsedStart)
}
}
TimeUI._remakeTimeSlider(true)
})
Dropy.init($('#mmgisTimeUIModeDropdown'), TimeUI.changeMode)
// Step dropdown
$('#mmgisTimeUIStepDropdown').html(
Dropy.construct(
Expand Down Expand Up @@ -475,6 +454,10 @@ const TimeUI = {
null,
true
)

// Set modeIndex to 1/Point if a deeplink had an endtime but no starttime
if (TimeUI.modeIndex != startingModeIndex)
TimeUI.changeMode(startingModeIndex)
},
fina() {
let date
Expand Down Expand Up @@ -528,6 +511,35 @@ const TimeUI = {
TimeUI._makeHistogram()
}
},
changeMode(idx) {
TimeUI.modeIndex = idx
if (TimeUI.modes[TimeUI.modeIndex] === 'Point') {
$('#mmgisTimeUIStartWrapper').css({ display: 'none' })

// Remove end date enforcement
TimeUI.endTempus.updateOptions({
restrictions: {
minDate: new Date(0),
},
})
} else {
$('#mmgisTimeUIStartWrapper').css({ display: 'inherit' })
// Reinforce min date
TimeUI.endTempus.updateOptions({
restrictions: {
minDate: TimeUI.startTempusSavedLastDate,
},
})
if (TimeUI._startTimestamp >= TimeUI._endTimestamp) {
const offsetStartDate = new Date(TimeUI._endTimestamp)
const parsedStart = TimeUI.startTempus.dates.parseInput(
new Date(offsetStartDate)
)
TimeUI.startTempus.dates.setValue(parsedStart)
}
}
TimeUI._remakeTimeSlider(true)
},
togglePlay(force) {
const mode = TimeUI.modes[TimeUI.modeIndex]
if (TimeUI.play || force === false) {
Expand Down
47 changes: 25 additions & 22 deletions src/essence/Basics/Layers_/LayerConstructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,29 +712,32 @@ const labels = (geojson, layerObj, leafletLayerObject, layer, sublayers) => {
const name = `labels_${layer._layerName}_${
subname || 'main'
}`.replace(/ /g, '_')
L_.Globe_.litho.removeLayer(name)
L_.Globe_.litho.addLayer('vector', {
name: name,
on: true,
// GeoJSON or path to geojson
// [lng, lat, elev?]
geojson: {
type: 'FeatureCollection',
features: globeLabels,
},
style: {
letPropertiesStyleOverride: true,
default: {
color: 'rgb(0, 0, 0)',
fillColor: 'rgb(255, 255, 255)',
fillOpacity: 1,
weight: 2,
fontSize: size === 'large' ? '18px' : '16px',
elevOffset: 4,
if (L_.Globe_) {
L_.Globe_.litho.removeLayer(name)
L_.Globe_.litho.addLayer('vector', {
name: name,
on: true,
// GeoJSON or path to geojson
// [lng, lat, elev?]
geojson: {
type: 'FeatureCollection',
features: globeLabels,
},
},
opacity: 1,
})
style: {
letPropertiesStyleOverride: true,
default: {
color: 'rgb(0, 0, 0)',
fillColor: 'rgb(255, 255, 255)',
fillOpacity: 1,
weight: 2,
fontSize:
size === 'large' ? '18px' : '16px',
elevOffset: 4,
},
},
opacity: 1,
})
}
}

// Short timeout since initial tooltip placement computation can take a bit
Expand Down

0 comments on commit 50a03fd

Please sign in to comment.