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

[Mapfish] Enable CQL Filter by JSON POST #921

Merged
merged 6 commits into from Mar 9, 2015

Conversation

Projects
None yet
2 participants
@jusabatier
Contributor

jusabatier commented Feb 20, 2015

This patch enable to send POST JSON data to mapfihapp with a cql_filter parameter.

Tested with :

{
    "layers": [{
        "layername": "geo_commune",
        "owstype": "WFS",
        "owsurl": "https://opendata.agglo-lepuyenvelay.fr/geoserver/cadastre/wfs",
        "cql_filter": "idu = 157"
    }, {
        "layername": "lepuy:secteurs_elus",
        "owstype": "WMS",
        "owsurl": "https://opendata.agglo-lepuyenvelay.fr/geoserver/wms",
        "cql_filter": "numsecteur = 8"
    }]
}

When I tested it, I can't load WMS and WFS servers simultaneously, so I added a condition over the layer Type in updateStoreFromWxSLayer().

This allow the javascipt to not crash. There still a lot of bugs with WFS protocol, but not related to this patch...

@@ -313,11 +313,23 @@ GEOR.mapinit = (function() {
var records = [], record;
var errors = [], count = 0;
Ext.each(initState, function(item) {
if (item.type == "WMSLayer" || item.type == "WFSLayer") {
if ( (item.type == "WMSLayer" || item.type == "WFSLayer") && item.type == type+'Layer' ) {

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

I don't understand why you had to change this

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

I don't understand why you had to change this

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

OK, sorry, I did no see "When I tested it, I can't load WMS and WFS servers simultaneously, so I added a condition over the layer Type in updateStoreFromWxSLayer()."

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

OK, sorry, I did no see "When I tested it, I can't load WMS and WFS servers simultaneously, so I added a condition over the layer Type in updateStoreFromWxSLayer()."

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

Looks good then

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

Looks good then

Show outdated Hide outdated mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js
record = stores[item.url].queryBy(function(r) {
return (r.get('name') == item.name);
}).first();
if (record) {
// handle cql_filter param in JSON POST
if( type == "WFS" ) {
if ( !(typeof item.cql_filter === 'undefined') ) {

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

I'd prefer:

if (item.hasOwnProperty("cql_filter")) {
@fvanderbiest

fvanderbiest Mar 6, 2015

Member

I'd prefer:

if (item.hasOwnProperty("cql_filter")) {
Show outdated Hide outdated mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js
if( type == "WFS" ) {
if ( !(typeof item.cql_filter === 'undefined') ) {
var format = new OpenLayers.Format.CQL();
record.data.layer.filter = format.read(item.cql_filter);

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

record.data.layer -> record.getLayer()

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

record.data.layer -> record.getLayer()

@fvanderbiest

This comment has been minimized.

Show comment
Hide comment
@fvanderbiest

fvanderbiest Mar 6, 2015

Member

Thanks for the contribution !

The mapfishapp readme should also be edited to explain the new abilities.

Member

fvanderbiest commented Mar 6, 2015

Thanks for the contribution !

The mapfishapp readme should also be edited to explain the new abilities.

Show outdated Hide outdated mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js
// handle cql_filter param in JSON POST
if( type == "WFS" ) {
if ( item.hasOwnProperty("cql_filter") ) {
var format = new OpenLayers.Format.CQL();

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

you probably miss the build dependency to OpenLayers/Format/CQL.js in the file header too

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

you probably miss the build dependency to OpenLayers/Format/CQL.js in the file header too

Show outdated Hide outdated mapfishapp/src/main/webapp/app/js/GEOR_mapinit.js
if( type == "WFS" ) {
if ( item.hasOwnProperty("cql_filter") ) {
var format = new OpenLayers.Format.CQL();
record.getLayer().filter = format.read(item.cql_filter);

This comment has been minimized.

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

record.getLayer().filter = (new OpenLayers.Format.CQL()).read(item.cql_filter); would be more concise

@fvanderbiest

fvanderbiest Mar 6, 2015

Member

record.getLayer().filter = (new OpenLayers.Format.CQL()).read(item.cql_filter); would be more concise

@fvanderbiest

This comment has been minimized.

Show comment
Hide comment
@fvanderbiest

fvanderbiest Mar 9, 2015

Member

And I forgot to tell you that, since it is a new feature, it should be pushed to master, not stable 14.12.
But since this is a relatively harmless patch, OK for this time ...

Member

fvanderbiest commented Mar 9, 2015

And I forgot to tell you that, since it is a new feature, it should be pushed to master, not stable 14.12.
But since this is a relatively harmless patch, OK for this time ...

fvanderbiest added a commit that referenced this pull request Mar 9, 2015

Merge pull request #921 from jusabatier/patch-2
[mapfishapp] enable CQL Filter by JSON POST

@fvanderbiest fvanderbiest merged commit 2d3cfc8 into georchestra:14.12 Mar 9, 2015

@fvanderbiest fvanderbiest added this to the 15.06 milestone Mar 9, 2015

@fvanderbiest fvanderbiest self-assigned this Mar 9, 2015

@fvanderbiest

This comment has been minimized.

Show comment
Hide comment
@fvanderbiest

fvanderbiest Jul 10, 2015

Member

Question: does the filter persist after the map context is restored (either via permalink or WMC) ?

Member

fvanderbiest commented Jul 10, 2015

Question: does the filter persist after the map context is restored (either via permalink or WMC) ?

@jusabatier

This comment has been minimized.

Show comment
Hide comment
@jusabatier

jusabatier Jul 10, 2015

Contributor

Can't remember what name we have to set for the JSON variable in the POST request.

I'll test it when I get the name to use, and think it could be a good thing to add it in the doc.

Contributor

jusabatier commented Jul 10, 2015

Can't remember what name we have to set for the JSON variable in the POST request.

I'll test it when I get the name to use, and think it could be a good thing to add it in the doc.

@fvanderbiest

This comment has been minimized.

Show comment
Hide comment
@fvanderbiest

fvanderbiest Jul 10, 2015

Member

Can't remember what name we have to set for the JSON variable in the POST request.

data

Member

fvanderbiest commented Jul 10, 2015

Can't remember what name we have to set for the JSON variable in the POST request.

data

@jusabatier

This comment has been minimized.

Show comment
Hide comment
@jusabatier

jusabatier Jul 10, 2015

Contributor

It's appear that for WMS, the modifications don't persist with permalink (so wmc) because it use the filter attribute which is not "standard" of WMS protocol. This need an update and we can reuse the code of my PR for filter which create an altered SLD and load it (like the styler do). Use this method allow to persist the changes for WMS.

Can't test it for WFS because I can't load my layer, maybe du to the problems I metionned in my previous posts in this thread, don't remember. I'll look at that when I'll have some times. I think it could persist with WFS because FILTERS is a standard attribute of WFS protocol.

I'll try to work on those improvment next week.

Contributor

jusabatier commented Jul 10, 2015

It's appear that for WMS, the modifications don't persist with permalink (so wmc) because it use the filter attribute which is not "standard" of WMS protocol. This need an update and we can reuse the code of my PR for filter which create an altered SLD and load it (like the styler do). Use this method allow to persist the changes for WMS.

Can't test it for WFS because I can't load my layer, maybe du to the problems I metionned in my previous posts in this thread, don't remember. I'll look at that when I'll have some times. I think it could persist with WFS because FILTERS is a standard attribute of WFS protocol.

I'll try to work on those improvment next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment