#!/usr/bin/env python3 """ Test script to verify shapefile overlay API returns correct bbox data """ import requests import json def test_shapefile_api(): """Test /api/overlay/shapefiles endpoint""" print("Testing /api/overlay/shapefiles endpoint...") try: response = requests.get('http://localhost:8000/api/overlay/shapefiles') if response.status_code == 200: data = response.json() print(f"\nāœ… API Response successful") print(f"Total shapefiles: {data.get('count', 0)}") if data.get('shapefiles'): print("\nšŸ“‹ Shapefile details:") for idx, shp in enumerate(data['shapefiles'], 1): print(f"\n{idx}. {shp.get('filename')}") print(f" Path: {shp.get('path')}") print(f" CRS: {shp.get('crs')}") print(f" Features: {shp.get('feature_count')}") print(f" Bbox: {shp.get('bbox')}") # Verify bbox format bbox = shp.get('bbox') if bbox and len(bbox) == 4: print(f" āœ… Bbox format valid: [minLon, minLat, maxLon, maxLat]") else: print(f" āŒ Bbox format invalid or missing!") else: print("\nāš ļø No shapefiles found") else: print(f"\nāŒ API returned status code: {response.status_code}") print(f"Response: {response.text}") except requests.exceptions.ConnectionError: print("\nāŒ Cannot connect to API server. Is it running on localhost:8000?") except Exception as e: print(f"\nāŒ Error: {e}") if __name__ == "__main__": test_shapefile_api()