{"version":3,"file":"hslayers-ng-components-draw-draw-edit.component-C2pfaMzQ.mjs","sources":["../../../projects/hslayers/components/draw/draw-edit/draw-edit.component.ts","../../../projects/hslayers/components/draw/draw-edit/draw-edit.component.html"],"sourcesContent":["import {Component, OnDestroy, OnInit, inject} from '@angular/core';\nimport {NgClass} from '@angular/common';\nimport {TranslatePipe} from '@ngx-translate/core';\n\nimport * as polygonClipping from 'polygon-clipping';\nimport polygonSplitter from 'polygon-splitter';\nimport {Feature} from 'ol';\nimport {LineString, Polygon, SimpleGeometry} from 'ol/geom';\nimport {Vector} from 'ol/source';\nimport {Vector as VectorLayer} from 'ol/layer';\n\nimport {HsDrawService} from 'hslayers-ng/services/draw';\nimport {HsEventBusService} from 'hslayers-ng/services/event-bus';\nimport {HsLanguageService} from 'hslayers-ng/services/language';\nimport {HsLogService} from 'hslayers-ng/services/log';\nimport {HsMapService} from 'hslayers-ng/services/map';\nimport {\n  HsQueryBaseService,\n  HsQueryVectorService,\n} from 'hslayers-ng/services/query';\nimport {HsToastService} from 'hslayers-ng/common/toast';\nimport {defaultStyle} from 'hslayers-ng/services/styler';\n\ndeclare type HsModifyOperations =\n  | 'difference'\n  | 'split'\n  | 'intersection'\n  | 'union';\n\n@Component({\n  selector: 'hs-draw-edit',\n  templateUrl: './draw-edit.component.html',\n  imports: [NgClass, TranslatePipe],\n})\nexport class HsDrawEditComponent implements OnDestroy, OnInit {\n  hsDrawService = inject(HsDrawService);\n  hsQueryBaseService = inject(HsQueryBaseService);\n  hsQueryVectorService = inject(HsQueryVectorService);\n  hsLanguageService = inject(HsLanguageService);\n  private hsLog = inject(HsLogService);\n  hsMapService = inject(HsMapService);\n  hsToastService = inject(HsToastService);\n  hsEventBusService = inject(HsEventBusService);\n\n  vectorQueryFeatureSubscription;\n  editOptions = ['difference', 'union', 'intersection', 'split'] as const;\n  selectedType: (typeof this.editOptions)[number];\n\n  selectedFeature;\n  editLayer = new VectorLayer({\n    properties: {\n      title: 'Layer editor helper',\n      queryable: true,\n      showInLayerManager: false,\n      sld: defaultStyle,\n    },\n    source: new Vector({}),\n  });\n\n  async ngOnInit(): Promise<void> {\n    if (this.hsDrawService.selectedLayer) {\n      this.hsDrawService.previouslySelected = this.hsDrawService.selectedLayer;\n    } else {\n      this.hsDrawService.previouslySelected = null;\n    }\n\n    await this.hsMapService.loaded();\n    this.hsMapService.getMap().addLayer(this.editLayer);\n    this.checkFeatureGeometryType(\n      this.hsQueryVectorService.selector.getFeatures().getArray()[0],\n    );\n    this.vectorQueryFeatureSubscription =\n      this.hsEventBusService.vectorQueryFeatureSelection.subscribe((data) => {\n        const selectorFeatures = data.selector.getFeatures().getArray();\n        if (!this.checkFeatureGeometryType(selectorFeatures[0])) {\n          return;\n        }\n        if (\n          selectorFeatures.length > 1 &&\n          this.editLayer !=\n            this.hsMapService.getLayerForFeature(data.feature) &&\n          this.selectedType == 'split'\n        ) {\n          if (selectorFeatures.length == 3) {\n            //Switch between two splitting lines\n            if (selectorFeatures[2].getGeometry().getType() == 'LineString') {\n              data.selector.getFeatures().remove(selectorFeatures[1]);\n              this.hsToastService.createToastPopupMessage(\n                this.hsLanguageService.getTranslation(\n                  'DRAW.featureEditor.featureEditor',\n                  undefined,\n                ),\n                this.hsLanguageService.getTranslation(\n                  'DRAW.featureEditor.onlyOneSplitLine',\n                  undefined,\n                ),\n                {\n                  type: 'info',\n                },\n              );\n            } else {\n              //Remove lastly selected feature.\n              //TODO: Feature is removed from selector properly but its style is not refreshed (looks like it's still selected)\n              data.selector.getFeatures().pop();\n            }\n          }\n          if (\n            selectorFeatures.length == 2 &&\n            selectorFeatures[1].getGeometry().getType() != 'LineString'\n          ) {\n            this.deselectMultiple();\n          }\n        }\n      });\n  }\n\n  ngOnDestroy() {\n    this.hsMapService.loaded().then((map) => {\n      map.removeLayer(this.editLayer);\n      this.setType(this.hsDrawService.type);\n      //Timeout necessary because setType triggers async deactivateDrawing\n      //HsDrawService.draw needs to be null in order to change draw source properly\n      setTimeout(() => {\n        if (this.hsDrawService.previouslySelected) {\n          this.hsDrawService.selectedLayer =\n            this.hsDrawService.previouslySelected;\n          this.hsDrawService.changeDrawSource();\n        } else {\n          this.hsDrawService.fillDrawableLayers();\n        }\n      });\n      this.vectorQueryFeatureSubscription.unsubscribe();\n    });\n  }\n\n  /**\n   * Check whether selected feature geometry type is valid\n   * (Geometry operations work on polygon only)\n   */\n  checkFeatureGeometryType(feature) {\n    if (!feature) {\n      return false;\n    }\n    const isValidType = feature.getGeometry().getType() == 'Polygon';\n    if (!isValidType) {\n      this.hsToastService.createToastPopupMessage(\n        this.hsLanguageService.getTranslation(\n          'DRAW.featureEditor.featureEditor',\n          undefined,\n        ),\n        'Only polygon geometry can be edited',\n        undefined,\n      );\n      this.resetState();\n    }\n    return isValidType;\n  }\n\n  /**\n   * Selects geometry operation (one of editOptions)\n   */\n  selectGeomOperation(option): void {\n    const features = this.hsQueryVectorService.selector.getFeatures();\n    this.selectedType = option;\n\n    if (this.hsDrawService.draw) {\n      const drawTypeRequired = option == 'split' ? 'LineString' : 'Polygon';\n      if (this.hsDrawService.type != drawTypeRequired) {\n        this.setType(drawTypeRequired);\n      }\n    }\n\n    if (this.selectedType == 'split') {\n      if (this.editLayer.getSource().getFeatures().length > 0) {\n        this.editLayer.getSource().clear();\n      }\n      if (features.getLength() > 1) {\n        this.deselectMultiple();\n      }\n      this.setType('LineString'); //Commence drawing right away\n    } else {\n      if (features.getLength() > 1) {\n        //Remove non polygon features from selection\n        const featuresToRemove = features\n          .getArray()\n          .filter((feature) => feature.getGeometry().getType() != 'Polygon');\n        for (const feature of featuresToRemove) {\n          features.remove(feature);\n        }\n      }\n    }\n  }\n\n  /**\n   * Deselects multi selection. Only one feature can be edited at the time\n   * Index can specify which feature to preserve in selection\n   */\n  deselectMultiple(index = 1): void {\n    this.hsToastService.createToastPopupMessage(\n      this.hsLanguageService.getTranslation('DRAW.featureEditor.featureEditor'),\n      this.hsLanguageService.getTranslation(\n        'DRAW.featureEditor.onlyOneFeatureToEdit',\n        undefined,\n      ),\n      {\n        type: 'info',\n      },\n    );\n    setTimeout(() => {\n      try {\n        const feature = this.hsQueryBaseService.selector\n          .getFeatures()\n          .getArray()[index];\n        this.hsQueryBaseService.clear('features');\n        this.hsQueryBaseService.selector.getFeatures().clear();\n        this.hsQueryBaseService.selector.getFeatures().push(feature);\n        this.hsQueryVectorService.createFeatureAttributeList();\n      } catch (error) {\n        this.hsLog.error(error);\n      }\n    });\n  }\n\n  /**\n   * Custom onDrawEnd callback preventing HsQueryBaseService.clearData\n   */\n  onDrawEnd(e): void {\n    setTimeout(() => {\n      if (this.selectedType == 'split') {\n        const features = this.editLayer.getSource().getFeatures();\n        if (features.length > 1) {\n          this.hsQueryVectorService.removeFeature(features[0]);\n\n          this.hsToastService.createToastPopupMessage(\n            this.hsLanguageService.getTranslation(\n              'DRAW.featureEditor.featureEditor',\n              undefined,\n            ),\n            this.hsLanguageService.getTranslation(\n              'DRAW.featureEditor.onlyOneSplitLine',\n              undefined,\n            ),\n            {\n              type: 'info',\n            },\n          );\n        }\n      }\n\n      this.hsDrawService.addFeatureToSelector(e.feature);\n    });\n  }\n\n  selectionMenuToggled(): void {\n    this.setType(this.hsDrawService.type);\n    this.editLayer.getSource().clear();\n  }\n\n  setType(what): void {\n    this.hsDrawService.selectedLayer = this.editLayer;\n\n    this.hsQueryBaseService.selector.setActive(\n      what === this.hsDrawService.type,\n    );\n    this.hsDrawService.modify.setActive(what === this.hsDrawService.type);\n\n    const type = this.hsDrawService.setType(what);\n    if (type) {\n      this.hsDrawService.activateDrawing({onDrawEnd: (e) => this.onDrawEnd(e)});\n    }\n    if (this.selectedType == 'split' && this.features.length > 1) {\n      this.deselectMultiple(0);\n    }\n  }\n\n  translateString(module: string, text: string): string {\n    return this.hsLanguageService.getTranslationIgnoreNonExisting(module, text);\n  }\n\n  /**\n   * Modify firstly selected features with the output of polygonClipping\n   */\n  setCoordinatesToFirstFeature(coords: any[]): void {\n    (this.features[0].feature.getGeometry() as SimpleGeometry).setCoordinates(\n      coords[0],\n      'XY',\n    );\n  }\n\n  get features() {\n    return this.hsQueryBaseService.features;\n  }\n\n  /**\n   * A wrapper for any modification of the selected polygons. Calls intersection(), split(), difference() or union() based on the type param.\n   * @param type - Type of modification.\n   */\n  modify(type: HsModifyOperations): void {\n    const features = [];\n    const editCoords = [];\n\n    this.features.forEach((feature, idx) => {\n      if ((type == 'difference' && idx < 2) || type != 'difference') {\n        features.push(feature.feature.clone());\n      }\n    });\n\n    for (const index in features) {\n      editCoords[index] = features[index].getGeometry().getCoordinates();\n    }\n\n    let newGeom;\n    let properties;\n    if (type === 'split') {\n      const splittingLine =\n        this.features.length > 1\n          ? (this.features[1].feature as Feature<LineString>)\n          : (this.editLayer\n              .getSource()\n              .getFeatures()[0] as Feature<LineString>);\n\n      newGeom = polygonSplitter(\n        {\n          type: 'Polygon',\n          coordinates: editCoords[0],\n        },\n        {\n          type: 'LineString',\n          coordinates: splittingLine.getGeometry().getCoordinates(),\n        },\n      ).geometry.coordinates;\n      properties = features[0].getProperties();\n    } else {\n      if (type == 'union' || type == 'intersection') {\n        const properties = {};\n        for (const f of features) {\n          Object.assign(properties, f.getProperties());\n        }\n      }\n      newGeom = polygonClipping[type](editCoords[0], ...editCoords.slice(1));\n    }\n\n    //TYPE SPECIFIC ACTION\n    this[type](newGeom, properties);\n  }\n\n  intersection(newGeom, properties): void {\n    if (newGeom.length > 0) {\n      this.setCoordinatesToFirstFeature(newGeom);\n      this.features[0].feature.setProperties(properties);\n      this.resetState();\n    } else {\n      this.hsToastService.createToastPopupMessage(\n        this.hsLanguageService.getTranslation(\n          'DRAW.featureEditor.featureEditor',\n          undefined,\n        ),\n        this.hsLanguageService.getTranslation(\n          'DRAW.featureEditor.noIntersection',\n          undefined,\n        ),\n        {\n          type: 'warning',\n        },\n      );\n    }\n  }\n\n  union(newGeom, properties): void {\n    const features = this.features;\n    const featuresLength = features.length;\n    for (let i = 0; i <= featuresLength; i++) {\n      //Remove all but the first (edited) features\n      if (features.length != 1) {\n        this.hsQueryVectorService.removeFeature(\n          features[features.length - 1].feature, //pop() ??\n        );\n      }\n    }\n    this.features[0].feature.setProperties(properties);\n    this.setCoordinatesToFirstFeature(newGeom);\n    this.resetState();\n  }\n\n  split(coords, properties): void {\n    for (const c of coords) {\n      const layer = this.hsMapService.getLayerForFeature(\n        this.features[0].feature,\n      );\n      const feature = new Feature(\n        Object.assign(properties, {geometry: new Polygon(c)}),\n      );\n\n      layer.getSource().addFeature(feature);\n    }\n    for (const feature of this.features) {\n      this.hsQueryVectorService.removeFeature(feature.feature);\n    }\n    this.resetState();\n  }\n\n  difference(newGeom: any[], properties): void {\n    //TODO: Not sure what to do with properties here\n    if (newGeom.length === 1) {\n      this.setCoordinatesToFirstFeature(newGeom);\n    } else {\n      const layer = this.hsMapService.getLayerForFeature(\n        this.features[0].feature,\n      );\n\n      for (const geom of newGeom) {\n        const feature = new Feature(new Polygon(geom));\n\n        layer.getSource().addFeature(feature);\n      }\n\n      for (const feature of this.features) {\n        this.hsQueryVectorService.removeFeature(feature.feature);\n      }\n    }\n    this.resetState();\n  }\n\n  resetState() {\n    this.editLayer.getSource().clear();\n    this.setType(this.hsDrawService.type);\n    this.hsQueryBaseService.clear('features');\n    this.hsQueryBaseService.selector.getFeatures().clear();\n    this.hsQueryBaseService.selector.setActive(true);\n  }\n}\n","@if (hsQueryBaseService.features.length === 0) {\n  <div class=\"alert alert-info w-75 m-auto mt-3 text-center\" role=\"alert\"\n    >\n    {{'DRAW.featureEditor.selectFeatureToEdit' | translate }}\n  </div>\n} @else {\n  <span class=\"w-75 text-center bg-primary text-white p-2 rounded mb-2\" style=\"--bs-bg-opacity: .8;\"><span\n  class=\"text-decoration-underline\">{{'DRAW.featureEditor.selectedFeature' | translate }}</span>\n{{'DRAW.featureEditor.featureCanBeEditedbyOptions' | translate }}:</span>\n<div class=\"rounded-0 my-1 draw-buttons d-flex justify-content-center\">\n  @for (option of editOptions; track option) {\n    <button class=\"btn btn-sm btn-light btn-outline-primary\"\n      [ngClass]=\"{active: selectedType === option }\" (click)=\"selectGeomOperation(option)\">\n      {{hsLanguageService.getTranslationIgnoreNonExisting('DRAW.featureEditor.editOptions',option, undefined)}}\n    </button>\n  }\n</div>\n@if (selectedType) {\n  <div class=\"d-flex flex-column align-items-center my-3 w-75 bg-secondary\"\n    style=\"--bs-bg-opacity: .02;\">\n    <div class=\"d-flex flex-column align-items-center border border-start-0 border-end-0 py-3 w-100\">\n      {{'DRAW.featureEditor.drawNewFeature' | translate }}\n      @if (selectedType !== 'split') {\n        <button class=\"w-50 btn btn-sm btn-light btn-outline-primary\"\n          (click)=\"setType('Polygon')\" [ngClass]=\"{active: hsDrawService.type==='Polygon' }\"\n          [title]=\"'COMMON.polygon' | translate \">\n          <i class=\"fa-solid fa-draw-polygon\"></i>\n        </button>\n      }\n      @if (selectedType === 'split') {\n        <button class=\"w-50 btn btn-sm btn-light btn-outline-primary\"\n          [ngClass]=\"{active: hsDrawService.type==='LineString' }\" (click)=\"setType('LineString')\"\n          data-toggle=\"tooltip\" [title]=\"'COMMON.line' | translate \">\n          <i class=\"fa-solid fa-slash\"></i>\n        </button>\n      }\n      <span class=\"py-1\"> {{'DRAW.featureEditor.orSelectOne' | translate }}\n      </span>\n      <button class=\"w-50 btn btn-sm btn-light btn-outline-primary\" [ngClass]=\"{active: !hsDrawService.type }\"\n        (click)=\"setType(hsDrawService.type)\" data-toggle=\"tooltip\" [title]=\"'COMMON.line' | translate \">\n        <i class=\"fa-solid fa-arrow-pointer\"></i>\n      </button>\n    </div>\n    @if (selectedType) {\n      <button class=\"btn btn-primary m-2 w-100\" (click)=\"modify(selectedType)\"\n        [disabled]=\"hsQueryBaseService.features.length < 2\">{{'COMMON.continue' | translate }}:\n        {{hsLanguageService.getTranslationIgnoreNonExisting('DRAW.featureEditor.editOptions',selectedType,\n      undefined)}}</button>\n    }\n  </div>\n}\n}\n"],"names":["VectorLayer","Vector"],"mappings":";;;;;;;;;;;;;;;;;;;MAkC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