Skip to content

Commit

Permalink
Merge pull request #1520 from pierotofy/restartchk
Browse files Browse the repository at this point in the history
Thermal as a first class citizen
  • Loading branch information
pierotofy authored Jul 8, 2024
2 parents a51a839 + 1a53f92 commit e10c031
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 86 deletions.
25 changes: 22 additions & 3 deletions app/static/app/js/MapView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MapView extends React.Component {
// and preference order (below)
if (props.selectedMapType === "auto"){
let preferredTypes = ['orthophoto', 'dsm', 'dtm'];
if (this.isThermalMap()) preferredTypes = ['plant'].concat(preferredTypes);

for (let i = 0; i < this.props.mapItems.length; i++){
let mapItem = this.props.mapItems[i];
Expand All @@ -57,6 +58,21 @@ class MapView extends React.Component {
this.handleMapTypeButton = this.handleMapTypeButton.bind(this);
}

isThermalMap = () => {
let thermalCount = 0;
for (let item of this.props.mapItems){
if (item.meta && item.meta.task && item.meta.task.orthophoto_bands){
if (item.meta.task.orthophoto_bands.length === 2 && item.meta.task.orthophoto_bands &&
item.meta.task.orthophoto_bands[0] && typeof(item.meta.task.orthophoto_bands[0].description) === "string" &&
item.meta.task.orthophoto_bands[0].description.toLowerCase() === "lwir"){
thermalCount++;
}
}
}

return thermalCount === this.props.mapItems.length;
}

getTilesByMapType(type){
// Go through the list of map items and return
// only those that match a particular type (in tile format)
Expand Down Expand Up @@ -85,16 +101,18 @@ class MapView extends React.Component {
}

render(){
const isThermal = this.isThermalMap();

let mapTypeButtons = [
{
label: _("Orthophoto"),
type: "orthophoto",
icon: "far fa-image"
},
{
label: _("Plant Health"),
label: isThermal ? _("Thermal") : _("Plant Health"),
type: "plant",
icon: "fa fa-seedling"
icon: isThermal ? "fa fa-thermometer-half" : "fa fa-seedling"
},
{
label: _("Surface Model"),
Expand Down Expand Up @@ -123,7 +141,7 @@ class MapView extends React.Component {
key={mapType.type}
onClick={this.handleMapTypeButton(mapType.type)}
title={mapType.label}
className={"btn btn-sm " + (mapType.type === this.state.selectedMapType ? "btn-primary" : "btn-default")}><i className={mapType.icon}></i><span className="hidden-sm hidden-xs"> {mapType.label}</span></button>
className={"btn btn-sm " + (mapType.type === this.state.selectedMapType ? "btn-primary" : "btn-default")}><i className={mapType.icon + " fa-fw"}></i><span className="hidden-sm hidden-xs"> {mapType.label}</span></button>
)}
</div>
</div>
Expand All @@ -136,6 +154,7 @@ class MapView extends React.Component {
public={this.props.public}
shareButtons={this.props.shareButtons}
permissions={this.props.permissions}
thermal={isThermal}
/>
</div>
</div>);
Expand Down
12 changes: 7 additions & 5 deletions app/static/app/js/components/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Map extends React.Component {
mapType: "orthophoto",
public: false,
shareButtons: true,
permissions: ["view"]
permissions: ["view"],
thermal: false
};

static propTypes = {
Expand All @@ -45,7 +46,8 @@ class Map extends React.Component {
mapType: PropTypes.oneOf(['orthophoto', 'plant', 'dsm', 'dtm']),
public: PropTypes.bool,
shareButtons: PropTypes.bool,
permissions: PropTypes.array
permissions: PropTypes.array,
thermal: PropTypes.bool
};

constructor(props) {
Expand Down Expand Up @@ -88,7 +90,7 @@ class Map extends React.Component {
case "orthophoto":
return _("Orthophoto");
case "plant":
return _("Plant Health");
return this.props.thermal ? _("Thermal") : _("Plant Health");
case "dsm":
return _("DSM");
case "dtm":
Expand All @@ -102,13 +104,13 @@ class Map extends React.Component {
case "orthophoto":
return "far fa-image fa-fw"
case "plant":
return "fa fa-seedling fa-fw";
return this.props.thermal ? "fa fa-thermometer-half fa-fw" : "fa fa-seedling fa-fw";
case "dsm":
case "dtm":
return "fa fa-chart-area fa-fw";
}
return "";
}
}

hasBands = (bands, orthophoto_bands) => {
if (!orthophoto_bands) return false;
Expand Down
Loading

0 comments on commit e10c031

Please sign in to comment.