contour map (near number limit)

Based on: https://github.com/optimisme/javascript-temperatureMap

by jpeter06

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.7.2/proj4.js"></script>
<canvas id='cns1' width='700' height='700' style=" height: 700px; width: 700px;"></canvas>
<script>
var potInst = `AGUAYO;418.582;4773;0 
ALUMINIO;139.979;4847.682;160 
ANLLARES;213.324;4746.143;0 
APARECID;214.65;4664.668;0 
BOIMENTE;134.718;4832.286;0 
BELESAR;114.598;4729.881;0 
CARTELLE;84.55;4691.437;0 
CAELGESE;413.044;4807.593;0 
COMPOSTI;207.187;4726.148;0 
EL PALO;207.114;4804.536;0 
PESOZ;185.244;4795.505;0 
ANTINANO;263.503;4804.951;0 
LA LOMBA;199.616;4722.142;0 
LA ROBLA;285.915;4742.073;0 
LADA;286.398;4798.81;0 
MASGALAN;72.732;4741.541;0 
MESON V.;66.627;4793.562;0 
MONTEARE;220.938;4714.504;0 
NARCEA;230.137;4798.308;0 
P.G.RODR;105.746;4820.374;0 
PENAGOS;435.946;4799.979;0 
SOTORIBE;265.857;4800.568;0 
TABIELLA;267.253;4827.853;0 
TINEO;233.544;4801.914;0 
TRIVES;149.417;4695.038;0 
VELILLA;350.86;4752.694;0 
VILECHA;287.19;4715.309;42.5 
VILLAMEC;253.88;4722.541;0 
ABANTO;479.913;4793.07;0 
ALDEADAV;194.468;4569.696;0 
ALMAZAN;541.075;4590.364;10.0 
AMOREBIE;527.221;4786.776;0 
SENGRACI;560.059;4685.658;0 
AZPEITIA;564.882;4787.393;0 
ARRUBAL;562.863;4702.871;0 
GARO-BAR;479.316;4739.748;0 
CASTEJON;610.375;4673.12;0 
ELEREBRO;612.443;4673.106;0 
GATICA;513.476;4804.686;0 
DUEROINT;165.265;4573.436;0 
C.RODRIG;208.986;4497.162;620 
GRIJOTA;376.124;4661.181;0 
GUENES;483.863;4784.212;0 
HERNANI;580.164;4789.657;0 
HERRERA;392.461;4713.851;0 
HINOJOSA;187.573;4540.07;0 
ICHASO;558.753;4769.331;0 
LORA;430.066;4713.392;0 
LA SERNA;611.086;4661.85;0 
MUDARRA;348.014;4627.024;0 
MURUARTE;597.207;4739.506;0 
OLMEDO;344.92;4606.413;0 
SANTURCE;492.132;4798.399;0 
SAUCELLE;183.288;4549.523;0 
TORDESIL;332.534;4596.788;0 
VILLARIN;214.073;4570.952;0 
VIRTUS;434.653;4757.444;0 
VITORIA;524.693;4748.902;0 
ZIERBENA;489.228;4800.594;0 
ARAGON;731.678;4565.954;659.3 
ASCO;801.704;4565.382;7.92 
BEGUES;908.673;4590.122;0 
BESCANO;973.594;4659.228;0...

JavaScript

'use strict';

// Based on https://github.com/optimisme/javascript-temperatureMap
var TemperatureMap = function (ctx) {

    this.ctx = ctx;
	this.mapPoints = [];
    this.points = [];
    this.polygon = [];
	this.optVal = 10;

    this.size = { height: ctx.canvas.height, width: ctx.canvas.width }
};

TemperatureMap.crossProduct = function (o, a, b) {
    return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
};

TemperatureMap.pointInPolygon = function (point, vs) {

    var x = point.x,
        y = point.y,
        inside = false,
        i = 0,
        j = 0,
        xi = 0,
        xj = 0,
        yi = 0,
        yj = 0,
        intersect = false;

    j = vs.length - 1;
    for (i = 0; i < vs.length; i = i + 1) {
        xi = vs[i].x;
        yi = vs[i].y;
        xj = vs[j].x;
        yj = vs[j].y;

        intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
        if (intersect) { inside = !inside; }
        j = i;
    }

    return inside;
};

TemperatureMap.squareDistance = function (p0, p1) {

    var x = p0.x - p1.x,
        y = p0.y - p1.y;

    return x * x + y * y;
};

TemperatureMap.hslToRgb = function (h, s, l) {

    var r, g, b, hue2rgb, q, p;

    if (s === 0) {
        r = g = b = l;
    } else {
        hue2rgb = function hue2rgb(p, q, t) {
            if (t < 0) {
                t += 1;
            } else if (t > 1) {
                t -= 1;
            }

            if (t >= 0.66) {
                return p;
            } else if (t >= 0.5) {
                return p + (q - p) * (0.66 - t) * 6;
            } else if (t >= 0.33) {
                return q;
            } else {
                return p + (q - p) * 6 * t;
            }
        };

        q = l < 0.5 ? l * (1 + s) : l + s - l * s;
        p = 2 * l - q;
        r = hue2rgb(p, q, h + 0.33);
        g = hue2rgb(p, q, h);
        b = hue2rgb(p, q, h - 0.33);
    }

    return [(r * 255) | 0, (g * 255) | 0, (b * 255) | 0]; // (x << 0) =...