Oops remember to test it next time..
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma 2019-11-29 12:52:18 +01:00
parent 0948bacaaf
commit 5d7fd63adc
2 changed files with 74 additions and 73 deletions

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Input,AfterViewInit } from '@angular/core'; import { Component, OnInit, Input,AfterViewInit } from '@angular/core';
import { IColorMap, IColor, IColorEntry,ILayer, IRenderer } from '../../models'; import { IColorMap, IColor, IColorEntry,ILayer, IRenderer } from '../../models/color.map';
@Component({ @Component({
@ -48,7 +48,7 @@ export class LegendComponent implements OnInit,AfterViewInit {
private getHex(color: IColor): string { public getHex(color: IColor): string {
return '#' + this.componentToHex(color.red) + this.componentToHex(color.green) + this.componentToHex(color.blue); return '#' + this.componentToHex(color.red) + this.componentToHex(color.green) + this.componentToHex(color.blue);
} }
@ -57,7 +57,7 @@ export class LegendComponent implements OnInit,AfterViewInit {
return hex.length === 1 ? `0${hex}` : hex; return hex.length === 1 ? `0${hex}` : hex;
} }
private getPart(renderer: IRenderer, index: number): string { public getPart(renderer: IRenderer, index: number): string {
let max = renderer.band.histogram.entries.reduce((max, entry) => entry.freqency > max ? entry.freqency : max, 0); let max = renderer.band.histogram.entries.reduce((max, entry) => entry.freqency > max ? entry.freqency : max, 0);
let scale = 75 / max; let scale = 75 / max;
let part = (renderer.band.histogram.entries[index].freqency * scale) + "%"; let part = (renderer.band.histogram.entries[index].freqency * scale) + "%";
@ -65,7 +65,7 @@ export class LegendComponent implements OnInit,AfterViewInit {
return part; return part;
} }
private getLabel(renderer: IRenderer, index: number): string { public getLabel(renderer: IRenderer, index: number): string {
let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0); let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
let percent = renderer.band.histogram.entries[index].freqency * scale; let percent = renderer.band.histogram.entries[index].freqency * scale;
return percent < 0.1 ? "" : percent.toFixed(1) + " %"; return percent < 0.1 ? "" : percent.toFixed(1) + " %";

View File

@ -1,69 +1,70 @@
export interface IColor { export interface IColor {
red: number, red: number,
green: number, green: number,
blue: number, blue: number,
alpha: number, alpha: number,
} }
export interface IColorEntry { export interface IColorEntry {
value: number, value: number,
color: IColor color: IColor
} }
export interface IHistogramEntry { export interface IHistogramEntry {
value: number, value: number,
freqency: number freqency: number
} }
export interface IHistogram { export interface IHistogram {
min: number, min: number,
max: number, max: number,
mean: number, mean: number,
stddev: number, stddev: number,
classes: number, classes: number,
entries: IHistogramEntry[] entries: IHistogramEntry[]
} }
export interface IGradientstop { export interface IGradientstop {
relativestop: number, relativestop: number,
color: IColor color: IColor
} }
export interface IColorMap { export interface IColorMap {
gradient: IGradientstop[], gradient: IGradientstop[],
noValue: IColorEntry, noValue: IColorEntry,
entries: IColorEntry[] entries: IColorEntry[],
} colormapType: string
}
export interface IBand {
histogram: IHistogram export interface IBand {
} histogram: IHistogram
}
export interface IRenderer {
band:IBand, export interface IRenderer {
colorMap: IColorMap band:IBand,
} colorMap: IColorMap
}
export interface IRenderoutput {
renderoutputType: string export interface IRenderoutput {
} renderoutputType: string
}
export interface IRenderoutputTiles {
renderoutputType: string, export interface IRenderoutputTiles {
minzoom: number, renderoutputType: string,
maxzoom: number minzoom: number,
} maxzoom: number
}
export interface IRenderoutputImage {
renderoutputType: string, export interface IRenderoutputImage {
extent: [number,number,number,number] renderoutputType: string,
} extent: [number,number,number,number]
}
export interface ILayer {
name: string, export interface ILayer {
unit: string, name: string,
index: number, unit: string,
renderer: IRenderer, index: number,
rendering: IRenderoutput renderer: IRenderer,
} rendering: IRenderoutput
}