{"version":3,"file":"hslayers-ng-components-wfs-filter.mjs","sources":["../../../projects/hslayers/components/wfs-filter/wfs-filter.component.ts","../../../projects/hslayers/components/wfs-filter/wfs-filter.component.html","../../../projects/hslayers/components/wfs-filter/hslayers-ng-components-wfs-filter.ts"],"sourcesContent":["import {AsyncPipe, NgClass} from '@angular/common';\nimport {\n  ChangeDetectionStrategy,\n  Component,\n  Signal,\n  inject,\n  computed,\n  signal,\n} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HttpClient} from '@angular/common/http';\nimport {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';\n\nimport * as olFormatFilter from 'ol/format/filter';\nimport {Vector as VectorLayer} from 'ol/layer';\nimport {Vector as VectorSource} from 'ol/source';\nimport {catchError, filter, lastValueFrom, map, switchMap, tap} from 'rxjs';\nimport {TranslatePipe} from '@ngx-translate/core';\n\nimport {HsEventBusService} from 'hslayers-ng/services/event-bus';\nimport {HsFiltersComponent, HsFiltersService} from 'hslayers-ng/common/filters';\nimport {HsLayerDescriptor, WfsFeatureAttribute} from 'hslayers-ng/types';\nimport {\n  HsLayerManagerService,\n  HsLayerSelectorService,\n} from 'hslayers-ng/services/layer-manager';\nimport {HsLayoutService} from 'hslayers-ng/services/layout';\nimport {\n  HsPanelBaseComponent,\n  HsPanelHeaderComponent,\n} from 'hslayers-ng/common/panels';\nimport {HsToastService} from 'hslayers-ng/common/toast';\nimport {HsProxyService, instOf} from 'hslayers-ng/services/utils';\nimport {\n  getDefinition,\n  getName,\n  getWfsAttributes,\n  getWfsUrl,\n  getWorkspace,\n  setWfsAttributes,\n} from 'hslayers-ng/common/extensions';\n\n@Component({\n  selector: 'hs-wfs-filter',\n  templateUrl: './wfs-filter.component.html',\n  styles: `\n    .hs-wfs-filter-panel > div {\n      padding: 0 0.75rem;\n    }\n  `,\n  imports: [\n    NgClass,\n    HsFiltersComponent,\n    FormsModule,\n    AsyncPipe,\n    HsPanelHeaderComponent,\n    TranslatePipe,\n  ],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class HsWfsFilterComponent extends HsPanelBaseComponent {\n  name = 'wfsFilter';\n\n  selectedLayer = signal<HsLayerDescriptor | null>(null);\n  rule = computed(() => this.selectedLayer()?.layer.get('wfsFilter') || {});\n\n  hsFiltersService = inject(HsFiltersService);\n  hsEventBusService = inject(HsEventBusService);\n  hsLayerManagerService = inject(HsLayerManagerService);\n  hsProxyService = inject(HsProxyService);\n  hsLayoutService = inject(HsLayoutService);\n  httpClient = inject(HttpClient);\n  hsLayerSelectorService = inject(HsLayerSelectorService);\n  hsToastService = inject(HsToastService);\n\n  availableLayers: Signal<HsLayerDescriptor[]>;\n\n  loadingLayerInfo = signal(false);\n\n  constructor() {\n    super();\n    const mainPanelStream = this.hsEventBusService.mapEventHandlersSet.pipe(\n      switchMap(() => this.hsLayoutService.mainpanel$),\n      filter((which) => which === 'wfsFilter'),\n      takeUntilDestroyed(),\n    );\n\n    this.availableLayers = toSignal(\n      mainPanelStream.pipe(\n        map(() => {\n          return this.hsLayerManagerService.data.layers.filter(\n            (l: HsLayerDescriptor) =>\n              instOf(l.layer, VectorLayer) &&\n              instOf(l.layer.getSource(), VectorSource) &&\n              (getWfsUrl(l.layer) || getDefinition(l.layer)),\n          );\n        }),\n        tap((layers) => {\n          const currentLayerTitle =\n            this.hsLayerSelectorService.currentLayer?.title;\n          if (currentLayerTitle) {\n            const layerToSelect = layers.find(\n              (layer) => layer.title === currentLayerTitle,\n            );\n            if (layerToSelect) {\n              this.selectLayer(layerToSelect);\n            }\n          }\n        }),\n      ),\n    );\n\n    // Use the same stream to update attributesExcludedFromList\n    mainPanelStream.subscribe(() => {\n      this.hsFiltersService.attributesExcludedFromList = [\n        'hs_normalized_IDW_value',\n        'boundedBy',\n      ];\n    });\n\n    this.hsEventBusService.resetWfsFilter\n      .pipe(\n        takeUntilDestroyed(),\n        filter(() => this.hsLayoutService.mainpanel === 'wfsFilter'),\n      )\n      .subscribe(() => {\n        this.updateLayer(this.selectedLayer(), undefined, undefined);\n      });\n  }\n\n  /**\n   * Selects a layer and updates the filter service\n   * @param layer The layer to select\n   */\n  async selectLayer(layer: HsLayerDescriptor | null) {\n    try {\n      this.selectedLayer.set(layer);\n\n      if (!layer || this.setExistingLayerAttributes(layer)) {\n        return;\n      }\n      this.loadingLayerInfo.set(true);\n      const wfsUrl = getWfsUrl(layer.layer) || getDefinition(layer.layer).url;\n      const url = new URL(wfsUrl);\n      url.search = ''; // Clear existing query parameters\n      url.searchParams.set('service', 'WFS');\n      url.searchParams.set('request', 'DescribeFeatureType');\n      url.searchParams.set('version', '2.0.0');\n      url.searchParams.set('typeName', getName(layer.layer));\n\n      const proxifiedUrl = this.hsProxyService.proxify(url.toString());\n\n      const response = await lastValueFrom(\n        this.httpClient.get(proxifiedUrl, {responseType: 'text'}).pipe(\n          catchError((error) => {\n            console.error('Error fetching WFS DescribeFeatureType:', error);\n            this.hsToastService.createToastPopupMessage(\n              'PANEL_HEADER.WFS_FILTER',\n              'WFS_FILTER.ERROR_FETCHING_LAYER_INFO',\n              {\n                type: 'danger',\n              },\n            );\n            throw error; // Re-throw the error to be caught by the outer try-catch\n          }),\n        ),\n      );\n\n      if (response) {\n        const {attributes, geometryAttribute} =\n          this.parseWfsDescribeFeatureType(\n            response,\n            layer.layer as VectorLayer<VectorSource>,\n          );\n        this.hsFiltersService.setLayerAttributes(attributes);\n        setWfsAttributes(layer.layer, attributes);\n        /**\n         * Set geometryAttribute to the layer's source so it can be easily accessed in loader function\n         */\n        layer.layer.getSource().set('geometryAttribute', geometryAttribute);\n      }\n      this.hsFiltersService.setSelectedLayer(layer);\n    } catch (error) {\n      console.error('Error in selectLayer:', error);\n      this.hsToastService.createToastPopupMessage(\n        'PANEL_HEADER.WFS_FILTER',\n        'WFS_FILTER.ERROR_SELECTING_LAYER',\n        {\n          type: 'danger',\n        },\n      );\n    } finally {\n      this.loadingLayerInfo.set(false);\n    }\n  }\n\n  /**\n   * Sets the existing layer attributes and returns true if successful, false otherwise\n   */\n  private setExistingLayerAttributes(layer: HsLayerDescriptor): boolean {\n    const layerAttributes = getWfsAttributes(layer.layer);\n    if (layerAttributes) {\n      this.hsFiltersService.setLayerAttributes(layerAttributes);\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * Parses the WFS DescribeFeatureType response XML into an array of feature attributes.\n   * @param xmlString The XML string response from the WFS DescribeFeatureType request.\n   * @param layer The layer object to determine geometry attribute from.\n   * @returns An object containing the attributes and geometry attribute name.\n   */\n  private parseWfsDescribeFeatureType(\n    xmlString: string,\n    layer: VectorLayer<VectorSource>,\n  ): {attributes: WfsFeatureAttribute[]; geometryAttribute: string | null} {\n    const parser = new DOMParser();\n    const xmlDoc = parser.parseFromString(xmlString, 'text/xml');\n    const featureTypeElement = xmlDoc.querySelector(\n      'xsd\\\\:complexType, complexType',\n    );\n\n    if (featureTypeElement) {\n      const allAttributes = Array.from(\n        featureTypeElement.querySelectorAll('xsd\\\\:element, element'),\n      ).map((el) => {\n        const name = el.getAttribute('name');\n        const type = el.getAttribute('type');\n        return {\n          name,\n          type,\n          isNumeric: this.isNumericType(type),\n        };\n      });\n\n      const geometryAttribute = this.determineGeometryAttribute(\n        layer,\n        allAttributes,\n      );\n\n      const attributes = allAttributes.filter(\n        (attr) => attr.name !== geometryAttribute,\n      );\n\n      return {attributes, geometryAttribute};\n    }\n    console.warn('No feature type found in the XML response');\n    return {attributes: [], geometryAttribute: null};\n  }\n\n  /**\n   * Determines if a given type is numeric.\n   * @param type The type string to check.\n   * @returns True if the type is numeric, false otherwise.\n   */\n  private isNumericType(type: string): boolean {\n    const numericTypes = ['decimal', 'double', 'float', 'int'];\n    return numericTypes.some((numericType) =>\n      type.toLowerCase().includes(numericType),\n    );\n  }\n\n  /**\n   * Determines the geometry attribute name based on the layer and attributes.\n   * @param layer The layer object to determine geometry attribute from.\n   * @param attributes The array of feature attributes.\n   * @returns The geometry attribute name or null if not found.\n   */\n  private determineGeometryAttribute(\n    layer: VectorLayer<VectorSource>,\n    attributes: WfsFeatureAttribute[],\n  ): string | null {\n    // Try to get geometry attribute name from layers' source\n    const source = layer.getSource();\n    const feature = source.getFeatures()[0];\n    if (feature) {\n      const geometryName = feature.getGeometryName();\n      if (\n        geometryName &&\n        attributes.some((attr) => attr.name === geometryName)\n      ) {\n        return geometryName;\n      }\n    }\n\n    // Look for geometry attribute in WFS response\n    const geometryAttr = attributes.find((attr) =>\n      this.isGeometryType(attr.type),\n    );\n    return geometryAttr ? geometryAttr.name : null;\n  }\n\n  /**\n   * Determines if a given type is a geometry type.\n   * @param type The type string to check.\n   * @returns True if the type is a geometry type, false otherwise.\n   */\n  private isGeometryType(type: string): boolean {\n    const geometryKeywords = [\n      'geometry',\n      'point',\n      'line',\n      'polygon',\n      'surface',\n      'curve',\n    ];\n    return geometryKeywords.some((keyword) =>\n      type.toLowerCase().includes(keyword),\n    );\n  }\n\n  /**\n   * Checks if a value is considered empty\n   */\n  private isEmptyValue(value: any): boolean {\n    return (\n      value === '<value>' ||\n      value === null ||\n      value === undefined ||\n      value === ''\n    );\n  }\n\n  /**\n   * Recursively checks if all filter values are filled\n   */\n  private areAllFilterValuesFilled(filter: any[]): boolean {\n    if (!Array.isArray(filter)) {\n      return !this.isEmptyValue(filter);\n    }\n\n    const [operator, ...operands] = filter;\n\n    // Check if it's a comparison operator\n    if (!Array.isArray(operands[0])) {\n      return !this.isEmptyValue(operands[1]);\n    }\n\n    // For logical operators, check all operands\n    return operands.every((operand) => this.areAllFilterValuesFilled(operand));\n  }\n\n  /**\n   * Applies the current filter to the selected layer and refreshes the source\n   */\n  applyFilters() {\n    const selectedLayer = this.selectedLayer();\n    if (selectedLayer) {\n      const currentFilter = this.rule().filter;\n\n      if (!this.areAllFilterValuesFilled(currentFilter)) {\n        this.hsToastService.createToastPopupMessage(\n          'PANEL_HEADER.WFS_FILTER',\n          'WFS_FILTER.INCOMPLETE_FILTER',\n          {\n            type: 'warning',\n          },\n        );\n        return;\n      }\n      const parsedFilter = this.parseFilter(currentFilter);\n      this.updateLayer(selectedLayer, parsedFilter, this.rule());\n    }\n  }\n\n  /**\n   * Updates the layer with the parsed filter\n   */\n  updateLayer(\n    selectedLayer: HsLayerDescriptor,\n    parsedFilter: any,\n    wfsFilter: any[],\n  ) {\n    selectedLayer.layer.set('wfsFilter', wfsFilter);\n    const source = selectedLayer.layer.getSource();\n    source.set('filter', parsedFilter);\n    source.refresh();\n    /**\n     * Manually pull features from WFS if layer is from Layman\n     */\n    if (getWorkspace(selectedLayer.layer)) {\n      this.hsEventBusService.refreshLaymanLayer.next(\n        selectedLayer.layer as VectorLayer<VectorSource>,\n      );\n    }\n  }\n\n  /**\n   * Parses the filter into OpenLayers format\n   * @param filter The filter to parse\n   * @returns Parsed OpenLayers filter\n   */\n  parseFilter(filter: any[]): any {\n    if (!Array.isArray(filter)) {\n      return null;\n    }\n\n    const [operator, ...operands] = filter;\n\n    switch (operator) {\n      case '||':\n        return olFormatFilter.or(...operands.map((op) => this.parseFilter(op)));\n      case '&&':\n        return olFormatFilter.and(\n          ...operands.map((op) => this.parseFilter(op)),\n        );\n      case '!':\n        return olFormatFilter.not(this.parseFilter(operands[0]));\n      case '==':\n        return olFormatFilter.equalTo(operands[0], operands[1]);\n      case '*=':\n        return olFormatFilter.like(operands[0], `*${operands[1]}*`);\n      case '!=':\n        return olFormatFilter.notEqualTo(operands[0], operands[1]);\n      case '<':\n        return olFormatFilter.lessThan(operands[0], operands[1]);\n      case '<=':\n        return olFormatFilter.lessThanOrEqualTo(operands[0], operands[1]);\n      case '>':\n        return olFormatFilter.greaterThan(operands[0], operands[1]);\n      case '>=':\n        return olFormatFilter.greaterThanOrEqualTo(operands[0], operands[1]);\n      default:\n        console.warn(`Unsupported operator: ${operator}`);\n        return null;\n    }\n  }\n\n  /**\n   * Opens the Add Data panel\n   */\n  openAddDataPanel() {\n    this.hsLayoutService.setMainPanel('addData');\n  }\n}\n","@if (isVisible$ | async) {\n<div class=\"card hs-main-panel hs-wfs-filter-panel\" [ngClass]=\"panelWidthClass\">\n  <hs-panel-header name=\"wfsFilter\" [panelTabs]=\"'WFS_FILTER'\" class=\"mb-3\">\n  </hs-panel-header>\n  <!-- Check if there are available WFS layers -->\n  @if (availableLayers()?.length > 0) {\n  <!-- Layer selection dropdown with floating label -->\n  <div class=\"m-3 form-floating\">\n    <select id=\"layerSelect\" class=\"form-select\" [ngModel]=\"selectedLayer()\" (ngModelChange)=\"selectLayer($event)\">\n      <option [ngValue]=\"null\">{{ 'WFS_FILTER.noLayerSelected' | translate }}</option>\n      @for (layer of availableLayers(); track layer) {\n      <option [ngValue]=\"layer\">\n        {{ layer.title }}\n      </option>\n      }\n    </select>\n    <label class=\"ms-2\" for=\"layerSelect\">{{ 'WFS_FILTER.layerToFilter' | translate }}</label>\n    @if(!selectedLayer()){\n    <p style=\"text-align: end;\" class=\"m-0 p-1 small text-secondary\">{{ 'WFS_FILTER.selectLayerToStart' | translate }}</p>\n    }\n  </div>\n\n  <!-- Display filter options if a layer is selected -->\n  @if (selectedLayer() ) {\n    @if(loadingLayerInfo()){\n    <div class=\"d-flex justify-content-center p-3\">\n      <span class=\"hs-loader hs-loader-dark \" style=\"width: 2rem; height: 2rem;\"></span>\n    </div>\n    }\n    @else {\n      <div class=\"card border-0\">\n        <div class=\"card-body d-flex flex-column\">\n          <!-- Filter component -->\n          <hs-filters [rule]=\"rule()\" [selectedLayer]=\"selectedLayer()\"></hs-filters>\n          <!-- Apply Filters button -->\n          @if(rule()?.filter){\n          <button class=\"btn btn-primary mt-3 align-self-end\" (click)=\"applyFilters()\">\n            {{ 'WFS_FILTER.applyFilters' | translate }}\n          </button>\n          }\n        </div>\n      </div>\n    }\n  }\n  } @else {\n  <!-- Display when no WFS layers are available -->\n  <div class=\"d-flex flex-column gap-2 gap-4 justify-content-center mt-5 px-3 py-4\">\n    <div class=\"d-flex justify-content-center\">\n      <div class=\"w-75\">\n        <h4>{{ 'WFS_FILTER.noWfsLayersAvailable' | translate }}</h4>\n        <p>{{ 'WFS_FILTER.addWfsLayerFirst' | translate }}</p>\n      </div>\n      <i class=\"fa-solid fa-layer-group mb-3 text-muted\" style=\"font-size: 48px\"></i>\n    </div>\n    <!-- Button to open the Add Data panel -->\n    <button class=\"btn btn-primary w-50 m-auto\" (click)=\"openAddDataPanel()\">\n      {{ 'WFS_FILTER.addWfsLayer' | translate }}\n    </button>\n  </div>\n  }\n</div>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["VectorLayer","VectorSource"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4DM,MAAO,oBAAqB,SAAQ,oBAAoB,CAAA;AAmB5D,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;QAnBT,IAAA,CAAA,IAAI,GAAG,WAAW;AAElB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAA2B,IAAI,yDAAC;QACtD,IAAA,CAAA,IAAI,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,gDAAC;AAEzE,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC3C,QAAA,IAAA,CAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC7C,QAAA,IAAA,CAAA,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACrD,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AACvC,QAAA,IAAA,CAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AACzC,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,QAAA,IAAA,CAAA,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;AACvD,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAIvC,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,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