Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kubilus1 committed Oct 26, 2024
1 parent 4613a78 commit 4e353dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 4 additions & 4 deletions autoortho/autoortho_fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class AutoOrtho(Operations):

def __init__(self, root, cache_dir='.cache'):
log.info(f"ROOT: {root}")
self.dds_re = re.compile(".*/(\d+)[-_](\d+)[-_]((?!ZL)\S*)(\d{2}).dds")
self.ktx2_re = re.compile(".*/(\d+)[-_](\d+)[-_]((?!ZL)\D*)(\d+).ktx2")
self.dsf_re = re.compile(".*/[-+]\d+[-+]\d+.dsf")
self.ter_re = re.compile(".*/\d+[-_]\d+[-_](\D*)(\d+).ter")
self.dds_re = re.compile(r".*/(\d+)[-_](\d+)[-_]((?!ZL)\S*)(\d{2}).dds")
self.ktx2_re = re.compile(r".*/(\d+)[-_](\d+)[-_]((?!ZL)\D*)(\d+).ktx2")
self.dsf_re = re.compile(r".*/[-+]\d+[-+]\d+.dsf")
self.ter_re = re.compile(r".*/\d+[-_]\d+[-_](\D*)(\d+).ter")
self.root = os.path.abspath(root)
self.cache_dir = cache_dir

Expand Down
17 changes: 14 additions & 3 deletions autoortho/getortho.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,32 @@ def get(self, idx=0, session=requests):
# Hack override maptype
#maptype = "ARC"

MAPID = "s2cloudless-2020_3857"
MAPID = "s2cloudless-2023_3857"
MATRIXSET = "g"
MAPTYPES = {
"EOX": f"https://{server}.s2maps-tiles.eu/wmts/?layer={MAPID}&style=default&tilematrixset={MATRIXSET}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix={self.zoom}&TileCol={self.col}&TileRow={self.row}",
"EOX": f"https://{server}.s2maps-tiles.eu/wmts?layer={MAPID}&style=default&tilematrixset={MATRIXSET}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix={self.zoom}&TileCol={self.col}&TileRow={self.row}",
"BI": f"https://ecn.t{server_num}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=13816",
"GO2": f"http://khms{server_num}.google.com/kh/v=934?x={self.col}&y={self.row}&z={self.zoom}",
"ARC": f"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{self.zoom}/{self.row}/{self.col}",
"NAIP": f"http://naip.maptiles.arcgis.com/arcgis/rest/services/NAIP/MapServer/tile/{self.zoom}/{self.row}/{self.col}",
"USGS": f"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{self.zoom}/{self.row}/{self.col}",
"FIREFLY": f"https://fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{self.zoom}/{self.row}/{self.col}"
}


#if self.maptype.upper() == "EOX":
# session.headers.update({'referer': 'https://s2maps.eu/'})


self.url = MAPTYPES[self.maptype.upper()]
#log.debug(f"{self} getting {url}")
header = {
"user-agent": "curl/7.68.0"
}

if self.maptype.upper() == "EOX":
log.info("EOX DETECTED")
header.update({'referer': 'https://s2maps.eu/'})

time.sleep((self.attempt/10))
self.attempt += 1

Expand All @@ -288,6 +297,8 @@ def get(self, idx=0, session=requests):
resp = 0
try:
if use_requests:
# FIXME: Not the best way to set headers
session.headers = header
#resp = session.get(self.url, stream=True)
resp = session.get(self.url)
status_code = resp.status_code
Expand Down

0 comments on commit 4e353dc

Please sign in to comment.