Beispiel #1
0
    def test_gmlobject_string(self):
        """Test the GmlObject type with a GML string.

        Test whether the returned XML is correct.

        """
        with open('tests/data/util/location/polygon_single_31370.gml',
                  'r') as gmlfile:
            gml = gmlfile.read()

            gml_element = etree.fromstring(gml.encode('utf8'))
            gml_element = gml_element.find(
                './/{http://www.opengis.net/gml}Polygon')

            gml_object = GmlObject(etree.tostring(gml_element).decode('utf8'))

            assert clean_xml(
                etree.tostring(gml_object.get_element()).decode('utf8')
            ) == clean_xml(
                '<gml:Polygon '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:exterior><gml'
                ':LinearRing><gml:posList>108636.150020818 194960.844295764 '
                '108911.922161617 194291.111953824 109195.573506438 '
                '195118.42837622 108636.150020818 '
                '194960.844295764</gml:posList></gml:LinearRing></gml'
                ':exterior></gml:Polygon>')
Beispiel #2
0
    def test_wfs_build_getfeature_request_bbox_filter(self):
        """Test the owsutil.wfs_build_getfeature_request method with an
        attribute filter, a box and a geometry_column.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        query = PropertyIsEqualTo(propertyname='gemeente', literal='Herstappe')
        filter_request = FilterRequest()
        filter_request = filter_request.setConstraint(query)
        filter_request = etree.tostring(filter_request, encoding='unicode')

        xml = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen',
            filter=filter_request,
            location=Within(Box(151650, 214675, 151750, 214775)),
            geometry_column='geom')
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <wfs:Query '
            'typeName="dov-pub:Boringen"> <ogc:Filter> <ogc:And> '
            '<ogc:PropertyIsEqualTo> '
            '<ogc:PropertyName>gemeente</ogc:PropertyName> '
            '<ogc:Literal>Herstappe</ogc:Literal> </ogc:PropertyIsEqualTo> '
            '<ogc:Within> <ogc:PropertyName>geom</ogc:PropertyName> '
            '<gml:Envelope xmlns:gml="http://www.opengis.net/gml" '
            'srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"> '
            '<gml:lowerCorner>151650.000000 214675.000000</gml:lowerCorner> '
            '<gml:upperCorner>151750.000000 214775.000000</gml:upperCorner> '
            '</gml:Envelope> </ogc:Within> </ogc:And> </ogc:Filter> '
            '</wfs:Query> </wfs:GetFeature>')
Beispiel #3
0
    def test_multipolygon_single_31370(self):
        """Test the Within filter with a GML containing a single
        multipolygon geometry in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/multipolygon_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        f = GmlFilter(gml, Within)
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Within><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':MultiSurface srsName="urn:ogc:def:crs:EPSG::31370"><gml'
            ':surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml'
            ':posList>108588.874796681 195015.998723923 108911.922161617 '
            '194251.71593371 109195.573506438 195134.186784266 '
            '108588.874796681 195015.998723923</gml:posList></gml:LinearRing'
            '></gml:exterior></gml:Polygon></gml:surfaceMember><gml'
            ':surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml'
            ':posList>109140.419078278 195748.764698045 109400.432811031 '
            '195307.529272768 109597.412911602 195772.402310114 '
            '109140.419078278 195748.764698045</gml:posList></gml:LinearRing'
            '></gml:exterior></gml:Polygon></gml:surfaceMember></gml'
            ':MultiSurface></ogc:Within>')
Beispiel #4
0
    def test_wfs_build_getfeature_request_sortby(self):
        """Test the owsutil.wfs_build_getfeature_request method with a sortby.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        sort_by = SortBy([SortProperty('diepte_tot_m', 'DESC')])

        try:
            sort_by = etree.tostring(sort_by.toXML(), encoding='unicode')
        except LookupError:
            # Python2.7 without lxml uses 'utf-8' instead.
            sort_by = etree.tostring(sort_by.toXML(), encoding='utf-8')

        xml = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen',
            propertyname=['fiche', 'diepte_tot_m'],
            sort_by=sort_by)
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"><wfs:Query '
            'typeName="dov-pub:Boringen"><wfs:PropertyName>fiche</wfs'
            ':PropertyName><wfs:PropertyName>diepte_tot_m</wfs:PropertyName'
            '><ogc:Filter/><ogc:SortBy><ogc:SortProperty><ogc:PropertyName'
            '>diepte_tot_m</ogc:PropertyName><ogc:SortOrder>DESC</ogc'
            ':SortOrder></ogc:SortProperty></ogc:SortBy></wfs:Query></wfs'
            ':GetFeature>')
Beispiel #5
0
    def test_line_multiple_31370_stable(self):
        """Test the WithinDistance filter with a GML containing multiple
        line geometries in EPSG:31370.

        Test whether the generated XML is correct and stable.

        """
        with open('tests/data/util/location/line_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, WithinDistance, {'distance': 100})
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml :LineString '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:posList>108344'
                '.619471974 195008.119519901 108801.613305297 '
                '194842.656235421 109077.385446096 '
                '195094.790764152</gml:posList></gml:LineString><gml'
                ':Distance units="meter">100.000000</gml:Distance></ogc'
                ':DWithin><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml :LineString '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:posList>108194'
                '.91459554 196032.416042867 108714.942061046 '
                '195528.146985407 108911.922161617 '
                '195528.146985407</gml:posList></gml:LineString><gml'
                ':Distance units="meter">100.000000</gml:Distance>'
                '</ogc:DWithin></ogc:Or>')
Beispiel #6
0
    def test_multiline_single_31370(self):
        """Test the WithinDistance filter with a GML containing a single
        multiline geometry in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/multiline_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        f = GmlFilter(gml, WithinDistance, {'distance': 100})
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:DWithin><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':MultiCurve srsName="urn:ogc:def:crs:EPSG::31370"><gml'
            ':curveMember><gml:LineString><gml:posList>108210.673003586 '
            '194850.535439444 108454.928328293 195031.757131969 '
            '108746.458877137 194834.777031398</gml:posList></gml:LineString'
            '></gml:curveMember><gml:curveMember><gml:LineString><gml'
            ':posList>109164.056690347 195055.394744037 109211.331914484 '
            '194661.434542896 109416.191219077 '
            '194440.816830258</gml:posList></gml:LineString></gml'
            ':curveMember></gml:MultiCurve><gml:Distance '
            'units="meter">100.000000</gml:Distance></ogc:DWithin>')
Beispiel #7
0
    def test_box_or_box(self):
        """Test a location filter expression using an Intersects(Box) and a
        Within(Box) filter.

        Test whether the generated XML is correct.

        """
        box_or_box = Or([
            Intersects(Box(50.9850, 3.6214, 51.1270, 3.8071, epsg=4326)),
            Within(Box(94720, 186910, 112220, 202870))
        ])
        xml = set_geometry_column(box_or_box, 'geom')

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Or><ogc:Intersects><ogc:PropertyName>geom</ogc'
            ':PropertyName><gml:Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"><gml'
            ':lowerCorner>50.985000 '
            '3.621400</gml:lowerCorner><gml:upperCorner>51.127000 '
            '3.807100</gml:upperCorner></gml:Envelope></ogc:Intersects><ogc'
            ':Within><ogc:PropertyName>geom</ogc:PropertyName><gml:Envelope '
            'srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml '
            ':lowerCorner>94720.000000 '
            '186910.000000</gml:lowerCorner><gml:upperCorner>112220.000000 '
            '202870.000000</gml:upperCorner></gml:Envelope></ogc:Within'
            '></ogc:Or>')
Beispiel #8
0
    def test_recursive(self):
        """Test a location filter expression using a recursive expression
        with And(Not(WithinDistance(Point) filter.

        Test whether the generated XML is correct.

        """
        point_and_box = And([
            Not([WithinDistance(Point(150000, 150000), 100)]),
            Within(Box(94720, 186910, 112220, 202870))
        ])
        xml = set_geometry_column(point_and_box, 'geom')

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:And><ogc:Not><ogc:DWithin><ogc:PropertyName>geom</ogc'
            ':PropertyName><gml:Point srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml'
            ':pos>150000.000000 '
            '150000.000000</gml:pos></gml:Point><gml:Distance '
            'units="meter">100.000000</gml:Distance></ogc:DWithin></ogc:Not'
            '><ogc:Within><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml'
            ':lowerCorner>94720.000000 '
            '186910.000000</gml:lowerCorner><gml:upperCorner>112220.000000 '
            '202870.000000</gml:upperCorner></gml:Envelope></ogc:Within'
            '></ogc:And>')
Beispiel #9
0
    def test_point_multiple_31370_stable(self):
        """Test the WithinDistance filter with a GML containing multiple
        point geometries in EPSG:31370.

        Test whether the generated XML is correct and stable.

        """
        with open('tests/data/util/location/point_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, WithinDistance, {'distance': 100})
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:Point '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:pos>109124'
                '.660670233 194937.206683695</gml:pos></gml:Point><gml'
                ':Distance units="meter">100.000000</gml:Distance></ogc'
                ':DWithin><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:Point '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:pos>109234'
                '.969526552 195772.402310114</gml:pos></gml:Point><gml'
                ':Distance units="meter">100.000000</gml:Distance>'
                '</ogc:DWithin></ogc:Or>')
Beispiel #10
0
    def test_polygon_and_box(self):
        """Test the combination of a Within filter with a GML containing a
        single polygon geometry in EPSG:31370 and a Box.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/polygon_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        polygon = GmlFilter(gml, Within)
        box = Box(94720, 186910, 112220, 202870)

        location_filter = Or([polygon, Within(box)])
        set_geometry_column(location_filter, 'geom')
        xml = location_filter.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Or><ogc:Within><ogc:PropertyName>geom</ogc:PropertyName'
            '><gml:Polygon srsName="urn:ogc:def:crs:EPSG::31370"><gml'
            ':exterior><gml:LinearRing><gml:posList>108636.150020818 '
            '194960.844295764 108911.922161617 194291.111953824 '
            '109195.573506438 195118.42837622 108636.150020818 '
            '194960.844295764</gml:posList></gml:LinearRing></gml:exterior'
            '></gml:Polygon></ogc:Within><ogc:Within><ogc:PropertyName>geom'
            '</ogc:PropertyName><gml:Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml'
            ':lowerCorner>94720.000000 '
            '186910.000000</gml:lowerCorner><gml:upperCorner>112220.000000 '
            '202870.000000</gml:upperCorner></gml:Envelope></ogc'
            ':Within></ogc:Or>')
Beispiel #11
0
    def test_polyon_multiple_31370_stable(self):
        """Test the Within filter with a GML containing multiple
        polygon geometries in EPSG:31370.

        Test whether the generated XML is correct and stable.

        """
        with open('tests/data/util/location/polygon_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, Within)
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:Within><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:Polygon '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:exterior'
                '><gml:LinearRing><gml:posList>108636.150020818 '
                '194960.844295764 108911.922161617 194291.111953824 '
                '109195.573506438 195118.42837622 108636.150020818 '
                '194960.844295764</gml:posList></gml:LinearRing></gml'
                ':exterior></gml:Polygon></ogc:Within><ogc:Within><ogc'
                ':PropertyName>geom</ogc:PropertyName><gml:Polygon '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:exterior'
                '><gml:LinearRing><gml:posList>107485.786233486 '
                '196741.544404921 107840.350414513 196339.704999757 '
                '108297.344247837 196843.974057217 107485.786233486 '
                '196741.544404921</gml:posList></gml:LinearRing></gml'
                ':exterior></gml:Polygon></ogc:Within></ogc:Or>')
Beispiel #12
0
    def test_wfs_build_getfeature_request_filter(self):
        """Test the owsutil.wfs_build_getfeature_request method with an
        attribute filter.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        query = PropertyIsEqualTo(propertyname='gemeente', literal='Herstappe')
        filter_request = FilterRequest()
        filter_request = filter_request.setConstraint(query)
        try:
            filter_request = etree.tostring(filter_request, encoding='unicode')
        except LookupError:
            # Python2.7 without lxml uses 'utf-8' instead.
            filter_request = etree.tostring(filter_request, encoding='utf-8')

        xml = owsutil.wfs_build_getfeature_request('dov-pub:Boringen',
                                                   filter=filter_request)
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <wfs:Query '
            'typeName="dov-pub:Boringen"> <ogc:Filter> '
            '<ogc:PropertyIsEqualTo> '
            '<ogc:PropertyName>gemeente</ogc:PropertyName> '
            '<ogc:Literal>Herstappe</ogc:Literal> </ogc:PropertyIsEqualTo> '
            '</ogc:Filter> </wfs:Query> </wfs:GetFeature>')
Beispiel #13
0
    def test_wfs_build_getfeature_request_bbox(self):
        """Test the owsutil.wfs_build_getfeature_request method with a
        typename, box and geometry_column.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        xml = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen',
            location=Within(Box(151650, 214675, 151750, 214775)),
            geometry_column='geom')
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"><wfs:Query '
            'typeName="dov-pub:Boringen"><ogc:Filter '
            'xmlns:ogc="http://www.opengis.net/ogc"><ogc:Within> '
            '<ogc:PropertyName>geom</ogc:PropertyName><gml:Envelope '
            'xmlns:gml="http://www.opengis.net/gml" srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml'
            ':lowerCorner>151650.000000 '
            '214675.000000</gml:lowerCorner><gml:upperCorner>151750.000000 '
            '214775.000000</gml:upperCorner></gml:Envelope></ogc:Within></ogc'
            ':Filter></wfs:Query></wfs:GetFeature>')
Beispiel #14
0
    def test_point_wgs84(self):
        """Test the Point type with WGS84 coordinates.

        Test whether the generated XML is correct.

        """
        point = Point(3.8071, 51.1270, epsg=4326)
        xml = point.get_element()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<gml:Point srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">'
            '<gml:pos>3.807100 51.127000</gml:pos></gml:Point>')
Beispiel #15
0
    def test_point(self):
        """Test the default Point type.

        Test whether the generated XML is correct.

        """
        point = Point(110680, 202030)
        xml = point.get_element()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<gml:Point srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370">'
            '<gml:pos>110680.000000 202030.000000</gml:pos></gml:Point>')
Beispiel #16
0
    def test_box_wgs84(self):
        """Test the Box type with WGS84 coordinates.

        Test whether the generated XML is correct.

        """
        box = Box(3.6214, 50.9850, 3.8071, 51.1270, epsg=4326)
        xml = box.get_element()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<gml:Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">'
            '<gml:lowerCorner>3.621400 50.985000</gml:lowerCorner>'
            '<gml:upperCorner>3.807100 51.127000</gml:upperCorner>'
            '</gml:Envelope>')
Beispiel #17
0
    def test_box(self):
        """Test the default Box type.

        Test whether the generated XML is correct.

        """
        box = Box(94720, 186910, 112220, 202870)
        xml = box.get_element()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<gml:Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370">'
            '<gml:lowerCorner>94720.000000 186910.000000</gml:lowerCorner>'
            '<gml:upperCorner>112220.000000 202870.000000</gml:upperCorner>'
            '</gml:Envelope>')
Beispiel #18
0
    def test_multipolygon_multiple_31370_stable(self):
        """Test the Within filter with a GML containing multiple
        multipolygon geometries in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/multipolygon_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, Within)
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:Within><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:MultiSurface '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:surfaceMember'
                '><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList'
                '>107564.578273715 196646.993956647 107785.195986354 '
                '196386.980223894 107966.417678878 197143.383810084 '
                '107564.578273715 '
                '196646.993956647</gml:posList></gml:LinearRing'
                '></gml:exterior></gml:Polygon></gml:surfaceMember><gml'
                ':surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing'
                '><gml:posList>108384.015492088 197214.29664629 '
                '108447.04912427 196489.40987619 108785.854897252 '
                '197269.45107445 108384.015492088 '
                '197214.29664629</gml:posList></gml:LinearRing'
                '></gml:exterior></gml:Polygon></gml:surfaceMember></gml'
                ':MultiSurface></ogc:Within><ogc:Within><ogc:PropertyName'
                '>geom</ogc:PropertyName><gml:MultiSurface '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:surfaceMember'
                '><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList'
                '>108588.874796681 195015.998723923 108911.922161617 '
                '194251.71593371 109195.573506438 195134.186784266 '
                '108588.874796681 '
                '195015.998723923</gml:posList></gml:LinearRing'
                '></gml:exterior></gml:Polygon></gml:surfaceMember><gml'
                ':surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing'
                '><gml:posList>109140.419078278 195748.764698045 '
                '109400.432811031 195307.529272768 109597.412911602 '
                '195772.402310114 109140.419078278 '
                '195748.764698045</gml:posList></gml:LinearRing'
                '></gml:exterior></gml:Polygon></gml:surfaceMember></gml'
                ':MultiSurface></ogc:Within></ogc:Or>')
Beispiel #19
0
    def test_equals_point(self):
        """Test the Equals spatial filter with a Point location.

        Test whether the generated XML is correct.

        """
        equals = Equals(Point(150000, 150000))
        equals.set_geometry_column('geom')
        xml = equals.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Equals><ogc:PropertyName>geom</ogc:PropertyName>'
            '<gml:Point srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370">'
            '<gml:pos>150000.000000 150000.000000</gml:pos></gml:Point>'
            '</ogc:Equals>')
Beispiel #20
0
    def test_wfs_build_getfeature_request_propertyname_stable(self):
        """Test the owsutil.wfs_build_getfeature_request method with a list
        of propertynames.

        Test whether the XML of the WFS GetFeature that is being generated is
        stable (i.e. independent of the order of the propertynames).

        """
        xml = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen', propertyname=['fiche', 'diepte_tot_m'])

        xml2 = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen', propertyname=['diepte_tot_m', 'fiche'])

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            etree.tostring(xml2).decode('utf8'))
Beispiel #21
0
    def test_intersects_box(self):
        """Test the Intersects spatial filter with a Box location.

        Test whether the generated XML is correct.

        """
        intersects = Intersects(Box(94720, 186910, 112220, 202870))
        intersects.set_geometry_column('geom')
        xml = intersects.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Intersects><ogc:PropertyName>geom</ogc:PropertyName>'
            '<gml:Envelope srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370">'
            '<gml:lowerCorner>94720.000000 186910.000000</gml:lowerCorner>'
            '<gml:upperCorner>112220.000000 202870.000000</gml:upperCorner>'
            '</gml:Envelope></ogc:Intersects>')
Beispiel #22
0
    def test_withindistance_point(self):
        """Test the WithinDistance spatial filter with a Point location.

        Test whether the generated XML is correct.

        """
        withindistance = WithinDistance(Point(150000, 150000), 100)
        withindistance.set_geometry_column('geom')
        xml = withindistance.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:DWithin><ogc:PropertyName>geom</ogc:PropertyName>'
            '<gml:Point srsDimension="2" '
            'srsName="http://www.opengis.net/gml/srs/epsg.xml#31370">'
            '<gml:pos>150000.000000 150000.000000</gml:pos></gml:Point>'
            '<gml:Distance units="meter">100.000000</gml:Distance>'
            '</ogc:DWithin>')
Beispiel #23
0
    def test_wfs_build_getfeature_request_onlytypename(self):
        """Test the owsutil.wfs_build_getfeature_request method with only a
        typename specified.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        xml = owsutil.wfs_build_getfeature_request('dov-pub:Boringen')
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"><wfs:Query '
            'typeName="dov-pub:Boringen"><ogc:Filter '
            'xmlns:ogc="http://www.opengis.net/ogc"/></wfs:Query></wfs'
            ':GetFeature>')
Beispiel #24
0
    def test_wfs_build_getfeature_request_propertyname(self):
        """Test the owsutil.wfs_build_getfeature_request method with a list
        of propertynames.

        Test whether the XML of the WFS GetFeature call is generated correctly.

        """
        xml = owsutil.wfs_build_getfeature_request(
            'dov-pub:Boringen', propertyname=['fiche', 'diepte_tot_m'])
        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" '
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'service="WFS" version="1.1.0" '
            'xsi:schemaLocation="http://www.opengis.net/wfs '
            'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <wfs:Query '
            'typeName="dov-pub:Boringen"> '
            '<wfs:PropertyName>fiche</wfs:PropertyName> '
            '<wfs:PropertyName>diepte_tot_m</wfs:PropertyName> <ogc:Filter/> '
            '</wfs:Query> </wfs:GetFeature>')
Beispiel #25
0
    def test_multiline_multiple_31370_stable(self):
        """Test the WithinDistance filter with a GML containing multiple
        multiline geometries in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/multiline_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, WithinDistance, {'distance': 100})
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:MultiCurve '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:curveMember><gml'
                ':LineString><gml:posList>108210.673003586 194850.535439444 '
                '108454.928328293 195031.757131969 108746.458877137 '
                '194834.777031398</gml:posList></gml:LineString></gml'
                ':curveMember><gml:curveMember><gml:LineString><gml:posList'
                '>109164.056690347 195055.394744037 109211.331914484 '
                '194661.434542896 109416.191219077 '
                '194440.816830258</gml:posList></gml:LineString></gml'
                ':curveMember></gml:MultiCurve><gml:Distance '
                'units="meter">100.000000</gml:Distance></ogc:DWithin><ogc'
                ':DWithin><ogc:PropertyName>geom</ogc:PropertyName><gml'
                ':MultiCurve '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:curveMember><gml'
                ':LineString><gml:posList>108226.431411631 196095.44967505 '
                '108384.015492088 196276.671367574 108580.995592658 '
                '196048.174450913</gml:posList></gml:LineString></gml'
                ':curveMember><gml:curveMember><gml:LineString><gml:posList'
                '>108911.922161617 196379.101019871 109030.110221959 '
                '196552.443508373 109282.244750689 '
                '196607.597936533</gml:posList></gml:LineString></gml'
                ':curveMember></gml:MultiCurve><gml:Distance '
                'units="meter">100.000000</gml:Distance></ogc:DWithin>'
                '</ogc:Or>')
Beispiel #26
0
    def test_point_single_31370(self):
        """Test the WithinDistance filter with a GML containing a single
        point geometry in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/point_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        f = GmlFilter(gml, WithinDistance, {'distance': 100})
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:DWithin><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':Point srsName="urn:ogc:def:crs:EPSG::31370"><gml:pos>109124'
            '.660670233 194937.206683695</gml:pos></gml:Point><gml:Distance '
            'units="meter">100.000000</gml:Distance></ogc:DWithin>')
Beispiel #27
0
    def test_stable(self):
        """Test the PropertyInList expression with a standard list.

        Test whether the generated query is correct and stable.

        """
        l = ['a', 'b', 'c']

        for p in permutations(l):
            query = PropertyInList('methode', list(p))
            xml = query.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>methode</ogc'
                ':PropertyName><ogc:Literal>a</ogc:Literal></ogc'
                ':PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName'
                '>methode</ogc:PropertyName><ogc:Literal>b</ogc:Literal></ogc'
                ':PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName'
                '>methode</ogc:PropertyName><ogc:Literal>c</ogc:Literal></ogc'
                ':PropertyIsEqualTo></ogc:Or>')
Beispiel #28
0
    def test_line_single_31370(self):
        """Test the WithinDistance filter with a GML containing a single
        line geometry in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/line_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        f = GmlFilter(gml, WithinDistance, {'distance': 100})
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:DWithin><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':LineString srsName="urn:ogc:def:crs:EPSG::31370"><gml:posList'
            '>108344.619471974 195008.119519901 108801.613305297 '
            '194842.656235421 109077.385446096 '
            '195094.790764152</gml:posList></gml:LineString><gml:Distance '
            'units="meter">100.000000</gml:Distance></ogc:DWithin>')
Beispiel #29
0
    def test_polygon_single_31370(self):
        """Test the Within filter with a GML containing a single
        polygon geometry in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/polygon_single_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        f = GmlFilter(gml, Within)
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
            '<ogc:Within><ogc:PropertyName>geom</ogc:PropertyName><gml'
            ':Polygon srsName="urn:ogc:def:crs:EPSG::31370"><gml:exterior'
            '><gml:LinearRing><gml:posList>108636.150020818 194960.844295764 '
            '108911.922161617 194291.111953824 109195.573506438 '
            '195118.42837622 108636.150020818 '
            '194960.844295764</gml:posList></gml:LinearRing></gml:exterior'
            '></gml:Polygon></ogc:Within>')
Beispiel #30
0
    def test_multipoint_multiple_31370_stable(self):
        """Test the WithinDistance filter with a GML containing multiple
        multipoint geometries in EPSG:31370.

        Test whether the generated XML is correct and stable.

        """
        with open('tests/data/util/location/multipoint_multiple_31370.gml',
                  'r') as gml_file:
            gml = gml_file.read()

        for i in range(10):
            f = GmlFilter(gml, WithinDistance, {'distance': 100})
            f.set_geometry_column('geom')
            xml = f.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:DWithin><ogc:PropertyName>geom</ogc'
                ':PropertyName><gml:MultiPoint '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:pointMember><gml'
                ':Point><gml:pos>108770.096489206 '
                '194992.361111855</gml:pos></gml:Point></gml:pointMember'
                '><gml:pointMember><gml:Point><gml:pos>109045.868630005 '
                '194929.327479672</gml:pos></gml:Point></gml:pointMember'
                '></gml:MultiPoint><gml:Distance '
                'units="meter">100.000000</gml:Distance></ogc:DWithin><ogc'
                ':DWithin><ogc:PropertyName>geom</ogc:PropertyName><gml'
                ':MultiPoint '
                'srsName="urn:ogc:def:crs:EPSG::31370"><gml:pointMember><gml'
                ':Point><gml:pos>108825.250917366 '
                '195433.596537133</gml:pos></gml:Point></gml:pointMember'
                '><gml:pointMember><gml:Point><gml:pos>108738.579673115 '
                '195614.818229658</gml:pos></gml:Point></gml:pointMember'
                '></gml:MultiPoint><gml:Distance '
                'units="meter">100.000000</gml:Distance></ogc:DWithin>'
                '</ogc:Or>')