Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/ol-ext: fix validation GeoJSON GeometryCollection geometry coordinates type #518

Conversation

tmszi
Copy link
Contributor

@tmszi tmszi commented Sep 17, 2022

Describe the bug
The <vl-interaction-select> component incorrectly validate feature property if it is GeoJSON GeometryCollection geometry type.

validator: value => value.every(or(isString, isNumber, isGeoJSONFeature)),

To Reproduce
Steps to reproduce the behavior:

  1. Use <vl-source-vector> component which load GeoJSON GeometryCollection geometry type data and <vl-interaction-select> component.

Example:

   <!-- POI vector layer -->
    <vl-layer-vector :id="poiLayerId">
      <vl-source-vector
        :wrap-x="true"
        :loader-factory="poiFeaturesLoader"
        :strategy-factory="loadingStrategyFactory"
        :attributions="attributions"
        :ref="poiLayerId"
      >
        <vl-style-func :factory="poiFeatureStyleFuncFactory" />
      </vl-source-vector>
    </vl-layer-vector>

    <vl-interaction-select
      :features.sync="selectedFeatures"
      ref="selectPoiFeature"
      :hitTolerance="hitTolerance"
      :filter="filterPOILayer"
    >
      <vl-style-func
        :factory="selectedPoiFeatureStyleFuncFactory"
      ></vl-style-func>
    </vl-interaction-select>
  1. Click on the feature on the map.
  2. See error inside web browser console

Error:

19:47:00.398 [Vue warn]: Invalid prop: custom validator check failed for prop "features".

found in

---> <VlInteractionSelect>
       <PoiVector>
         <VlMap>
           <Map> at src/components/Map.vue
             <QPage>
               <PageIndex> at src/pages/Index.vue
                 <QPageContainer>
                   <QLayout>
                     <MainLayout> at src/layouts/MainLayout.vue
                       <App> at src/App.vue
                         <Root> vue.runtime.esm.js:619
    VueJS 23
    changed mixins.js:759
    flush index.js:54
    debounced index.js:38
    3 mixins.js:3877
    RxJS 35
    dispatchEvent Target.js:118
    insertAt Collection.js:202
    push Collection.js:224
    extend Collection.js:144
    handleEvent Select.js:475
    handleMapBrowserEvent PluggableMap.js:987
    dispatchEvent Target.js:118
    clickTimeoutId_ MapBrowserEventHandler.js:130

Expected behavior
<vl-interaction-select> component should be properly validate feature property if it is GeoJSON GeometryCollection geometry type.

Additional context:
For validation GeoJSON GeometryCollection geometry coordinates type is correct path feature.geometry.geometries[0].coordinates

isArray(geometry.coordinates)

Example of a GeometryCollection:

{ "type": "GeometryCollection",
"geometries": [
  { "type": "Point",
    "coordinates": [100.0, 0.0]
    },
  { "type": "LineString",
    "coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
    }
 ]
}

…nates type

Access GeometryCollection geometry coordinates:

`feature.geometry.geometries[0].coordinates`
Copy link
Owner

@ghettovoice ghettovoice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks 👍

@ghettovoice ghettovoice merged commit 7bb0cec into ghettovoice:master Sep 29, 2022
ghettovoice added a commit that referenced this pull request Oct 9, 2022
- fix #315
- merge #518
- update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants