app.config.ts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. //import WMTSTileGrid from 'ol/tilegrid/WMTS';
  2. import proj4 from 'proj4';
  3. import {Fill, Stroke, Style} from 'ol/style';
  4. import {OSM, TileWMS, Vector as VectorSource, XYZ, WMTS} from 'ol/source';
  5. import {Tile, Vector as VectorLayer} from 'ol/layer';
  6. import {TopoJSON} from 'ol/format';
  7. import {View} from 'ol';
  8. import {get as getProjection, transform} from 'ol/proj';
  9. //import {getTopLeft, getWidth} from 'ol/extent';
  10. import {register} from 'ol/proj/proj4';
  11. import env from './env.config.json';
  12. import i18n from './translations.json';
  13. proj4.defs(
  14. 'EPSG:3045',
  15. '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
  16. );
  17. proj4.defs(
  18. 'EPSG:5514',
  19. '+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'
  20. );
  21. register(proj4);
  22. const sjtskProjection = getProjection('EPSG:5514');
  23. //const utm33nProjection = getProjection('EPSG:3045');
  24. function getHostname() {
  25. const url = window.location.href;
  26. const urlArr = url.split('/');
  27. const domain = urlArr[2];
  28. return urlArr[0] + '//' + domain;
  29. }
  30. export const cartodbLayer = new Tile({
  31. source: new XYZ({
  32. url:
  33. 'https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
  34. attributions: [
  35. 'CartoDB Positron, © <a href="https://carto.com/attributions" target="_blank">CARTO</a>',
  36. '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
  37. ],
  38. }),
  39. title: 'OpenStreetMap světlá',
  40. visible: true,
  41. base: true,
  42. editor: {editable: false},
  43. removable: false,
  44. });
  45. export const osmLayer = new Tile({
  46. source: new OSM(),
  47. title: 'OpenStreetMap barevná',
  48. base: true,
  49. visible: false,
  50. editor: {editable: false},
  51. removable: false,
  52. });
  53. export const zm100Layer = new Tile({
  54. source: new TileWMS({
  55. url: 'https://geoportal.cuzk.cz/WMS_ZM100_PUB/WMService.aspx',
  56. params: {
  57. LAYERS: 'GR_ZM100',
  58. },
  59. attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
  60. }),
  61. /*source: new TileWMS({
  62. url:
  63. 'https://ags.cuzk.cz/arcgis/services/VektorovaMapa/MapServer/WmsServer?',
  64. params: {
  65. //https://ags.cuzk.cz/arcgis/services/VektorovaMapa/MapServer/WmsServer?request=GetCapabilities&service=WMS
  66. LAYERS: `1,2,3,4,5,6,7,8,9,10,11,12,13,14,193,194,195,196,
  67. 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,
  68. 19,20,78,79,80,81,23,24,21,22,197,198,199,200,201,202,203,204,205,
  69. 52,53,54,
  70. 26,27,92,94,93,95,96,
  71. 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`,
  72. },
  73. }),*/
  74. /*source: new WMTS({
  75. url: 'https://geoportal.cuzk.cz/WMTS_ZM/WMTService.aspx',
  76. format: 'image/png',
  77. layer: 'zm',
  78. matrixSet: 'jtsk:epsg:5514',
  79. tileGrid: new WMTSTileGrid({
  80. origin: [51.874963785131, 11.082166373399],
  81. resolutions: [
  82. 3,2,1
  83. ],
  84. matrixIds: [1, 2, 3],
  85. }),
  86. }),*/
  87. title: 'Mapa ČR 1:100 000',
  88. base: true,
  89. visible: false,
  90. removable: false,
  91. });
  92. export const mcr500Layer = new Tile({
  93. source: new TileWMS({
  94. url: 'https://geoportal.cuzk.cz/WMS_MCR500/WMService.aspx',
  95. params: {
  96. LAYERS: 'GR_MCR500',
  97. },
  98. attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
  99. }),
  100. title: 'Mapa ČR 1:500 000',
  101. base: true,
  102. visible: false,
  103. removable: false,
  104. });
  105. export const ortofotoLayer = new Tile({
  106. source: new TileWMS({
  107. url: 'https://geoportal.cuzk.cz/WMS_ORTOFOTO_PUB/WMService.aspx',
  108. params: {
  109. LAYERS: 'GR_ORTFOTORGB',
  110. },
  111. attributions: ['© <a href="geoportal.cuzk.cz" target="_blank">ČÚZK</a>'],
  112. }),
  113. title: 'Ortofoto ČÚZK',
  114. base: true,
  115. visible: false,
  116. removable: false,
  117. thumbnail: 'https://www.agrihub.sk/hsl-ng/img/orto.jpg',
  118. });
  119. export const perc2color = (perc: number): string => {
  120. perc = perc * 100;
  121. let r;
  122. let g;
  123. const b = 0;
  124. if (perc < 50) {
  125. r = 255;
  126. g = Math.round(5.1 * perc);
  127. } else {
  128. g = 255;
  129. r = Math.round(510 - 5.1 * perc);
  130. }
  131. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  132. const h = r * 0x10000 + g * 0x100 + b * 0x1;
  133. return `rgba(${r}, ${g}, ${b}, 0.7)`;
  134. };
  135. const decimal2prettyPerc = (x) => {
  136. return `${(x * 100).toFixed(2)}&nbsp;%`;
  137. };
  138. const indexStyle = (feature) => {
  139. if (isNaN(feature.get('aggregate'))) {
  140. return [
  141. new Style({
  142. fill: new Fill({
  143. color: '#FFF',
  144. }),
  145. stroke: new Stroke({
  146. color: '#3399CC',
  147. width: 0.25,
  148. }),
  149. }),
  150. ];
  151. } else {
  152. return [
  153. new Style({
  154. fill: new Fill({
  155. color: perc2color(feature.get('aggregate')),
  156. }),
  157. stroke: new Stroke({
  158. color: '#FFFFFF',
  159. width: 0.15,
  160. }),
  161. }),
  162. ];
  163. }
  164. };
  165. export const obce = new VectorSource({
  166. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  167. url: require('./data/obce_cr_20210310_5p_5514.topojson').default,
  168. overlaps: false,
  169. attributions: ['CC-BY ČÚZK, 2021'],
  170. });
  171. export const obceIndexLayer = new VectorLayer({
  172. source: obce,
  173. editor: {editable: false},
  174. autoLegend: false,
  175. visible: true,
  176. style: indexStyle,
  177. title: 'Obce ČR: Rural attractiveness index',
  178. });
  179. obceIndexLayer.set('popUp', {
  180. attributes: [
  181. {
  182. attribute: 'aggregate',
  183. label: 'agregovaný index',
  184. displayFunction: decimal2prettyPerc,
  185. },
  186. {
  187. attribute: 'Konec chudoby',
  188. displayFunction: decimal2prettyPerc,
  189. },
  190. {
  191. attribute: 'Zdraví a kvalitní život',
  192. displayFunction: decimal2prettyPerc,
  193. },
  194. {
  195. attribute: 'Kvalitní vzdělání',
  196. displayFunction: decimal2prettyPerc,
  197. },
  198. {
  199. attribute: 'Důstojná práce a ekonomický růst',
  200. displayFunction: decimal2prettyPerc,
  201. },
  202. {
  203. attribute: 'Udržitelná města a obce',
  204. displayFunction: decimal2prettyPerc,
  205. },
  206. {
  207. attribute: 'Ostatní',
  208. displayFunction: decimal2prettyPerc,
  209. },
  210. ],
  211. });
  212. obceIndexLayer.set('editable', false);
  213. //obceIndexLayer.set('queryable', false);
  214. const masStyle = (feature) =>
  215. new Style({
  216. fill: new Fill({
  217. color: feature.get('mas_type') == 'member' ? '#1d941d' : '#f6cd61',
  218. }),
  219. stroke: new Stroke({
  220. color: '#ffffff',
  221. width: 0.6,
  222. }),
  223. });
  224. export const masLayer = new VectorLayer({
  225. source: new VectorSource({
  226. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  227. url: require('./data/mas_2021.topojson').default,
  228. overlaps: false,
  229. }),
  230. editor: {editable: false},
  231. visible: false,
  232. opacity: 0.8,
  233. style: masStyle,
  234. title: 'MAS ČR',
  235. popUp: {
  236. attributes: [
  237. /*{attribute: 'mas_type', label: 'člen NS MAS?', displayFunction: (attr) => {TODO:}}*/
  238. ],
  239. },
  240. attributions: ['&copy; NS MAS ČR, http://nsmascr.cz/o-nas/'],
  241. });
  242. const okresyStyle = new Style({
  243. stroke: new Stroke({
  244. color: '#111111',
  245. width: 0.4,
  246. }),
  247. });
  248. export const okresyLayer = new VectorLayer({
  249. source: new VectorSource({
  250. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  251. url: require('./data/okresy_cr_20210310_5p_5514.topojson').default,
  252. overlaps: false,
  253. }),
  254. editor: {editable: false},
  255. visible: false,
  256. style: okresyStyle,
  257. title: 'Okresy ČR',
  258. attributions: ['CC-BY ČÚZK, 2021'],
  259. });
  260. const krajeStyle = new Style({
  261. stroke: new Stroke({
  262. color: '#000000',
  263. width: 0.6,
  264. }),
  265. });
  266. export const krajeLayer = new VectorLayer({
  267. source: new VectorSource({
  268. format: new TopoJSON({dataProjection: 'EPSG:5514'}),
  269. url: require('./data/kraje_cr_20210310_5p_5514.topojson').default,
  270. overlaps: false,
  271. }),
  272. editor: {editable: false},
  273. visible: true,
  274. style: krajeStyle,
  275. title: 'Kraje ČR',
  276. attributions: ['CC-BY ČÚZK, 2021'],
  277. });
  278. export const AppConfig = {
  279. useProxy: false,
  280. //proxyPrefix: '../8085/',
  281. geonamesUser: env.geonamesUser,
  282. default_layers: [cartodbLayer, osmLayer, mcr500Layer, ortofotoLayer],
  283. popUpDisplay: 'hover',
  284. project_name: 'erra/map',
  285. default_view: new View({
  286. projection: sjtskProjection,
  287. center: transform([15.628, 49.864249], 'EPSG:4326', 'EPSG:5514'),
  288. zoom: 7.6,
  289. units: 'm',
  290. }),
  291. advanced_form: true,
  292. datasources: [],
  293. hostname: {
  294. default: {
  295. title: 'Default',
  296. type: 'default',
  297. editable: false,
  298. url: getHostname(),
  299. },
  300. },
  301. panelWidths: {
  302. datasource_selector: 400,
  303. },
  304. panelsEnabled: {
  305. composition_browser: false,
  306. feature_crossfilter: false,
  307. info: true,
  308. saveMap: false,
  309. sensors: false,
  310. tracking: false,
  311. routing: false,
  312. permalink: false,
  313. legend: false,
  314. feature_table: false,
  315. draw: false,
  316. },
  317. status_manager_url: '/statusmanager/',
  318. sidebarPosition: 'right',
  319. sizeMode: 'fullscreen',
  320. translationOverrides: i18n,
  321. };
  322. export default AppConfig;