geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
515 stars 402 forks source link

Import shape file fails #6015

Open offtherailz opened 4 years ago

offtherailz commented 4 years ago

Description

When try to import a shape file, I've an error of "Ops..."

How to reproduce

Expected Result The shape file is imported

Current Result The import fails, the ops window is shown.

Browser info (use this site: https://www.whatsmybrowser.org/ for non expert users) | Browser Affected | Version | |---|---| |Internet Explorer| | |Edge| | |Chrome| | |Firefox| | |Safari| |

Other useful information

error in console

ypeError: Cannot read property 'push' of undefined
    at rbush._insert (index.js:302)
    at rbush.insert (index.js:121)
    at rbush.load (index.js:89)
    at RBush.load (RBush.js:90)
    at VectorSource.addFeaturesInternal (Vector.js:428)
    at VectorSource.addFeatures (Vector.js:390)
    at Feature.eval [as addFeatures] (Feature.jsx:156)
    at Feature.componentDidMount (Feature.jsx:186)
    at commitLifeCycles (react-dom.development.js:21964)
    at commitLayoutEffects (react-dom.development.js:25288)
    at HTMLUnknownElement.callCallback (react-dom.development.js:362)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:411)
    at invokeGuardedCallback (react-dom.development.js:466)
    at commitRootImpl (react-dom.development.js:25024)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12188) "
    at ErrorBoundary (webpack:///./node_modules/react-error-boundary/dist/commonjs/ErrorBoundary.js?:36:5)
    at div
    at Router (webpack:///./node_modules/react-router/es/Router.js?:33:5)
    at ConnectedRouter (webpack:///./node_modules/connected-react-router/esm/ConnectedRouter.js?:56:7)
    at ConnectedRouterWithContext (webpack:///./node_modules/connected-react-router/esm/ConnectedRouter.js?:154:25)
    at Connect(ConnectedRouterWithContext) (webpack:///./node_modules/react-redux/es/components/connectAdvanced.js?:151:37)
    at IntlProvider (webpack:///./node_modules/react-intl/lib/index.es.js?:802:9)
    at Localized (webpack:///./web/client/components/I18N/Localized.jsx?:52:5)
    at Theme (webpack:///./web/client/components/theme/Theme.jsx?:108:5)
    at SideEffect(Theme) (webpack:///./node_modules/react-side-effect/lib/index.js?:62:9)
    at Connect(SideEffect(Theme)) (webpack:///./node_modules/react-redux/es/components/connectAdvanced.js?:151:37)
    at div
    at StandardRouter (webpack:///./web/client/components/app/StandardRouter.jsx?:88:5)
    at Connect(StandardRouter) (webpack:///./node_modules/react-redux/es/components/connectAdvanced.js?:151:37)
    at DragDropContext(Connect(StandardRouter)) (webpack:///./node_modules/react-dnd/lib/DragDropContext.js?:81:5)
    at Provider (webpack:///./node_modules/react-redux/es/components/Provider.js?:21:24)
    at StandardApp (webpack:///./web/client/components/app/StandardApp.jsx?:132:5)"
overrideMethod @ react_devtools_backend.js:2273
onError @ StandardRouter.jsx:135
componentDidCatch @ ErrorBoundary.js:57
callback @ react-dom.development.js:23150
callCallback @ react-dom.development.js:13862
commitUpdateEffects @ react-dom.development.js:13900
commitUpdateQueue @ react-dom.development.js:13888
commitLifeCycles @ react-dom.development.js:21998
commitLayoutEffects @ react-dom.development.js:25288
callCallback @ react-dom.development.js:362
invokeGuardedCallbackDev @ react-dom.development.js:411
invokeGuardedCallback @ react-dom.development.js:466
commitRootImpl @ react-dom.development.js:25024
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12188
commitRoot @ react-dom.development.js:24865
finishSyncRender @ react-dom.development.js:24251
performSyncWorkOnRoot @ react-dom.development.js:24223
eval @ react-dom.development.js:12238
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12188
flushSyncCallbackQueueImpl @ react-dom.development.js:12233
flushSyncCallbackQueue @ react-dom.development.js:12221
discreteUpdates$1 @ react-dom.development.js:24365
discreteUpdates @ react-dom.development.js:1486
dispatchDiscreteEvent @ react-dom.development.js:5926
tdipisa commented 4 years ago

@offtherailz seems to be happening using this specific SHP, other SHPs I tried are working fine.

vlt1 commented 4 years ago

@tdipisa @offtherailz After rather long investigation the solution seems to be to simply update openlayers to at least version 6.4.0(I've tried 6.3.0, 6.1.0, it still didn't work properly). I've found that there is specifically one problematic feature in the shapefile, that covers antarctica, if we delete it then the rest of the features are displayed correctly. What is interesting I used an online service to convert the shp file and it gave a geojson file that was working fine even with antarctica. (Also I should note that if I import in EPSG:4326 the shapefile is displayed correctly, the problem seems to be only with EPSG:3857, also leaflet doesn't seem to be affected by the problem). Substituting that feature in the geojson that we get from shpjs with the one from geojson I got from the online service solves the problem. There seems to be no significant differences in coordinates (the differences are on the order of 10-14 - 10-15). Very strange. Anyways, updating close to the most recent version of openlayers(the latest is 6.4.3) solves the problem, but it seems to have some changes to it's apis. The changes that I've noticed is that the map no longer zooms out farther then the map(like we can't zoom out so that we get a thin strip in the middle of the screen, the map always occupies the whole window), also zooming with mouse scroll has changed, the amount of the zoom in I get with one scroll became much smaller. I've also had to make a couple of changes to the code to make it compile. Because it seems like a significant change I've decided we should probably first discuss it here.

tdipisa commented 4 years ago

@vlt1 thank you, we haven't in plan an update of OL for this release. I put this issue in blocked status for now waiting for feedback of other devs like @offtherailz

offtherailz commented 4 years ago

Yes, it makes sense, a bug related on rendering coordinates out from current projection definition area.