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

Use circle for selection #3500

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions assets/src/modules/SelectionTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'ol/geom';

import GML3 from 'ol/format/GML3';
import WKT from 'ol/format/WKT';
import GeoJSON from 'ol/format/GeoJSON';

import WFS from '../modules/WFS.js';
Expand Down Expand Up @@ -140,14 +141,23 @@ export default class SelectionTool {
}

for (const featureType of this.allFeatureTypeSelected) {
const gml = new GML3({srsName: mainLizmap.qgisProjectProjection});

// TODO create a geometry collection from the selection draw?
const gmlNode = gml.writeGeometryNode(selectionFeature.getGeometry());

const serializer = new XMLSerializer();
const formatWKT = new WKT();
let featureWKT = '';
// Translate circle coords to WKT
if (selectionFeature.getGeometry().getType() === 'Circle') {
const center = selectionFeature.getGeometry().getCenter()
const radius = selectionFeature.getGeometry().getRadius()
featureWKT = `CIRCULARSTRING(
${center[0] - radius} ${center[1]},
${center[0]} ${center[1] + radius},
${center[0] + radius} ${center[1]},
${center[0]} ${center[1] - radius},
${center[0] - radius} ${center[1]})`;
Comment on lines +150 to +155
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
featureWKT = `CIRCULARSTRING(
${center[0] - radius} ${center[1]},
${center[0]} ${center[1] + radius},
${center[0] + radius} ${center[1]},
${center[0]} ${center[1] - radius},
${center[0] - radius} ${center[1]})`;
featureWKT = `CURVEPOLYGON( CIRCULARSTRING(
${center[0] - radius} ${center[1]},
${center[0]} ${center[1] + radius},
${center[0] + radius} ${center[1]},
${center[0]} ${center[1] - radius},
${center[0] - radius} ${center[1]}) )`;

} else {
featureWKT = formatWKT.writeFeature(selectionFeature);
}

let spatialFilter = this._geomOperator + `($geometry, geom_from_gml('${serializer.serializeToString(gmlNode.firstChild)}'))`;
let spatialFilter = this._geomOperator + `($geometry, geom_from_wkt('${featureWKT}'))`;

const lConfig = mainLizmap.config.layers[featureType];

Expand Down
4 changes: 0 additions & 4 deletions lizmap/www/assets/css/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -2568,10 +2568,6 @@ div.tooltip {
vertical-align: text-bottom;
}

#selectiontool .digitizing-circle{
display: none;
}

lizmap-selection-invert svg {
width: 14px;
height: 14px;
Expand Down
Loading
Loading