src/Gisplay/Maps/ProportionalSymbolsMap.js
import { Map } from './Map';
import { Legend } from '../Legend';
/**
* Proportional Symbols Map implementation.
*/
export class ProportionalSymbolsMap extends Map {
constructor(bgmap, geometry, options) {
super(bgmap, geometry, options);
this.geometry = geometry;
this.aesthetics = new Array();
this.legend; //@Rui TODO WUT
this.annotations = new Array();
this.map = bgmap;
this.id = mapcount++;
this.type = 'PS';
this.loadOptions(options, bgmap);
this.dynamic = options.sizeByClass == undefined ? true : !options.sizeByClass;
if (this.dynamic == true) {
this.maxpointsize = options.maxPointSize == undefined ? 10.0 : parseFloat(options.maxPointSize);
this.minpointsize = options.minPointSize == undefined ? 1.0 : parseFloat(options.minPointSize);
}
maps.push(this);
this.initialize();
}
draw() {
this.clear();
if (this.dynamic == false)
for (var i = this.aesthetics.length - 1; i >= 0; i--) {
if (this.aesthetics[i].enabled == true)
this.drawPoints(this.aesthetics[i]);
}
else {
for (var i = this.aesthetics.length - 1; i >= 0; i--) {
if (this.aesthetics[i].enabled == true)
this.drawProporcionalPoints(this.aesthetics[i]);
}
}
}
buildLegend() {
this.legend = new Legend(this.id, this.legendTitle);
if (this.aesthetics.length == 1)
this.legend.insertProportionalSymbols(this.aesthetics[0], this, this.numberOfLegendItems);
else
for (let i = this.aesthetics.length - 1; i >= 0; i--)
if (i == 0)
this.legend.insertProportionalSymbols(this.aesthetics[i], this, 2);
else
this.legend.insertProportionalSymbols(this.aesthetics[i], this, 1);
this.legend.insertLegend(this.map);
}
defaults(defaultid) {
const options = {};
switch (defaultid) {
case 1:
options.maxPointSize = 60;
options.minPointSize = 5;
options.colorScheme = ['green', 'red', 'blue'];
options.numberOfClasses = 1;
break;
default:
break;
}
return options;
}
}