Exemplo n.º 1
0
    def test_format_feature(self):
        features = process.read_feature(self.ds_file_path)
        name, feature = features.next()

        assert feature is not None

        level = 1
        feature_json = json.loads(feature.ExportToJson())
        result = process.format_feature(feature, self.tolerance, level)

        assert result["properties"]["osm_id"] == feature_json["id"]
        assert result["properties"]["name"] == feature_json["properties"].get("name")
        assert result["properties"]["name_en"] == feature_json["properties"].get("name:en")
        assert result["properties"]["iso3166"] == feature_json["properties"].get("ISO3166-1")
        assert result["properties"]["admin_level"] == level

        assert result["properties"]["is_in_country"] is None
        assert result["properties"]["parent_id"] is None
        assert result["properties"]["is_simplified"] is None

        assert result["geometry"].ExportToJson() == feature.GetGeometryRef().ExportToJson()
        assert (
            result["simplified_geometry"].ExportToJson()
            == process.simplify_geom(feature, self.tolerance).ExportToJson()
        )
Exemplo n.º 2
0
    def test_format_feature(self):
        features = process.read_feature(self.ds_file_path)
        name, feature = features.next()

        assert feature is not None

        level = 1
        feature_json = json.loads(feature.ExportToJson())
        result = process.format_feature(feature, self.tolerance, level)

        assert result['properties']['osm_id'] == feature_json['id']
        assert result['properties']['name'] == feature_json['properties'].get(
            'name')
        assert result['properties']['name_en'] == feature_json[
            'properties'].get('name:en')
        assert result['properties']['iso3166'] == feature_json[
            'properties'].get('ISO3166-1')
        assert result['properties']['admin_level'] == level

        assert result['properties']['is_in_country'] is None
        assert result['properties']['parent_id'] is None
        assert result['properties']['is_simplified'] is None

        assert result['geometry'].ExportToJson() == feature.GetGeometryRef(
        ).ExportToJson()
        assert result['simplified_geometry'].ExportToJson(
        ) == process.simplify_geom(feature, self.tolerance).ExportToJson()
Exemplo n.º 3
0
    def test_simplify_geom(self):
        features = process.read_feature(self.ds_file_path_2)
        name, feature = features.next()

        assert feature is not None
        result = process.simplify_geom(feature, self.tolerance).ExportToJson()
        expected = feature.GetGeometryRef().SimplifyPreserveTopology(self.tolerance).ExportToJson()
        assert result == expected
Exemplo n.º 4
0
    def test_simplify_geom(self):
        features = process.read_feature(self.ds_file_path_2)
        name, feature = features.next()

        assert feature is not None
        result = process.simplify_geom(feature, self.tolerance).ExportToJson()
        expected = feature.GetGeometryRef().SimplifyPreserveTopology(
            self.tolerance).ExportToJson()
        assert result == expected