Procházet zdrojové kódy

🚧 align to African needs

jmacura před 4 roky
rodič
revize
18733771af

+ 2 - 2
src/adjuster/adjuster-legend.service.ts

@@ -1,7 +1,7 @@
 import hsv2rgb from 'hsv2rgb';
 import {Injectable} from '@angular/core';
 
-import {decimal2prettyPerc, obceIndexLayer, perc2color} from '../app.config';
+import {decimal2prettyPerc, districtsIndexLayer, perc2color} from '../app.config';
 import {AdjusterPresetsService, Factor} from './adjuster-presets.service';
 
 @Injectable({providedIn: 'root'})
@@ -60,7 +60,7 @@ export class AdjusterLegendService {
         displayFunction: decimal2prettyPerc,
       })
     }
-    obceIndexLayer.set('popUp', {
+    districtsIndexLayer.set('popUp', {
       attributes: attrs
     });
   }

+ 13 - 5
src/adjuster/adjuster-presets.service.ts

@@ -12,8 +12,8 @@ export class AdjusterPresetsService {
   activeProblem: Problem;
   activeRole: Role;
   activeSchema: Schema;
-  applicationLoD = 'http://www.semanticweb.org/attractiveness/municipality';
-  applicationCoverage = 'http://www.semanticweb.org/attractiveness/CzechRepublic';
+  applicationLoD = 'http://www.semanticweb.org/attractiveness/district';
+  applicationCoverage = 'http://www.semanticweb.org/attractiveness/Uganda'; //and Kenya, but it is equal in terms of dataset availability
   defaultSchemaId: string;
   enabledRoleIds: Array<string>;
   enabledSchemaIds: Array<string>;
@@ -105,6 +105,7 @@ export class AdjusterPresetsService {
           )
         }
       });
+    console.log('Roles', this.roles);
     if (this.enabledRoleIds) {
       this.roles = this.roles.filter((role) => this.enabledRoleIds.includes(role.id));
     }
@@ -129,10 +130,17 @@ export class AdjusterPresetsService {
           )
         }
       });
-      if (this.enabledSchemaIds) {
-        this.schemas = this.schemas.filter((schema) => this.enabledSchemaIds.includes(schema.id));
-      }
+    console.log('Schemas', this.schemas)
+    if (this.enabledSchemaIds) {
+      this.schemas = this.schemas.filter((schema) => this.enabledSchemaIds.includes(schema.id));
+    }
     this.activeSchema = this.schemas.find((schema) => schema.id == this.defaultSchemaId) ?? this.schemas[0];
+    for (const group of this.activeSchema.groups) {
+      console.log(this.activeSchema.groups);
+      const ds = this.ontology
+      .find((subject) => subject['@id'] == group.id)["http://www.semanticweb.org/attractiveness/hasDataset"]
+      console.log(`Datasets of ${group.labels[0]['@value']}:`, ds)
+    }
     this.schemaChanges.next(this.activeSchema);
   }
 

+ 6 - 6
src/adjuster/adjuster.service.ts

@@ -15,7 +15,7 @@ import clusteringMethods from '../data/clustering_methods.json';
 import {AdjusterEventService} from './adjuster-event.service';
 import {AdjusterLegendService} from './adjuster-legend.service';
 import {AdjusterPresetsService, Factor} from './adjuster-presets.service';
-import {obce, obceIndexLayer, osmLayer} from '../app.config';
+import {districts, districtsIndexLayer, osmLayer} from '../app.config';
 import {RDFSubject} from './ontology.model';
 
 @Injectable({providedIn: 'root'})
@@ -148,7 +148,7 @@ export class AdjusterService {
   calculateIndex(): void {
     this._raiInProcess = true;
     this.$http
-      .post(this.serviceBaseUrl + 'cz/scores/', {
+      .post(this.serviceBaseUrl + 'africa/scores/', {
         factors: this.factors.map((f) => {
           return {
             factor: f.id,
@@ -222,7 +222,7 @@ export class AdjusterService {
     }
 
     this.$http
-      .post(this.serviceBaseUrl + 'cz/clusters/', {
+      .post(this.serviceBaseUrl + 'africa/clusters/', {
         numberOfClusters: this.numberOfClusters,
         datasets: params
       })
@@ -329,7 +329,7 @@ export class AdjusterService {
   init(): void {
     this._loadInProcess = true;
     this.$http
-      .get(this.serviceBaseUrl + 'cz/datasets/')
+      .get(this.serviceBaseUrl + 'africa/datasets/')
       .toPromise()
       .then((data: any) => {
         //console.log(data);
@@ -388,7 +388,7 @@ export class AdjusterService {
     }*/
     let errs = 0;
     //let logs = 0;
-    obce.forEachFeature((feature) => {
+    districts.forEachFeature((feature) => {
       // Pair each feature with its attractivity data
       const featureData = codeRecordRelations[feature.get('nationalCode')];
       if (!featureData) {
@@ -410,7 +410,7 @@ export class AdjusterService {
       });
     });
     // Since we are updating the features silently, we now have to refresh manually
-    obce.getFeatures()[0].dispatchEvent('change');
+    districts.getFeatures()[0].dispatchEvent('change');
   }
 
   processClusters(

+ 27 - 159
src/app.config.ts

@@ -1,18 +1,16 @@
-//import WMTSTileGrid from 'ol/tilegrid/WMTS';
-import proj4 from 'proj4';
+//import proj4 from 'proj4';
 import {Fill, Stroke, Style} from 'ol/style';
 import {OSM, TileWMS, Vector as VectorSource, XYZ, WMTS} from 'ol/source';
 import {Tile, Vector as VectorLayer} from 'ol/layer';
 import {TopoJSON} from 'ol/format';
 import {View} from 'ol';
 import {get as getProjection, transform} from 'ol/proj';
-//import {getTopLeft, getWidth} from 'ol/extent';
-import {register} from 'ol/proj/proj4';
+//import {register} from 'ol/proj/proj4';
 
 import env from './env.config.json';
 import i18n from './translations.json';
 
-proj4.defs(
+/*proj4.defs(
   'EPSG:3045',
   '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
 );
@@ -21,7 +19,7 @@ proj4.defs(
   '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=542.5,89.2,456.9,5.517,2.275,5.516,6.96 +units=m +no_defs'
 );
 register(proj4);
-const sjtskProjection = getProjection('EPSG:5514');
+const sjtskProjection = getProjection('EPSG:5514');*/
 //const utm33nProjection = getProjection('EPSG:3045');
 
 function getHostname() {
@@ -33,7 +31,7 @@ function getHostname() {
 
 export const cartodbLayer = new Tile({
   properties: {
-    title: 'OpenStreetMap světlá',
+    title: 'OpenStreetMap bright',
     base: true,
     editor: {editable: false},
     removable: false,
@@ -51,7 +49,7 @@ export const cartodbLayer = new Tile({
 
 export const osmLayer = new Tile({
   properties: {
-    title: 'OpenStreetMap barevná',
+    title: 'OpenStreetMap colorful',
     base: true,
     editor: {editable: false},
     removable: false,
@@ -60,82 +58,6 @@ export const osmLayer = new Tile({
   visible: false,
 });
 
-export const zm100Layer = new Tile({
-  properties: {
-    title: 'Mapa ČR 1:100 000',
-    base: true,
-    removable: false,
-  },
-  source: new TileWMS({
-    url: 'https://geoportal.cuzk.cz/WMS_ZM100_PUB/WMService.aspx',
-    params: {
-      LAYERS: 'GR_ZM100',
-    },
-    attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
-  }),
-  /*source: new TileWMS({
-    url:
-      'https://ags.cuzk.cz/arcgis/services/VektorovaMapa/MapServer/WmsServer?',
-    params: {
-      //https://ags.cuzk.cz/arcgis/services/VektorovaMapa/MapServer/WmsServer?request=GetCapabilities&service=WMS
-      LAYERS: `1,2,3,4,5,6,7,8,9,10,11,12,13,14,193,194,195,196,
-17,18,15,16,82,83,84,85,86,87,88,89,90,91,182,183,184,185,186,187,188,189,190,191,192,
-19,20,78,79,80,81,23,24,21,22,197,198,199,200,201,202,203,204,205,
-52,53,54,
-26,27,92,94,93,95,96,
-29,30,31,32,76,97,98,99,100,101,102,103,104,108,109,105,106,107,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155`,
-    },
-  }),*/
-  /*source: new WMTS({
-    url: 'https://geoportal.cuzk.cz/WMTS_ZM/WMTService.aspx',
-    format: 'image/png',
-    layer: 'zm',
-    matrixSet: 'jtsk:epsg:5514',
-    tileGrid: new WMTSTileGrid({
-      origin: [51.874963785131, 11.082166373399],
-      resolutions: [
-        3,2,1
-      ],
-      matrixIds: [1, 2, 3],
-    }),
-  }),*/
-  visible: false,
-});
-
-export const mcr500Layer = new Tile({
-  properties: {
-    title: 'Mapa ČR 1:500 000',
-    base: true,
-    removable: false,
-  },
-  source: new TileWMS({
-    url: 'https://geoportal.cuzk.cz/WMS_MCR500/WMService.aspx',
-    params: {
-      LAYERS: 'GR_MCR500',
-    },
-    attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
-  }),
-  
-  visible: false,
-});
-
-export const ortofotoLayer = new Tile({
-  properties: {
-    title: 'Ortofoto ČÚZK',
-    base: true,
-    removable: false,
-    thumbnail: 'https://www.agrihub.sk/hsl-ng/img/orto.jpg',
-  },
-  source: new TileWMS({
-    url: 'https://geoportal.cuzk.cz/WMS_ORTOFOTO_PUB/WMService.aspx',
-    params: {
-      LAYERS: 'GR_ORTFOTORGB',
-    },
-    attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
-  }),
-  visible: false,
-});
-
 export const perc2color = (perc: number): string => {
   perc = perc * 100;
   let r;
@@ -185,109 +107,55 @@ const indexStyle = (feature) => {
   }
 };
 
-export const obce = new VectorSource({
-  format: new TopoJSON({dataProjection: 'EPSG:5514'}),
-  url: require('./data/obce_cr_20210310_5p_5514.topojson').default,
+export const districts = new VectorSource({
+  format: new TopoJSON({dataProjection: 'EPSG:4326'}),
+  url: require('./data/kenya+uganda_districts_10p_4326.topojson').default,
   overlaps: false,
-  attributions: ['CC-BY ČÚZK, 2021'],
+  attributions: ['HDX, IEBC, Uganda Bureau of Statistics with support from WHO'],
 });
 
-export const obceIndexLayer = new VectorLayer({
+export const districtsIndexLayer = new VectorLayer({
   properties: {
     editor: {editable: false},
     autoLegend: false,
-    title: 'Obce ČR: Rural attractiveness index',
+    title: 'Kenya & Uganda districts: Rural attractiveness index',
   },
-  source: obce,
+  source: districts,
   visible: true,
   style: indexStyle,
 });
-obceIndexLayer.set('popUp', {
+districtsIndexLayer.set('popUp', {
   attributes: [
     {
       attribute: 'aggregate',
-      label: 'agregovaný index',
+      label: 'aggregated',
       displayFunction: decimal2prettyPerc,
     },
   ],
 });
-obceIndexLayer.set('editable', false);
+districtsIndexLayer.set('editable', false);
 //obceIndexLayer.set('queryable', false);
 
-const masStyle = (feature) =>
-  new Style({
-    fill: new Fill({
-      color: feature.get('mas_type') == 'member' ? '#1d941d' : '#f6cd61',
-    }),
-    stroke: new Stroke({
-      color: '#ffffff',
-      width: 0.6,
-    }),
-  });
-
-export const masLayer = new VectorLayer({
-  properties: {
-    editor: {editable: false},
-    title: 'MAS ČR',
-    attributions: ['&copy; NS MAS ČR, http://nsmascr.cz/o-nas/'],
-    popUp: {
-      attributes: [
-        /*{attribute: 'mas_type', label: 'člen NS MAS?', displayFunction: (attr) => {TODO:}}*/
-      ],
-    },
-  },
-  source: new VectorSource({
-    format: new TopoJSON({dataProjection: 'EPSG:5514'}),
-    url: require('./data/mas_2021.topojson').default,
-    overlaps: false,
-  }),
-  visible: false,
-  opacity: 0.8,
-  style: masStyle,
-});
-
-const okresyStyle = new Style({
-  stroke: new Stroke({
-    color: '#111111',
-    width: 0.4,
-  }),
-});
-
-export const okresyLayer = new VectorLayer({
-  properties: {
-    editor: {editable: false},
-    title: 'Okresy ČR',
-    attributions: ['CC-BY ČÚZK, 2021'],
-  },
-  source: new VectorSource({
-    format: new TopoJSON({dataProjection: 'EPSG:5514'}),
-    url: require('./data/okresy_cr_20210310_5p_5514.topojson').default,
-    overlaps: false,
-  }),
-  visible: false,
-  style: okresyStyle,
-});
-
-const krajeStyle = new Style({
+const countryStyle = new Style({
   stroke: new Stroke({
     color: '#000000',
     width: 0.6,
   }),
 });
 
-export const krajeLayer = new VectorLayer({
+export const countryLayer = new VectorLayer({
   properties: {
     editor: {editable: false},
-    title: 'Kraje ČR',
-    attributions: ['CC-BY ČÚZK, 2021'],
+    title: 'Uganda',
   },
   source: new VectorSource({
-    format: new TopoJSON({dataProjection: 'EPSG:5514'}),
-    url: require('./data/kraje_cr_20210310_5p_5514.topojson').default,
+    format: new TopoJSON({dataProjection: 'EPSG:4326'}),
+    url: require('./data/uganda_districts_2020_10p_4326.topojson').default,
+    attributions: ['HDX, Uganda Bureau of Statistics with support from WHO'],
     overlaps: false,
   }),
   visible: true,
-  style: krajeStyle,
+  style: countryStyle,
 });
 
 export const AppConfig = {
@@ -295,13 +163,13 @@ export const AppConfig = {
   useProxy: false,
   //proxyPrefix: '../8085/',
   geonamesUser: env.geonamesUser,
-  default_layers: [cartodbLayer, osmLayer, mcr500Layer, ortofotoLayer],
+  default_layers: [cartodbLayer, osmLayer],
   popUpDisplay: 'hover',
   project_name: 'erra/map',
   default_view: new View({
-    projection: sjtskProjection,
-    center: transform([15.628, 49.864249], 'EPSG:4326', 'EPSG:5514'),
-    zoom: 7.6,
+    //projection: sjtskProjection,
+    center: transform([34.2, 1.1], 'EPSG:4326', 'EPSG:3857'),
+    zoom: 6.3,
   }),
   advanced_form: true,
   datasources: [],

+ 13 - 15
src/app.service.ts

@@ -1,4 +1,4 @@
-import hsv2rgb from 'hsv2rgb';
+//import hsv2rgb from 'hsv2rgb';
 import {Feature} from 'ol';
 import {Fill, Stroke, Style} from 'ol/style';
 import {Geometry} from 'ol/geom';
@@ -19,7 +19,7 @@ import {AdjusterComponent} from './adjuster/adjuster.component';
 import {AdjusterEventService} from './adjuster/adjuster-event.service';
 import {AdjusterLegendService} from './adjuster/adjuster-legend.service';
 import {AdjusterService} from './adjuster/adjuster.service';
-import {AppConfig, krajeLayer, masLayer, obceIndexLayer, okresyLayer} from './app.config';
+import {AppConfig, countryLayer, districtsIndexLayer} from './app.config';
 
 @Injectable({providedIn: 'root'})
 export class AppService {
@@ -57,7 +57,7 @@ export class AppService {
       this.init();
     });
     this.hsEventBus.olMapLoads.subscribe(() => {
-      this.ensureLayerIsLoaded(obceIndexLayer);
+      this.ensureLayerIsLoaded(districtsIndexLayer);
       for (const method of this.adjusterService.methods) {
         this.ensureLayerIsLoaded(method.layer);
       }
@@ -65,7 +65,7 @@ export class AppService {
   }
 
   init(): void {
-    this.hsLanguageService.setLanguage('cs');
+    //this.hsLanguageService.setLanguage('en');
     this.hsLayoutService.setDefaultPanel('adjuster');
   }
 
@@ -78,20 +78,20 @@ export class AppService {
         properties: {
           editor: {editable: false},
           autoLegend: false,
-          title: `Obce ČR: ${method.name.replace(/\((.+?)\)/g, '')} clusters`,
-          attributions: ['CC-BY ČÚZK, 2021'],
+          title: `Kenya & Uganda districts: ${method.name.replace(/\((.+?)\)/g, '')} clusters`,
           popUp: {
             attributes: [
               {
                 attribute: method.codename,
-                label: 'ID shluku',
+                label: 'Cluster ID',
               },
             ],
           },
         },
         source: new VectorSource({
-          format: new TopoJSON({dataProjection: 'EPSG:5514'}),
-          url: require('./data/obce_cr_20210310_5p_5514.topojson').default,
+          format: new TopoJSON({dataProjection: 'EPSG:4326'}),
+          url: require('./data/kenya+uganda_districts_10p_4326.topojson').default,
+          attributions: ['HDX, IEBC, Uganda Bureau of Statistics with support from WHO'],
           overlaps: false,
         }),
         visible: true,
@@ -106,16 +106,14 @@ export class AppService {
     }
     // obceIndexLayer, okresyLayer and krajeLayer must be pushed in this order
     // so they will display in correct order
-    AppConfig.default_layers.push(obceIndexLayer as any);
-    obceIndexLayer
+    AppConfig.default_layers.push(districtsIndexLayer as any);
+    districtsIndexLayer
       .getSource()
       .on('featuresloadend', () =>
         this.adjusterEventService.layerReady.next({name: 'index'})
       );
-    (obceIndexLayer.getSource() as any).legend_categories = this.adjusterLegendService.createIndexLegend();
-    AppConfig.default_layers.push(masLayer as any);
-    AppConfig.default_layers.push(okresyLayer as any);
-    AppConfig.default_layers.push(krajeLayer as any);
+    (districtsIndexLayer.getSource() as any).legend_categories = this.adjusterLegendService.createIndexLegend();
+    AppConfig.default_layers.push(countryLayer as any);
     this.hsConfig.update(AppConfig);
   }
 

+ 7 - 15
src/attractiveness.config.json

@@ -3,26 +3,18 @@
     "haclustwd2",
     "km50l.cluster"
   ],
-  "defaultClassificationSchema": "http://www.semanticweb.org/attractiveness/UNSDG",
+  "defaultClassificationSchema": "http://www.semanticweb.org/attractiveness/Custom",
   "enabledRoles": [
-    "http://www.semanticweb.org/attractiveness/RegionalGovernment",
-    "http://www.semanticweb.org/attractiveness/ScoutLeader",
-    "http://www.semanticweb.org/attractiveness/CZMayor",
-    "http://www.semanticweb.org/attractiveness/CZYoungFamily",
-    "http://www.semanticweb.org/attractiveness/CZFarmer"
+    "http://www.semanticweb.org/attractiveness/WildlifeDocumentarist",
+    "http://www.semanticweb.org/attractiveness/YoungAdventurer",
+    "http://www.semanticweb.org/attractiveness/FamilyTrip"
   ],
   "enabledSchemas": [
-    "http://www.semanticweb.org/attractiveness/GEMET",
-    "http://www.semanticweb.org/attractiveness/NAL",
-    "http://www.semanticweb.org/attractiveness/UNSDG"
+    "http://www.semanticweb.org/attractiveness/Custom"
   ],
   "initialWeights": {
-    "http://www.semanticweb.org/attractiveness/poverty": 0.1,
-    "http://www.semanticweb.org/attractiveness/wellbeing": 0.25,
-    "http://www.semanticweb.org/attractiveness/qualityeducation": 0.1,
-    "http://www.semanticweb.org/attractiveness/decentwork": 0,
-    "http://www.semanticweb.org/attractiveness/sustainablecities": 0.85,
-    "other": 0
+    "http://www.semanticweb.org/attractiveness/allDatasets": 0.8,
+    "other": 0.2
   },
   "serviceBaseUrl": "https://jmacura.eu/ws/"
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/kenya+uganda_districts_10p_4326.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/kenya_districts_2017_10p_4326.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/kraje_cr_20210310_5p_5514.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/mas_2021.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/obce_cr_20210310_5p_5514.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 5
src/data/obce_cr_20210310_simplified_5514.geojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/okresy_cr_20210310_5p_5514.topojson


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/data/uganda_districts_2020_10p_4326.topojson


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů