map = {
const context = this ? this.getContext("2d") : DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
let resolutionScale = window.devicePixelRatio || 1
context.clearRect(0, 0, width * resolutionScale, height * resolutionScale);
let idShaded = context.createImageData(width * resolutionScale, height * resolutionScale);
let dataShaded = idShaded.data;
var posShaded = 0;
for(let j = 0; j < height * resolutionScale; j++){
for(let i = 0; i < width * resolutionScale; i++){
let pointCoords = projection.invert([i/resolutionScale,j/resolutionScale]);
let px = swissDemData['invGeoTransform'][0] + pointCoords[0]* swissDemData['invGeoTransform'][1];
let py = swissDemData['invGeoTransform'][3] + pointCoords[1] * swissDemData['invGeoTransform'][5];
let shadedValue;
if(Math.floor(px) >= 0 && Math.ceil(px) < swissDemData['xSize'] && Math.floor(py) >= 0 && Math.ceil(py) < swissDemData['ySize']){
shadedValue = 255*(1+hillshadeData[Math.floor(py)][Math.floor(px)])/2;
} else {
shadedValue = 255;
}
dataShaded[posShaded] = 0;
dataShaded[posShaded+1] = 0;
dataShaded[posShaded+2] = 0;
dataShaded[posShaded+3] = 255 - shadedValue;
posShaded=posShaded+4;
}
}
context.putImageData( idShaded, 0, 0);
context.lineWidth = 2;
context.beginPath(), path(borders), context.stroke();
return context.canvas;
}