3 <script src="../../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
7 function test_Intersects(t) {
12 '<Filter xmlns="http://www.opengis.net/ogc">' +
14 '<PropertyName>Geometry</PropertyName>' +
15 '<gml:Polygon xmlns:gml="http://www.opengis.net/gml">' +
16 '<gml:outerBoundaryIs>' +
18 '<gml:coordinates decimal="." cs="," ts=" ">2488789,289552 2588789,289552 2588789,389552 2488789,389552 2488789,289552</gml:coordinates>' +
20 '</gml:outerBoundaryIs>' +
25 var format = new OpenLayers.Format.Filter.v1_0_0();
26 var filter = new OpenLayers.Filter.Spatial({
27 type: OpenLayers.Filter.Spatial.INTERSECTS,
29 value: OpenLayers.Geometry.fromWKT("POLYGON((2488789 289552, 2588789 289552, 2588789 389552, 2488789 389552, 2488789 289552))")
33 var node = format.write(filter);
34 t.xml_eq(node, str, "filter correctly written");
37 var doc = (new OpenLayers.Format.XML).read(str);
38 var got = format.read(doc.firstChild);
39 t.eq(got.type, filter.type, "read correct type");
40 t.eq(got.property, filter.property, "read correct property");
41 t.geom_eq(got.value, filter.value, "read correct value");
45 function test_Within(t) {
50 '<Filter xmlns="http://www.opengis.net/ogc">' +
52 '<PropertyName>Geometry</PropertyName>' +
53 '<gml:Polygon xmlns:gml="http://www.opengis.net/gml">' +
54 '<gml:outerBoundaryIs>' +
56 '<gml:coordinates decimal="." cs="," ts=" ">2488789,289552 2588789,289552 2588789,389552 2488789,389552 2488789,289552</gml:coordinates>' +
58 '</gml:outerBoundaryIs>' +
63 var format = new OpenLayers.Format.Filter.v1_0_0();
64 var filter = new OpenLayers.Filter.Spatial({
65 type: OpenLayers.Filter.Spatial.WITHIN,
67 value: OpenLayers.Geometry.fromWKT("POLYGON((2488789 289552, 2588789 289552, 2588789 389552, 2488789 389552, 2488789 289552))")
71 var node = format.write(filter);
72 t.xml_eq(node, str, "filter correctly written");
75 var doc = (new OpenLayers.Format.XML).read(str);
76 var got = format.read(doc.firstChild);
77 t.eq(got.type, filter.type, "read correct type");
78 t.eq(got.property, filter.property, "read correct property");
79 t.geom_eq(got.value, filter.value, "read correct value");
83 function test_Contains(t) {
88 '<Filter xmlns="http://www.opengis.net/ogc">' +
90 '<PropertyName>Geometry</PropertyName>' +
91 '<gml:Polygon xmlns:gml="http://www.opengis.net/gml">' +
92 '<gml:outerBoundaryIs>' +
94 '<gml:coordinates decimal="." cs="," ts=" ">2488789,289552 2588789,289552 2588789,389552 2488789,389552 2488789,289552</gml:coordinates>' +
96 '</gml:outerBoundaryIs>' +
101 var format = new OpenLayers.Format.Filter.v1_0_0();
102 var filter = new OpenLayers.Filter.Spatial({
103 type: OpenLayers.Filter.Spatial.CONTAINS,
104 property: "Geometry",
105 value: OpenLayers.Geometry.fromWKT("POLYGON((2488789 289552, 2588789 289552, 2588789 389552, 2488789 389552, 2488789 289552))")
109 var node = format.write(filter);
110 t.xml_eq(node, str, "filter correctly written");
113 var doc = (new OpenLayers.Format.XML).read(str);
114 var got = format.read(doc.firstChild);
115 t.eq(got.type, filter.type, "read correct type");
116 t.eq(got.property, filter.property, "read correct property");
117 t.geom_eq(got.value, filter.value, "read correct value");