@@ -60,6 +60,13 @@ def test_to_geojson(self, gdf):
60
60
]
61
61
})
62
62
63
+ def test_to_wkt (self , gdf ):
64
+ vc = DriverVectorCube (gdf )
65
+ assert vc .to_wkt () == (
66
+ ['POLYGON ((1 1, 3 1, 2 3, 1 1))' , 'POLYGON ((4 2, 5 4, 3 4, 4 2))' ],
67
+ 'EPSG:4326' ,
68
+ )
69
+
63
70
def test_with_cube_to_geojson (self , gdf ):
64
71
vc1 = DriverVectorCube (gdf )
65
72
dims , coords = vc1 .get_xarray_cube_basics ()
@@ -97,3 +104,75 @@ def test_with_cube_to_geojson(self, gdf):
97
104
}),
98
105
]
99
106
})
107
+
108
+ @pytest .mark .parametrize (["geojson" , "expected" ], [
109
+ (
110
+ {"type" : "Polygon" , "coordinates" : [[(1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 )]]},
111
+ [
112
+ DictSubSet ({
113
+ "type" : "Feature" ,
114
+ "geometry" : {"type" : "Polygon" , "coordinates" : (((1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 ),),)},
115
+ "properties" : {},
116
+ }),
117
+ ],
118
+ ),
119
+ (
120
+ {"type" : "MultiPolygon" , "coordinates" : [[[(1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 )]]]},
121
+ [
122
+ DictSubSet ({
123
+ "type" : "Feature" ,
124
+ "geometry" : {"type" : "MultiPolygon" , "coordinates" : [(((1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 ),),)]},
125
+ "properties" : {},
126
+ }),
127
+ ],
128
+ ),
129
+ (
130
+ {
131
+ "type" : "Feature" ,
132
+ "geometry" : {"type" : "MultiPolygon" , "coordinates" : [[[(1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 )]]]},
133
+ "properties" : {"id" : "12_3" },
134
+ },
135
+ [
136
+ DictSubSet ({
137
+ "type" : "Feature" ,
138
+ "geometry" : {"type" : "MultiPolygon" , "coordinates" : [(((1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 ),),)]},
139
+ "properties" : {"id" : "12_3" },
140
+ }),
141
+ ],
142
+ ),
143
+ (
144
+ {
145
+ "type" : "FeatureCollection" ,
146
+ "features" : [
147
+ {
148
+ "type" : "Feature" ,
149
+ "geometry" : {"type" : "Polygon" , "coordinates" : [[(1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 )]]},
150
+ "properties" : {"id" : 1 },
151
+ },
152
+ {
153
+ "type" : "Feature" ,
154
+ "geometry" : {"type" : "MultiPolygon" , "coordinates" : [[[(1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 )]]]},
155
+ "properties" : {"id" : 2 },
156
+ },
157
+ ],
158
+ },
159
+ [
160
+ DictSubSet ({
161
+ "type" : "Feature" ,
162
+ "geometry" : {"type" : "Polygon" , "coordinates" : (((1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 ),),)},
163
+ "properties" : {"id" : 1 },
164
+ }),
165
+ DictSubSet ({
166
+ "type" : "Feature" ,
167
+ "geometry" : {"type" : "MultiPolygon" , "coordinates" : [(((1 , 1 ), (3 , 1 ), (2 , 3 ), (1 , 1 ),),)]},
168
+ "properties" : {"id" : 2 },
169
+ }),
170
+ ],
171
+ ),
172
+ ])
173
+ def test_from_geojson (self , geojson , expected ):
174
+ vc = DriverVectorCube .from_geojson (geojson )
175
+ assert vc .to_geojson () == DictSubSet ({
176
+ "type" : "FeatureCollection" ,
177
+ "features" : expected ,
178
+ })
0 commit comments