Commit 6502e68d authored by Romulo Pereira Goncalves's avatar Romulo Pereira Goncalves
Browse files

Merge branch 'documentation' of...

Merge branch 'documentation' of git.gfz-potsdam.de:habitat-sampler/HabitatSampler into documentation
parents 78f11ede 12aec796
Pipeline #23672 failed with stage
in 12 seconds
......@@ -92,16 +92,21 @@ multi_Class_Sampling <- function(in.raster,
max_num_cores = 5,
plot_on_browser = TRUE) {
if (length(list.files(
outPath,
all.files = FALSE,
include.dirs = TRUE,
no.. = TRUE
)) != 0) {
message("The results directory must be empty. Don't forget to save your previous results!!!")
return(NULL)
# Checks if its a new or a resumed run and asks the user to remove all .tif
# files from the results folder in case of a new run.
if(step == 1){
if (length(list.files(
outPath,
pattern = ".tif$",
all.files = FALSE,
include.dirs = TRUE,
no.. = TRUE
)) != 0) {
message("Remove all .tif files from the Results directory! Don't forget to save them and the other files.
All other files will be overwriten when a new sampling is started.")
return(NULL)
}
}
###first steps: data preparation
if (class(reference) == "SpatialPointsDataFrame") {
reference <- as.data.frame(raster::extract(in.raster, reference))
......
......@@ -12,6 +12,29 @@
#'
#' @export
plot_results <- function(inPath, color = NULL) {
# Compares the number of .kmz to that of .tif. If .tif files are missing the
# user's attention is drawn.
if (length(list.files(
outPath,
pattern = ".tif$",
all.files = FALSE,
include.dirs = TRUE,
no.. = TRUE
)) != length(list.files(
outPath,
pattern = ".kmz$",
all.files = FALSE,
include.dirs = TRUE,
no.. = TRUE
))) {
message("Make sure the number of the .tif files fits to the number of the .kmz files and that
there are no other files from previous runs.
If you have resumed a run, then the data of the aborted and the continued run needs
to be in the Results directory. You need them for plotting the classification map.")
return(NULL)
}
curr_wd <- getwd()
##3.a.1##
setwd(inPath)
......
This diff is collapsed.
/* global LeafletWidget, $, L */
LeafletWidget.methods.addImageQuery = function(layerId, bounds, type, digits, prefix) {
(function(){
var map = this;
// Create correct bounding box.
var boundsarr = [
[bounds[3],bounds[0]],
[bounds[1],bounds[2]]
];
map.on(type, function(e) {
var visible = true;
if (!(map.layerManager.getVisibleGroups().includes(layerId))) {
visible = false;
}
rasterPicker.pick(e, layerId, boundsarr, digits, prefix, visible);
});
}).call(this);
};
......@@ -28,58 +28,44 @@ rasterPicker.old = function(e, x, data) {
}
};
rasterPicker.pick = function(event, leafletConfig, digits, prefix) {
var rasterLayers = this.getRasterLayers(leafletConfig);
rasterPicker.pick = function(event, layerId, bounds, digits, prefix, visible) {
var outputWidget = this.getInfoLegend(layerId);
if (!visible) {
$(outputWidget).hide();
return;
}
var rasterLayers = this.getRasterLayers(layerId, bounds);
var pickedLayerData = {};
// collect values of clicked raster layers
var rasterHitInfos = this.getLayerIdHits(rasterLayers, event.latlng);
// Return if nothing was found.
if (rasterHitInfos.length === 0) {
$(outputWidget).hide();
return;
}
for (var rasterHitInfo_key in rasterHitInfos) {
var rasterHitInfo = rasterHitInfos[rasterHitInfo_key];
pickedLayerData[rasterHitInfo.layerId] = this.getLayerData(rasterHitInfo, event.latlng /*, event.zoom?*/);
}
// render collected hit values
var outputWidget = this.getInfoLegend(leafletConfig);
outputWidget.innerHTML = this.renderInfo(pickedLayerData, digits, prefix);
};
rasterPicker.getInfoLegend = function(leafletConfig) {
var elementId = null;
for (var call_key in leafletConfig.calls) {
var call = leafletConfig.calls[call_key];
if (call.method == "addControl" && call.args.length>2 && call.args[2] === "imageValues") {
elementId = call.args[2];
}
}
var element = null;
if (elementId!==null) {
element = window.document.getElementById(elementId);
}
if (element===null) {
rasterPicker.getInfoLegend = function(layerId) {
var element = window.document.getElementById("imageValues" + "-" + layerId);
if (element === null) {
// LOG ERROR or WARNING?
console.log("leafem: No control widget found in Leaflet setup. Can't show layer info.");
}
return element;
};
rasterPicker.getRasterLayers = function(leafletConfig) {
var rasterLayers = [];
for (var call_key in leafletConfig.calls) {
var call = leafletConfig.calls[call_key];
if (call.method == "addRasterImage" && call.args.length>=5) {
/* Parameters:
0. image data
1. latlng bounds
2. number?
3. ?
4. layerId
5. groupId
*/
rasterLayers.push({
layerId: call.args[4],
bounds: call.args[1]
});
}
}
rasterPicker.getRasterLayers = function(layerId, bounds) {
var rasterLayers = [{
layerId: layerId,
bounds: bounds
}];
// TODO check if layer is hidden?
return rasterLayers;
};
......@@ -134,18 +120,16 @@ rasterPicker.renderInfo = function(pickedLayerData, digits, prefix) {
var text = "";
for (var layer_key in pickedLayerData) {
var layer = pickedLayerData[layer_key];
if (layer.value === undefined) {
if (layer.value === undefined || layer.value === null) {
continue;
} else {
$(document.getElementById("imageValues" + "-" + layer_key)).show();
}
if(digits === null) {
text += prefix+ "<strong>"+ layer.layerId + ": </strong>"+ layer.value+ "</br>";
if(digits === "null" || digits === null) {
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value+ "</small>";
} else {
text += prefix+ "<strong>"+ layer.layerId + ": </strong>"+ layer.value.toFixed(digits)+ "</br>";
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value.toFixed(digits)+ "</small>";
}
/*text += "<br/> (lat,lng=" + layer.lat + "," + layer.lng + ")";
text += "<br/> (x,y=" + layer.index.x + "," + layer.index.y + ")";
text += "</li>\n";*/
}
/*return "<ul>"+text+"</ul>";*/
return text;
};
LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) {
this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group);
};
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<GroundOverlay>
<name>layer</name>
<Icon><href>step_01.png</href><viewBoundScale>0.75</viewBoundScale></Icon>
<LatLonBox>
<north>53.0575767378268</north><south>53.0451084378268</south><east>12.6993218786229</east><west>12.6729488786229</west>
</LatLonBox>
</GroundOverlay></kml>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<GroundOverlay>
<name>layer</name>
<Icon><href>step_02.png</href><viewBoundScale>0.75</viewBoundScale></Icon>
<LatLonBox>
<north>53.0575767378268</north><south>53.0451084378268</south><east>12.6993218786229</east><west>12.6729488786229</west>
</LatLonBox>
</GroundOverlay></kml>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment