예제 #1
0
    def test_point_multiple_31370(self):
        """Test the WithinDistance filter with a GML containing multiple
        point geometries in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/point_multiple_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 xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 2

        points = [
            '109124.660670233 194937.206683695',
            '109234.969526552 195772.402310114'
        ]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}DWithin'

            point = f.find('./{http://www.opengis.net/gml}Point')
            assert point.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = point.find('./{http://www.opengis.net/gml}pos').text
            assert posList in points

            points.remove(posList)

        assert len(points) == 0
예제 #2
0
    def test_multipolygon_multiple_31370(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()

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

        assert xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 2

        multipolygons = [
            [
                '107564.578273715 196646.993956647 107785.195986354 '
                '196386.980223894 107966.417678878 197143.383810084 '
                '107564.578273715 196646.993956647',
                '108384.015492088 197214.29664629 108447.04912427 '
                '196489.40987619 108785.854897252 197269.45107445 '
                '108384.015492088 197214.29664629'
            ],
            [
                '108588.874796681 195015.998723923 108911.922161617 '
                '194251.71593371 109195.573506438 195134.186784266 '
                '108588.874796681 195015.998723923',
                '109140.419078278 195748.764698045 109400.432811031 '
                '195307.529272768 109597.412911602 195772.402310114 '
                '109140.419078278 195748.764698045'
            ]
        ]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}Within'

            multicurve = f.find('./{http://www.opengis.net/gml}MultiSurface')
            assert multicurve.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = [
                p.text for p in multicurve.findall(
                    './/{http://www.opengis.net/gml}posList')
            ]
            multipolygons.remove(posList)

        assert len(multipolygons) == 0
예제 #3
0
    def test_multiline_multiple_31370(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()

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

        assert xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 2

        multilines = [[
            '108210.673003586 194850.535439444 108454.928328293 '
            '195031.757131969 108746.458877137 194834.777031398',
            '109164.056690347 195055.394744037 109211.331914484 '
            '194661.434542896 109416.191219077 194440.816830258'
        ],
                      [
                          '108226.431411631 196095.44967505 108384.015492088 '
                          '196276.671367574 108580.995592658 196048.174450913',
                          '108911.922161617 196379.101019871 109030.110221959 '
                          '196552.443508373 109282.244750689 196607.597936533'
                      ]]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}DWithin'

            multicurve = f.find('./{http://www.opengis.net/gml}MultiCurve')
            assert multicurve.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = [
                p.text for p in multicurve.findall(
                    './/{http://www.opengis.net/gml}posList')
            ]
            multilines.remove(posList)

        assert len(multilines) == 0
예제 #4
0
    def test_multipoint_multiple_31370(self):
        """Test the WithinDistance filter with a GML containing multiple
        multipoint geometries in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/multipoint_multiple_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 xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 2

        multipoints = [[
            '108770.096489206 194992.361111855',
            '109045.868630005 194929.327479672'
        ],
                       [
                           '108825.250917366 195433.596537133',
                           '108738.579673115 195614.818229658'
                       ]]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}DWithin'

            multipoint = f.find('./{http://www.opengis.net/gml}MultiPoint')
            assert multipoint.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = [
                p.text for p in multipoint.findall(
                    './/{http://www.opengis.net/gml}pos')
            ]
            multipoints.remove(posList)

        assert len(multipoints) == 0
예제 #5
0
    def test_polyon_multiple_disjoint_31370(self):
        """Test the Disjoint filter with the And combinator with a GML
        containing multiple polygon geometries in EPSG:31370.

        Test whether the generated XML is correct.

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

        f = GmlFilter(gml, Disjoint, combinator=And)
        f.set_geometry_column('geom')
        xml = f.toXML()

        assert xml.tag == '{http://www.opengis.net/ogc}And'
        assert len(list(xml)) == 2

        polygons = [
            '108636.150020818 194960.844295764 108911.922161617 '
            '194291.111953824 109195.573506438 195118.42837622 '
            '108636.150020818 194960.844295764',
            '107485.786233486 196741.544404921 107840.350414513 '
            '196339.704999757 108297.344247837 196843.974057217 '
            '107485.786233486 196741.544404921'
        ]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}Disjoint'

            point = f.find('./{http://www.opengis.net/gml}Polygon')
            assert point.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = point.find('.//{http://www.opengis.net/gml}posList').text
            assert posList in polygons

            polygons.remove(posList)

        assert len(polygons) == 0
예제 #6
0
    def test_line_multiple_31370(self):
        """Test the WithinDistance filter with a GML containing multiple
        line geometries in EPSG:31370.

        Test whether the generated XML is correct.

        """
        with open('tests/data/util/location/line_multiple_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 xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 2

        lines = [
            '108344.619471974 195008.119519901 108801.613305297 '
            '194842.656235421 109077.385446096 195094.790764152',
            '108194.91459554 196032.416042867 108714.942061046 '
            '195528.146985407 108911.922161617 195528.146985407'
        ]

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}DWithin'

            point = f.find('./{http://www.opengis.net/gml}LineString')
            assert point.get('srsName') == 'urn:ogc:def:crs:EPSG::31370'

            posList = point.find('./{http://www.opengis.net/gml}posList').text
            assert posList in lines

            lines.remove(posList)

        assert len(lines) == 0