예제 #1
0
    def test_validate_GGNRA(self):
        """
        """
        unzip(join(self.tmp, "open-trails-GGNRA.zip"), None, (".geojson", ".csv"))

        files = (
            join(self.tmp, "trail_segments.geojson"),
            join(self.tmp, "named_trails.csv"),
            join(self.tmp, "trailheads.geojson"),
            join(self.tmp, "stewards.csv"),
            join(self.tmp, "areas.geojson"),
        )

        messages, result = validators.check_open_trails(*files)

        self.assertFalse(result)

        expected_messages = [
            ("error", "bad-data-stewards", 'Required stewards field "license" is missing.'),
            ("success", "valid-file-trail-segments", "Your trail-segments.geojson file looks good."),
            ("success", "valid-file-named-trails", "Your named-trails.csv file looks good."),
            ("warning", "bad-data-trailheads", 'Optional trailheads field "area_id" is missing.'),
            ("warning", "missing-file-areas", "Could not find optional file areas.geojson."),
        ]

        self.assertEqual(len(messages), len(expected_messages))

        for expected in expected_messages:
            self.assertTrue(expected in messages)
예제 #2
0
    def test_segments_conversion_Boulder_County(self):
        ''' Test overall segments conversion.
        '''

        copy('test-files/Boulder_County_Trails.zip', self.tmp)

        path = unzip(join(self.tmp, 'Boulder_County_Trails.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        # self.assertEqual(len(m), 2)

        # converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        # expected_ids = map(str, range(1, len(converted_ids) + 1))
        # self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['trailname'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        self.assertEqual(converted_names.count('Coal Creek Trail'),12)

        named_trails = make_named_trails(converted_geojson['features'])
        coal_creek = [t['name'] for t in named_trails if t['name'] == 'Coal Creek Trail']
        willows = [t['name'] for t in named_trails if t['name'] == 'Willows Trail']
        ninetyfifth = [t['name'] for t in named_trails if t['name'] == '95th Street']
        niwot = [t['name'] for t in named_trails if t['name'] == 'Niwot Trail System']

        expected = [1,1,1,1]
        actual = [len(willows),len(niwot),len(coal_creek),len(ninetyfifth)]
        self.assertEqual(actual,expected)
예제 #3
0
    def test_segments_conversion_Nested(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Nested.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)
예제 #4
0
    def test_segments_conversion_Nested(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Nested.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)
예제 #5
0
    def test_segments_conversion_San_Antonio(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-San-Antonio.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 7)

        converted_ids = [
            f['properties']['id'] for f in converted_geojson['features']
        ]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [f['properties']['Name'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [
            f['properties']['foot'] for f in converted_geojson['features']
        ]
        expected_foots = [None for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [
            f['properties']['bicycle'] for f in converted_geojson['features']
        ]
        expected_bikes = [None for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [
            f['properties']['horse'] for f in converted_geojson['features']
        ]
        expected_horses = [None for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [
            f['properties']['ski'] for f in converted_geojson['features']
        ]
        expected_skis = [None for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [
            f['properties']['wheelchair']
            for f in converted_geojson['features']
        ]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [
            f['properties']['motor_vehicles']
            for f in converted_geojson['features']
        ]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #6
0
    def testConvert(self):
        ''' Test basic SHP to GeoJSON conversion.
        '''
        for name in os.listdir(self.tmp):
            path = unzip(join(self.tmp, name))
            self.doFileConversion(path)

            # clean up - delete uneeded shapefiles
            dont_delete = ['csv','zip','geojson']
            for file in os.listdir(self.tmp):
                if file.split('.')[1] not in dont_delete:
                    os.remove(self.tmp +'/'+file)
예제 #7
0
    def testConvert(self):
        """ Test basic SHP to GeoJSON conversion.
        """
        for name in os.listdir(self.tmp):
            path = unzip(join(self.tmp, name))
            self.doFileConversion(path)

            # clean up - delete uneeded shapefiles
            dont_delete = ["csv", "zip", "geojson"]
            for file in os.listdir(self.tmp):
                if file.split(".")[1] not in dont_delete:
                    os.remove(self.tmp + "/" + file)
예제 #8
0
    def testConvert(self):
        ''' Test basic SHP to GeoJSON conversion.
        '''
        for name in os.listdir(self.tmp):
            path = unzip(join(self.tmp, name))
            self.doFileConversion(path)

            # clean up - delete uneeded shapefiles
            dont_delete = ['csv', 'zip', 'geojson']
            for file in os.listdir(self.tmp):
                if file.split('.')[1] not in dont_delete:
                    os.remove(self.tmp + '/' + file)
예제 #9
0
    def test_trailheads_conversion_Ohio(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-points-Ohio.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.trailheads_transform(geojson, None)

        self.assertEqual(len(m), 1)

        converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        expected_ids = [f['properties']['id'] for f in geojson['features']]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['name'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)
예제 #10
0
    def test_segments_conversion_GGNRA(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-GGNRA.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['trail_name'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        named_trails = make_named_trails(converted_geojson['features'])
        self.assertEqual(len(named_trails), 4)

        uses = {'Multi-Use': 'yes', 'Hiking': 'yes', 'Hiking and Horses': 'yes'}
        converted_foots = [f['properties']['foot'] for f in converted_geojson['features']]
        expected_foots = [uses.get(f['properties']['use_type'], None) for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        uses = {'Multi-Use': 'yes', 'Hiking': 'no', 'Hiking and Horses': 'no'}
        converted_bikes = [f['properties']['bicycle'] for f in converted_geojson['features']]
        expected_bikes = [uses.get(f['properties']['use_type'], None) for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {'Multi-Use': 'no', 'Hiking': 'no', 'Hiking and Horses': 'yes'}
        converted_horses = [f['properties']['horse'] for f in converted_geojson['features']]
        expected_horses = [uses.get(f['properties']['use_type'], None) for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f['properties']['ski'] for f in converted_geojson['features']]
        expected_skis = ['yes', 'no', 'yes', 'yes', None, 'yes']
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f['properties']['wheelchair'] for f in converted_geojson['features']]
        expected_wheelchairs = [None] * 6
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f['properties']['motor_vehicles'] for f in converted_geojson['features']]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #11
0
    def test_segments_conversion_Boulder_County(self):
        ''' Test overall segments conversion.
        '''

        copy('test-files/Boulder_County_Trails.zip', self.tmp)

        path = unzip(join(self.tmp, 'Boulder_County_Trails.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        # self.assertEqual(len(m), 2)

        # converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        # expected_ids = map(str, range(1, len(converted_ids) + 1))
        # self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [
            f['properties']['trailname'] for f in geojson['features']
        ]
        self.assertEqual(converted_names, expected_names)

        self.assertEqual(converted_names.count('Coal Creek Trail'), 12)

        named_trails = make_named_trails(converted_geojson['features'])
        coal_creek = [
            t['name'] for t in named_trails if t['name'] == 'Coal Creek Trail'
        ]
        willows = [
            t['name'] for t in named_trails if t['name'] == 'Willows Trail'
        ]
        ninetyfifth = [
            t['name'] for t in named_trails if t['name'] == '95th Street'
        ]
        niwot = [
            t['name'] for t in named_trails
            if t['name'] == 'Niwot Trail System'
        ]

        expected = [1, 1, 1, 1]
        actual = [len(willows), len(niwot), len(coal_creek), len(ninetyfifth)]
        self.assertEqual(actual, expected)
예제 #12
0
    def test_segments_conversion_Santa_Clara(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Santa-Clara.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        expected_ids = [str(f['properties']['OBJECTID']) for f in geojson['features']]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['NAME'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        uses = {'hiking': 'yes', 'hiking/equestrian': 'yes', 'hiking/equestrian/bicycling': 'yes'}
        converted_foots = [f['properties']['foot'] for f in converted_geojson['features']]
        expected_foots = [uses.get(f['properties']['PUBUSE'], None) for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        uses = {'hiking': 'no', 'hiking/equestrian': 'no', 'hiking/equestrian/bicycling': 'yes'}
        converted_bikes = [f['properties']['bicycle'] for f in converted_geojson['features']]
        expected_bikes = [uses.get(f['properties']['PUBUSE'], None) for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {'hiking': 'no', 'hiking/equestrian': 'yes', 'hiking/equestrian/bicycling': 'yes'}
        converted_horses = [f['properties']['horse'] for f in converted_geojson['features']]
        expected_horses = [uses.get(f['properties']['PUBUSE'], None) for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f['properties']['ski'] for f in converted_geojson['features']]
        expected_skis = ['no' for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f['properties']['wheelchair'] for f in converted_geojson['features']]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f['properties']['motor_vehicles'] for f in converted_geojson['features']]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #13
0
    def test_segments_conversion_Santa_Clara(self):
        """ Test overall segments conversion.
        """
        path = unzip(join(self.tmp, "lake-man-Santa-Clara.zip"))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f["properties"]["id"] for f in converted_geojson["features"]]
        expected_ids = [f["properties"]["OBJECTID"] for f in geojson["features"]]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f["properties"]["name"] for f in converted_geojson["features"]]
        expected_names = [f["properties"]["NAME"] for f in geojson["features"]]
        self.assertEqual(converted_names, expected_names)

        uses = {"hiking": "yes", "hiking/equestrian": "yes", "hiking/equestrian/bicycling": "yes"}
        converted_foots = [f["properties"]["foot"] for f in converted_geojson["features"]]
        expected_foots = [uses.get(f["properties"]["PUBUSE"], None) for f in geojson["features"]]
        self.assertEqual(converted_foots, expected_foots)

        uses = {"hiking": "no", "hiking/equestrian": "no", "hiking/equestrian/bicycling": "yes"}
        converted_bikes = [f["properties"]["bicycle"] for f in converted_geojson["features"]]
        expected_bikes = [uses.get(f["properties"]["PUBUSE"], None) for f in geojson["features"]]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {"hiking": "no", "hiking/equestrian": "yes", "hiking/equestrian/bicycling": "yes"}
        converted_horses = [f["properties"]["horse"] for f in converted_geojson["features"]]
        expected_horses = [uses.get(f["properties"]["PUBUSE"], None) for f in geojson["features"]]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f["properties"]["ski"] for f in converted_geojson["features"]]
        expected_skis = ["no" for f in geojson["features"]]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f["properties"]["wheelchair"] for f in converted_geojson["features"]]
        expected_wheelchairs = [None for f in geojson["features"]]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f["properties"]["motor_vehicles"] for f in converted_geojson["features"]]
        expected_motor_vehicles = [None for f in geojson["features"]]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #14
0
    def test_segments_conversion_GGNRA(self):
        """ Test overall segments conversion.
        """
        path = unzip(join(self.tmp, "lake-man-GGNRA.zip"))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f["properties"]["id"] for f in converted_geojson["features"]]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f["properties"]["name"] for f in converted_geojson["features"]]
        expected_names = [f["properties"]["trail_name"] for f in geojson["features"]]
        self.assertEqual(converted_names, expected_names)

        uses = {"Multi-Use": "yes", "Hiking": "yes", "Hiking and Horses": "yes"}
        converted_foots = [f["properties"]["foot"] for f in converted_geojson["features"]]
        expected_foots = [uses.get(f["properties"]["use_type"], None) for f in geojson["features"]]
        self.assertEqual(converted_foots, expected_foots)

        uses = {"Multi-Use": "yes", "Hiking": "no", "Hiking and Horses": "no"}
        converted_bikes = [f["properties"]["bicycle"] for f in converted_geojson["features"]]
        expected_bikes = [uses.get(f["properties"]["use_type"], None) for f in geojson["features"]]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {"Multi-Use": "no", "Hiking": "no", "Hiking and Horses": "yes"}
        converted_horses = [f["properties"]["horse"] for f in converted_geojson["features"]]
        expected_horses = [uses.get(f["properties"]["use_type"], None) for f in geojson["features"]]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f["properties"]["ski"] for f in converted_geojson["features"]]
        expected_skis = ["yes", "no", "yes", "yes", None, "yes"]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f["properties"]["wheelchair"] for f in converted_geojson["features"]]
        expected_wheelchairs = [None] * 6
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f["properties"]["motor_vehicles"] for f in converted_geojson["features"]]
        expected_motor_vehicles = [None for f in geojson["features"]]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #15
0
    def test_trailheads_conversion_Ohio(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-points-Ohio.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.trailheads_transform(geojson, None)

        self.assertEqual(len(m), 1)

        converted_ids = [
            f['properties']['id'] for f in converted_geojson['features']
        ]
        expected_ids = [f['properties']['id'] for f in geojson['features']]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [f['properties']['name'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)
예제 #16
0
    def test_segments_conversion_Portland(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Portland.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        expected_ids = [f['properties']['TRAILID'] for f in geojson['features']]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['TRAILNAME'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [f['properties']['foot'] for f in converted_geojson['features']]
        expected_foots = ['yes' for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [f['properties']['bicycle'] for f in converted_geojson['features']]
        expected_bikes = ['yes' for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [f['properties']['horse'] for f in converted_geojson['features']]
        expected_horses = [None for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f['properties']['ski'] for f in converted_geojson['features']]
        expected_skis = [None for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f['properties']['wheelchair'] for f in converted_geojson['features']]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f['properties']['motor_vehicles'] for f in converted_geojson['features']]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #17
0
    def test_segments_conversion_Portland(self):
        """ Test overall segments conversion.
        """
        path = unzip(join(self.tmp, "lake-man-Portland.zip"))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [f["properties"]["id"] for f in converted_geojson["features"]]
        expected_ids = [f["properties"]["TRAILID"] for f in geojson["features"]]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f["properties"]["name"] for f in converted_geojson["features"]]
        expected_names = [f["properties"]["TRAILNAME"] for f in geojson["features"]]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [f["properties"]["foot"] for f in converted_geojson["features"]]
        expected_foots = ["yes" for f in geojson["features"]]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [f["properties"]["bicycle"] for f in converted_geojson["features"]]
        expected_bikes = ["yes" for f in geojson["features"]]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [f["properties"]["horse"] for f in converted_geojson["features"]]
        expected_horses = [None for f in geojson["features"]]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f["properties"]["ski"] for f in converted_geojson["features"]]
        expected_skis = [None for f in geojson["features"]]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f["properties"]["wheelchair"] for f in converted_geojson["features"]]
        expected_wheelchairs = [None for f in geojson["features"]]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f["properties"]["motor_vehicles"] for f in converted_geojson["features"]]
        expected_motor_vehicles = [None for f in geojson["features"]]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #18
0
    def test_segments_conversion_San_Antonio(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-San-Antonio.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 7)

        converted_ids = [f['properties']['id'] for f in converted_geojson['features']]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f['properties']['name'] for f in converted_geojson['features']]
        expected_names = [f['properties']['Name'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [f['properties']['foot'] for f in converted_geojson['features']]
        expected_foots = [None for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [f['properties']['bicycle'] for f in converted_geojson['features']]
        expected_bikes = [None for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [f['properties']['horse'] for f in converted_geojson['features']]
        expected_horses = [None for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f['properties']['ski'] for f in converted_geojson['features']]
        expected_skis = [None for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f['properties']['wheelchair'] for f in converted_geojson['features']]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f['properties']['motor_vehicles'] for f in converted_geojson['features']]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #19
0
    def test_segments_conversion_San_Antonio(self):
        """ Test overall segments conversion.
        """
        path = unzip(join(self.tmp, "lake-man-San-Antonio.zip"))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 7)

        converted_ids = [f["properties"]["id"] for f in converted_geojson["features"]]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [f["properties"]["name"] for f in converted_geojson["features"]]
        expected_names = [f["properties"]["Name"] for f in geojson["features"]]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [f["properties"]["foot"] for f in converted_geojson["features"]]
        expected_foots = [None for f in geojson["features"]]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [f["properties"]["bicycle"] for f in converted_geojson["features"]]
        expected_bikes = [None for f in geojson["features"]]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [f["properties"]["horse"] for f in converted_geojson["features"]]
        expected_horses = [None for f in geojson["features"]]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [f["properties"]["ski"] for f in converted_geojson["features"]]
        expected_skis = [None for f in geojson["features"]]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [f["properties"]["wheelchair"] for f in converted_geojson["features"]]
        expected_wheelchairs = [None for f in geojson["features"]]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [f["properties"]["motor_vehicles"] for f in converted_geojson["features"]]
        expected_motor_vehicles = [None for f in geojson["features"]]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #20
0
    def test_segments_conversion_Santa_Clara(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Santa-Clara.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [
            f['properties']['id'] for f in converted_geojson['features']
        ]
        expected_ids = [
            str(f['properties']['OBJECTID']) for f in geojson['features']
        ]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [f['properties']['NAME'] for f in geojson['features']]
        self.assertEqual(converted_names, expected_names)

        uses = {
            'hiking': 'yes',
            'hiking/equestrian': 'yes',
            'hiking/equestrian/bicycling': 'yes'
        }
        converted_foots = [
            f['properties']['foot'] for f in converted_geojson['features']
        ]
        expected_foots = [
            uses.get(f['properties']['PUBUSE'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_foots, expected_foots)

        uses = {
            'hiking': 'no',
            'hiking/equestrian': 'no',
            'hiking/equestrian/bicycling': 'yes'
        }
        converted_bikes = [
            f['properties']['bicycle'] for f in converted_geojson['features']
        ]
        expected_bikes = [
            uses.get(f['properties']['PUBUSE'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {
            'hiking': 'no',
            'hiking/equestrian': 'yes',
            'hiking/equestrian/bicycling': 'yes'
        }
        converted_horses = [
            f['properties']['horse'] for f in converted_geojson['features']
        ]
        expected_horses = [
            uses.get(f['properties']['PUBUSE'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [
            f['properties']['ski'] for f in converted_geojson['features']
        ]
        expected_skis = ['no' for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [
            f['properties']['wheelchair']
            for f in converted_geojson['features']
        ]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [
            f['properties']['motor_vehicles']
            for f in converted_geojson['features']
        ]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #21
0
    def test_segments_conversion_GGNRA(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-GGNRA.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [
            f['properties']['id'] for f in converted_geojson['features']
        ]
        expected_ids = map(str, range(1, len(converted_ids) + 1))
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [
            f['properties']['trail_name'] for f in geojson['features']
        ]
        self.assertEqual(converted_names, expected_names)

        named_trails = make_named_trails(converted_geojson['features'])
        self.assertEqual(len(named_trails), 4)

        uses = {
            'Multi-Use': 'yes',
            'Hiking': 'yes',
            'Hiking and Horses': 'yes'
        }
        converted_foots = [
            f['properties']['foot'] for f in converted_geojson['features']
        ]
        expected_foots = [
            uses.get(f['properties']['use_type'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_foots, expected_foots)

        uses = {'Multi-Use': 'yes', 'Hiking': 'no', 'Hiking and Horses': 'no'}
        converted_bikes = [
            f['properties']['bicycle'] for f in converted_geojson['features']
        ]
        expected_bikes = [
            uses.get(f['properties']['use_type'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_bikes, expected_bikes)

        uses = {'Multi-Use': 'no', 'Hiking': 'no', 'Hiking and Horses': 'yes'}
        converted_horses = [
            f['properties']['horse'] for f in converted_geojson['features']
        ]
        expected_horses = [
            uses.get(f['properties']['use_type'], None)
            for f in geojson['features']
        ]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [
            f['properties']['ski'] for f in converted_geojson['features']
        ]
        expected_skis = ['yes', 'no', 'yes', 'yes', None, 'yes']
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [
            f['properties']['wheelchair']
            for f in converted_geojson['features']
        ]
        expected_wheelchairs = [None] * 6
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [
            f['properties']['motor_vehicles']
            for f in converted_geojson['features']
        ]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)
예제 #22
0
    def test_segments_conversion_Portland(self):
        ''' Test overall segments conversion.
        '''
        path = unzip(join(self.tmp, 'lake-man-Portland.zip'))
        geojson = transformers.shapefile2geojson(join(self.tmp, path))

        m, converted_geojson = transformers.segments_transform(geojson, None)
        self.assertEqual(len(m), 2)

        converted_ids = [
            f['properties']['id'] for f in converted_geojson['features']
        ]
        expected_ids = [
            f['properties']['TRAILID'] for f in geojson['features']
        ]
        self.assertEqual(converted_ids, expected_ids)

        converted_names = [
            f['properties']['name'] for f in converted_geojson['features']
        ]
        expected_names = [
            f['properties']['TRAILNAME'] for f in geojson['features']
        ]
        self.assertEqual(converted_names, expected_names)

        converted_foots = [
            f['properties']['foot'] for f in converted_geojson['features']
        ]
        expected_foots = ['yes' for f in geojson['features']]
        self.assertEqual(converted_foots, expected_foots)

        converted_bikes = [
            f['properties']['bicycle'] for f in converted_geojson['features']
        ]
        expected_bikes = ['yes' for f in geojson['features']]
        self.assertEqual(converted_bikes, expected_bikes)

        converted_horses = [
            f['properties']['horse'] for f in converted_geojson['features']
        ]
        expected_horses = [None for f in geojson['features']]
        self.assertEqual(converted_horses, expected_horses)

        converted_skis = [
            f['properties']['ski'] for f in converted_geojson['features']
        ]
        expected_skis = [None for f in geojson['features']]
        self.assertEqual(converted_skis, expected_skis)

        converted_wheelchairs = [
            f['properties']['wheelchair']
            for f in converted_geojson['features']
        ]
        expected_wheelchairs = [None for f in geojson['features']]
        self.assertEqual(converted_wheelchairs, expected_wheelchairs)

        converted_motor_vehicles = [
            f['properties']['motor_vehicles']
            for f in converted_geojson['features']
        ]
        expected_motor_vehicles = [None for f in geojson['features']]
        self.assertEqual(converted_motor_vehicles, expected_motor_vehicles)