Commit 4bb7dea
Fix: Add error handling for missing 'tiles' key in stac_tile response (#1282)
* Fix: Prevent titiler_endpoint from being overwritten in stac_tile
When stac_stats fails for Planetary Computer items, it was overwriting
the titiler_endpoint variable with a fallback string endpoint. This caused
the subsequent tile request to use the wrong endpoint path (/stac/ instead
of /item/), which expects different parameters and returns errors.
Changes:
1. Use a separate fallback_endpoint variable for stac_stats fallback
2. Add error handling to check for 'tiles' key before accessing it
3. Provide informative error messages based on API response type
Fixes opengeos/geoai#468
* Fix stac_bounds to handle GeoJSON Feature format from Planetary Computer
The Planetary Computer /item/info.geojson endpoint returns a GeoJSON Feature
with bounds nested in properties.{asset}.bounds, not a top-level bbox field.
This fix:
- Checks for bounds in properties.{asset}.bounds format
- Falls back to calculating bbox from geometry coordinates
- Ensures map zooms to correct location when visualizing NAIP items
Fixes opengeos/geoai#468
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Silently handle stac_stats failures instead of printing errors
When stac_stats fails (e.g., for Planetary Computer items that don't
support the statistics endpoint), the errors were being printed to stdout,
cluttering the output.
This fix:
- Wraps both primary and fallback stac_stats calls in try-except
- Silently continues without rescaling if stats are unavailable
- Removes the print(stats['detail']) statement
- Sets stats=None if both attempts fail
The tile visualization works fine without stats - they're only used for
automatic rescaling, which isn't critical for display.
Fixes opengeos/geoai#468
* Fix check_titiler_endpoint to handle endpoint objects properly
The real bug: check_titiler_endpoint was calling .lower() on the endpoint
parameter without checking if it was a string first. When stac_stats was
called with a PlanetaryComputerEndpoint object, it would pass it through
check_titiler_endpoint again, which would fail trying to call .lower() on
the object.
This caused stac_stats to fail and fall back to the giswqs endpoint, which
then printed error messages.
The fix:
- Check isinstance(titiler_endpoint, str) before calling .lower()
- Allow endpoint objects to pass through unchanged
- Now stac_stats works correctly with Planetary Computer from the start
- No more fallback needed, no more error messages
- Stats are properly retrieved and used for automatic rescaling
This is the proper fix instead of just silencing errors.
Fixes opengeos/geoai#468
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 11ab00f commit 4bb7dea
1 file changed
Lines changed: 55 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
132 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
133 | 140 | | |
| 141 | + | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
| |||
706 | 714 | | |
707 | 715 | | |
708 | 716 | | |
709 | | - | |
| 717 | + | |
710 | 718 | | |
711 | 719 | | |
712 | 720 | | |
713 | 721 | | |
714 | | - | |
| 722 | + | |
715 | 723 | | |
716 | 724 | | |
717 | 725 | | |
| |||
732 | 740 | | |
733 | 741 | | |
734 | 742 | | |
735 | | - | |
736 | | - | |
737 | 743 | | |
738 | 744 | | |
739 | 745 | | |
| |||
850 | 856 | | |
851 | 857 | | |
852 | 858 | | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
853 | 879 | | |
854 | 880 | | |
855 | 881 | | |
| |||
915 | 941 | | |
916 | 942 | | |
917 | 943 | | |
918 | | - | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
919 | 967 | | |
920 | 968 | | |
921 | 969 | | |
| |||
0 commit comments