text stringlengths 0 1.47k |
|---|
parser.add_argument("--proxy", default=argparse.SUPPRESS, help=PROXY_HELP) |
args = ap.parse_args(_neg_coords(sys.argv[1:])) |
if args.cmd == "sample": |
bb = tuple(map(float, args.bbox.split(","))) |
items = sample(bb, args.n, args.spread, args.seed, [k for k in args.skip.split(",") if k], |
named_only=not args.include_unnamed, proxy=args.proxy) |
for it in items: |
it["heading"] = (it["heading"] + args.heading_offset) % 360 |
if not items: |
sys.exit("no panorama points found in the area (area too small, or no Baidu street view here)") |
pages = [items[k:k + 12] for k in range(0, len(items), 12)] |
for pi, page in enumerate(pages): |
out = args.out if pi == 0 else args.out.with_name(f"{args.out.stem}_{pi + 1}{args.out.suffix}") |
sheet(page, out, cache=args.cache, proxy=args.proxy) |
print(out) |
idx = args.out.with_suffix(".index.json") |
idx.write_text(json.dumps(items, ensure_ascii=False, indent=1), encoding="utf-8") |
dates = sorted(str(i.get("date") or "")[:4] for i in items) |
print(f"{len(items)} points, capture years {dates[0]}–{dates[-1]}; index -> {idx}") |
return |
if args.cmd == "near": |
print(json.dumps(near(*map(float, args.latlon.split(",")), proxy=args.proxy), ensure_ascii=False)) |
elif args.cmd == "info": |
print(json.dumps(info(args.id, proxy=args.proxy), ensure_ascii=False, indent=1)) |
elif args.cmd == "scan": |
lat, lon = map(float, args.center.split(",")) |
res = scan(lat, lon, args.radius, args.step, proxy=args.proxy) |
args.out.write_text(json.dumps(res, ensure_ascii=False, indent=1), encoding="utf-8") |
print(f"{len(res)} panos -> {args.out}") |
elif args.cmd == "render": |
render(args.id, args.heading, args.pitch, args.fov, cache=args.cache, proxy=args.proxy).save(args.out) |
print(args.out) |
elif args.cmd == "sheet": |
if args.spec: |
items = json.loads(args.spec.read_text(encoding="utf-8")) |
else: |
if args.ids: |
need_pos = bool(args.within or args.toward) |
panos = {p: (info(p, proxy=args.proxy) if need_pos else None) for p in args.ids.split(",")} |
else: |
panos = json.loads(args.panos.read_text(encoding="utf-8")) |
if args.within: |
wl, wo, wr = map(float, args.within.split(",")) |
panos = {k: v for k, v in panos.items() if geo.distance((wl, wo), v["wgs"]) <= wr} |
if args.road: |
keys = [k for k in args.road.split(",") if k] |
panos = {k: v for k, v in panos.items() if any(x in ((v or {}).get("road") or "") for x in keys)} |
print(f"{len(panos)} points after --road filter") |
if args.spread: |
panos = thin(panos, args.spread) |
print(f"{len(panos)} points after --spread thinning") |
target = tuple(map(float, args.toward.split(","))) if args.toward else None |
items = [] |
for pid, v in panos.items(): |
if args.headings: |
for hd in (float(x) for x in args.headings.split(",")): |
items.append({"id": pid, "heading": hd % 360, "pitch": args.pitch, "fov": args.fov}) |
continue |
if target: |
hd = geo.bearing(tuple(v["wgs"]), target) + args.offset |
elif args.heading is not None: |
hd = args.heading |
else: |
ap.error("need --heading, --headings or --toward") |
items.append({"id": pid, "heading": hd % 360, "pitch": args.pitch, "fov": args.fov}) |
pages = [items[k:k + args.limit] for k in range(0, len(items), args.limit)] or [[]] |
for pi, page in enumerate(pages): |
# page 1 is written to --out itself, later pages get _2, _3…, to avoid "the file given by --out doesn't exist" |
out = args.out if pi == 0 else args.out.with_name(f"{args.out.stem}_{pi + 1}{args.out.suffix}") |
sheet(page, out, cache=args.cache, proxy=args.proxy) |
print(out) |
if len(pages) > 1: |
print(f"{len(pages)} pages: {args.out.name} plus {args.out.stem}_2 … _{len(pages)}, {args.limit} cells per page") |
if len(pages) > 1 or args.spec is None: |
idx = args.out.with_suffix(".index.json") |
idx.write_text(json.dumps(items, indent=1), encoding="utf-8") |
print(f"index -> {idx}") |
if __name__ == "__main__": |
# Chinese-locale Windows writes GBK by default: m², ñ make it crash, and the Chinese the agent reads comes out garbled |
sys.stdout.reconfigure(encoding="utf-8") |
sys.stderr.reconfigure(encoding="utf-8", errors="backslashreplace") |
main() |
# ===== file: skills/geo-sleuth/scripts/board.py ===== |
#!/usr/bin/env python3 |
# /// script |
# requires-python = ">=3.10" |
# dependencies = [] |
# /// |
"""Candidate board: every candidate, clue, piece of evidence and exclusion during geolocation is recorded here; ranking and the next step are computed by the script, not from memory. |
Rules are written as code, not left to self-discipline: |
- There is no "delete candidate" operation. Exclusion has exactly one entry point, `exclude`, and it must be given a computed file (output of geo.py frame, terrain.py and the like); |
the clue itself must be text that was read or a computed result; an inference can only down-weight (likelihood ratio clamped to 1/3–3). |
- Exclusion scope must be ≤ evidence scope: for candidates with extent (district/area/road), exclude must state with --covers which stretch the evidence covers; |
coverage under half is rejected. Looking at one point and excluding the whole road (one point standing in for the whole area) is a mistake that recurred twice. |
- Discrete candidates are never averaged to a midpoint: the main answer in report is always first place; the rest go to alternatives. |
- Population and fame are not evidence: the prior is uniform by default (optionally by area); there is no by-population option. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.