src/Gisplay/Maps/ChangeMap.js
import { Map } from './Map';
import { Legend } from '../Legend';
import { Aesthetic } from '../Aesthetic';
/**
* ChangeMap implementation 07/03
*/
export class ChangeMap extends Map {
constructor(bgmap, geometry, options) {
super(bgmap, geometry, options);
this.geometry = geometry;
this.aesthetics = new Array();
this.attr = "change";
this.loadOptions(options, bgmap);
this.id = mapcount++;
this.attr = "change";//@Rui Duplicate?
this.type = 'CM';
maps.push(this);
this.initialize();
/* return this;*/
}
draw() {
this.clear();
for (let i = 0; i < this.aesthetics.length; i++) {
if (this.aesthetics[i].enabled == true) {
this.drawContinuousPolygons(this.aesthetics[i]);
}
this.drawBorders(this.aesthetics[i]);
}
}
preProcessData(geojson, numberOf, algorithm, colorscheme) {
const aesarray = [];
const values = [];
let breaks;
//var fcolor;
for (let g = 0; g < geojson.features.length && (this.maxfeatures == undefined || g < this.maxfeatures); g++) {
if (typeof geojson.features[g].properties[this.minuend] == 'number' && geojson.features[g].properties[this.minuend] != null && typeof geojson.features[g].properties[this.subtrahend] == 'number' && geojson.features[g].properties[this.subtrahend] != null) {
this.max = Math.max(this.max, geojson.features[g].properties[this.minuend] - geojson.features[g].properties[this.subtrahend]);
this.min = Math.min(this.min, geojson.features[g].properties[this.minuend] - geojson.features[g].properties[this.subtrahend]);
}
}
breaks = [this.min, this.max];
this.fcolor = chroma.scale(colorscheme);
const aes = new Aesthetic(0, this.attr, this.fcolor, [0, 0, 0, 1], null, [breaks[0], breaks[1]]);
aes.outer = true;
aesarray.push(aes);
this.aesthetics = aesarray;
}
buildLegend() {
this.legend = new Legend(this.id, this.legendTitle);
this.legend.insertGradient(this, this.min, 0, this.max);
this.legend.insertLegend(this.map);
}
defaults() {
const options = {};
return options;
}
}