text stringlengths 0 1.47k |
|---|
return MOS[y, x].astype(np.float32) |
AZ = np.arange(0, 360, 5.0) |
DIST = np.array([1500, 2000, 2500, 3000, 3500, 4000, 5000, 6000, 7000, 8000, 9000], dtype=float) |
NEAR = np.array([0, 300, 600, 900, 1200], dtype=float) |
res = [] |
for idx, (lat, lon, tags) in enumerate(pts): |
la, lo = terrain._dest_np(lat, lon, AZ, DIST) |
h = elev(la, lo) |
ln, lon_n = terrain._dest_np(lat, lon, AZ, NEAR) |
hn = elev(ln, lon_n) |
h0 = float(np.median(hn)) |
if hn.max() - hn.min() > 40: # not flat nearby |
continue |
ang = np.degrees(np.arctan2(h - h0 - 1.5, DIST[None, :])) |
hor = ang.max(axis=1) |
rel = (h - h0).max(axis=1) |
mt = hor >= 6.0 |
low = hor < 1.2 |
if not mt.any() or low.sum() < 6: |
continue |
# find a continuous flat-horizon run right next to the mountain |
best = 0 |
for i in range(72): |
if not mt[i]: |
continue |
for sgn in (-1, 1): |
j = (i + sgn) % 72 |
# allow a 1-cell transition |
k = 0 |
run = 0 |
while k < 20: |
jj = (i + sgn * (k + 1)) % 72 |
if low[jj]: |
run += 1 |
elif run == 0 and k < 2: |
pass |
else: |
break |
k += 1 |
best = max(best, run) |
if best < 6: |
continue |
i = int(np.argmax(hor)) |
res.append({"lat": round(lat, 5), "lon": round(lon, 5), "h0": round(h0), "max_ang": round(float(hor[i]), 1), |
"az": float(AZ[i]), "relief": round(float(rel[i])), "flat_run_deg": best * 5, |
"name": tags.get("name", ""), "hs": tags.get("highspeed", ""), "elec": tags.get("electrified", ""), |
"id": tags.get("id", tags.get("@id", ""))}) |
print("hits", len(res), file=sys.stderr) |
json.dump(res, open(sys.argv[2], "w"), ensure_ascii=False, indent=0) |
# ===== file: examples/rail-skyline-session/railgeom.py ===== |
# /// script |
# requires-python = ">=3.10" |
# dependencies = ["numpy"] |
# /// |
"""Round 3: filter camera positions by the bridge-line geometry inferred from the pier spacing in the frame. |
This is a case-specific script for episode 13; the three bridge-distance windows are hard-coded from estimates for that photo. |
Kept only as a reproduction record; not guaranteed to run on another photo. |
Inferred from the photo (f≈1281–1435 px, 32 m spans): the bridge line's perpendicular distance from the camera position is about 450–750 m, its nearest point about 30–45° left of frame center, |
the distance along the center sight line about 600–800 m, at the right edge about 0.9–1.4 km; the bridge line crosses the frame diagonally from near-left to far-right. |
For each stage-2 camera position (with its best heading H), take the bridge sample points within field of view [-27°,27°] and 300–2500 m, and check one by one: |
- nearest bridge point on the center sight line (±3°) at 550–900 m |
- bridge point at the left edge (-26°±3°) at 350–750 m |
- bridge point at the right edge (+22°±4°) at 800–1700 m |
""" |
import json, math, sys, glob |
import numpy as np |
gj = json.load(open("rail_bridges.geojson")) |
cell = {} |
for f in gj["features"]: |
if f["properties"].get("electrified") == "no": |
continue |
c = f["geometry"]["coordinates"] |
for (x1, y1), (x2, y2) in zip(c, c[1:]): |
d = math.hypot((x2 - x1) * 111320 * math.cos(math.radians(y1)), (y2 - y1) * 110540) |
n = max(1, int(d // 50)) |
for k in range(n + 1): |
la, lo = y1 + (y2 - y1) * k / n, x1 + (x2 - x1) * k / n |
cell.setdefault((int(la / 0.02), int(lo / 0.02)), []).append((la, lo)) |
def near(lat, lon): |
i, j = int(lat / 0.02), int(lon / 0.02) |
out = [] |
for di in (-2, -1, 0, 1, 2): |
for dj in (-2, -1, 0, 1, 2): |
out += cell.get((i + di, j + dj), []) |
return np.array(out) if out else np.zeros((0, 2)) |
recs = [] |
for f in sorted(glob.glob("f2_?.json")): |
recs += json.load(open(f)) |
out = [] |
for r in recs: |
if r["rms"] > 0.6 or r["flatpen"] > 0.15: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.