Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermal as a first class citizen #1520

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading