Skip to content

Commit

Permalink
Reproject query geometries when project layers have a different CRS (…
Browse files Browse the repository at this point in the history
…ref: `"querybbox"`, `"querybypolygon"` and `"querybydrawpolygon"` controls) (#478)

* 🐛 Add check source.external boolen value

* explode conditionals

* explicit `is_coors` variable

* If visible is set to false due a CORS issue, no more control is set visible. Map canvas is dirty

* Add also visibility property of a layer (ex. external wms)

* extract function `isExternalImageLayer(layer)`

* change comment

* change comment

* 3.8.8

* 🐛 Fix issue results on query by bbox and query by polygon map control. Use original geometry if layer projection is the same of map projection. Otherwise, use a reprojected geometry without replace original one

* Change boolean condition

* Use same boolean condition

* inline comment

* comments

---------

Co-authored-by: Raruto <[email protected]>
  • Loading branch information
volterra79 and Raruto authored Aug 29, 2023
1 parent d346ece commit d61feec
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/app/core/utils/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ const geoutils = {
feature_count,
filterConfig,
multilayers,
projection:mapProjection
projection: mapProjection
})
} else {
const d = $.Deferred();
Expand All @@ -1006,12 +1006,14 @@ const geoutils = {
const queryErrors = [];
let layersLenght = layers.length;
layers.forEach(layer => {
const filter = new Filter(filterConfig);
const filter = new Filter(filterConfig);
const layerCrs = layer.getProjection().getCode();
/**
* convert
*/
filter.setGeometry((mapCrs !== layerCrs) ? geometry.clone().transform(mapCrs, layerCrs): geometry);
// Convert filter geometry from `mapCRS` to `layerCrs`
filter.setGeometry(
(mapCrs === layerCrs)
? geometry
: geometry.clone().transform(mapCrs, layerCrs)
);
layer.query({
filter,
feature_count
Expand Down Expand Up @@ -1045,19 +1047,22 @@ const geoutils = {
const mapCrs = projection.getCode();
const filter = new Filter(filterConfig);
if (multilayers) {
let filterGeometry = geometry;
if (!layers.length) d.resolve([]);
const multiLayers = _.groupBy(layers, layer => `${layer.getMultiLayerId()}_${layer.getProjection().getCode()}`);
const numberRequestd = Object.keys(multiLayers).length;
let layersLength = numberRequestd;
for (let key in multiLayers) {
const _multilayer = multiLayers[key];
const layers = _multilayer;
const multilayer = multiLayers[key][0];
const provider = multilayer.getProvider('filter');
const layerCrs = multilayer.getProjection().getCode();
if (mapCrs !== layerCrs) filterGeometry = filterGeometry.clone().transform(mapCrs, layerCrs);
filter.setGeometry(filterGeometry);
const layers = _multilayer;
const multilayer = multiLayers[key][0];
const provider = multilayer.getProvider('filter');
const layerCrs = multilayer.getProjection().getCode();
// Convert filter geometry from `mapCRS` to `layerCrs`
filter.setGeometry(
(mapCrs === layerCrs)
? geometry
: geometry.clone().transform(mapCrs, layerCrs)
);
provider.query({
filter,
layers,
Expand All @@ -1076,7 +1081,12 @@ const geoutils = {
let layersLenght = layers.length;
layers.forEach(layer => {
const layerCrs = layer.getProjection().getCode();
filter.setGeometry((mapCrs !== layerCrs) ? geometry.clone().transform(mapCrs, layerCrs): geometry);
// Convert filter geometry from `mapCRS` to `layerCrs`
filter.setGeometry(
(mapCrs === layerCrs)
? geometry
: geometry.clone().transform(mapCrs, layerCrs)
);
layer.query({
filter,
filterConfig,
Expand Down

0 comments on commit d61feec

Please sign in to comment.