<commit_before><script type="text/babel">
  import Vue from 'vue'
  import uuid from 'uuid/v4'
  import Feature from 'ol/feature'
  import { isPlainObject } from 'lodash/fp'
  import mergeDescriptors from '../../utils/multi-merge-descriptors'
  import plainProps from '../../utils/plain-props'
  import cmp from '../ol-virt-cmp'
  import styleTarget from '../style-target'
  import { geoJson } from '../../ol-ext'
  import * as assert from '../../utils/assert'

  const props = {
    id: {
      type: [String, Number],
      default: () => uuid()
    },
    properties: {
      type: Object,
      default: () => Object.create(null)
    }
  }

  const methods = {
    /**
     * Create feature without inner style applying, feature level style
     * will be applied in the layer level style function.
     * @return {ol.Feature}
     * @protected
     */
    createOlObject () {
      /**
       * @type {ol.Feature}
       * @private
       */
      let feature = new Feature(this.properties)
      feature.setId(this.id)

      return feature
    },
    /**
     * @return {void}
     * @protected
     */
    defineAccessors () {
      Object.defineProperties(this, {
        $feature: {
          enumerable: true,
          get: this.getFeature
        },
        $layer: {
          enumerable: true,
          get: () => this.$services && this.$services.layer
        },
        $map: {
          enumerable: true,
          get: () => this.$services && this.$services.map
        },
        $view: {
          enumerable: true,
          get: () => this.$services && this.$services.view
        },
        $geometry: {
          enumerable: true,
          get: this.getGeometry
        }
      })
    },
    /**
     * @returns {ol.Feature|undefined}
     */
    getFeature () {
      return this.$olObject
    },
    /**
     * @return {ol.geom.Geometry|undefined}
     * @throws {AssertionError}
     */
    getGeometry () {
      assert.hasFeature(this)

      return this.$feature.getGeometry()
    },
    /**
     * @param {ol.geom.Geometry|Vue|GeoJSONGeometry|undefined} geom
     * @return {void}
     * @throws {AssertionError}
     */
    setGeometry (geom) {
      assert.hasView(this)
      assert.hasFeature(this)

      if (geom instanceof Vue) {
        geom = geom.$geometry
      } else if (isPlainObject(geom)) {
        geom = geoJson.readGeometry(geom, this.$view.getProjection())
      }
      if (geom !== this.$geometry) {
        this.$feature.setGeometry(geom)
      }
    },
    /**
     * @return {Object}
     * @protected
     */
    getServices () {
      const vm = this

      return mergeDescriptors(this::cmp.methods.getServices(), {
        get feature () { return vm.$feature }
      })
    },
    /**
     * @return {ol.Feature|undefined}
     * @protected
     */
    getStyleTarget () {
      return this.$feature
    },
    /**
     * @param {number} pixel
     * @return {boolean}
     */
    isAtPixel (pixel) {
      assert.hasMap(this)

      return this.$map.forEachFeatureAtPixel(
        pixel,
        f => f === this.$feature,<commit_msg>improve async components: implement internal geometry container for vl-feature<commit_after><script type="text/babel">
  import Vue from 'vue'
  import uuid from 'uuid/v4'
  import Feature from 'ol/feature'
  import { isPlainObject } from 'lodash/fp'
  import mergeDescriptors from '../../utils/multi-merge-descriptors'
  import plainProps from '../../utils/plain-props'
  import cmp from '../ol-virt-cmp'
  import styleTarget from '../style-target'
  import { geoJson } from '../../ol-ext'
  import * as assert from '../../utils/assert'

  const props = {
    id: {
      type: [String, Number],
      default: () => uuid()
    },
    properties: {
      type: Object,
      default: () => Object.create(null)
    }
  }

  const methods = {
    /**
     * Create feature without inner style applying, feature level style
     * will be applied in the layer level style function.
     * @return {ol.Feature}
     * @protected
     */
    createOlObject () {
      /**
       * @type {ol.Feature}
       * @private
       */
      let feature = new Feature(this.properties)
      feature.setId(this.id)
      feature.setGeometry(this._geometry)

      return feature
    },
    /**
     * @return {void}
     * @protected
     */
    defineAccessors () {
      Object.defineProperties(this, {
        $feature: {
          enumerable: true,
          get: this.getFeature
        },
        $layer: {
          enumerable: true,
          get: () => this.$services && this.$services.layer
        },
        $map: {
          enumerable: true,
          get: () => this.$services && this.$services.map
        },
        $view: {
          enumerable: true,
          get: () => this.$services && this.$services.view
        },
        $geometry: {
          enumerable: true,
          get: this.getGeometry
        }
      })
    },
    /**
     * @returns {ol.Feature|undefined}
     */
    getFeature () {
      return this.$olObject
    },
    /**
     * @return {ol.geom.Geometry|undefined}
     */
    getGeometry () {
      return this._geometry
    },
    /**
     * @param {ol.geom.Geometry|Vue|GeoJSONGeometry|undefined} geom
     * @return {void}
     * @throws {AssertionError}
     */
    setGeometry (geom) {
      assert.hasView(this)

      if (geom instanceof Vue) {
        geom = geom.$geometry
      } else if (isPlainObject(geom)) {
        geom = geoJson.readGeometry(geom, this.$view.getProjection())
      }
      if (geom !== this._geometry) {
        /**
         * @type {ol.geom.Geometry|undefined}
         * @private
         */
        this._geometry = geom
      }
      if (this.$feature && geom !== this.$feature.getGeometry()) {
        this.$feature.setGeometry(geom)
      }
    },
    /**
     * @return {Object}
     * @protected
     */
    getServices () {
      const vm = this

      return mergeDescriptors(this::cmp.methods.getServices(), {
        get feature () { return vm.$feature }
      })
    },
    /**
     * @return {ol.Feature|undefined}
     * @protected
     */
    getStyleTarget () {
      return this.$feature
    },
    /**
     * @param {number} pixel
     * @return {boolean}
     */
    isAtPixel (pixel) {
      assert.hasMap(this)

      return this.$map.forEachFeatureAtPixel(
        pixel,
        f => f === this.$feature,
{'fraction_non_alphanumeric': 0.14475743348982786, 'fraction_numerical': 0.00031298904538341156, 'mean_word_length': 1.822879858657244, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6700274', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1907, 'n_words': 405}