app.component.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {Component} from '@angular/core';
  2. import proj4 from 'proj4';
  3. import {
  4. HsConfig,
  5. HsEventBusService,
  6. HsLanguageService,
  7. HsLayoutService,
  8. HsPanelContainerService,
  9. HsSidebarService,
  10. HsToastService,
  11. } from 'hslayers-ng';
  12. import {OSM} from 'ol/source';
  13. import {Tile} from 'ol/layer';
  14. import {View} from 'ol';
  15. import {get as getProjection, transform} from 'ol/proj';
  16. import {register} from 'ol/proj/proj4';
  17. import {AppService} from './app.service';
  18. import {FcCalculatorComponent} from './calculator/calculator-panel.component';
  19. proj4.defs(
  20. 'EPSG:3045',
  21. '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
  22. );
  23. proj4.defs(
  24. 'EPSG:5514',
  25. '+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'
  26. );
  27. register(proj4);
  28. @Component({
  29. selector: 'application-root',
  30. templateUrl: './app.component.html',
  31. styleUrls: ['./app.component.scss'],
  32. })
  33. export class AppComponent {
  34. /* You can name your app as you like or not at all */
  35. title = 'hslayers-application';
  36. sjtskProjection = getProjection('EPSG:5514');
  37. constructor(
  38. private appService: AppService,
  39. /* Inject here all modules from HSLayers-NG which you intend to use */
  40. public hsConfig: HsConfig,
  41. private hsEventBus: HsEventBusService,
  42. private hsLanguageService: HsLanguageService,
  43. private hsLayoutService: HsLayoutService,
  44. public hsPanelContainerService: HsPanelContainerService,
  45. public hsSidebarService: HsSidebarService,
  46. private hsToastService: HsToastService
  47. ) {
  48. /* Create new button in the sidebar */
  49. this.hsSidebarService.addButton({
  50. panel: 'calculator',
  51. module: 'calculator',
  52. order: 0,
  53. title: 'Field Calculator', //() =>
  54. //this.hsLanguageService.getTranslation('ADJUSTER.adjustFactors'),
  55. description: 'Adjust factors for computation',
  56. icon: 'icon-analytics-piechart',
  57. });
  58. /* Create new panel itself */
  59. this.hsPanelContainerService.create(FcCalculatorComponent, {});
  60. /* Switch language to cs */
  61. this.hsEventBus.layoutLoads.subscribe(() => {
  62. this.hsLanguageService.setLanguage('en');
  63. this.hsLayoutService.setDefaultPanel('calculator');
  64. });
  65. this.hsConfig.update({
  66. default_view: new View({
  67. projection: this.sjtskProjection,
  68. center: transform([16.964, 49.248], 'EPSG:4326', 'EPSG:5514'),
  69. zoom: 14,
  70. }),
  71. default_layers: [
  72. /* Baselayers */
  73. new Tile({
  74. source: new OSM(),
  75. visible: true,
  76. properties: {
  77. title: 'OpenStreetMap',
  78. base: true,
  79. removable: false,
  80. },
  81. }),
  82. ],
  83. });
  84. }
  85. }