clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

feat/atlas-next-horizon
atlas / internal / generate / sources / arcgishub / national.go
national.go 2.7K
1package arcgishub23import (4 "strings"56 "github.com/FelineStateMachine/atlas/internal/generate/doc"7)89// The national enrichment. A state GIS viewer is usually a branded window onto10// federal datasets, so the generic move is to read the federal layers directly,11// by any city's own bounding box, and every curated city gains the same12// hydrography without a line of per-city curation.13//14// Every national layer labels quiet: the hydrology is the city's context, not15// its headline, and a map flooded with creek names is a map about the wrong16// thing.1718// slugSubwatersheds names the captured dataset the membership join reads, so19// the join and the table cannot drift apart on a spelling.20const slugSubwatersheds = "subwatersheds"2122// national is the enrichment every curated city receives: the watersheds its23// ground drains through, in two grains of the USGS hydrologic unit hierarchy,24// and the named streams and waterbodies that do the draining.25var national = []dataset{26 {27 Slug: "watersheds", Title: "Watersheds",28 Geometry: "polygon",29 ZoneOf: hucZone("huc10", "Watershed"),30 Label: "quiet",31 National: true,32 },33 {34 Slug: slugSubwatersheds, Title: "Subwatersheds",35 Geometry: "polygon",36 ZoneOf: hucZone("huc12", "Subwatershed"),37 Label: "quiet",38 National: true,39 },40 {41 Slug: "streams", Title: "Streams",42 Geometry: "line",43 ZoneOf: func(f fields) zoneKey {44 name := strings.TrimSpace(f["gnis_name"])45 if name == "" {46 return zoneKey{}47 }48 return zoneKey{Key: doc.Slugify(name), Title: name, Subtitle: "Stream"}49 },50 StrokeWidth: 10,51 Label: "quiet",52 National: true,53 Role: "water",54 },55 {56 Slug: "waterbodies", Title: "Waterbodies",57 Geometry: "polygon",58 // Every pond draws into the basemap; only the named ones earn a zone59 // anyone could search for.60 ZoneOf: func(f fields) zoneKey {61 name := strings.TrimSpace(f["GNIS_NAME"])62 if name == "" {63 return zoneKey{}64 }65 return zoneKey{Key: doc.Slugify(name), Title: name, Subtitle: "Waterbody"}66 },67 Label: "quiet",68 National: true,69 Role: "water",70 },71}7273// hucZone folds a watershed-boundary layer into one zone per hydrologic unit,74// titled by the unit's own name with the code kept legible beside the grain.75// The code is the bucket key: it is nationally unique and survives an upstream76// refresh, where the layer's object ids are load artifacts that churn.77func hucZone(field, grain string) func(fields) zoneKey {78 return func(f fields) zoneKey {79 code, name := strings.TrimSpace(f[field]), strings.TrimSpace(f["name"])80 if code == "" || name == "" {81 return zoneKey{}82 }83 return zoneKey{Key: code, Title: name, Subtitle: grain + " ยท HUC " + code}84 }85}