Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How i can add logical operators AND, OR both togehter in WFS openlayers.

    <script type="text/javascript">
    var map;

    function init() {

        var bounds = new OpenLayers.Bounds(
                2309872.5, 2399960.25,
                2388258.25, 2450114.75
            );
                var options = {
                controls: [
                            new OpenLayers.Control.Navigation(),
                            new OpenLayers.Control.PanZoom()

                ],
                maxExtent: bounds,
                maxResolution: 306.1943359375,
                projection: "EPSG:32644",
                units: 'm'
            };
            map = new OpenLayers.Map('map', options);
            var  map_wms = new OpenLayers.Layer.WMS(
                "cite:union - Tiled", "http://localhost:8080/geoserver/cite/wms",
                {
                    LAYERS: 'cite:union',
                    tiled: true,
                    EPSG:32644,
                    tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
                },
                {
                    buffer: 0,
                    displayOutsideMaxExtent: true,
                    isBaseLayer: true
                } 
            );



        var layerPolygon2 = new OpenLayers.Layer.Vector("Layer Information", {
                                        strategies: [new OpenLayers.Strategy.BBOX()],
                                        visibility: true,
                                        protocol: new OpenLayers.Protocol.WFS({
                                        version: "1.0.0",
                                        srsName: "EPSG:32644", // this is the default
                                        url:  "http://localhost:8080/geoserver/cite/wfs",
                                        featureType:"union",
                                        featureNS: "http://www.opengeospatial.net/cite",
                                        extractAttributes: true,
                                        transparent:true,
                                        geometryName: "the_geom"


                                        })

                filter: new OpenLayers.Filter.Logical({
                type: OpenLayers.Filter.Logical.AND,
                filters: [
                    new OpenLayers.Filter.Logical({
                    type: OpenLayers.Filter.Logical.OR,
                    filters: [
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "classes",
                        value: "A?Pt"
                        }),
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "classes",
                        value: "P"
                        })
                        ]
                    )}
                    new OpenLayers.Filter.Logical({
                    type: OpenLayers.Filter.Logical.OR,
                    filters: [
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "luse_2005",
                        value: "BU"
                        }),
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "luse_2005",
                        value: "CL"
                        })
                        ]
                    )}

                ]

            })


            });



            map.addLayers([map_wms,layerPolygon2]);

            map.zoomToMaxExtent();

}

when i try to run above code in browser nothing is being displayed and firebug showing ReferenceError: init is not defined init() error.

thanks!!

share|improve this question
    
problem solved..we can use both operators AND,OR togehter in WFS openlayers. –  user2227374 Apr 29 '13 at 1:16
1  
This doesn't have much detail. Can you show a code sample, explain any issues you've found (e.g. with WFS server support), and anything else that may help other users. –  BradHards Apr 29 '13 at 11:25

1 Answer 1

BradHards...I have just define a rule outside the vector layer and use this in vector as we do to give style for vector layers.

var rule_fsa = new OpenLayers.Rule({
            filter: new OpenLayers.Filter.Logical({
            type: OpenLayers.Filter.Logical.AND,
            filters: [
                new OpenLayers.Filter.Logical({
                type: OpenLayers.Filter.Logical.OR,
                filters: [
                    new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: "classes",
                    value: "A?Pt"
                    }),
                    new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: "classes",
                    value: "P"
                    })
                    ]
                    }),
                    new OpenLayers.Filter.Logical({
                    type: OpenLayers.Filter.Logical.OR,
                    filters: [
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "luse_2005",
                        value: "BU"
                        }),
                        new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "luse_2005",
                        value: "CL"
                        })
                        ]
                        })

                ]
                }),
                symbolizer: {
                fillColor: "#ff00ff",
                fillOpacity: 0.6,
                strokeWidth: 0,
                }
                });



            style.addRules([rule_fsa]); 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.