Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ See [`docs/versioning.md`](docs/versioning.md) for what the numbers mean and

## Unreleased

### Added

- Places of the day can come from Panoramax: `scripts/curation/harvest_px.py`
harvests a batch in the same layout as `harvest.py`, and `maply-places`
takes a Panoramax picture's direction as its heading and links its page.
Mapillary serves no image in Ukraine, so the first Ukrainian places of the
day, Kyiv and Kharkiv, come this way. Kharkiv itself is now inside the
curation's Ukrainian zone.

## v0.1.0-beta.1 - 2026-11-23

For the operator: this release applies migrations 031 and 032. Pull the image
Expand Down
11 changes: 10 additions & 1 deletion cmd/maply-places/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ type candidate struct {
IsPano bool `json:"is_pano"`
Author string `json:"author"`
License string `json:"license"`
// Heading is the direction the frame's centre faces, as the harvest
// found it. Mapillary's is asked again (see heading); a Panoramax
// batch's comes from the picture's view:azimuth and is used as is.
Heading *float64 `json:"heading"`
}

type reviews struct {
Expand Down Expand Up @@ -289,6 +293,8 @@ func (p *preparer) prepare(batchDir, ref string, c candidate, yaw *float64) (*pl
if pl.heading, err = p.heading(c, cacheBase+".heading.json"); err != nil {
return nil, err
}
} else {
pl.heading = c.Heading
}
if c.IsPano {
if pl.thumbYaw, err = p.thumbYaw(pl.key, cacheBase+".v1.yaw", yaw); err != nil {
Expand Down Expand Up @@ -557,8 +563,11 @@ func (pl *place) insert() string {
kind = "panorama"
}
sourceURL := ""
if pl.c.Source == "mapillary" {
switch pl.c.Source {
case "mapillary":
sourceURL = "https://www.mapillary.com/app/?pKey=" + pl.c.SourceID
case "panoramax":
sourceURL = "https://api.panoramax.xyz/#focus=pic&pic=" + pl.c.SourceID
}
heading := "NULL"
if pl.heading != nil {
Expand Down
4 changes: 3 additions & 1 deletion docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ The hood and handlebar at the bottom of a frame are no reason to drop a place. F

Difficulty by weekday: Monday is easy (a recognizable city), Friday is hard (remote areas), weekends are for "Where am I?" and themed rounds.

Russia, Ukraine and Belarus are in the game (decision of 22 October 2026). Excluded: the front line, Crimea and occupied territories, military sites, and frames with recognizable faces. Mapillary blurs faces and plates itself. Whether Panoramax does so has not been checked.
Russia, Ukraine and Belarus are in the game (decision of 22 October 2026). Excluded: the front line, Crimea and occupied territories, military sites, and frames with recognizable faces. Mapillary blurs faces and plates itself, and so does Panoramax.

Mapillary serves no image for any frame in Ukraine: its tiles list the frames, but the API gives none of them a picture (#45). Ukraine comes from Panoramax through `harvest_px.py`, which writes the same batch layout as `harvest.py`, with the picture's direction as the heading. Its 360° coverage there is thin: in November 2026 a scan of the country found one sequence in Kyiv, one picture in Brovary (at night) and one in Kharkiv. Kharkiv itself is in; the region around it is not.

### The free pool

Expand Down
119 changes: 119 additions & 0 deletions scripts/curation/harvest_px.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""Collect candidate places of the day from Panoramax.

Mapillary serves no image for any frame in Ukraine (see issue #45), so
Ukraine comes from Panoramax. This is harvest.py for Panoramax: the same
batch layout, so screen.py, choose.py, maply-places and faces.py read it as
they read a Mapillary batch.

For every region of the plan it asks Panoramax's search for the pictures
within the region's radius and keeps one: a 360° equirectangular panorama
captured in 2018 or later, with a known direction (view:azimuth, which
becomes the game's compass heading), in a part of a country pool.allowed()
lets in. Among those it takes the largest original, then the newest.

python -I harvest_px.py <out> <plan.json>

plan.json is a list of {"region": "Kyiv, UA", "lat": 50.41, "lon": 30.52,
"km": 3, "kind": "city"}; kind is the scene (city, town or nature). An
"id" names the picture a reviewer picked from the region's sequence; it
still has to pass the same checks.

Output: <out>/candidates.json and <out>/full/NNN.jpg, the panorama scaled to
4096 px wide, the width maply-places -sharpen gives Mapillary panoramas.
A region with nothing usable says why.
"""
import io, json, math, os, sys, time, urllib.request
from PIL import Image
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
os.environ.setdefault("MAPILLARY_TOKEN", "") # pool.py reads it at import; nothing here calls Mapillary
import pool

API = "https://api.panoramax.xyz/api/search"
UA = pool.UA
MIN_DATE = "2018"
WIDTH = 4096


def get(url, timeout=120):
for attempt in range(3):
try:
req = urllib.request.Request(url, headers={"User-Agent": UA})
return urllib.request.urlopen(req, timeout=timeout).read()
except Exception:
if attempt == 2:
raise
time.sleep(2 * (attempt + 1))


def usable(f, countries):
"""The reason a picture is passed over, or "" when it can be a candidate."""
p = f["properties"]
if (p.get("pers:interior_orientation") or {}).get("field_of_view") != 360:
return "not a 360° panorama"
if p.get("view:azimuth") is None:
return "no direction"
if (p.get("datetime") or "") < MIN_DATE:
return "before 2018"
lon, lat = f["geometry"]["coordinates"]
iso = pool.country_of(countries, lat, lon)
if not iso or not pool.allowed(iso, lat, lon):
return "in a part left out"
if "hd" not in f.get("assets", {}):
return "no original"
return ""


def main():
out, plan_path = sys.argv[1], sys.argv[2]
plan = json.load(open(plan_path))
countries = pool.load_countries()
os.makedirs(f"{out}/full", exist_ok=True)
cands = []
for r in plan:
d = r.get("km", 3) / 111
dl = d / math.cos(math.radians(r["lat"]))
bbox = f"{r['lon'] - dl},{r['lat'] - d},{r['lon'] + dl},{r['lat'] + d}"
feats = json.loads(get(f"{API}?bbox={bbox}&limit=500")).get("features", [])
why = {}
ok = []
for f in feats:
reason = usable(f, countries)
if reason:
why[reason] = why.get(reason, 0) + 1
else:
ok.append(f)
if not ok:
print(f"{r['region']}: nothing of {len(feats)} pictures: {why}", file=sys.stderr)
continue
ok.sort(key=lambda f: (f["properties"].get("original_file:size") or 0, f["properties"]["datetime"]), reverse=True)
if r.get("id"):
ok = [f for f in ok if f["id"] == r["id"]]
if not ok:
print(f"{r['region']}: picture {r['id']} is not usable or not within {r.get('km', 3)} km", file=sys.stderr)
continue
f = ok[0]
p = f["properties"]
n = len(cands) + 1
im = Image.open(io.BytesIO(get(f["assets"]["hd"]["href"]))).convert("RGB")
if im.width > WIDTH:
im = im.resize((WIDTH, WIDTH // 2), Image.LANCZOS)
im.save(f"{out}/full/{n:03d}.jpg", quality=92)
lon, lat = f["geometry"]["coordinates"]
producer = p.get("geovisio:producer") or next(
(x.get("name") for x in f.get("providers", []) if "producer" in x.get("roles", [])), "")
cands.append({
"n": n, "region": r["region"], "kind": r.get("kind", "city"),
"country": pool.country_of(countries, lat, lon),
"source": "panoramax", "source_id": f["id"],
"lat": lat, "lon": lon, "is_pano": True,
"captured_at": int(time.mktime(time.strptime(p["datetime"][:19], "%Y-%m-%dT%H:%M:%S")) * 1000),
"heading": float(p["view:azimuth"]),
"author": producer, "license": p.get("license") or "CC-BY-SA-4.0",
})
print(f"{n:03d} {r['region']}: {len(ok)} of {len(feats)} usable, took {f['id']} ({p['datetime'][:10]}, {im.width} px)", file=sys.stderr)
json.dump(cands, open(f"{out}/candidates.json", "w"), ensure_ascii=False, indent=1)
print(f"candidates: {len(cands)} of {len(plan)} regions", file=sys.stderr)


if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions scripts/curation/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def allowed(iso, lat, lon):
near them, disputed land, and far islands of another continent."""
if iso == "UA":
# West and centre only: no front line, no occupied land, no Crimea.
# Kharkiv itself is in (owner decision, 2026-11-23): the city, not
# the region around it, which runs up to the front and the border.
if abs(lat - 49.99) < 0.12 and abs(lon - 36.23) < 0.2:
return True
return (lon < 32.5 and lat > 47.0) or (lon < 31.0 and lat > 45.6)
if iso == "RU":
if lon < 40 and lat < 54: # the regions along the Ukrainian border
Expand Down