git-svn-id: http://svn.openlayers.org/trunk/openlayers@10269 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
139 lines
5.4 KiB
HTML
139 lines
5.4 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
function test_initialize(t) {
|
|
t.plan(1);
|
|
|
|
var format = new OpenLayers.Format.WFST.v1_1_0({});
|
|
t.ok(format instanceof OpenLayers.Format.WFST.v1_1_0, "constructor returns instance");
|
|
}
|
|
|
|
function test_read(t) {
|
|
t.plan(2);
|
|
|
|
var data = readXML("TransactionResponse");
|
|
var format = new OpenLayers.Format.WFST.v1_1_0({
|
|
featureNS: "http://www.openplans.org/topp",
|
|
featureType: "states"
|
|
});
|
|
var result = format.read(data);
|
|
t.eq(result.insertIds[0], "none", "InsertIds read correctly");
|
|
t.eq(result.success, true, "Success read correctly");
|
|
}
|
|
|
|
function test_read_hits(t) {
|
|
t.plan(1);
|
|
var data = readXML("NumberOfFeatures");
|
|
var format = new OpenLayers.Format.WFST.v1_1_0({
|
|
featureNS: "http://mapserver.gis.umn.edu/mapserver",
|
|
featureType: "AAA64"
|
|
});
|
|
var result = format.read(data, {output: "object"});
|
|
t.eq(result.numberOfFeatures, 625, "numberOfFeatures of FeatureCollection correctly read");
|
|
}
|
|
|
|
function test_write(t) {
|
|
|
|
var format = new OpenLayers.Format.WFST.v1_1_0({
|
|
featureNS: "http://www.openplans.org/topp",
|
|
featureType: "states",
|
|
featurePrefix: "topp",
|
|
geometryName: "the_geom"
|
|
});
|
|
|
|
var cases = [{
|
|
id: "query0",
|
|
writer: "wfs:Query",
|
|
arg: {
|
|
filter: new OpenLayers.Filter.Spatial({
|
|
type: OpenLayers.Filter.Spatial.BBOX,
|
|
value: new OpenLayers.Bounds (1,2,3,4)
|
|
})
|
|
}
|
|
}, {
|
|
id: "getfeature0",
|
|
writer: "wfs:GetFeature",
|
|
arg: {
|
|
resultType: "hits",
|
|
propertyNames: ["STATE_NAME", "STATE_FIPS", "STATE_ABBR"]
|
|
}
|
|
}];
|
|
|
|
t.plan(cases.length);
|
|
|
|
var test, got, exp;
|
|
for(var i=0; i<cases.length; ++i) {
|
|
test = cases[i];
|
|
exp = readXML(test.id);
|
|
got = format.writeNode(test.writer, test.arg);
|
|
t.xml_eq(got, exp, test.id + ": correct request");
|
|
}
|
|
}
|
|
|
|
var xmlFormat = new OpenLayers.Format.XML();
|
|
function readXML(id) {
|
|
var xml = document.getElementById(id).firstChild.nodeValue;
|
|
return xmlFormat.read(xml).documentElement;
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width:512px; height:256px"> </div>
|
|
<div id="NumberOfFeatures"><!--
|
|
<?xml version='1.0' encoding="ISO-8859-1" ?>
|
|
<wfs:FeatureCollection
|
|
xmlns:rws="http://mapserver.gis.umn.edu/mapserver"
|
|
xmlns:gml="http://www.opengis.net/gml"
|
|
xmlns:wfs="http://www.opengis.net/wfs"
|
|
xmlns:ogc="http://www.opengis.net/ogc"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://intranet.rijkswaterstaat.nl/services/geoservices/nwb_wegen?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=feature:AAA64&OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" numberOfFeatures="625">
|
|
</wfs:FeatureCollection>
|
|
--></div>
|
|
<div id="TransactionResponse"><!--
|
|
<wfs:TransactionResponse version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:tiger="http://www.census.gov" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:sf="http://www.openplans.org/spearfish" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<wfs:TransactionSummary>
|
|
<wfs:totalInserted>0</wfs:totalInserted>
|
|
<wfs:totalUpdated>1</wfs:totalUpdated>
|
|
<wfs:totalDeleted>0</wfs:totalDeleted>
|
|
</wfs:TransactionSummary>
|
|
<wfs:TransactionResults/>
|
|
<wfs:InsertResults>
|
|
<wfs:Feature>
|
|
<ogc:FeatureId fid="none"/>
|
|
</wfs:Feature>
|
|
</wfs:InsertResults>
|
|
</wfs:TransactionResponse>
|
|
--></div>
|
|
<div id="query0"><!--
|
|
<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
|
|
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
|
<ogc:BBOX>
|
|
<ogc:PropertyName>the_geom</ogc:PropertyName>
|
|
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
|
|
<gml:lowerCorner>1 2</gml:lowerCorner>
|
|
<gml:upperCorner>3 4</gml:upperCorner>
|
|
</gml:Envelope>
|
|
</ogc:BBOX>
|
|
</ogc:Filter>
|
|
</wfs:Query>
|
|
--></div>
|
|
<div id="getfeature0"><!--
|
|
<wfs:GetFeature service="WFS" version="1.1.0" resultType="hits" xmlns:topp="http://www.openplans.org/topp"
|
|
xmlns:wfs="http://www.opengis.net/wfs"
|
|
xmlns:ogc="http://www.opengis.net/ogc"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
|
|
<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
|
|
<wfs:PropertyName>STATE_NAME</wfs:PropertyName>
|
|
<wfs:PropertyName>STATE_FIPS</wfs:PropertyName>
|
|
<wfs:PropertyName>STATE_ABBR</wfs:PropertyName>
|
|
</wfs:Query>
|
|
</wfs:GetFeature>
|
|
--></div>
|
|
</body>
|
|
</html>
|