]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Format/WFS.html
add some margin around image
[syp.git] / openlayers / tests / Format / WFS.html
1 <html>
2 <head>
3   <script src="../../lib/OpenLayers.js"></script>
4   <script>  
5     function test_wfs_update_node(t) {
6         t.plan(2);
7         var expected = readXML("Update");
8         var updateFeature = new OpenLayers.Feature.Vector(
9             new OpenLayers.Geometry.Point(1,2),
10             {foo: "bar"});
11         updateFeature.fid = "fid.42";
12         updateFeature.state = OpenLayers.State.UPDATE;
13         var format = new OpenLayers.Format.WFS({
14             'featureNS':'http://www.openplans.org/topp',
15             'featureName': 'states',
16             'geometryName': 'the_geom',
17             'featurePrefix': 'topp'
18         }, {options:{}});
19         var updateNode = format.update(updateFeature);
20         t.xml_eq(updateNode, expected, "update node matches expected XML value.");
21         var format = new OpenLayers.Format.WFS({
22             'featurePrefix': 'topp'
23         }, {options:{typename: 'states', 'featureNS': 'http://www.openplans.org/topp', 'geometry_column': 'the_geom' }});
24         var updateNode = format.update(updateFeature);
25         t.xml_eq(updateNode, expected, "update node matches expected XML value.");
26     }
27     function test_wfs_delete_node(t) {
28         t.plan(2);
29         var expected = readXML("Delete");
30         var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0,0));
31         feature.state = OpenLayers.State.DELETE;
32         feature.fid = "fid.37";
33         var format = new OpenLayers.Format.WFS({
34             'featureNS':'http://www.openplans.org/topp',
35             'featureName': 'states',
36             'featurePrefix': 'topp'
37         }, {options:{}});
38         var deleteNode = format.remove(feature);
39         t.xml_eq(deleteNode, expected, "delete node matches expected XML value.");
40         var format = new OpenLayers.Format.WFS({
41             'featurePrefix': 'topp'
42         }, {options:{typename: 'states', 'featureNS': 'http://www.openplans.org/topp'}});
43         var deleteNode = format.remove(feature);
44         t.xml_eq(deleteNode, expected, "delete node matches expected XML value.");
45     }
46     function readXML(id) {
47         var xml = document.getElementById(id).firstChild.nodeValue;
48         return new OpenLayers.Format.XML().read(xml).documentElement;        
49     }
50
51   </script>
52 </head>
53 <body>
54 <div id="Update"><!--
55 <wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
56     <wfs:Property>
57         <wfs:Name>the_geom</wfs:Name>
58         <wfs:Value>
59             <gml:Point xmlns:gml="http://www.opengis.net/gml">
60                 <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
61             </gml:Point>
62         </wfs:Value>
63     </wfs:Property>
64     <wfs:Property>
65         <wfs:Name>foo</wfs:Name>
66         <wfs:Value>bar</wfs:Value>
67     </wfs:Property>
68     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
69         <ogc:FeatureId fid="fid.42"/>
70     </ogc:Filter>
71 </wfs:Update>
72 --></div>
73 <div id="Delete"><!--
74 <wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
75     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
76         <ogc:FeatureId fid="fid.37"/>
77     </ogc:Filter>
78 </wfs:Delete>
79 --></div>
80 </body>
81 </html>