Browse Source

Merge branch 'develop' of jmacura/polirural-attractiveness-clustering into master

jmacura 5 years ago
parent
commit
6c75bea69a

+ 1 - 1
src/adjuster/adjuster.service.js

@@ -15,7 +15,7 @@ export class AdjusterService {
         : 'https://publish.lesprojekt.cz/nodejs/';
     this.factors = [];
     this.clusters = [];
-    this.method = 'haclust';
+    this.method = 'haclustwd2';
     this._clusteringInProcess = true;
     this.init();
   }

+ 24 - 7
src/app.component.js

@@ -55,7 +55,7 @@ export const HsComponent = {
       }
     });
     $scope.$on('clusters_loaded', function (event, args) {
-      randomColorPalette = generateRandomColorPalette(
+      colorPalette = generateRandomColorPalette(
         PraAdjusterService.clusters.length
       );
     });
@@ -63,17 +63,31 @@ export const HsComponent = {
   controllerAs: 'vm',
 };
 
-let randomColorPalette = [];
+// https://colorbrewer2.org/?type=qualitative&scheme=Paired&n=12
+let colorPalette = [
+  '#a6cee3',
+  '#1f78b4',
+  '#b2df8a',
+  '#33a02c',
+  '#fb9a99',
+  '#e31a1c',
+  '#fdbf6f',
+  '#ff7f00',
+  '#cab2d6',
+  '#6a3d9a',
+  '#ffff99',
+  '#b15928',
+];
 
 const nuts2style = new Style({
   stroke: new Stroke({
-    color: '#FFFFFF',
+    color: '#000000',
     width: 0.5,
   }),
 });
 
 // TODO: 'method' must be obtained from AdjusterService
-const method = 'haclust';
+const method = 'haclustwd2';
 const nuts3style = function (feature) {
   if (isNaN(feature.get(method))) {
     return [
@@ -91,7 +105,7 @@ const nuts3style = function (feature) {
     return [
       new Style({
         fill: new Fill({
-          color: randomColorPalette[feature.get(method) - 1],
+          color: colorPalette[feature.get(method) - 1],
         }),
       }),
     ];
@@ -123,18 +137,21 @@ nuts3Layer.set('popUp', {
 
 /**
  * https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
+ * @private
  * @param {number} colorCount Number of colors to randomly generate
  * @returns {Array<Array<Number>>} Array of RGB colors
  */
 function generateRandomColorPalette(colorCount) {
-  const palette = [];
+  const palette = colorPalette;
   const goldenRatioConjugate = 0.618033988749895;
-  for (let i = 0; i < colorCount; i++) {
+  let i = palette.length;
+  while (i < colorCount) {
     let h = Math.random();
     h += goldenRatioConjugate;
     h %= 1;
     h *= 360;
     palette.push(hsv2rgb(h, 0.5, 0.95));
+    i++;
   }
   return palette;
   //return `rgba(${r}, ${g}, ${b}, 0.7)`;

BIN
src/images/cropped-favicon-32x32.png


+ 1 - 0
src/index.html

@@ -7,6 +7,7 @@
   <meta name="description"
     content="Rural attractiveness calculation and visualization application developed in PoliRural project. 2020">
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+  <link href="<%= htmlWebpackPlugin.files.favicon %>" rel="icon">
   <meta name="apple-mobile-web-app-capable" content="yes" />
   <meta name="apple-mobile-web-app-status-bar-style" content="black" />
   <% for (var css in htmlWebpackPlugin.files.css) { %>

+ 1 - 1
webpack.common.js

@@ -41,7 +41,7 @@ module.exports = {
       template: './src/index.html',
       // We manually inject css and js files in our template
       inject: false,
-      // favicon: 'assets/img/favicon.ico'
+      favicon: './src/images/cropped-favicon-32x32.png',
     }),
   ],
   module: {