mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Name the Local area, say what each News section needs, and credit its sources
Local reads the area at the view centre (`/outline?at=`) and asks the feed
for its reports (`at`): the area is outlined faintly on the globe and named
at the top of the section ("News from Kazakhstan"; within 500 km at sea).
A disputed area is named as itself. A read that a newer look replaced, or
one left behind by a switch to Conflicts, is dropped, and a server without
the area route is asked once.
A section read from a key the server lacks says which key it needs
(503 `no_key`), that the key was refused (`key_rejected`) or that its
daily allowance is spent (`key_quota`); the other section keeps reading.
Liveuamap and World News API join the key registry.
Cards name the service a report came through ("via GDELT Project"), and
Liveuamap and Natural Earth are credited once their data shows. Economy is
a category of its own. Disputed-area labels are smaller and show the name
only; outlines keep up to 300 parts.
This commit is contained in:
1 parent
fa736a7cd5
commit
edb5837ae5
27 files changed
+1343
-154
No files matched your search
@@ -291,14 +291,17 @@ function normalizeRing(ring) {
|
||||
}
|
||||
|
||||
/**
|
||||
* `/api/news/outline` → `{polygons, borders, disputed}`: the dissolved extent
|
||||
* (`{outer, holes}`), the national borders inside it (rings) and its disputed
|
||||
* areas, invalid parts dropped.
|
||||
* `/api/news/outline` → `{polygons, borders, disputed, area}`: the dissolved
|
||||
* extent (`{outer, holes}`), the national borders inside it (rings), its
|
||||
* disputed areas and, answering a point, the area named there (else null),
|
||||
* invalid parts dropped.
|
||||
*/
|
||||
export function normalizeOutlinePayload(payload) {
|
||||
const polygons = [];
|
||||
// Above every country's island count (Indonesia's is 208): an outline cut
|
||||
// short leaves islands outside the area, read again on each settle there.
|
||||
for (const raw of Array.isArray(payload?.polygons)
|
||||
? payload.polygons.slice(0, 200)
|
||||
? payload.polygons.slice(0, 300)
|
||||
: []) {
|
||||
const outer = normalizeRing(raw?.outer);
|
||||
if (!outer) continue;
|
||||
@@ -332,7 +335,23 @@ export function normalizeOutlinePayload(payload) {
|
||||
rings,
|
||||
});
|
||||
}
|
||||
return { polygons, borders, disputed };
|
||||
return { polygons, borders, disputed, area: outlineArea(payload?.area) };
|
||||
}
|
||||
|
||||
const AREA_KINDS = ['country', 'region', 'disputed'];
|
||||
function outlineArea(raw) {
|
||||
const key = text(raw?.key, 80);
|
||||
const name = text(raw?.name, 80);
|
||||
if (!key || !name) return null;
|
||||
return {
|
||||
key,
|
||||
name,
|
||||
kind: AREA_KINDS.includes(raw.kind) ? raw.kind : 'country',
|
||||
country:
|
||||
typeof raw.country === 'string' && /^[A-Z]{2}$/.test(raw.country)
|
||||
? raw.country
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
/** `/api/news/feed` → `{reports, nextBefore}`, or null without a report list. */
|
||||
|
||||
Reference in new issue
Block a user