SourceMeta.coverage is constructed from all Sources whose metadata did not fail to parse:
@classmethod
@property
def coverage(cls) -> GeoSeries:
coverages: list[GeoSeries] = []
for source in cls.catalog.values():
try:
axis = pd.Index([source.name] * len(source.coverage), name='source')
coverage = (
source.coverage
.set_crs('epsg:4326')
.set_axis(axis)
)
except Exception as e:
logger.error(
f'Could not get coverage for {source.name}, skipping:\n'
f'{e}'
)
else:
coverages.append(coverage)
coverage = pd.concat(coverages)
cls.coverage = coverage
return coverage
and matches for a location are determined by the Sources in coverage which overlap the location's georeferenced bbox, and contain the Source's keyword in the reversed georeferenced address:
coverage: GeoSeries = SourceMeta.coverage
index = set(coverage.index)
loc = [
source.name
for source in cls.catalog.values() if
source.name in index
and source.keyword.casefold() in display_name
]
matches = matches.loc[loc]
The issue was in this block of code, loc wasn't correctly determined
briefly tested with the main clause test:
if __name__ == '__main__':
from tile2net import Raster
# when testing, comment out super().
assert Raster(location='New Brunswick, New Jersey').source == 'nj'
assert Raster(location='New York City').source == 'nyc'
assert Raster(location='New York').source in ('nyc', 'ny')
assert Raster(location='Massachusetts').source == 'ma'
assert Raster(location='King County, Washington').source == 'king'
assert Raster(location='Washington, DC', zoom=19).source == 'dc'
assert Raster(location='Los Angeles', zoom=19).source == 'la'
assert Raster(location='Jersey City', zoom=19).source == 'nj'
assert Raster(location='Hoboken', zoom=19).source == 'nj'
with an Exception artificially raised under LosAngeles:
# to test case where a source raises an error due to metadata failure
# other sources should still function
@class_attr
@property
def metadata(cls):
raise NotImplementedError
resolved issue #23 source.py
SourceMeta.coverage is constructed from all Sources whose metadata did not fail to parse:
and matches for a location are determined by the Sources in coverage which overlap the location's georeferenced bbox, and contain the Source's keyword in the reversed georeferenced address:
The issue was in this block of code,
loc
wasn't correctly determinedbriefly tested with the main clause test:
with an Exception artificially raised under
LosAngeles
: