3 <script src="../../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_read(t) {
9 var data = readXML("FeatureCollection");
10 var format = new OpenLayers.Format.WFST({
11 featureNS: "http://www.openplans.org/topp",
14 var features = format.read(data);
16 t.eq(features.length, 1, "number of features read from FeatureCollection is correct");
19 function test_write(t) {
21 var format = new OpenLayers.Format.WFST({
22 featureNS: "http://www.openplans.org/topp",
23 featureType: "states",
24 featurePrefix: "topp",
25 geometryName: "the_geom"
28 var feature = new OpenLayers.Feature.Vector(
29 new OpenLayers.Geometry.Point(1,2),
32 var insertFeature = feature.clone();
33 insertFeature.state = OpenLayers.State.INSERT;
34 var updateFeature = feature.clone();
35 updateFeature.fid = "fid.42";
36 updateFeature.state = OpenLayers.State.UPDATE;
37 var deleteFeature = feature.clone();
38 deleteFeature.state = OpenLayers.State.DELETE;
39 deleteFeature.fid = "fid.37";
43 "GetFeature": {maxFeatures: 1},
45 "Insert": insertFeature,
46 "Update": updateFeature,
47 "Delete": deleteFeature
51 for(var snippet in snippets) {
52 arg = snippets[snippet]
53 var expected = readXML(snippet);
54 var got = format.writers["wfs"][snippet].apply(format, [arg]);
55 t.xml_eq(got, expected, snippet + " request created correctly");
59 function readXML(id) {
60 var xml = document.getElementById(id).firstChild.nodeValue;
61 return new OpenLayers.Format.XML().read(xml).documentElement;
67 <div id="map" style="width:512px; height:256px"> </div>
69 <div id="FeatureCollection"><!--
70 <wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:gml="http://www.opengis.net/gml">
72 <topp:states fid="states.3">
74 <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
79 <gml:coordinates decimal="." cs="," ts=" ">-75.70742,38.557476 -75.71106,38.649551 -75.724937,38.83017 -75.752922,39.141548 -75.761658,39.247753 -75.764664,39.295849 -75.772697,39.383007 -75.791435,39.723755 -75.775269,39.724442 -75.745934,39.774818 -75.695114,39.820347 -75.644341,39.838196 -75.583794,39.840008 -75.470345,39.826435 -75.42083,39.79887 -75.412117,39.789658 -75.428009,39.77813 -75.460754,39.763248 -75.475128,39.741718 -75.476334,39.719971 -75.489639,39.714745 -75.610725,39.612793 -75.562996,39.566723 -75.590187,39.463768 -75.515572,39.36694 -75.402481,39.257637 -75.397728,39.073036 -75.324852,39.012386 -75.307899,38.945911 -75.190941,38.80867 -75.083138,38.799812 -75.045998,38.44949 -75.068298,38.449963 -75.093094,38.450451 -75.350204,38.455208 -75.69915,38.463066 -75.70742,38.557476</gml:coordinates>
81 </gml:outerBoundaryIs>
86 <topp:STATE_NAME>Delaware</topp:STATE_NAME>
87 <topp:STATE_FIPS>10</topp:STATE_FIPS>
88 <topp:SUB_REGION>S Atl</topp:SUB_REGION>
89 <topp:STATE_ABBR>DE</topp:STATE_ABBR>
90 <topp:LAND_KM>5062.456</topp:LAND_KM>
91 <topp:WATER_KM>1385.022</topp:WATER_KM>
92 <topp:PERSONS>666168.0</topp:PERSONS>
93 <topp:FAMILIES>175867.0</topp:FAMILIES>
94 <topp:HOUSHOLD>247497.0</topp:HOUSHOLD>
95 <topp:MALE>322968.0</topp:MALE>
96 <topp:FEMALE>343200.0</topp:FEMALE>
97 <topp:WORKERS>247566.0</topp:WORKERS>
98 <topp:DRVALONE>258087.0</topp:DRVALONE>
99 <topp:CARPOOL>42968.0</topp:CARPOOL>
100 <topp:PUBTRANS>8069.0</topp:PUBTRANS>
101 <topp:EMPLOYED>335147.0</topp:EMPLOYED>
102 <topp:UNEMPLOY>13945.0</topp:UNEMPLOY>
103 <topp:SERVICE>87973.0</topp:SERVICE>
104 <topp:MANUAL>44140.0</topp:MANUAL>
105 <topp:P_MALE>0.485</topp:P_MALE>
106 <topp:P_FEMALE>0.515</topp:P_FEMALE>
107 <topp:SAMP_POP>102776.0</topp:SAMP_POP>
110 </wfs:FeatureCollection>
113 <div id="GetFeature"><!--
114 <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
115 <wfs:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
118 <div id="Transaction"><!--
119 <wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0"/>
121 <div id="Insert"><!--
122 <wfs:Insert xmlns:wfs="http://www.opengis.net/wfs">
123 <feature:states xmlns:feature="http://www.openplans.org/topp">
125 <gml:Point xmlns:gml="http://www.opengis.net/gml">
126 <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
129 <feature:foo>bar</feature:foo>
133 <div id="Update"><!--
134 <wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
136 <wfs:Name>the_geom</wfs:Name>
138 <gml:Point xmlns:gml="http://www.opengis.net/gml">
139 <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
144 <wfs:Name>foo</wfs:Name>
145 <wfs:Value>bar</wfs:Value>
147 <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
148 <ogc:FeatureId fid="fid.42"/>
152 <div id="Delete"><!--
153 <wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
154 <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
155 <ogc:FeatureId fid="fid.37"/>