Skip to content

Comments

[ISSUE #28] Prevent merging of CQL filter for multiple layers#29

Closed
afabiani wants to merge 1 commit intomapfish:mainfrom
afabiani:ISSUE_28
Closed

[ISSUE #28] Prevent merging of CQL filter for multiple layers#29
afabiani wants to merge 1 commit intomapfish:mainfrom
afabiani:ISSUE_28

Conversation

@afabiani
Copy link
Collaborator

@afabiani afabiani commented Feb 3, 2025

When trying to issue the same CQL_FILTER parameter to more layers, it the filter has same values it will get merged by the library thus causing an error on the GetMap response.

Image

Sample Requests

FAILING (Same "CQL_FILTER":"(\"CFCC\"='D31')")

curl 'https://mapstore.geosolutionsgroup.com/mapstore/pdf/create.json' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: en,en-US;q=0.9,it;q=0.8' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: _ga=GA1.2.1103152313.1703075700; _hp2_props.2826793817=%7B%22account_state%22%3A%22active%22%2C%22account_plan%22%3A%22Enterprise%2021%22%2C%22billing_cycle%22%3A1%7D; userty.core.p.f3de1b=__2VySWQiOiI2MGI0NzRlMDY0MmFhMmNlMjA1MjNlMWExNjU2Y2E2NCJ9eyJ1c; userty.core.s.f3de1b=__WQiOiI2MmNkYTVjMzUyMmM3YTgyMWY2YjYyNDg2MTMzZmNlZiIsInN0IjoxNzIwNTEwMDM3MTk0LCJyZWFkeSI6dHJ1ZSwid3MiOiJ7XCJ3XCI6MTkyMCxcImhcIjo5NDN9Iiwic2UiOjE3MjA1MTMyODU0NDgsInB2IjoxfQ==eyJza; SL_C_23361dd035530_SID={"1e81b1058a277e08b89ce1a8afae7c273bf43218":{"sessionId":"f7FmOL--tBCWeQ-JFdeNB","visitorId":"-yfOGT2cCwlQvSJbfnz9h"}}; _hp2_id.2826793817=%7B%22userId%22%3A%222363252127558520%22%2C%22pageviewId%22%3A%22319791905379445%22%2C%22sessionId%22%3A%226521940240948917%22%2C%22identity%22%3A%22201003634192%22%2C%22trackerVersion%22%3A%224.0%22%2C%22identityField%22%3Anull%2C%22isIdentified%22%3A1%7D' \
  -H 'Origin: https://mapstore.geosolutionsgroup.com' \
  -H 'Pragma: no-cache' \
  -H 'Referer: https://mapstore.geosolutionsgroup.com/mapstore/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw $'{"units":"m","srs":"EPSG:3857","layout":"A2_no_legend","dpi":96,"outputFilename":"mapstore-print","geodetic":false,"mapTitle":"","comment":"","layers":[{"baseURL":"https://maps1.geosolutionsgroup.com/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["osm:osm"],"format":"image/jpeg","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_roads"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"CFCC\\"=\'D31\')"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_landmarks"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"CFCC\\"=\'D31\')"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_poi"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["tiger:poi2"],"format":"image/png; mode=8bit","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:us_states"],"format":"image/vnd.jpeg-png8","styles":["pophade"],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"SUB_REGION\\"=\'E N Cen\' OR \\"SUB_REGION\\"=\'E S Cen\' OR \\"SUB_REGION\\"=\'Mid Atl\' OR \\"SUB_REGION\\"=\'Mtn\')"}}],"pages":[{"center":[-9487713.46548843,4598022.3360901],"scale":36978669.431820706,"rotation":0}],"legends":[{"name":"OSM Bright","classes":[{"name":"","icons":["https://maps1.geosolutionsgroup.com/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=osm%3Aosm&STYLE=&SCALE=36978669.431820706&width=24&height=24&minSymbolSize=24&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"ny_roads","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_roads&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"poly_landmarks","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_landmarks&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"poi","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_poi&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"Manhattan (NY) points of interest","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=tiger%3Apoi2&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"States of US","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Aus_states&STYLE=pophade&SCALE=36978669.431820706&width=100&height=50&minSymbolSize=50&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]}],"credits":"OSM Bright Rendering GeoSolutions Data © OpenStreetMap contributors, ODbL","projection":"EPSG:3857","outputFormat":"pdf"}'

GOOD (Different "CQL_FILTER":"(\"CFCC\"='D32')" and "CQL_FILTER":"(\"CFCC\"='D31')")

curl 'https://mapstore.geosolutionsgroup.com/mapstore/pdf/create.json' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: en,en-US;q=0.9,it;q=0.8' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: _ga=GA1.2.1103152313.1703075700; _hp2_props.2826793817=%7B%22account_state%22%3A%22active%22%2C%22account_plan%22%3A%22Enterprise%2021%22%2C%22billing_cycle%22%3A1%7D; userty.core.p.f3de1b=__2VySWQiOiI2MGI0NzRlMDY0MmFhMmNlMjA1MjNlMWExNjU2Y2E2NCJ9eyJ1c; userty.core.s.f3de1b=__WQiOiI2MmNkYTVjMzUyMmM3YTgyMWY2YjYyNDg2MTMzZmNlZiIsInN0IjoxNzIwNTEwMDM3MTk0LCJyZWFkeSI6dHJ1ZSwid3MiOiJ7XCJ3XCI6MTkyMCxcImhcIjo5NDN9Iiwic2UiOjE3MjA1MTMyODU0NDgsInB2IjoxfQ==eyJza; SL_C_23361dd035530_SID={"1e81b1058a277e08b89ce1a8afae7c273bf43218":{"sessionId":"f7FmOL--tBCWeQ-JFdeNB","visitorId":"-yfOGT2cCwlQvSJbfnz9h"}}; _hp2_id.2826793817=%7B%22userId%22%3A%222363252127558520%22%2C%22pageviewId%22%3A%22319791905379445%22%2C%22sessionId%22%3A%226521940240948917%22%2C%22identity%22%3A%22201003634192%22%2C%22trackerVersion%22%3A%224.0%22%2C%22identityField%22%3Anull%2C%22isIdentified%22%3A1%7D' \
  -H 'Origin: https://mapstore.geosolutionsgroup.com' \
  -H 'Pragma: no-cache' \
  -H 'Referer: https://mapstore.geosolutionsgroup.com/mapstore/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw $'{"units":"m","srs":"EPSG:3857","layout":"A2_no_legend","dpi":96,"outputFilename":"mapstore-print","geodetic":false,"mapTitle":"","comment":"","layers":[{"baseURL":"https://maps1.geosolutionsgroup.com/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["osm:osm"],"format":"image/jpeg","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_roads"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"CFCC\\"=\'D32\')"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_landmarks"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"CFCC\\"=\'D31\')"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:ny_poi"],"format":"image/png8","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["tiger:poi2"],"format":"image/png; mode=8bit","styles":[""],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en"}},{"baseURL":"https://gs-stable.geo-solutions.it/geoserver/wms?","opacity":1,"singleTile":false,"type":"WMS","layers":["gs:us_states"],"format":"image/vnd.jpeg-png8","styles":["pophade"],"customParams":{"TRANSPARENT":true,"TILED":true,"EXCEPTIONS":"application/vnd.ogc.se_inimage","scaleMethod":"accurate","ENV":"mapstore_language:en","CQL_FILTER":"(\\"SUB_REGION\\"=\'E N Cen\' OR \\"SUB_REGION\\"=\'E S Cen\' OR \\"SUB_REGION\\"=\'Mid Atl\' OR \\"SUB_REGION\\"=\'Mtn\')"}}],"pages":[{"center":[-9487713.46548843,4598022.3360901],"scale":36978669.431820706,"rotation":0}],"legends":[{"name":"OSM Bright","classes":[{"name":"","icons":["https://maps1.geosolutionsgroup.com/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=osm%3Aosm&STYLE=&SCALE=36978669.431820706&width=24&height=24&minSymbolSize=24&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"ny_roads","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_roads&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"poly_landmarks","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_landmarks&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"poi","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Any_poi&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"Manhattan (NY) points of interest","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=tiger%3Apoi2&STYLE=&SCALE=36978669.431820706&width=12&height=12&minSymbolSize=12&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]},{"name":"States of US","classes":[{"name":"","icons":["https://gs-stable.geo-solutions.it/geoserver/wms?TRANSPARENT=true&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=gs%3Aus_states&STYLE=pophade&SCALE=36978669.431820706&width=100&height=50&minSymbolSize=50&LEGEND_OPTIONS=forceLabels%3A%3BfontAntialiasing%3Atrue%3Bdpi%3A96%3BfontStyle%3A%3BfontName%3AVerdana%3BfontSize%3A8&format=image%2Fpng"]}]}],"credits":"OSM Bright Rendering GeoSolutions Data © OpenStreetMap contributors, ODbL","projection":"EPSG:3857","outputFormat":"pdf"}'

@tdipisa
Copy link
Collaborator

tdipisa commented Feb 19, 2025

@afabiani it would be good to provide a good description for this PR to inform about the purpose of this contribution and to help with the review. Can you provide that, please?

After this, is it possible to have someone for a review? @aaime? @jodygarnett?

}

private HTTPMapReader createMapReader(PJsonObject layer) {
private HTTPMapReader createMapReader(PJsonObject layer, RenderingContext context) {
Copy link

Choose a reason for hiding this comment

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

The context does not seem to be used, why was it added?

hosts.add(HostMatcher.ACCEPT_ALL);
config.setHosts(hosts);
PJsonObject globalParams = createGlobalParams();
PJsonObject emptyParams = new PJsonObject(new JSONObject(), "globalParams");;
Copy link

Choose a reason for hiding this comment

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

Why do you need empty params, I thought the code was null safe here.

@afabiani
Copy link
Collaborator Author

Closing this one since the use case is covered already by the global settings mergeableParams available from version 2.3-SNAPSHOT, even thou the online documentation is outdated:

@afabiani afabiani closed this Feb 25, 2025
@afabiani afabiani deleted the ISSUE_28 branch February 25, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants