summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Format/SOSGetFeatureOfInterest.html
blob: c80078f2d1978873049ac3d78c8cf25c0e649ab8 (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
<html>
<head>
    <script src="../OLLoader.js"></script>
    <script type="text/javascript">

    function test_read_SOSGetFeatureOfInterest_single(t) {
        t.plan(6);

        var parser = new OpenLayers.Format.SOSGetFeatureOfInterest();
        var text =
            '<?xml version="1.0" encoding="UTF-8"?>' +
            '<sa:SamplingPoint xmlns:sa="http://www.opengis.net/sampling/1.0" xmlns:gml="http://www.opengis.net/gml" gml:id="urn:ogc:object:feature:OSIRIS-HWS:4fc335bc-06d7-4d5e-a72a-1ac73b9f3b56">' +
            '<gml:name>Roof of the IfGI</gml:name>' +
            '<sa:position>' +
            '<gml:Point>' +
            '<gml:pos srsName="urn:ogc:def:crs:EPSG:4326">52.1524 5.3722</gml:pos>' +
            '</gml:Point>' +
            '</sa:position>' +
            '</sa:SamplingPoint>';

        var res = parser.read(text);
        t.eq(res.length, 1, "One feature parsed from response");
        t.eq(res[0].attributes.id, "urn:ogc:object:feature:OSIRIS-HWS:4fc335bc-06d7-4d5e-a72a-1ac73b9f3b56", "gml:id correctly parsed");
        t.eq(res[0].attributes.name, "Roof of the IfGI", "gml:name correctly parsed");
        t.eq(res[0].geometry instanceof OpenLayers.Geometry.Point, true, "Geometry is a point geometry");
        t.eq(res[0].geometry.x, 5.3722, "Geometry x coordinate correctly parsed");
        t.eq(res[0].geometry.y, 52.1524, "Geometry y coordinate correctly parsed");
    }

    function test_read_SOSGetFeatureOfInterest_multiple(t) {
        t.plan(6);

        var parser = new OpenLayers.Format.SOSGetFeatureOfInterest();
        var text =
            '<?xml version="1.0" encoding="UTF-8"?>' +
            '<gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml" xmlns:sa="http://www.opengis.net/sampling/1.0">' +
            '<gml:featureMember>' +
            '<sa:SamplingPoint gml:id="urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93">' +
            '<gml:name>weather @ roof of the ifgi, MS, Germany</gml:name>' +
            '<sa:position>' +
            '<gml:Point>' +
            '<gml:pos srsName="urn:ogc:def:crs:EPSG:4326">51.9412 7.6103</gml:pos>' +
            '</gml:Point>' +
            '</sa:position>' +
            '</sa:SamplingPoint>' +
            '</gml:featureMember>' +
            '<gml:featureMember>' +
            '<sa:SamplingPoint gml:id="urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111">' +
            '<gml:name>waether @ roof of the FH Kaernten, Villach, Austria</gml:name>' +
            '<sa:position>' +
            '<gml:Point>' +
            '<gml:pos srsName="urn:ogc:def:crs:EPSG:4326">46.611644 13.883498</gml:pos>' +
            '</gml:Point>' +
            '</sa:position>' +
            '</sa:SamplingPoint>' +
            '</gml:featureMember>' +
            '</gml:FeatureCollection>';

        var res = parser.read(text);
        t.eq(res.length, 2, "Two features parsed from response");
        t.eq(res[0].attributes.id, "urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93", "gml:id correctly parsed");
        t.eq(res[1].attributes.name, "waether @ roof of the FH Kaernten, Villach, Austria", "gml:name correctly parsed");
        t.eq(res[1].geometry instanceof OpenLayers.Geometry.Point, true, "Geometry is a point geometry");
        t.eq(res[1].geometry.x, 13.883498, "Geometry x coordinate correctly parsed");
        t.eq(res[1].geometry.y, 46.611644, "Geometry y coordinate correctly parsed");
    }

    function test_write_SOSGetFeatureOfInterest(t) {
        t.plan(1);
        var expect = '<GetFeatureOfInterest xmlns="http://www.opengis.net/sos/1.0" version="1.0.0" service="SOS" xsi:schemaLocation="http://www.opengis.net/sos/1.0 http://schemas.opengis.net/sos/1.0.0/sosAll.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><FeatureOfInterestId>urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93</FeatureOfInterestId><FeatureOfInterestId>urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111</FeatureOfInterestId></GetFeatureOfInterest>';
        var format = new OpenLayers.Format.SOSGetFeatureOfInterest();
        var output = format.writeNode("sos:GetFeatureOfInterest", {fois: ['urn:ogc:object:feature:OSIRIS-HWS:3d3b239f-7696-4864-9d07-15447eae2b93', 'urn:ogc:object:feature:OSIRIS-HWS:efeb807b-bd24-4128-a920-f6729bcdd111']});
        t.xml_eq(output, expect, "Request XML is written out correctly");
    }

    </script>
</head>
<body>
</body>
</html>