@@ -194,9 +194,9 @@ def test_items_properties_filter(app):
194194
195195def test_items_filter_cql_ids (app ):
196196 """Test /items endpoint with ids options."""
197- filter = {"op" : "=" , "args" : [{"property" : "ogc_fid" }, 1 ]}
197+ filter_query = {"op" : "=" , "args" : [{"property" : "ogc_fid" }, 1 ]}
198198 response = app .get (
199- f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter )} "
199+ f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter_query )} "
200200 )
201201 assert response .status_code == 200
202202 assert response .headers ["content-type" ] == "application/geo+json"
@@ -222,7 +222,7 @@ def test_items_filter_cql_ids(app):
222222 response = app .get (
223223 "/collections/public.landsat_wrs/items?filter-lang=cql2-text&filter=ogc_fid IN (1,2)"
224224 )
225- print ( response . content )
225+
226226 assert response .status_code == 200
227227 assert response .headers ["content-type" ] == "application/geo+json"
228228 body = response .json ()
@@ -237,9 +237,9 @@ def test_items_filter_cql_ids(app):
237237
238238def test_items_properties_filter_cql2 (app ):
239239 """Test /items endpoint with properties filter options."""
240- filter = {"op" : "=" , "args" : [{"property" : "path" }, 13 ]}
240+ filter_query = {"op" : "=" , "args" : [{"property" : "path" }, 13 ]}
241241 response = app .get (
242- f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter )} "
242+ f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter_query )} "
243243 )
244244 assert response .status_code == 200
245245 assert response .headers ["content-type" ] == "application/geo+json"
@@ -250,22 +250,22 @@ def test_items_properties_filter_cql2(app):
250250 assert body ["features" ][0 ]["properties" ]["path" ] == 13
251251
252252 # invalid type (str instead of int)
253- filter = {"op" : "=" , "args" : [{"property" : "path" }, "d" ]}
253+ filter_query = {"op" : "=" , "args" : [{"property" : "path" }, "d" ]}
254254 response = app .get (
255- f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter )} "
255+ f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter_query )} "
256256 )
257257 assert response .status_code == 500
258258 assert "integer is required" in response .json ()["detail" ]
259259
260- filter = {
260+ filter_query = {
261261 "op" : "and" ,
262262 "args" : [
263263 {"op" : "=" , "args" : [{"property" : "path" }, 13 ]},
264264 {"op" : "=" , "args" : [{"property" : "row" }, 10 ]},
265265 ],
266266 }
267267 response = app .get (
268- f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter )} "
268+ f"/collections/public.landsat_wrs/items?filter-lang=cql2-json&filter={ json .dumps (filter_query )} "
269269 )
270270 assert response .status_code == 200
271271 assert response .headers ["content-type" ] == "application/geo+json"
@@ -423,3 +423,63 @@ def test_items_datetime(app):
423423 )
424424 assert response .status_code == 422
425425 assert response .headers ["content-type" ] == "application/json"
426+
427+
428+ def test_items_geometry_return_options (app ):
429+ """Test /items endpoint with geometry return options."""
430+ response = app .get ("/collections/public.landsat_wrs/items?ids=1&geom-column=none" )
431+ assert response .status_code == 200
432+ assert response .headers ["content-type" ] == "application/geo+json"
433+ body = response .json ()
434+ assert len (body ["features" ]) == 1
435+ assert body ["numberMatched" ] == 1
436+ assert body ["numberReturned" ] == 1
437+ assert body ["features" ][0 ]["id" ] == "1"
438+ assert body ["features" ][0 ]["properties" ]["ogc_fid" ] == 1
439+ assert "geometry" not in body ["features" ][0 ]
440+
441+ response = app .get ("/collections/public.landsat_wrs/items?ids=1&bbox-only=true" )
442+ assert response .status_code == 200
443+ assert response .headers ["content-type" ] == "application/geo+json"
444+ body = response .json ()
445+ assert len (body ["features" ]) == 1
446+ assert body ["numberMatched" ] == 1
447+ assert body ["numberReturned" ] == 1
448+ assert body ["features" ][0 ]["id" ] == "1"
449+ assert body ["features" ][0 ]["properties" ]["ogc_fid" ] == 1
450+ assert body ["features" ][0 ]["geometry" ] == {
451+ "coordinates" : [
452+ [
453+ [- 22.2153 , 79.6888 ],
454+ [- 22.2153 , 81.8555 ],
455+ [- 8.97407 , 81.8555 ],
456+ [- 8.97407 , 79.6888 ],
457+ [- 22.2153 , 79.6888 ],
458+ ]
459+ ],
460+ "type" : "Polygon" ,
461+ }
462+
463+ response = app .get ("/collections/public.landsat_wrs/items?ids=1&simplify=.001" )
464+ assert response .status_code == 200
465+ assert response .headers ["content-type" ] == "application/geo+json"
466+ body = response .json ()
467+ assert len (body ["features" ]) == 1
468+ assert body ["numberMatched" ] == 1
469+ assert body ["numberReturned" ] == 1
470+ assert body ["features" ][0 ]["id" ] == "1"
471+ assert body ["features" ][0 ]["properties" ]["ogc_fid" ] == 1
472+ print (body ["features" ][0 ]["geometry" ])
473+ assert body ["features" ][0 ]["geometry" ] == {
474+ "coordinates" : [
475+ [
476+ [- 10.803 , 80.989 ],
477+ [- 8.974 , 80.342 ],
478+ [- 16.985 , 79.689 ],
479+ [- 22.215 , 81.092 ],
480+ [- 13.255 , 81.856 ],
481+ [- 10.803 , 80.989 ],
482+ ]
483+ ],
484+ "type" : "Polygon" ,
485+ }
0 commit comments