app.config.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import proj4 from 'proj4';
  2. import {Fill, Stroke, Style} from 'ol/style';
  3. import {OSM, Vector as VectorSource} from 'ol/source';
  4. import {Tile, Vector as VectorLayer} from 'ol/layer';
  5. import {TopoJSON} from 'ol/format';
  6. import {View} from 'ol';
  7. import {get as getProjection, transform} from 'ol/proj';
  8. import {register} from 'ol/proj/proj4';
  9. proj4.defs(
  10. 'EPSG:3045',
  11. '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
  12. );
  13. proj4.defs(
  14. 'EPSG:5514',
  15. '+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'
  16. );
  17. register(proj4);
  18. const sjtskProjection = getProjection('EPSG:5514');
  19. //const utm33nProjection = getProjection('EPSG:3045');
  20. function getHostname() {
  21. const url = window.location.href;
  22. const urlArr = url.split('/');
  23. const domain = urlArr[2];
  24. return urlArr[0] + '//' + domain;
  25. }
  26. export const osmLayer = new Tile({
  27. source: new OSM(),
  28. title: 'OpenStreetMap',
  29. base: true,
  30. editor: {editable: false},
  31. removable: false,
  32. });
  33. const stroke = new Stroke({
  34. color: '#3399CC',
  35. width: 0.25,
  36. });
  37. function perc2color(perc) {
  38. perc = perc * 100;
  39. let r;
  40. let g;
  41. const b = 0;
  42. if (perc < 50) {
  43. r = 255;
  44. g = Math.round(5.1 * perc);
  45. } else {
  46. g = 255;
  47. r = Math.round(510 - 5.1 * perc);
  48. }
  49. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  50. const h = r * 0x10000 + g * 0x100 + b * 0x1;
  51. return `rgba(${r}, ${g}, ${b}, 0.7)`;
  52. }
  53. const styles = function (feature) {
  54. if (isNaN(feature.get('aggregate'))) {
  55. return [
  56. new Style({
  57. fill: new Fill({
  58. color: '#FFF',
  59. }),
  60. stroke: stroke,
  61. }),
  62. ];
  63. } else {
  64. return [
  65. new Style({
  66. fill: new Fill({
  67. color: perc2color(feature.get('aggregate')),
  68. }),
  69. stroke: stroke,
  70. }),
  71. ];
  72. }
  73. };
  74. export const obce = new VectorSource({
  75. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  76. url: require('./data/obce_cr_20210310_5p_5514.topojson').default,
  77. overlaps: false,
  78. });
  79. export const obceLayer = new VectorLayer({
  80. source: obce,
  81. editor: {editable: false},
  82. visible: true,
  83. style: styles,
  84. title: 'Obce ČR',
  85. attributions: ['CC-BY ČÚZK, 2021'],
  86. });
  87. obceLayer.set('popUp', {
  88. attributes: [
  89. {attribute: 'text', label: 'Název'},
  90. {
  91. attribute: 'aggregate',
  92. label: 'RAI',
  93. displayFunction: (x) => {
  94. return `${(x * 100).toFixed(2)}&nbsp;%`;
  95. },
  96. },
  97. 'Social & Human', //TODO: factors?
  98. ],
  99. });
  100. obceLayer.set('editable', false);
  101. //obceLayer.set('queryable', false);
  102. export const AppConfig = {
  103. //proxyPrefix: '../8085/',
  104. default_layers: [osmLayer, obceLayer],
  105. popUpDisplay: 'hover',
  106. project_name: 'erra/map',
  107. default_view: new View({
  108. projection: sjtskProjection,
  109. center: transform([15.628, 49.864249], 'EPSG:4326', 'EPSG:5514'),
  110. zoom: 7.6,
  111. units: 'm',
  112. }),
  113. advanced_form: true,
  114. datasources: [],
  115. hostname: {
  116. default: {
  117. title: 'Default',
  118. type: 'default',
  119. editable: false,
  120. url: getHostname(),
  121. },
  122. },
  123. panelWidths: {},
  124. panelsEnabled: {
  125. composition_browser: false,
  126. feature_crossfilter: false,
  127. info: false,
  128. saveMap: false,
  129. sensors: false,
  130. tracking: false,
  131. routing: false,
  132. permalink: false,
  133. legend: false,
  134. feature_table: false,
  135. draw: false,
  136. },
  137. sizeMode: 'fullscreen',
  138. translationOverrides: {
  139. 'cs': {
  140. 'ADJUSTER': {
  141. adjustFactors: 'Vyladit faktory',
  142. calculate: 'Vypočítat',
  143. calcAttractivity: 'Počítám atraktivitu',
  144. calcClusters: 'Počítám shluky',
  145. loading: 'Načítám',
  146. loadingData: 'Načítám data',
  147. noDataSelectedMsg:
  148. 'Vyberte alespoň jednu datovou sadu a nastavte váhu aspoň jednoho faktoru na ne-nulovou hodnotu.',
  149. serverError: 'Chyba serveru',
  150. },
  151. },
  152. 'en': {
  153. 'ADJUSTER': {
  154. adjustFactors: 'Adjust Factors',
  155. calculate: 'Calculate',
  156. calcAttractivity: 'Calculating attractivity',
  157. calcClusters: 'Calculating clusters',
  158. loading: 'Loading',
  159. loadingData: 'Loading data',
  160. noDataSelectedMsg: `Select at least one dataset and set at least one factor's weight to a non-zero value.`,
  161. serverError: 'Server error',
  162. },
  163. },
  164. },
  165. };
  166. export default AppConfig;