app.config.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. import env from './env.config.json';
  10. import i18n from './translations.json';
  11. proj4.defs(
  12. 'EPSG:3045',
  13. '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
  14. );
  15. proj4.defs(
  16. 'EPSG:5514',
  17. '+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'
  18. );
  19. register(proj4);
  20. const sjtskProjection = getProjection('EPSG:5514');
  21. //const utm33nProjection = getProjection('EPSG:3045');
  22. function getHostname() {
  23. const url = window.location.href;
  24. const urlArr = url.split('/');
  25. const domain = urlArr[2];
  26. return urlArr[0] + '//' + domain;
  27. }
  28. export const osmLayer = new Tile({
  29. source: new OSM(),
  30. title: 'OpenStreetMap',
  31. base: true,
  32. editor: {editable: false},
  33. removable: false,
  34. });
  35. export const perc2color = (perc: number): string => {
  36. perc = perc * 100;
  37. let r;
  38. let g;
  39. const b = 0;
  40. if (perc < 50) {
  41. r = 255;
  42. g = Math.round(5.1 * perc);
  43. } else {
  44. g = 255;
  45. r = Math.round(510 - 5.1 * perc);
  46. }
  47. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  48. const h = r * 0x10000 + g * 0x100 + b * 0x1;
  49. return `rgba(${r}, ${g}, ${b}, 0.7)`;
  50. };
  51. const decimal2prettyPerc = (x) => {
  52. return `${(x * 100).toFixed(2)}&nbsp;%`;
  53. };
  54. const indexStyle = (feature) => {
  55. if (isNaN(feature.get('aggregate'))) {
  56. return [
  57. new Style({
  58. fill: new Fill({
  59. color: '#FFF',
  60. }),
  61. stroke: new Stroke({
  62. color: '#3399CC',
  63. width: 0.25,
  64. }),
  65. }),
  66. ];
  67. } else {
  68. return [
  69. new Style({
  70. fill: new Fill({
  71. color: perc2color(feature.get('aggregate')),
  72. }),
  73. stroke: new Stroke({
  74. color: '#FFFFFF',
  75. width: 0.15,
  76. }),
  77. }),
  78. ];
  79. }
  80. };
  81. export const obce = new VectorSource({
  82. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  83. url: require('./data/obce_cr_20210310_5p_5514.topojson').default,
  84. overlaps: false,
  85. });
  86. export const obceIndexLayer = new VectorLayer({
  87. source: obce,
  88. editor: {editable: false},
  89. visible: true,
  90. style: indexStyle,
  91. title: 'Obce ČR: Rural attractiveness index',
  92. attributions: ['CC-BY ČÚZK, 2021'],
  93. });
  94. obceIndexLayer.set('popUp', {
  95. attributes: [
  96. {
  97. attribute: 'aggregate',
  98. label: 'agregovaný index',
  99. displayFunction: decimal2prettyPerc,
  100. },
  101. {
  102. attribute: 'Konec chudoby',
  103. displayFunction: decimal2prettyPerc,
  104. },
  105. {
  106. attribute: 'Zdraví a kvalitní život',
  107. displayFunction: decimal2prettyPerc,
  108. },
  109. {
  110. attribute: 'Kvalitní vzdělání',
  111. displayFunction: decimal2prettyPerc,
  112. },
  113. {
  114. attribute: 'Důstojná práce a ekonomický růst',
  115. displayFunction: decimal2prettyPerc,
  116. },
  117. {
  118. attribute: 'Udržitelná města a obce',
  119. displayFunction: decimal2prettyPerc,
  120. },
  121. {
  122. attribute: 'Ostatní',
  123. displayFunction: decimal2prettyPerc,
  124. },
  125. ],
  126. });
  127. obceIndexLayer.set('editable', false);
  128. //obceIndexLayer.set('queryable', false);
  129. const okresyStyle = new Style({
  130. stroke: new Stroke({
  131. color: '#111111',
  132. width: 0.4,
  133. }),
  134. });
  135. export const okresyLayer = new VectorLayer({
  136. source: new VectorSource({
  137. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  138. url: require('./data/okresy_cr_20210310_5p_5514.topojson').default,
  139. overlaps: false,
  140. }),
  141. editor: {editable: false},
  142. visible: false,
  143. style: okresyStyle,
  144. title: 'Okresy ČR',
  145. attributions: ['CC-BY ČÚZK, 2021'],
  146. });
  147. const krajeStyle = new Style({
  148. stroke: new Stroke({
  149. color: '#000000',
  150. width: 0.6,
  151. }),
  152. });
  153. export const krajeLayer = new VectorLayer({
  154. source: new VectorSource({
  155. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  156. url: require('./data/kraje_cr_20210310_5p_5514.topojson').default,
  157. overlaps: false,
  158. }),
  159. editor: {editable: false},
  160. visible: true,
  161. style: krajeStyle,
  162. title: 'Kraje ČR',
  163. attributions: ['CC-BY ČÚZK, 2021'],
  164. });
  165. export const AppConfig = {
  166. //proxyPrefix: '../8085/',
  167. geonamesUser: env.geonamesUser,
  168. default_layers: [osmLayer],
  169. popUpDisplay: 'hover',
  170. project_name: 'erra/map',
  171. default_view: new View({
  172. projection: sjtskProjection,
  173. center: transform([15.628, 49.864249], 'EPSG:4326', 'EPSG:5514'),
  174. zoom: 7.6,
  175. units: 'm',
  176. }),
  177. advanced_form: true,
  178. datasources: [],
  179. hostname: {
  180. default: {
  181. title: 'Default',
  182. type: 'default',
  183. editable: false,
  184. url: getHostname(),
  185. },
  186. },
  187. panelWidths: {
  188. datasource_selector: 400,
  189. },
  190. panelsEnabled: {
  191. composition_browser: false,
  192. feature_crossfilter: false,
  193. info: true,
  194. saveMap: false,
  195. sensors: false,
  196. tracking: false,
  197. routing: false,
  198. permalink: false,
  199. legend: false,
  200. feature_table: false,
  201. draw: false,
  202. },
  203. status_manager_url: '/statusmanager/',
  204. sidebarPosition: 'right',
  205. sizeMode: 'fullscreen',
  206. translationOverrides: i18n,
  207. };
  208. export default AppConfig;