qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

Bug in zoomToSelection in Attribute Table #516

Closed rsrg-zwiama closed 5 months ago

rsrg-zwiama commented 5 months ago

The zoomTo button in the attribute table is not working for features with 3 dimensions (z-geometry), since the zoomToExtent function expects a bounding box with 4 entries and the geojsonBbox function returns 6. Possible fix for this would be to add a test for the bounding box length --> if (bbox.length === 6) https://github.com/qgis/qwc2/blob/23781e1d8f37547e8746d8daad1ad5abeabdba77/plugins/AttributeTable.jsx#L574C19-L574C19

    zoomToSelection = () => {
        const collection = {
            type: "FeatureCollection",
            features: this.state.filteredSortedFeatures.filter(feature => this.state.selectedFeatures[feature.id] === true && feature.geometry)
        };
        if (!isEmpty(collection.features)) {
            if (collection.features.length === 1 && collection.features[0].geometry.type === "Point") {
                const zoom = MapUtils.computeZoom(this.props.mapScales, this.props.zoomLevel);
                this.props.zoomToPoint(collection.features[0].geometry.coordinates, zoom, this.props.mapCrs);
            } else  {
                let bbox = geojsonBbox(collection);
                if (bbox.length === 6) {
                    bbox = [bbox[0], bbox[1], bbox[3], bbox[4]];
                }
                this.props.zoomToExtent(bbox, this.props.mapCrs);
            }
        }
    };
manisandro commented 5 months ago

Thanks, fixed in https://github.com/qgis/qwc2/commit/2a73be0b99b630f731a7ffeec40456c6f1fb41ec

rsrg-zwiama commented 5 months ago

thank you!