Spaces:
Runtime error
Runtime error
tiling
Browse files63 unmodified lines64656667686967686970717273747576777879808170717273747576777879808182838485868788899085 unmodified lines17617717817517918018118218318418518618718818919019119219319419519663 unmodified lines changed = 0 for p in glob.glob(os.path.join(dirpath, "*.geojson")): base = os.path.basename(p) nums = re.findall(r"-?\d+", base) # grab all integers anywhere # ensure we have exactly 5 integers if len(nums) < 5: nums = re.findall(r"-?\d+", base) if len(nums) >= 5: last5 = nums[-5:] target = "_".join(last5) + ".geojson" if target != base: dst = os.path.join(dirpath, target) # avoid accidental collisions if os.path.exists(dst): k = 1 root = "_".join(last5) while os.path.exists(os.path.join(dirpath, f"{root}__{k}.geojson")): k += 1 dst = os.path.join(dirpath, f"{root}__{k}.geojson") os.replace(p, dst) changed += 1 nums = (["0"] * (5 - len(nums))) + nums else: nums = nums[-5:] target = "_".join(nums) + ".geojson" if target != base: dst = os.path.join(dirpath, target) # avoid collisions if os.path.exists(dst): k = 1 root = "_".join(nums) while os.path.exists(os.path.join(dirpath, f"{root}__{k}.geojson")): k += 1 dst = os.path.join(dirpath, f"{root}__{k}.geojson") os.replace(p, dst) changed += 1 return changed
# configWEIGHT_DIR = os.getenv("DTR2_WEIGHT_DIR", "/data/weights") os.makedirs(WEIGHT_DIR, exist_ok=True) 85 unmodified lines preds_geo_dir = os.path.join(tiles_dir, "predictions_geo") os.makedirs(preds_geo_dir, exist_ok=True) project_to_geojson(tiles_dir, preds_dir, preds_geo_dir)
_sanitize_geojson_filenames(preds_geo_dir)
geos = glob.glob(os.path.join(preds_geo_dir, "*.geojson")) if not geos: return None, None, None, f"Error: No geojson files found in {preds_geo_dir}."
bad = [ os.path.basename(g) for g in geos if not re.fullmatch(r"-?\d+_-?\d+_-?\d+_-?\d+_-?\d+\.geojson", os.path.basename(g))] if bad: return None, None, None, "Error: Unexpected GeoJSON names (need 5 integers): " + ", ".join(bad)
# stitch + clean + filter crowns = stitch_crowns(preds_geo_dir, 1)app.py+28-16