summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/filter.html
blob: 866495f6f008fb504b3982a546f0dd6b982093ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
    <link rel="stylesheet" href="style.css" type="text/css">
    <style>
    #in {
        width: 90%;
        height: 250px;
    }
    #out0, #out1 {
        height: 100px;
        width: 90%;
        overflow: auto;
    }
    </style>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        
        var filter_1_0 = new OpenLayers.Format.Filter({version: "1.0.0"});
        var filter_1_1 = new OpenLayers.Format.Filter({version: "1.1.0"});
        var xml = new OpenLayers.Format.XML();
        
        var filter;
        function write() {
            var code = input.value;
            try {
                eval(code);
            } catch(err) {
                out0.value = err.message;
                out1.value = "";
            }
            try {
                out0.value = xml.write(filter_1_0.write(filter));
            } catch(err) {
                out0.value = err.message;
                if(err.lineNumber != undefined) {
                    out0.value += " (line " + err.lineNumber + " " +
                                        err.fileName + ")";
                }
            }
            try {
                out1.value = xml.write(filter_1_1.write(filter));
            } catch(err) {
                out1.value = err.message;
                if(err.lineNumber != undefined) {
                    out1.value += " (line " + err.lineNumber + " " +
                                        err.fileName + ")";
                }
            }
        }
        
        var input, out0;
        window.onload = function() {
            input = document.getElementById("in");
            out0 = document.getElementById("out0");
            out1 = document.getElementById("out1");
            out0.value = "";
            out1.value = "";
            document.getElementById("write").onclick = write;
        };

    </script>
  </head>
  <body>
    <h1 id="title">Filter Encoding</h1>
    <div id="tags">
        filter, format, comparison, filter encoding, fe, logical, attribute,
        attributive, spatial, advanced
    </div>
    <p id="shortdesc">
        Using the filter format write out filter objects.
    </p>
    <textarea id="in">
filter = new OpenLayers.Filter.Logical({
    type: OpenLayers.Filter.Logical.AND,
    filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.LIKE,
            property: "person",
            value: "me"
        }),
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
            property: "mean",
            value: "yes"
        }),
        new OpenLayers.Filter.Spatial({
            type: OpenLayers.Filter.Spatial.BBOX,
            value: new OpenLayers.Bounds(-180, -90, 180, 90),
            projection: "EPSG:4326"
        })
    ]
});
    </textarea>
    <button id="write">write</button><br>
    Filter Encoding 1.0
    <textarea id="out0"></textarea><br>
    Filter Encoding 1.1
    <textarea id="out1"></textarea><br>
    <p id="docs">
    </p>
  </body>
</html>