qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

editing PointZ geometry types #486

Closed rsrg-zwiama closed 8 months ago

rsrg-zwiama commented 8 months ago

We came over an error that occures, when editing plugin is used with a pointlayer from geometry type PointZ. Editing of the geometry is not possible in the mapViewer. The console log gets following error in EditingSupport.jsx:137:122:

Uncaught TypeError: t.slice is not a function
    e EditingSupport.jsx:137
    Rg EditingSupport.jsx:139
    Rg EditingSupport.jsx:122
    dispatchEvent Target.js:114
    handleUpEvent Modify.js:1138
    handleEvent Pointer.js:137
    handleEvent Modify.js:869
    handleMapBrowserEvent Map.js:1153
    dispatchEvent Target.js:114
    handlePointerUp_ MapBrowserEventHandler.js:208
    i events.js:63
    handlePointerDown_ MapBrowserEventHandler.js:276

For MulitPointZ features everything works fine. I think the error occurs due to different data representation of PointZ and MulitPointZ coordinates in mapViewer. PointZ is an 'simple' array, MulitPointZ is a 'list of array(s)':

MulitpointZ: coordinates: [Array(3)] 0: [2675023.836615818, 1246172.218314369, 0]

MulitPointZ

PointZ: coordinates: [2675057.0838, 1246721.7189, 475.882995605]

PointZ

Furthermore the code part to recognize a non zero z-geometry is not working. In image above the Z-value is 475.88, but the variable doesn't update: geomReadOnly: undefined So editing of the point isn't blocked.

For setting the geometry with Z=0 I tried following code snippet what solved the error message. https://github.com/qgis/qwc2/blame/50f1692ac9ee31064d6b455081d0ec40071c7aa4/plugins/map/EditingSupport.jsx#L137

        if (this.props.editing.geomType.endsWith('Z') && !this.props.editing.geomType.endsWith('PointZ')) {
            feature.geometry.coordinates = feature.geometry.coordinates.map(addZCoordinateIfNeeded);
        }
        if (this.props.editing.geomType.endsWith('PointZ')) {
            feature.geometry.coordinates = [feature.geometry.coordinates[0],feature.geometry.coordinates[1],0];
        }

The issue with editing point geometry with non-zero z-value remains. As far as I understand the handling of z-values was added here: https://github.com/qgis/qwc2/commit/c0947426f5d9d613dfff032ce50072080bf76973 and the different representation of coordinates for PointZ and MultiPointZ affects the nonZeroCoordinate function in the same way.

manisandro commented 8 months ago

Thanks, fixed in https://github.com/qgis/qwc2/commit/51e5cd895fa3a42bc79538f18654f84ffd07c31e and https://github.com/qgis/qwc2/commit/015f2df63b2ebeede322e3120f06c9bb8ddd3f1b

rsrg-zwiama commented 8 months ago

Great, thank you!