wrolpi/modules/map/api.py

396 lines
17 KiB
Python
Raw Normal View History

A map is exported as a PDF: a 1:24,000 quadrangle, in layers, on a sheet, which says where it is (#1006) * The map can choose a 1:24,000 quadrangle to export (#971) The first part of exporting a map as a PDF: a grid of 7.5-minute quadrangles is drawn over the map, and a click chooses one. The grid is arithmetic, so it needs no data. Exporting itself is not here yet; the button is disabled. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A quadrangle of the map is exported as a PDF with a layer for each map layer (#972) * A quadrangle of the map is exported as a PDF with a layer for each map layer The browser draws the quadrangle off the screen at the size of a 1:24,000 sheet, once for each layer which is on, and the API puts the images in a PDF, each in a layer of its own which a reader can show and hide. A layer in which nothing is drawn is left out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The exported map's canvas keeps what was drawn, and an export's memory is bounded - The drawing buffer is asked for where this MapLibre reads it (canvasContextAttributes); as an option of the map it was ignored, so the canvas could be read after it was cleared. - Each layer's pixels are compressed in the PDF as the layer is added. PyMuPDF kept them uncompressed until the PDF was written: about 90 MB a layer of a quadrangle, all at once. - The pixels of all the layers together are limited, before any image is decoded. - pymupdf is imported when a PDF is made, not when the API starts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where on the Earth it is (#973) * An exported map says where on the Earth it is The PDF's page has a geospatial viewport (ISO 32000-2): the page is the map in Web Mercator, with the latitude and longitude of each corner. The corners are the edges of the picture the browser drew, read from the map which drew it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map whose edge is the antimeridian can be exported The map's arithmetic puts the east edge of the last quadrangle before the antimeridian a rounding error past 180 degrees, and the export was refused. An edge within 1e-8 of a degree of 180 is at 180 (it is not wrapped to -180); a map which is really across the antimeridian is still refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map is on a sheet: a margin, a grid, scale bars and notes (#974) * An exported map is on a sheet: a margin, a grid, scale bars and notes The map is put on a larger page with what a topographic map has around it: a title, the latitude and longitude of its corners and of ticks between them, scale bars (kilometers, miles, feet), and notes of the projection, the grid and where the map's data is from. Over the map is a 1,000 meter UTM grid, each line named in the margin. The grid and the margin are PDF layers of their own. The PDF says where the map is, not where the page is. The picker has a box to export the map alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The scale of a narrow map is written under its name, not over it A quadrangle near a pole is two inches wide, which is not room for its name and its scale on one line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where a compass points (#975) * An exported map says where a compass points The sheet has a diagram of the three norths (true, grid and magnetic) beside its scale bars, and a note of how far magnetic north is from true north on the day the map was made, and how fast it moves. The declination is from the World Magnetic Model 2025 (NOAA NCEI and the British Geological Survey; public domain), whose coefficient file is shipped: nothing is downloaded. The model is good until 2030; outside its years nothing is said of a compass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A corner of an exported map is not also a tick The edges of the picture the browser draws are a hair outside the quadrangle's, so the quadrangle's own edges were taken for ticks inside the map, and each was written over the coordinate of its corner. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A compass which passes due south has moved a little, not most of the way around Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map can be exported at 400 DPI (#976) The picker has a choice of 300 or 400 DPI. A map is drawn less sharp than was asked for, rather than refused, when it would be more pixels than the API makes a PDF of: a quadrangle near the equator, or one with many layers on. The picker says so while it draws. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported quadrangle goes by the name the USGS gives it (#977) * An exported quadrangle goes by the name the USGS gives it The picker says what the chosen quadrangle is called, and the sheet's title, the PDF's title and the file's name have it. Where the USGS has no name, which is most of the world, a quadrangle goes by where it is, as before. The names are an index of the 65,600 7.5 minute quadrangles of The National Map (U.S. Geological Survey; public domain), which is shipped: nothing is downloaded. In Alaska a USGS quadrangle is wider than 7.5 minutes, so a quadrangle of the picker's grid there is "Part of" the one which has its middle. The places the tests of the map export are of are changed for others. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An area half of which is the last quadrangle of the land is a part of it The middle of such an area is on the quadrangle's east or north edge, with no quadrangle beyond it, and it was given no name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The PDF of a map is made by a Job, which the browser watches (#978) * The PDF of a map is made by a Job, which the browser watches A PDF of a quadrangle is a minute or two of work on a Raspberry Pi 4, and the request which waited for it was cut off after a minute: only the smallest quadrangles could be exported there. Now the browser describes the map, sends the image of each layer in a request of its own, and starts a Job; it watches the Job, shows how far along it is, and fetches the PDF when the Job is done. Cancel stops the Job. The images are kept on disk until the PDF is made of them, and an export is removed when it is an hour old. The credits on the sheet are no longer cut off: an attribution which names many sources is each of them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A cancelled map export stops, and is removed - A cancelled Job is not over until the thread making the PDF has stopped, so the next Job does not start beside it; the work can also be stopped while the sheet is drawn and the PDF written. - DELETE /api/map/export/<id> stops an export at any step and removes what was sent; the browser calls it when the person exporting cancels, while layers are sent as well as while the PDF is made. - An export whose Job is waiting or running is not removed for being old; one whose Job was cancelled is removed at once. - Cancel while the map is drawn stops the drawing between two layers. - Exports are kept in a directory made for this user alone, which is refused when it is a link or is another user's; only what is an export there is removed. - A request for the finished PDF which is lost is made again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's areas and lines go under the map's labels, and its own labels over them (#979) An overlay was drawn whole over the basemap, so an area it filled covered the names of what is in it. Labels are now always on top: the areas, lines and pictures of every overlay are under the basemap's labels, and the text, icons and points of every overlay are over them. It is so in the map, the standalone viewer, and an exported PDF, where an overlay with both is two layers ("Towers" and "Towers (labels)"). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's ground is over the ground of every basemap file (#980) * An overlay's ground is over the ground of every basemap file On a map of several basemap files, the ground of an overlay was put before the first label of the first file, which is under the land, water and roads of every file after it: an overlay's areas and lines were hidden, and in an exported PDF its layer was just above the background. It goes where the basemap's labels begin: the first of the labels which are over all of the basemap's ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The labels of every basemap file are over the ground of every file A map of several basemap files was their layers one file after another, so only the labels of the last file were on top: the labels of the others were under the land, water and roads of the files after them, and under the ground of an overlay. Both viewers now draw the ground of every file and then the labels of every file. The contour lines are drawn after the basemap's labels and are not of the basemap: an overlay's ground goes under the basemap's labels, not under the contours instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Contours are drawn from as deep as the terrain file goes (#981) The map read a terrain file to zoom 8, which is how deep the terrain WROLPi offers goes, however deep the file was. It now reads a file as deep as the file says it goes, in both viewers, and draws finer contour lines from a deeper file: every 40 feet (or 20 meters) from zoom 11, as a 1:24,000 sheet has. A file which goes to zoom 8 is drawn as it was. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map names its small roads (#982) * An exported map names its small roads A quadrangle is drawn at about zoom 13. The basemap's style names small roads from zoom 15, and its tiles have no names for them below zoom 14, so the streets of a town were printed as lines with no names. Before the map is drawn, the tiles of zoom 14 which the quadrangle is in are read, and the roads in them which have a name are given to the export map as a source of its own. The layer which names small roads draws from that source, as its style says to. At the scale of a sheet most streets are shorter than their names, and a map writes a name along a line only where the line is longer. Such a road is named over its middle, turned as the road goes; a road in pieces is named once. A source whose tiles can not be read is exported as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The names of small roads are placed by the export, at every latitude A quadrangle nearer the equator is drawn at a little over zoom 14, where the names were not read and the style still kept them for zoom 15: such a map had no names of small roads. They are now read wherever a layer would not name roads. Every name of a small road is now a point: over the middle of its road, turned as the road goes under it, again every 400 pixels of a long road. Before, a road long enough was left for the map to name along its line, which the map often does not (the line bends, or is in pieces), and a short piece beside it was named too. One place decides where a road is named, so a road in pieces is named once, and a piece of another kind of road does not take the name. Reading the names can be cancelled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a bar of meters, its norths in mils, and how far apart its contour lines are (#983) Under the map are bars of kilometers, meters, miles and feet. How far the grid's north and a compass's north are from true north is written in mils as well as in degrees, in the diagram and in the notes: a compass may be marked in either. A map which is exported with its contour lines says how far apart they are (CONTOUR INTERVAL 40 FEET), under the bars. The browser knows: it is the interval of the tiles the lines are made for at the zoom of the sheet, in the unit the map measures in. It says so with the sheet, and what is not an interval is not written. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet says what the quadrangles around it are called (#984) * A sheet says what the quadrangles around it are called Under the scale bars is a diagram of nine squares, the map the middle one, and beside it what the USGS calls each of the eight around it: the sheets to print to carry on off the edge of this one. The names are from the index of quadrangles which names the sheet itself. A quadrangle with no name (out to sea, or over a border) has no number; a map of where the USGS names nothing, and a map too narrow for the diagram, go without. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A sheet is never beside itself Where a quadrangle of the USGS is wider than the map (Alaska), the area the size of the map to its east or west is often more of the quadrangle the map is in, and the diagram named the sheet as its own neighbor. The quadrangle on a side is now the next one which is not the map's own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a legend of the lines of its map (#985) * A sheet has a legend of the lines of its map Under the scale bars is what each kind of line of the map is: highway, major road, minor road, path, railway, boundary, contour and index contour, each a piece of the line as the map draws it, on the color of the map's land. The map's style says how a line is drawn at each zoom, and a sheet is drawn at one. The browser, which has the style, says what each line's color, width, dashes and edges are at that zoom; the API draws them. A line is in the legend when its layer is exported and draws something at that zoom. What the browser sends is made into lines before it is kept: what is not a line is left out, and the map is exported. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A legend has no line too thin to see, and no name longer than its room A style brings a line in from nothing as the map is zoomed in: a path is a few hundredths of a point wide on a quadrangle near the equator. It was in the legend, drawn several times wider than on the map. A line under a tenth of a point is now left out, by the browser and by the API. What a line is called is cut to the room beside its line, as the name of an adjoining quadrangle is. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Fixes to the map PDF export: wrong neighbors, leftover exports, exports which outlive the map (#989) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks (#990) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks A layer of the PDF was one image, drawn where the topmost of its layers is. The parks of Land Cover are under the water on the map and its piers are over it, so all of Land Cover was drawn over the water: a lake in a park, or among houses, was not on the PDF. A second basemap file put its water over the first's buildings. A layer is now as many images as it must be, each where it is on the map, in one layer of the PDF: a part which fills an area stays where it is, and a part which is only lines is drawn with the next. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map file which is of somewhere else is not drawn when a map is exported Each basemap file is several images of an exported map, and most files of a library are of other places: each was an image of nothing, counted against how many images an export may be and how sharp it may be. A file whose own edges are outside the quadrangle is now left out before the layers are counted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its streams (#991) A basemap draws streams from zoom 14, and service roads and taxiways from 13. A quadrangle is drawn a little short of that (zoom 13.8 at 40 degrees, 13.2 at 61), from tiles which have them: none were on the PDF. What is drawn from a zoom no deeper than a quadrangle's detail is drawn. Names are left as they are. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An export which is cancelled stops at once, in the middle of a request (#993) * An export which is cancelled stops at once, in the middle of a request An export was stopped between two requests. The image of a layer is tens of megabytes, which is a long request on a slow connection, and a request to a server which has stopped answering never ends: the export said it was stopping until then. Cancel, and leaving the map, now end the request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The requests an export makes after its layers are sent are seen to be stopped too Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map is exported as it is printed: on white, in dark lines (#996) * A map is exported as it is printed: on white, in dark lines The light and dark maps are made for a screen. On paper their roads are white on pale gray and their streams half a pixel of pale blue. The printed map is a third look, of the map's own: white ground, dark road edges and names, blue streams wide enough to see, paths drawn, brown contours. It is what a map is exported in unless Light or Dark is chosen where the quadrangle is, and the choice is remembered in the browser. While a quadrangle is chosen the map is shown in the look it will be exported in. The light and dark maps are as they were. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * Changing the look of the map does not move it What is done when a new style is in place was asked for after the style was set. A style which only differs from the one the map has is in place before that, so it was done at the next change of style instead, with where the map had been at this one: the map went back there when a quadrangle was chosen, and again when it was not. It is asked for first, and the map is not moved at all. An export no longer waits for the map to be still, which it need not and which nothing ended. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The colors of the printed map are chosen where its layers are (#997) * The colors of the printed map are chosen where its layers are While a quadrangle is chosen and the map is shown as it is printed, each layer of the layer control has its color beside it, to be changed: one for most, three for the land (what grows, what was built, sand and ice) and two for names (the name, and what is around it). A basemap has several colors where one is chosen, which are shades of it. The edge of a road stays dark. What is chosen is remembered in the browser, and can be put back. The map on the screen is as it was. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A ramp on a bridge is the color of a major road, as it is off one A basemap draws a ramp on a bridge in the color of a minor road on a bridge: on the printed map it was white where the rest of the ramp is yellow, and followed the color chosen for minor roads. What puts the colors back is a button, which a keyboard reaches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A layer with nothing in it does not make an exported map less sharp (#1001) * A layer with nothing in it does not make an exported map less sharp How sharp a map may be depends on how many images it is, and every group of layers was counted: a basemap file with no runway, highway or boundary in the quadrangle was images of nothing, drawn, sent, and counted against the rest. A map of 23 images asked for at 400 DPI was made at 330. The groups are now looked at first, on a small map, and only those with something in them are drawn, as sharp as that many may be. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An image which arrives after its export was removed is not kept, and one mil is a mil Stopping an export while an image was on its way left the image behind it, in a directory nothing would remove for an hour. An angle of one mil was "1 mils" on the sheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The map which is exported from is made as sharp as it is to be (#1002) * The map which is exported from is made as sharp as it is to be The groups of a map are looked at on a small map, which was then made larger to draw them. A browser lets a canvas be larger when it is made than it lets one be made larger afterwards: a quadrangle asked for at 400 DPI was 33 million pixels, 288 DPI at 40 degrees, less than before the groups were looked at first. The small map is now removed, and the map which is exported from is made in its place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A canvas the browser stopped drawing on is not a layer with nothing in it A canvas whose drawing was taken away by the browser reads as clear, and a group looked at then was left out of the PDF without a word: the export fails instead. An export stopped as the last group is looked at does not make the map it would have been drawn on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where it is in a projection Adobe Acrobat knows (#1003) * An exported map says where it is in a projection Adobe Acrobat knows The page was said to be in Web Mercator, which it is drawn in. Acrobat does not know Web Mercator, in the words of the standard or in Esri's: it took the page for a map, and put every place on it at 0, 0. The page is now said to be Mercator on the WGS 84 ellipsoid, which it reads, with the same corners. Between the corners the two differ by under three centimeters on the ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * How well a page is said to be where it is, is measured from what the PDF says The test of it measured two formulas of its own. It now reads the corners and the projection from the PDF and does a reader's sum with them. The few centimeters are of a quadrangle: a taller page is less well said, by the square of how tall it is, which the comment now says and a test measures. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The help says how a map is exported as a PDF (#1004) The help of the map is five pages, one of them the PDF export. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 17:22:21 -07:00
import asyncio
from http import HTTPStatus
from sanic import Request, response, Blueprint
from sanic_ext import validate
from sanic_ext.extensions.openapi import openapi
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007) * A fallout model, checked against six Nevada tests The local fallout of a surface burst lands where layered winds carry particles of every size from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC; the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's predictions of the same contours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A prototype fallout panel on the map Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one wind or in the winds aloft of one of the six Nevada tests. Nothing is saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout lands where it meets the ground A particle stops falling at the first level where it is at or below the ground under it, not at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The map panel reads the ground from the terrain files the user has downloaded; the Nevada tests are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout falls from the cloud's cap, skirt and stem The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt burst now draws a 1000 R/hr contour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Close-in fallout measured after three Nevada surface bursts Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10 predicted them, with each shot's winds. The deposition grid can look closely at part of the fallout, and measures hotlines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout rises with the cloud, and heavy particles drop out low All of the activity starts in the early fireball and rises with the cloud, whose base and top climb with the square root of time (SIMFIC). Each particle rises with the air less its own settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a light one rides to the top. A burst above the ground puts down less, by its scaled height. Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel offers the weapons in service today Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026 Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry for each published setting. Fission shares are not public; they are assumed as Glasstone and Dolan plan for, and the user may change them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's dropdowns open above it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A variable-yield weapon is named once, with each setting's yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel uses the forecast winds aloft WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels (about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places the map does not show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A nuclear mode on the map: targets, and fallout A radiation button under the print button turns nuclear mode on and off. In it, targets (likely detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin without one is a plain pin, as every pin was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets keep their weapon, and nuclear mode shows the fallout of all of them A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast winds aloft fetched most recently; a burst tried out from the map can be saved as a target. A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a pin's label and color may be left out of an update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * An improvised device is named once, with each yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout of many targets is calculated in seconds, and shown as it goes A particle size's settling speed is read from a table by altitude rather than solved again for every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms, through a message channel, which a browser does not hold back in a hidden tab as it does timers; it says how far it has got, and draws the fallout on flat ground while the terrain is read. A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets every target's weapon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout grid covers where fallout shows, not past the poles The faintest particles of a burst are carried thousands of km in two days; with many targets the grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid now covers the spots which can reach the faintest band drawn, the image's corners stay within Web Mercator's 85 degrees, and so does the area whose terrain is read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout across a continent is drawn where it lands The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and the southern part of the image was drawn far from its targets. Each image row now takes the grid row at its own latitude. A burst far from the first target keeps its plume as wide, east to west, as at its own latitude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Terrain across the antimeridian, and ground with no number, do not break the fallout Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic read past the tile's pixels; one sample with no number made every target's lowest ground NaN and every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map is left out of the grid rather than breaking it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Every target's weapon is set in one change Setting it target by target, eight at once, lost most of the changes: each request wrote the whole pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives every target the weapon in one change of the config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The every-target weapon picker starts empty and always applies It showed the first target's weapon, so choosing that weapon for all of them did nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout is carried by the winds where it is, region by region A field of forecasts on a grid over the targets replaces the one forecast for all of them. Each particle rises and falls through the wind at its place, height and hour, read between the surrounding grid points, hours and heights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The winds aloft are fetched as a Job, ninety places a minute The free forecast service allows 600 calls a minute and a place costs six, so a field of up to 540 points is fetched in paced batches by a Job, which the fallout panel follows, instead of inside one request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A small burst's hot fallout is kept on a grid over many, and the panel says what it shows - Each burst's narrow close-in fallout is also put on a fine grid, so the lethal zone of a small target is not averaged away in the cells kilometers wide of a grid over targets far apart. - The legend says the dose rate is as at one hour, with all the fallout down, and what R/hr is; the error quoted is the unscaled model's. - The TNA's yield is 150 kt: its source gives only an upper bound below 300. - Weapons show their fission share beside their yield. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout can be watched landing, hour by hour A timeline under the legend plays, or steps through, the 48 hours after the bursts: each hour shows only the fallout which has landed by then, at its dose rate then (t^-1.2 from H+1), on the same cells as the whole of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The map can show the total dose of someone outdoors, hour by hour A "Show" picker switches from the dose rate to the total dose (R) someone outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's arrival to the hour on the timeline, or over the first two weeks. Its bands say what each dose does to a person. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against the Army's fallout manuals - FM 3-3-1's worked decay and dose problems are tests. - FM 3-11.3's cloud and Zone I nomograms, read from their images, are a fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt, and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of modern weapons, which the test shots do not reach. - The legend says real fallout may decay faster or slower than usual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against two megaton bursts in the Pacific Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot fallout goes where it went and about as far. Castle Bravo (15 Mt), whose winds were measured only below its cloud: its fallout arrives when it did, and its hot fallout reaching a third as far is kept in view as a known gap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Winds are read from the right points at every spacing, and cover the landing - A field's points were filed by rounding (lat + 90) / spacing but looked up by flooring it: at 4 and 8 degrees, which do not divide 90, every point read half its neighbor's wind. Both now count whole spacings from the equator. - The forecast starts at midnight UTC, so two days could end before the fallout of a burst this hour was down; three are fetched (the same call weight), and the panel says when the last hour's winds are held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bravo's known gap is not its unmeasured upper winds Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees of the measured one but do not lengthen its hot contours; the fixture's caveat and the test's explanation said otherwise, and now say what was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rain takes fallout out of the air where it falls A falling particle in rain loses a share of its activity every step: fast inside the rain cloud ("rainout"), slower below it, by how hard it rains ("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none above it. What is taken out comes down where the particle was. The forecast now asks for relative humidity at 14 levels, and each hour's rain cloud is taken as HYSPLIT takes it: from the lowest level 80% humid to the first above it less than 60%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * With no forecast, the fallout of 30 past days of the month - wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis, the winds aloft of 30 days of each month (one from each year 1991-2020) over the whole world: a gzip file a month, about 4 MB, for the release download location. - WROLPi fetches the months it lacks once, while there is the Internet, each checked against a sha256 pinned in modules/map/climatology.py (none pinned until the files are published), and serves them to the panel. - The panel's "Past days of a month" wind runs the bursts in each day and shows on what share of the days each place had the chosen dose rate; it is chosen for us when there is no forecast, or it has run out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology's months are published, and their sha256 pinned Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology worker waits for the Internet and the drive on startup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Counting the past days says flat ground at once, not the forecast's terrain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout reuses each yield's paths, about 10 times faster On flat ground in a day's held winds, how each parcel rises with the cloud and falls does not depend on the wind, so it is worked out once per yield and kept for every burst and day. The rising cloud is carried by the winds over ground zero (it drifts about 10 km); the fall still reads the winds where the particle is. A field of one hour is read without its hours, and the nearest point to a cell past the field is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rising cloud reads the winds over ground zero from arrays, by level Each parcel's rise is kept as the levels of the column it passes through (steps in the same level as one) and their seconds, so a burst reads the column once and sums. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel shows a progress bar while it calculates At the top of the panel, filled as far as the bursts are done, or moving without a count until there is one. A calculation stopped by removing the last target no longer leaves the panel busy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout runs in Web Workers, with a Cancel button The days are spread over workers, one for each core but one (left for the page), at most 6, and at most 2 where the browser says it has 2 GB or less. A worker is given the next day as it finishes one, and sends back only the cells reached. Where workers cannot be made, or fail, the days are calculated on the page as before. The days are counted on cells as wide as the coarsest day's grid, so the count does not depend on which day finishes first. Cancel, beside the progress bar, stops a calculation (and its workers) at once; Calculate starts it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's bursts are spread over Web Workers too The workers now take any task: a past day, or a burst. The page and the workers build each burst's winds and terrain with the same functions (work.js), so the fallout is the same either way; the flat pass and the terrain pass each run on their own workers, and Cancel stops them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The bursts' grid is made in parts by the Web Workers The grid is a sum over the bursts' spots, sharpened by the most any burst raises a cell, so it is made in a fixed number of parts (a burst's spots in one) on one frame, and joined on the page. The page makes the same parts when there are no workers, so the grid is the same either way. The forecast's warnings (bursts outside the winds, rain) are no longer worked out again on every progress update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's hours are labeled once an hour, not on every progress update Writing each hour's label (toLocaleString) took most of the page's time while the workers calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent - Outside the forecast's field, the nearest point is looked for only among the points which can be nearest somewhere in the grid cell (kept for each cell); the same point as looking through them all. Longitudes are wrapped however far round the world a particle is carried. - The progress is shown at most ten times a second. - The workers are sent the forecast's arrays, not the forecast as fetched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel in steps: the targets, then the fallout hour by hour or in total Nuclear mode opens on the targets; nothing is calculated until the user goes on. The winds and terrain wait under Options, with what is used said beside it. The timeline runs from the first hour to two weeks, saying how much the fallout has weakened since H+1; the view of all the fallout as if landed at H+1 is gone. Going back and on again with nothing changed draws what was calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is a step of its own, between the targets and the fallout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel says it is an estimate; how it compares with the test bursts goes in the help Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets are tried out until saved; the saved ones are loaded first, and saved all at once Nuclear mode starts with no targets. Targets added are tried out, and the saved targets join them when the user loads them. Saving replaces the saved targets with the list, in one change, and is refused until they were loaded (or there are none), so none are lost unseen. A target can be taken out of the list. The burst tried out from the map's menu is gone: a target tried out does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins The pins are plain pins again. The targets have their own endpoints, and their own table on the Pins tab, where one can be deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table The commit before this one was missing these files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The weather is a subscription: a forecast around the saved targets, downloaded every day The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel starts. The Manage tab has a Weather section: turning it on or off, what it downloads, how its downloads went, and the forecast kept. Only the newest forecast is kept, and it covers four days. The wind step asks the user to turn the download on, and warns, there and beside the fallout, when the forecast runs out before the fallout is down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast service may take three minutes to answer, and a timeout says so A batch of four days' forecasts took 43 seconds, near the old 60-second limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's targets step has an Add a target button: the next click on the map places it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
from modules.map import climatology, export, export_job, lib, quads, schema, search, winds
from modules.map.nuclear import TargetsChanged, get_map_nuclear_config
from modules.map.pins import get_map_pins_config
A map is exported as a PDF: a 1:24,000 quadrangle, in layers, on a sheet, which says where it is (#1006) * The map can choose a 1:24,000 quadrangle to export (#971) The first part of exporting a map as a PDF: a grid of 7.5-minute quadrangles is drawn over the map, and a click chooses one. The grid is arithmetic, so it needs no data. Exporting itself is not here yet; the button is disabled. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A quadrangle of the map is exported as a PDF with a layer for each map layer (#972) * A quadrangle of the map is exported as a PDF with a layer for each map layer The browser draws the quadrangle off the screen at the size of a 1:24,000 sheet, once for each layer which is on, and the API puts the images in a PDF, each in a layer of its own which a reader can show and hide. A layer in which nothing is drawn is left out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The exported map's canvas keeps what was drawn, and an export's memory is bounded - The drawing buffer is asked for where this MapLibre reads it (canvasContextAttributes); as an option of the map it was ignored, so the canvas could be read after it was cleared. - Each layer's pixels are compressed in the PDF as the layer is added. PyMuPDF kept them uncompressed until the PDF was written: about 90 MB a layer of a quadrangle, all at once. - The pixels of all the layers together are limited, before any image is decoded. - pymupdf is imported when a PDF is made, not when the API starts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where on the Earth it is (#973) * An exported map says where on the Earth it is The PDF's page has a geospatial viewport (ISO 32000-2): the page is the map in Web Mercator, with the latitude and longitude of each corner. The corners are the edges of the picture the browser drew, read from the map which drew it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map whose edge is the antimeridian can be exported The map's arithmetic puts the east edge of the last quadrangle before the antimeridian a rounding error past 180 degrees, and the export was refused. An edge within 1e-8 of a degree of 180 is at 180 (it is not wrapped to -180); a map which is really across the antimeridian is still refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map is on a sheet: a margin, a grid, scale bars and notes (#974) * An exported map is on a sheet: a margin, a grid, scale bars and notes The map is put on a larger page with what a topographic map has around it: a title, the latitude and longitude of its corners and of ticks between them, scale bars (kilometers, miles, feet), and notes of the projection, the grid and where the map's data is from. Over the map is a 1,000 meter UTM grid, each line named in the margin. The grid and the margin are PDF layers of their own. The PDF says where the map is, not where the page is. The picker has a box to export the map alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The scale of a narrow map is written under its name, not over it A quadrangle near a pole is two inches wide, which is not room for its name and its scale on one line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where a compass points (#975) * An exported map says where a compass points The sheet has a diagram of the three norths (true, grid and magnetic) beside its scale bars, and a note of how far magnetic north is from true north on the day the map was made, and how fast it moves. The declination is from the World Magnetic Model 2025 (NOAA NCEI and the British Geological Survey; public domain), whose coefficient file is shipped: nothing is downloaded. The model is good until 2030; outside its years nothing is said of a compass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A corner of an exported map is not also a tick The edges of the picture the browser draws are a hair outside the quadrangle's, so the quadrangle's own edges were taken for ticks inside the map, and each was written over the coordinate of its corner. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A compass which passes due south has moved a little, not most of the way around Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map can be exported at 400 DPI (#976) The picker has a choice of 300 or 400 DPI. A map is drawn less sharp than was asked for, rather than refused, when it would be more pixels than the API makes a PDF of: a quadrangle near the equator, or one with many layers on. The picker says so while it draws. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported quadrangle goes by the name the USGS gives it (#977) * An exported quadrangle goes by the name the USGS gives it The picker says what the chosen quadrangle is called, and the sheet's title, the PDF's title and the file's name have it. Where the USGS has no name, which is most of the world, a quadrangle goes by where it is, as before. The names are an index of the 65,600 7.5 minute quadrangles of The National Map (U.S. Geological Survey; public domain), which is shipped: nothing is downloaded. In Alaska a USGS quadrangle is wider than 7.5 minutes, so a quadrangle of the picker's grid there is "Part of" the one which has its middle. The places the tests of the map export are of are changed for others. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An area half of which is the last quadrangle of the land is a part of it The middle of such an area is on the quadrangle's east or north edge, with no quadrangle beyond it, and it was given no name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The PDF of a map is made by a Job, which the browser watches (#978) * The PDF of a map is made by a Job, which the browser watches A PDF of a quadrangle is a minute or two of work on a Raspberry Pi 4, and the request which waited for it was cut off after a minute: only the smallest quadrangles could be exported there. Now the browser describes the map, sends the image of each layer in a request of its own, and starts a Job; it watches the Job, shows how far along it is, and fetches the PDF when the Job is done. Cancel stops the Job. The images are kept on disk until the PDF is made of them, and an export is removed when it is an hour old. The credits on the sheet are no longer cut off: an attribution which names many sources is each of them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A cancelled map export stops, and is removed - A cancelled Job is not over until the thread making the PDF has stopped, so the next Job does not start beside it; the work can also be stopped while the sheet is drawn and the PDF written. - DELETE /api/map/export/<id> stops an export at any step and removes what was sent; the browser calls it when the person exporting cancels, while layers are sent as well as while the PDF is made. - An export whose Job is waiting or running is not removed for being old; one whose Job was cancelled is removed at once. - Cancel while the map is drawn stops the drawing between two layers. - Exports are kept in a directory made for this user alone, which is refused when it is a link or is another user's; only what is an export there is removed. - A request for the finished PDF which is lost is made again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's areas and lines go under the map's labels, and its own labels over them (#979) An overlay was drawn whole over the basemap, so an area it filled covered the names of what is in it. Labels are now always on top: the areas, lines and pictures of every overlay are under the basemap's labels, and the text, icons and points of every overlay are over them. It is so in the map, the standalone viewer, and an exported PDF, where an overlay with both is two layers ("Towers" and "Towers (labels)"). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's ground is over the ground of every basemap file (#980) * An overlay's ground is over the ground of every basemap file On a map of several basemap files, the ground of an overlay was put before the first label of the first file, which is under the land, water and roads of every file after it: an overlay's areas and lines were hidden, and in an exported PDF its layer was just above the background. It goes where the basemap's labels begin: the first of the labels which are over all of the basemap's ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The labels of every basemap file are over the ground of every file A map of several basemap files was their layers one file after another, so only the labels of the last file were on top: the labels of the others were under the land, water and roads of the files after them, and under the ground of an overlay. Both viewers now draw the ground of every file and then the labels of every file. The contour lines are drawn after the basemap's labels and are not of the basemap: an overlay's ground goes under the basemap's labels, not under the contours instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Contours are drawn from as deep as the terrain file goes (#981) The map read a terrain file to zoom 8, which is how deep the terrain WROLPi offers goes, however deep the file was. It now reads a file as deep as the file says it goes, in both viewers, and draws finer contour lines from a deeper file: every 40 feet (or 20 meters) from zoom 11, as a 1:24,000 sheet has. A file which goes to zoom 8 is drawn as it was. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map names its small roads (#982) * An exported map names its small roads A quadrangle is drawn at about zoom 13. The basemap's style names small roads from zoom 15, and its tiles have no names for them below zoom 14, so the streets of a town were printed as lines with no names. Before the map is drawn, the tiles of zoom 14 which the quadrangle is in are read, and the roads in them which have a name are given to the export map as a source of its own. The layer which names small roads draws from that source, as its style says to. At the scale of a sheet most streets are shorter than their names, and a map writes a name along a line only where the line is longer. Such a road is named over its middle, turned as the road goes; a road in pieces is named once. A source whose tiles can not be read is exported as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The names of small roads are placed by the export, at every latitude A quadrangle nearer the equator is drawn at a little over zoom 14, where the names were not read and the style still kept them for zoom 15: such a map had no names of small roads. They are now read wherever a layer would not name roads. Every name of a small road is now a point: over the middle of its road, turned as the road goes under it, again every 400 pixels of a long road. Before, a road long enough was left for the map to name along its line, which the map often does not (the line bends, or is in pieces), and a short piece beside it was named too. One place decides where a road is named, so a road in pieces is named once, and a piece of another kind of road does not take the name. Reading the names can be cancelled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a bar of meters, its norths in mils, and how far apart its contour lines are (#983) Under the map are bars of kilometers, meters, miles and feet. How far the grid's north and a compass's north are from true north is written in mils as well as in degrees, in the diagram and in the notes: a compass may be marked in either. A map which is exported with its contour lines says how far apart they are (CONTOUR INTERVAL 40 FEET), under the bars. The browser knows: it is the interval of the tiles the lines are made for at the zoom of the sheet, in the unit the map measures in. It says so with the sheet, and what is not an interval is not written. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet says what the quadrangles around it are called (#984) * A sheet says what the quadrangles around it are called Under the scale bars is a diagram of nine squares, the map the middle one, and beside it what the USGS calls each of the eight around it: the sheets to print to carry on off the edge of this one. The names are from the index of quadrangles which names the sheet itself. A quadrangle with no name (out to sea, or over a border) has no number; a map of where the USGS names nothing, and a map too narrow for the diagram, go without. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A sheet is never beside itself Where a quadrangle of the USGS is wider than the map (Alaska), the area the size of the map to its east or west is often more of the quadrangle the map is in, and the diagram named the sheet as its own neighbor. The quadrangle on a side is now the next one which is not the map's own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a legend of the lines of its map (#985) * A sheet has a legend of the lines of its map Under the scale bars is what each kind of line of the map is: highway, major road, minor road, path, railway, boundary, contour and index contour, each a piece of the line as the map draws it, on the color of the map's land. The map's style says how a line is drawn at each zoom, and a sheet is drawn at one. The browser, which has the style, says what each line's color, width, dashes and edges are at that zoom; the API draws them. A line is in the legend when its layer is exported and draws something at that zoom. What the browser sends is made into lines before it is kept: what is not a line is left out, and the map is exported. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A legend has no line too thin to see, and no name longer than its room A style brings a line in from nothing as the map is zoomed in: a path is a few hundredths of a point wide on a quadrangle near the equator. It was in the legend, drawn several times wider than on the map. A line under a tenth of a point is now left out, by the browser and by the API. What a line is called is cut to the room beside its line, as the name of an adjoining quadrangle is. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Fixes to the map PDF export: wrong neighbors, leftover exports, exports which outlive the map (#989) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks (#990) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks A layer of the PDF was one image, drawn where the topmost of its layers is. The parks of Land Cover are under the water on the map and its piers are over it, so all of Land Cover was drawn over the water: a lake in a park, or among houses, was not on the PDF. A second basemap file put its water over the first's buildings. A layer is now as many images as it must be, each where it is on the map, in one layer of the PDF: a part which fills an area stays where it is, and a part which is only lines is drawn with the next. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map file which is of somewhere else is not drawn when a map is exported Each basemap file is several images of an exported map, and most files of a library are of other places: each was an image of nothing, counted against how many images an export may be and how sharp it may be. A file whose own edges are outside the quadrangle is now left out before the layers are counted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its streams (#991) A basemap draws streams from zoom 14, and service roads and taxiways from 13. A quadrangle is drawn a little short of that (zoom 13.8 at 40 degrees, 13.2 at 61), from tiles which have them: none were on the PDF. What is drawn from a zoom no deeper than a quadrangle's detail is drawn. Names are left as they are. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An export which is cancelled stops at once, in the middle of a request (#993) * An export which is cancelled stops at once, in the middle of a request An export was stopped between two requests. The image of a layer is tens of megabytes, which is a long request on a slow connection, and a request to a server which has stopped answering never ends: the export said it was stopping until then. Cancel, and leaving the map, now end the request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The requests an export makes after its layers are sent are seen to be stopped too Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map is exported as it is printed: on white, in dark lines (#996) * A map is exported as it is printed: on white, in dark lines The light and dark maps are made for a screen. On paper their roads are white on pale gray and their streams half a pixel of pale blue. The printed map is a third look, of the map's own: white ground, dark road edges and names, blue streams wide enough to see, paths drawn, brown contours. It is what a map is exported in unless Light or Dark is chosen where the quadrangle is, and the choice is remembered in the browser. While a quadrangle is chosen the map is shown in the look it will be exported in. The light and dark maps are as they were. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * Changing the look of the map does not move it What is done when a new style is in place was asked for after the style was set. A style which only differs from the one the map has is in place before that, so it was done at the next change of style instead, with where the map had been at this one: the map went back there when a quadrangle was chosen, and again when it was not. It is asked for first, and the map is not moved at all. An export no longer waits for the map to be still, which it need not and which nothing ended. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The colors of the printed map are chosen where its layers are (#997) * The colors of the printed map are chosen where its layers are While a quadrangle is chosen and the map is shown as it is printed, each layer of the layer control has its color beside it, to be changed: one for most, three for the land (what grows, what was built, sand and ice) and two for names (the name, and what is around it). A basemap has several colors where one is chosen, which are shades of it. The edge of a road stays dark. What is chosen is remembered in the browser, and can be put back. The map on the screen is as it was. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A ramp on a bridge is the color of a major road, as it is off one A basemap draws a ramp on a bridge in the color of a minor road on a bridge: on the printed map it was white where the rest of the ramp is yellow, and followed the color chosen for minor roads. What puts the colors back is a button, which a keyboard reaches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A layer with nothing in it does not make an exported map less sharp (#1001) * A layer with nothing in it does not make an exported map less sharp How sharp a map may be depends on how many images it is, and every group of layers was counted: a basemap file with no runway, highway or boundary in the quadrangle was images of nothing, drawn, sent, and counted against the rest. A map of 23 images asked for at 400 DPI was made at 330. The groups are now looked at first, on a small map, and only those with something in them are drawn, as sharp as that many may be. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An image which arrives after its export was removed is not kept, and one mil is a mil Stopping an export while an image was on its way left the image behind it, in a directory nothing would remove for an hour. An angle of one mil was "1 mils" on the sheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The map which is exported from is made as sharp as it is to be (#1002) * The map which is exported from is made as sharp as it is to be The groups of a map are looked at on a small map, which was then made larger to draw them. A browser lets a canvas be larger when it is made than it lets one be made larger afterwards: a quadrangle asked for at 400 DPI was 33 million pixels, 288 DPI at 40 degrees, less than before the groups were looked at first. The small map is now removed, and the map which is exported from is made in its place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A canvas the browser stopped drawing on is not a layer with nothing in it A canvas whose drawing was taken away by the browser reads as clear, and a group looked at then was left out of the PDF without a word: the export fails instead. An export stopped as the last group is looked at does not make the map it would have been drawn on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where it is in a projection Adobe Acrobat knows (#1003) * An exported map says where it is in a projection Adobe Acrobat knows The page was said to be in Web Mercator, which it is drawn in. Acrobat does not know Web Mercator, in the words of the standard or in Esri's: it took the page for a map, and put every place on it at 0, 0. The page is now said to be Mercator on the WGS 84 ellipsoid, which it reads, with the same corners. Between the corners the two differ by under three centimeters on the ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * How well a page is said to be where it is, is measured from what the PDF says The test of it measured two formulas of its own. It now reads the corners and the projection from the PDF and does a reader's sum with them. The few centimeters are of a quadrangle: a taller page is less well said, by the square of how tall it is, which the comment now says and a test measures. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The help says how a map is exported as a PDF (#1004) The help of the map is five pages, one of them the PDF export. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 17:22:21 -07:00
from modules.map.sheet import legend_as_sent
from wrolpi.api_utils import json_response
from wrolpi.common import wrol_mode_check
from wrolpi.events import Events
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
map_bp = Blueprint('Map', '/api/map')
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
@map_bp.get('/files')
@openapi.description('List available PMTiles map files')
def get_files(_: Request):
files = lib.get_pmtiles_files()
return json_response(dict(files=files), HTTPStatus.OK)
@map_bp.delete('/files/<filename:path>')
@openapi.description('Delete a PMTiles map file')
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
@wrol_mode_check
async def delete_file(_: Request, filename: str):
try:
deleted = lib.delete_pmtiles_file(filename)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
if deleted:
return response.empty()
return response.json({'error': 'File not found'}, HTTPStatus.NOT_FOUND)
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
@map_bp.post('/files/visible')
@openapi.description('Show a PMTiles map file on the map, or ignore it')
@validate(schema.MapFileVisibleRequest)
@wrol_mode_check
async def post_file_visible(_: Request, body: schema.MapFileVisibleRequest):
try:
found = lib.set_pmtiles_file_visible(body.map_path, body.visible)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
if found:
return response.empty()
return response.json({'error': 'File not found'}, HTTPStatus.NOT_FOUND)
@map_bp.get('/subscribe')
@openapi.description('Get map catalog and current subscriptions')
def get_subscriptions(request: Request):
catalog = lib.get_map_catalog()
subscriptions = lib.get_map_subscriptions(request.ctx.session)
return json_response(dict(catalog=catalog, subscriptions=subscriptions), HTTPStatus.OK)
Squashed commit of the following: commit 26bde0fb48d59a86c2fb9f53a7218d49f22d4860 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 13:25:56 2022 -0700 Using osm2pgsql append to preserve other imported maps. commit c6c52623eaf02e691b1e75dcf39c3a8334ead55a Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 8 08:20:38 2022 -0700 Using placeholder instead of loader when table is loading. commit 44fec6490e26603c88a98f6bc70fc18686e17f09 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:58:34 2022 -0700 Simplifying tableRow function. commit 11b8b57f1fa59556397620f3cad9a33a0237501d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:53:51 2022 -0700 Removing scientific humanFileSize. commit 0a09d0a6963afebed7f388aad71bbdd3151d2e9e Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:46:22 2022 -0700 Fixing active loader. commit 07f4deeac861351d7483ef57278eb2e0941e31fb Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:40:44 2022 -0700 Increasing recommended map file size. commit af3ac492c81f4c8f84563a448bc272ae9334d32d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:35:13 2022 -0700 Reworking logic order for simplicity. Fetching downloads on interval. commit 3d9d31fcec87ed02ced7f67c34907faa5a3b54e5 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 20:24:39 2022 -0700 Handling when pbf import status are loading. commit 3798961a48e7c9eb165ca4e4051f239dbb088d0c Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:53:50 2022 -0700 Fetching import status every 30 seconds. commit f7a8193b0955d14ead8090aa74ce3c5a681b57ec Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:33:17 2022 -0700 Stopping renderd during installation. commit 5bf050b59e0a6e391184596f5e6f0737dea1221d Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:26:59 2022 -0700 Removing duplciate serve. commit 892e3315eeeb5d2516996b901a32a73a66dae078 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:22:14 2022 -0700 Setting bash flags in sub-install script. commit d5d2acd2cd85e089c78aa85a27c5d966222a1347 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 19:20:19 2022 -0700 Moving bulk of installation script into separate script so the latest code will be used during initial installation. commit ab030d8af834a4a8772edd06df360c51e72fbb02 Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:40:34 2022 -0700 Removing mod_tile/ajt directory instead of entire contents of mod_tile. Showing import as relative to media directory. commit c05199db4ecf56f4d096051b58689457882af12a Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 18:39:59 2022 -0700 Remvoing marker from map. commit ba5df4cf62d61b55281277a6254836e973c766ae Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:57:41 2022 -0700 Creating import_map.sh script. commit 1a16e46130e775efe375adb22917ba12e44855cd Author: Roland <roland@learningselfreliance.com> Date: Mon Mar 7 11:11:01 2022 -0700 Increasing ram usage during import to avoid hanging import. commit 0f5ce1a9f806f1c0878dd804b04587b6340ffd16 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 19:19:47 2022 -0700 Increasing map_file.size size. commit eb6e01512af59fb4a18ab15643c7bc61f3d48e53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:55:55 2022 -0700 Copying leaflet js/css files into docker container and to Apache directory so they will be available offline. commit 5b687324e119f021673f42e8d079b83034b70d53 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:36:06 2022 -0700 Matching tab height on Map page. commit 8031786d672e18366e9a2eb2d7bdfcd8611d27f3 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:34:20 2022 -0700 Shrinking HelpPopup Icon. commit 5ea94488e43bbc5c414e61c9173a3cfa908c7104 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:31:30 2022 -0700 Testing if no PBFs are requested to be imported. commit c4e86be1faed78bd3af1f3487471c01a1958a433 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:18:48 2022 -0700 Using Icon instead of Button for HelpPopup. commit 51d94f6d85885803813544fea16a56372babaa82 Author: Roland <roland@learningselfreliance.com> Date: Sat Mar 5 18:07:03 2022 -0700 PBF files are sorted by the api. commit 40f3a7ff04a83db0153f64a88a37f1d56ce043aa Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 18:35:51 2022 -0700 Adding help popup. commit 1da8d9fa403ec2a3b3c16c11a3937de37c895a35 Author: Roland <roland@learningselfreliance.com> Date: Fri Mar 4 09:41:01 2022 -0700 Moving message up. Clearing cached tiles after import. commit 3192adf95192554c194c9e0a8aeb149822462682 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:37:13 2022 -0700 Removing osm2pgsql from api docker because it seems to be unsupported. commit 0e10522f3cdc7edd374c14f230bb2dbd68ab1a94 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:36:39 2022 -0700 Disabling import button for docker. Adding download instructions. commit e1d8f55d159fb4d4ef2ece859ef7cc1059885791 Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 21:14:55 2022 -0700 Map files can be imported on RPi. commit 3128530e09968430a71b27cd2e75a567f85a708b Author: Roland <roland@learningselfreliance.com> Date: Thu Mar 3 15:31:54 2022 -0700 Adding shm_size to increase size to render large map tiles. commit f3cf80fae0ce46f44ea9ac5033f68a32d0197ae3 Author: Roland <roland@learningselfreliance.com> Date: Wed Mar 2 10:39:18 2022 -0700 Can get status of map imports. commit 3b7bbce004cd55a5d89980c2c09124b72c450bc6 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 20:51:13 2022 -0700 Adding map link to 50x.html. Swapping links using hostname to make it easier on the user. commit a8b6b60fe182233f40c2f1ecd825636c3d37fd23 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:01:50 2022 -0700 Moving Inventory link to end. commit c5346b8dc2ff83262d6fd153130912809dfd7574 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:47 2022 -0700 Squashed commit of the following: commit 39f0b8f3fc049fffd140d551cd91d7d9dba6d416 Author: Roland <roland@learningselfreliance.com> Date: Tue Mar 1 12:00:13 2022 -0700 Starting map refresh function. commit 2fac9ddf07e378389ddd85ca972f33b3323d30ac Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:43:47 2022 -0700 Updating readme with map requirements. commit 8325e1ea89537128329e313ab4b5588f8809d1c9 Author: Roland <roland@learningselfreliance.com> Date: Mon Feb 28 16:05:35 2022 -0700 Fixing order of map db init scripts. Creating index.html to display map. Using :8084 index file to display the map. commit 8f81539dd9d25fc26607f472c156d41ddcfc11f5 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 19:17:14 2022 -0700 Installing apache2. commit c7aaef07f8291070aeaf5e7df553e34aca0719ec Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 18:41:07 2022 -0700 Always configure postgres extensions. Initialize gis with dc. commit aa725ed4b8ec46d17accebd96dd41508ea2d9caf Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 15:48:20 2022 -0700 Map is displayed as iframe. commit de9bb92dcaf44996e7727adce7774f01895ddf52 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:16:56 2022 -0700 Running script in openstreetmap directory. commit f277388095d2221aa6407643ab655f26dc349eb7 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 12:06:41 2022 -0700 Bumping version for map. commit afd4aaeffb2aced2dc5c1a8f94038885c8287265 Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:59:31 2022 -0700 Checking that the installation script is on an rpi. commit a799382ceac3c201fc01d41fd63e37607282831a Author: Roland <roland@learningselfreliance.com> Date: Sun Feb 27 11:49:21 2022 -0700 Only running mod_tile install once. commit 0b98bb19cd4d86c9630a863cab4eb46410d1c9d1 Author: Roland <roland@learningselfreliance.com> Date: Fri Feb 25 11:31:21 2022 -0700 Building out map install script. commit 7c799775c11df573fa6cd65451adea28c0832cb0 Author: Roland <roland@learningselfreliance.com> Date: Thu Feb 24 12:16:53 2022 -0700 Creating OSM installation script. commit d3b93a3ee97d1ae4a00b6a0423ed59ea8b897ccd Author: Roland <roland@learningselfreliance.com> Date: Tue Feb 22 15:39:04 2022 -0700 Removing unused map module.
2022-03-08 13:26:03 -07:00
@map_bp.post('/subscribe')
@openapi.description('Subscribe to a map region for automatic downloads')
@validate(schema.MapSubscribeRequest)
@wrol_mode_check
async def post_subscribe(request: Request, body: schema.MapSubscribeRequest):
try:
with request.ctx.db.write() as session:
await lib.subscribe(session, body.name, body.region)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
Events.send_created(f'Map subscription created for {body.name}')
return response.empty(HTTPStatus.CREATED)
@map_bp.delete('/subscribe/<region:str>')
@openapi.description('Unsubscribe from a map region')
@wrol_mode_check
async def delete_subscription(request: Request, region: str):
try:
with request.ctx.db.write() as session:
await lib.unsubscribe(session, region)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.NOT_FOUND)
return response.empty(HTTPStatus.NO_CONTENT)
@map_bp.get('/pins')
@openapi.description('Get all map pins')
def get_pins(_: Request):
pins = get_map_pins_config().pins
return json_response(dict(pins=pins), HTTPStatus.OK)
@map_bp.post('/pins')
@openapi.description('Add a map pin')
@validate(schema.MapPinRequest)
async def add_pin(_: Request, body: schema.MapPinRequest):
pin = get_map_pins_config().add_pin(body.lat, body.lon, body.label, body.color)
return json_response(dict(pin=pin), HTTPStatus.CREATED)
@map_bp.delete('/pins/<pin_id:int>')
@openapi.description('Delete a map pin by ID')
async def delete_pin(_: Request, pin_id: int):
if get_map_pins_config().delete_pin(pin_id):
return response.empty(HTTPStatus.NO_CONTENT)
return response.json({'error': 'Pin not found'}, HTTPStatus.NOT_FOUND)
@map_bp.put('/pins/<pin_id:int>')
@openapi.description('Update a map pin by ID')
@validate(schema.MapPinUpdateRequest)
async def update_pin(_: Request, pin_id: int, body: schema.MapPinUpdateRequest):
if get_map_pins_config().update_pin(pin_id, body.label, body.color):
return response.empty(HTTPStatus.NO_CONTENT)
return response.json({'error': 'Pin not found'}, HTTPStatus.NOT_FOUND)
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007) * A fallout model, checked against six Nevada tests The local fallout of a surface burst lands where layered winds carry particles of every size from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC; the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's predictions of the same contours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A prototype fallout panel on the map Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one wind or in the winds aloft of one of the six Nevada tests. Nothing is saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout lands where it meets the ground A particle stops falling at the first level where it is at or below the ground under it, not at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The map panel reads the ground from the terrain files the user has downloaded; the Nevada tests are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout falls from the cloud's cap, skirt and stem The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt burst now draws a 1000 R/hr contour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Close-in fallout measured after three Nevada surface bursts Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10 predicted them, with each shot's winds. The deposition grid can look closely at part of the fallout, and measures hotlines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout rises with the cloud, and heavy particles drop out low All of the activity starts in the early fireball and rises with the cloud, whose base and top climb with the square root of time (SIMFIC). Each particle rises with the air less its own settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a light one rides to the top. A burst above the ground puts down less, by its scaled height. Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel offers the weapons in service today Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026 Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry for each published setting. Fission shares are not public; they are assumed as Glasstone and Dolan plan for, and the user may change them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's dropdowns open above it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A variable-yield weapon is named once, with each setting's yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel uses the forecast winds aloft WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels (about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places the map does not show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A nuclear mode on the map: targets, and fallout A radiation button under the print button turns nuclear mode on and off. In it, targets (likely detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin without one is a plain pin, as every pin was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets keep their weapon, and nuclear mode shows the fallout of all of them A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast winds aloft fetched most recently; a burst tried out from the map can be saved as a target. A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a pin's label and color may be left out of an update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * An improvised device is named once, with each yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout of many targets is calculated in seconds, and shown as it goes A particle size's settling speed is read from a table by altitude rather than solved again for every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms, through a message channel, which a browser does not hold back in a hidden tab as it does timers; it says how far it has got, and draws the fallout on flat ground while the terrain is read. A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets every target's weapon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout grid covers where fallout shows, not past the poles The faintest particles of a burst are carried thousands of km in two days; with many targets the grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid now covers the spots which can reach the faintest band drawn, the image's corners stay within Web Mercator's 85 degrees, and so does the area whose terrain is read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout across a continent is drawn where it lands The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and the southern part of the image was drawn far from its targets. Each image row now takes the grid row at its own latitude. A burst far from the first target keeps its plume as wide, east to west, as at its own latitude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Terrain across the antimeridian, and ground with no number, do not break the fallout Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic read past the tile's pixels; one sample with no number made every target's lowest ground NaN and every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map is left out of the grid rather than breaking it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Every target's weapon is set in one change Setting it target by target, eight at once, lost most of the changes: each request wrote the whole pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives every target the weapon in one change of the config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The every-target weapon picker starts empty and always applies It showed the first target's weapon, so choosing that weapon for all of them did nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout is carried by the winds where it is, region by region A field of forecasts on a grid over the targets replaces the one forecast for all of them. Each particle rises and falls through the wind at its place, height and hour, read between the surrounding grid points, hours and heights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The winds aloft are fetched as a Job, ninety places a minute The free forecast service allows 600 calls a minute and a place costs six, so a field of up to 540 points is fetched in paced batches by a Job, which the fallout panel follows, instead of inside one request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A small burst's hot fallout is kept on a grid over many, and the panel says what it shows - Each burst's narrow close-in fallout is also put on a fine grid, so the lethal zone of a small target is not averaged away in the cells kilometers wide of a grid over targets far apart. - The legend says the dose rate is as at one hour, with all the fallout down, and what R/hr is; the error quoted is the unscaled model's. - The TNA's yield is 150 kt: its source gives only an upper bound below 300. - Weapons show their fission share beside their yield. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout can be watched landing, hour by hour A timeline under the legend plays, or steps through, the 48 hours after the bursts: each hour shows only the fallout which has landed by then, at its dose rate then (t^-1.2 from H+1), on the same cells as the whole of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The map can show the total dose of someone outdoors, hour by hour A "Show" picker switches from the dose rate to the total dose (R) someone outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's arrival to the hour on the timeline, or over the first two weeks. Its bands say what each dose does to a person. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against the Army's fallout manuals - FM 3-3-1's worked decay and dose problems are tests. - FM 3-11.3's cloud and Zone I nomograms, read from their images, are a fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt, and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of modern weapons, which the test shots do not reach. - The legend says real fallout may decay faster or slower than usual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against two megaton bursts in the Pacific Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot fallout goes where it went and about as far. Castle Bravo (15 Mt), whose winds were measured only below its cloud: its fallout arrives when it did, and its hot fallout reaching a third as far is kept in view as a known gap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Winds are read from the right points at every spacing, and cover the landing - A field's points were filed by rounding (lat + 90) / spacing but looked up by flooring it: at 4 and 8 degrees, which do not divide 90, every point read half its neighbor's wind. Both now count whole spacings from the equator. - The forecast starts at midnight UTC, so two days could end before the fallout of a burst this hour was down; three are fetched (the same call weight), and the panel says when the last hour's winds are held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bravo's known gap is not its unmeasured upper winds Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees of the measured one but do not lengthen its hot contours; the fixture's caveat and the test's explanation said otherwise, and now say what was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rain takes fallout out of the air where it falls A falling particle in rain loses a share of its activity every step: fast inside the rain cloud ("rainout"), slower below it, by how hard it rains ("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none above it. What is taken out comes down where the particle was. The forecast now asks for relative humidity at 14 levels, and each hour's rain cloud is taken as HYSPLIT takes it: from the lowest level 80% humid to the first above it less than 60%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * With no forecast, the fallout of 30 past days of the month - wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis, the winds aloft of 30 days of each month (one from each year 1991-2020) over the whole world: a gzip file a month, about 4 MB, for the release download location. - WROLPi fetches the months it lacks once, while there is the Internet, each checked against a sha256 pinned in modules/map/climatology.py (none pinned until the files are published), and serves them to the panel. - The panel's "Past days of a month" wind runs the bursts in each day and shows on what share of the days each place had the chosen dose rate; it is chosen for us when there is no forecast, or it has run out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology's months are published, and their sha256 pinned Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology worker waits for the Internet and the drive on startup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Counting the past days says flat ground at once, not the forecast's terrain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout reuses each yield's paths, about 10 times faster On flat ground in a day's held winds, how each parcel rises with the cloud and falls does not depend on the wind, so it is worked out once per yield and kept for every burst and day. The rising cloud is carried by the winds over ground zero (it drifts about 10 km); the fall still reads the winds where the particle is. A field of one hour is read without its hours, and the nearest point to a cell past the field is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rising cloud reads the winds over ground zero from arrays, by level Each parcel's rise is kept as the levels of the column it passes through (steps in the same level as one) and their seconds, so a burst reads the column once and sums. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel shows a progress bar while it calculates At the top of the panel, filled as far as the bursts are done, or moving without a count until there is one. A calculation stopped by removing the last target no longer leaves the panel busy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout runs in Web Workers, with a Cancel button The days are spread over workers, one for each core but one (left for the page), at most 6, and at most 2 where the browser says it has 2 GB or less. A worker is given the next day as it finishes one, and sends back only the cells reached. Where workers cannot be made, or fail, the days are calculated on the page as before. The days are counted on cells as wide as the coarsest day's grid, so the count does not depend on which day finishes first. Cancel, beside the progress bar, stops a calculation (and its workers) at once; Calculate starts it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's bursts are spread over Web Workers too The workers now take any task: a past day, or a burst. The page and the workers build each burst's winds and terrain with the same functions (work.js), so the fallout is the same either way; the flat pass and the terrain pass each run on their own workers, and Cancel stops them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The bursts' grid is made in parts by the Web Workers The grid is a sum over the bursts' spots, sharpened by the most any burst raises a cell, so it is made in a fixed number of parts (a burst's spots in one) on one frame, and joined on the page. The page makes the same parts when there are no workers, so the grid is the same either way. The forecast's warnings (bursts outside the winds, rain) are no longer worked out again on every progress update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's hours are labeled once an hour, not on every progress update Writing each hour's label (toLocaleString) took most of the page's time while the workers calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent - Outside the forecast's field, the nearest point is looked for only among the points which can be nearest somewhere in the grid cell (kept for each cell); the same point as looking through them all. Longitudes are wrapped however far round the world a particle is carried. - The progress is shown at most ten times a second. - The workers are sent the forecast's arrays, not the forecast as fetched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel in steps: the targets, then the fallout hour by hour or in total Nuclear mode opens on the targets; nothing is calculated until the user goes on. The winds and terrain wait under Options, with what is used said beside it. The timeline runs from the first hour to two weeks, saying how much the fallout has weakened since H+1; the view of all the fallout as if landed at H+1 is gone. Going back and on again with nothing changed draws what was calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is a step of its own, between the targets and the fallout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel says it is an estimate; how it compares with the test bursts goes in the help Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets are tried out until saved; the saved ones are loaded first, and saved all at once Nuclear mode starts with no targets. Targets added are tried out, and the saved targets join them when the user loads them. Saving replaces the saved targets with the list, in one change, and is refused until they were loaded (or there are none), so none are lost unseen. A target can be taken out of the list. The burst tried out from the map's menu is gone: a target tried out does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins The pins are plain pins again. The targets have their own endpoints, and their own table on the Pins tab, where one can be deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table The commit before this one was missing these files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The weather is a subscription: a forecast around the saved targets, downloaded every day The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel starts. The Manage tab has a Weather section: turning it on or off, what it downloads, how its downloads went, and the forecast kept. Only the newest forecast is kept, and it covers four days. The wind step asks the user to turn the download on, and warns, there and beside the fallout, when the forecast runs out before the fallout is down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast service may take three minutes to answer, and a timeout says so A batch of four days' forecasts took 43 seconds, near the old 60-second limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's targets step has an Add a target button: the next click on the map places it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
@map_bp.get('/nuclear/targets')
@openapi.description('Get the saved nuclear targets')
def get_targets(_: Request):
return json_response(dict(targets=get_map_nuclear_config().targets), HTTPStatus.OK)
@map_bp.put('/nuclear/targets')
@openapi.description('Save the nuclear targets: the ones given replace the saved ones, which must be those loaded')
@validate(schema.MapTargetsRequest)
async def put_targets(_: Request, body: schema.MapTargetsRequest):
try:
targets = get_map_nuclear_config().replace_targets(body.targets, body.loaded_ids)
except TargetsChanged as e:
return response.json({'error': str(e)}, HTTPStatus.CONFLICT)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
return json_response(dict(targets=targets), HTTPStatus.OK)
@map_bp.delete('/nuclear/targets/<target_id:int>')
@openapi.description('Delete a saved nuclear target by ID')
async def delete_target(_: Request, target_id: int):
if get_map_nuclear_config().delete_target(target_id):
return response.empty(HTTPStatus.NO_CONTENT)
return response.json({'error': 'Target not found'}, HTTPStatus.NOT_FOUND)
@map_bp.get('/search')
@openapi.description('Search for places in map search indexes')
async def search_places(request: Request):
q = request.args.get('q', '')
if not q or len(q.strip()) < 1:
return json_response({'error': 'Query parameter "q" is required'}, HTTPStatus.BAD_REQUEST)
try:
limit = int(request.args.get('limit', 12))
offset = int(request.args.get('offset', 0))
lat = float(request.args.get('lat')) if request.args.get('lat') is not None else None
lon = float(request.args.get('lon')) if request.args.get('lon') is not None else None
except (ValueError, TypeError):
return json_response({'error': 'Invalid query parameters'}, HTTPStatus.BAD_REQUEST)
data = search.search_places(q.strip(), limit=limit, offset=offset, lat=lat, lon=lon)
return json_response(data, HTTPStatus.OK)
@map_bp.get('/search/estimate')
@openapi.description('Get estimated count of map search results')
async def get_search_estimate(request: Request):
q = request.args.get('q', '')
if not q or len(q.strip()) < 1:
return json_response({'map_places': 0}, HTTPStatus.OK)
count = search.search_places_count(q.strip())
return json_response({'map_places': count}, HTTPStatus.OK)
@map_bp.get('/search/status')
@openapi.description('Get status of map search indexes')
async def get_search_status(_: Request):
status = search.get_search_status()
return json_response(status, HTTPStatus.OK)
@map_bp.post('/search/rebuild')
@openapi.description('Rebuild all map search indexes')
@wrol_mode_check
async def rebuild_search_indexes(_: Request):
started = search.rebuild_all_search_indexes()
if started:
return json_response({'message': 'Search index rebuild started'}, HTTPStatus.ACCEPTED)
return json_response({'error': 'No PMTiles files found'}, HTTPStatus.NOT_FOUND)
@map_bp.post('/search/rebuild/<filename:path>')
@openapi.description('Rebuild search index for a single PMTiles file')
@wrol_mode_check
async def rebuild_single_search_index(_: Request, filename: str):
try:
started = search.rebuild_search_index(filename)
except ValueError as e:
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
if started:
return json_response({'message': f'Search index rebuild started for {filename}'}, HTTPStatus.ACCEPTED)
return json_response({'error': 'File not found'}, HTTPStatus.NOT_FOUND)
A map is exported as a PDF: a 1:24,000 quadrangle, in layers, on a sheet, which says where it is (#1006) * The map can choose a 1:24,000 quadrangle to export (#971) The first part of exporting a map as a PDF: a grid of 7.5-minute quadrangles is drawn over the map, and a click chooses one. The grid is arithmetic, so it needs no data. Exporting itself is not here yet; the button is disabled. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A quadrangle of the map is exported as a PDF with a layer for each map layer (#972) * A quadrangle of the map is exported as a PDF with a layer for each map layer The browser draws the quadrangle off the screen at the size of a 1:24,000 sheet, once for each layer which is on, and the API puts the images in a PDF, each in a layer of its own which a reader can show and hide. A layer in which nothing is drawn is left out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The exported map's canvas keeps what was drawn, and an export's memory is bounded - The drawing buffer is asked for where this MapLibre reads it (canvasContextAttributes); as an option of the map it was ignored, so the canvas could be read after it was cleared. - Each layer's pixels are compressed in the PDF as the layer is added. PyMuPDF kept them uncompressed until the PDF was written: about 90 MB a layer of a quadrangle, all at once. - The pixels of all the layers together are limited, before any image is decoded. - pymupdf is imported when a PDF is made, not when the API starts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where on the Earth it is (#973) * An exported map says where on the Earth it is The PDF's page has a geospatial viewport (ISO 32000-2): the page is the map in Web Mercator, with the latitude and longitude of each corner. The corners are the edges of the picture the browser drew, read from the map which drew it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map whose edge is the antimeridian can be exported The map's arithmetic puts the east edge of the last quadrangle before the antimeridian a rounding error past 180 degrees, and the export was refused. An edge within 1e-8 of a degree of 180 is at 180 (it is not wrapped to -180); a map which is really across the antimeridian is still refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map is on a sheet: a margin, a grid, scale bars and notes (#974) * An exported map is on a sheet: a margin, a grid, scale bars and notes The map is put on a larger page with what a topographic map has around it: a title, the latitude and longitude of its corners and of ticks between them, scale bars (kilometers, miles, feet), and notes of the projection, the grid and where the map's data is from. Over the map is a 1,000 meter UTM grid, each line named in the margin. The grid and the margin are PDF layers of their own. The PDF says where the map is, not where the page is. The picker has a box to export the map alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The scale of a narrow map is written under its name, not over it A quadrangle near a pole is two inches wide, which is not room for its name and its scale on one line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where a compass points (#975) * An exported map says where a compass points The sheet has a diagram of the three norths (true, grid and magnetic) beside its scale bars, and a note of how far magnetic north is from true north on the day the map was made, and how fast it moves. The declination is from the World Magnetic Model 2025 (NOAA NCEI and the British Geological Survey; public domain), whose coefficient file is shipped: nothing is downloaded. The model is good until 2030; outside its years nothing is said of a compass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A corner of an exported map is not also a tick The edges of the picture the browser draws are a hair outside the quadrangle's, so the quadrangle's own edges were taken for ticks inside the map, and each was written over the coordinate of its corner. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A compass which passes due south has moved a little, not most of the way around Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map can be exported at 400 DPI (#976) The picker has a choice of 300 or 400 DPI. A map is drawn less sharp than was asked for, rather than refused, when it would be more pixels than the API makes a PDF of: a quadrangle near the equator, or one with many layers on. The picker says so while it draws. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported quadrangle goes by the name the USGS gives it (#977) * An exported quadrangle goes by the name the USGS gives it The picker says what the chosen quadrangle is called, and the sheet's title, the PDF's title and the file's name have it. Where the USGS has no name, which is most of the world, a quadrangle goes by where it is, as before. The names are an index of the 65,600 7.5 minute quadrangles of The National Map (U.S. Geological Survey; public domain), which is shipped: nothing is downloaded. In Alaska a USGS quadrangle is wider than 7.5 minutes, so a quadrangle of the picker's grid there is "Part of" the one which has its middle. The places the tests of the map export are of are changed for others. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An area half of which is the last quadrangle of the land is a part of it The middle of such an area is on the quadrangle's east or north edge, with no quadrangle beyond it, and it was given no name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The PDF of a map is made by a Job, which the browser watches (#978) * The PDF of a map is made by a Job, which the browser watches A PDF of a quadrangle is a minute or two of work on a Raspberry Pi 4, and the request which waited for it was cut off after a minute: only the smallest quadrangles could be exported there. Now the browser describes the map, sends the image of each layer in a request of its own, and starts a Job; it watches the Job, shows how far along it is, and fetches the PDF when the Job is done. Cancel stops the Job. The images are kept on disk until the PDF is made of them, and an export is removed when it is an hour old. The credits on the sheet are no longer cut off: an attribution which names many sources is each of them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A cancelled map export stops, and is removed - A cancelled Job is not over until the thread making the PDF has stopped, so the next Job does not start beside it; the work can also be stopped while the sheet is drawn and the PDF written. - DELETE /api/map/export/<id> stops an export at any step and removes what was sent; the browser calls it when the person exporting cancels, while layers are sent as well as while the PDF is made. - An export whose Job is waiting or running is not removed for being old; one whose Job was cancelled is removed at once. - Cancel while the map is drawn stops the drawing between two layers. - Exports are kept in a directory made for this user alone, which is refused when it is a link or is another user's; only what is an export there is removed. - A request for the finished PDF which is lost is made again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's areas and lines go under the map's labels, and its own labels over them (#979) An overlay was drawn whole over the basemap, so an area it filled covered the names of what is in it. Labels are now always on top: the areas, lines and pictures of every overlay are under the basemap's labels, and the text, icons and points of every overlay are over them. It is so in the map, the standalone viewer, and an exported PDF, where an overlay with both is two layers ("Towers" and "Towers (labels)"). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An overlay's ground is over the ground of every basemap file (#980) * An overlay's ground is over the ground of every basemap file On a map of several basemap files, the ground of an overlay was put before the first label of the first file, which is under the land, water and roads of every file after it: an overlay's areas and lines were hidden, and in an exported PDF its layer was just above the background. It goes where the basemap's labels begin: the first of the labels which are over all of the basemap's ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The labels of every basemap file are over the ground of every file A map of several basemap files was their layers one file after another, so only the labels of the last file were on top: the labels of the others were under the land, water and roads of the files after them, and under the ground of an overlay. Both viewers now draw the ground of every file and then the labels of every file. The contour lines are drawn after the basemap's labels and are not of the basemap: an overlay's ground goes under the basemap's labels, not under the contours instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Contours are drawn from as deep as the terrain file goes (#981) The map read a terrain file to zoom 8, which is how deep the terrain WROLPi offers goes, however deep the file was. It now reads a file as deep as the file says it goes, in both viewers, and draws finer contour lines from a deeper file: every 40 feet (or 20 meters) from zoom 11, as a 1:24,000 sheet has. A file which goes to zoom 8 is drawn as it was. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map names its small roads (#982) * An exported map names its small roads A quadrangle is drawn at about zoom 13. The basemap's style names small roads from zoom 15, and its tiles have no names for them below zoom 14, so the streets of a town were printed as lines with no names. Before the map is drawn, the tiles of zoom 14 which the quadrangle is in are read, and the roads in them which have a name are given to the export map as a source of its own. The layer which names small roads draws from that source, as its style says to. At the scale of a sheet most streets are shorter than their names, and a map writes a name along a line only where the line is longer. Such a road is named over its middle, turned as the road goes; a road in pieces is named once. A source whose tiles can not be read is exported as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The names of small roads are placed by the export, at every latitude A quadrangle nearer the equator is drawn at a little over zoom 14, where the names were not read and the style still kept them for zoom 15: such a map had no names of small roads. They are now read wherever a layer would not name roads. Every name of a small road is now a point: over the middle of its road, turned as the road goes under it, again every 400 pixels of a long road. Before, a road long enough was left for the map to name along its line, which the map often does not (the line bends, or is in pieces), and a short piece beside it was named too. One place decides where a road is named, so a road in pieces is named once, and a piece of another kind of road does not take the name. Reading the names can be cancelled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a bar of meters, its norths in mils, and how far apart its contour lines are (#983) Under the map are bars of kilometers, meters, miles and feet. How far the grid's north and a compass's north are from true north is written in mils as well as in degrees, in the diagram and in the notes: a compass may be marked in either. A map which is exported with its contour lines says how far apart they are (CONTOUR INTERVAL 40 FEET), under the bars. The browser knows: it is the interval of the tiles the lines are made for at the zoom of the sheet, in the unit the map measures in. It says so with the sheet, and what is not an interval is not written. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet says what the quadrangles around it are called (#984) * A sheet says what the quadrangles around it are called Under the scale bars is a diagram of nine squares, the map the middle one, and beside it what the USGS calls each of the eight around it: the sheets to print to carry on off the edge of this one. The names are from the index of quadrangles which names the sheet itself. A quadrangle with no name (out to sea, or over a border) has no number; a map of where the USGS names nothing, and a map too narrow for the diagram, go without. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A sheet is never beside itself Where a quadrangle of the USGS is wider than the map (Alaska), the area the size of the map to its east or west is often more of the quadrangle the map is in, and the diagram named the sheet as its own neighbor. The quadrangle on a side is now the next one which is not the map's own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A sheet has a legend of the lines of its map (#985) * A sheet has a legend of the lines of its map Under the scale bars is what each kind of line of the map is: highway, major road, minor road, path, railway, boundary, contour and index contour, each a piece of the line as the map draws it, on the color of the map's land. The map's style says how a line is drawn at each zoom, and a sheet is drawn at one. The browser, which has the style, says what each line's color, width, dashes and edges are at that zoom; the API draws them. A line is in the legend when its layer is exported and draws something at that zoom. What the browser sends is made into lines before it is kept: what is not a line is left out, and the map is exported. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A legend has no line too thin to see, and no name longer than its room A style brings a line in from nothing as the map is zoomed in: a path is a few hundredths of a point wide on a quadrangle near the equator. It was in the legend, drawn several times wider than on the map. A line under a tenth of a point is now left out, by the browser and by the API. What a line is called is cut to the room beside its line, as the name of an adjoining quadrangle is. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * Fixes to the map PDF export: wrong neighbors, leftover exports, exports which outlive the map (#989) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks (#990) * A sheet names what is around it, and its edges, by where they are and not a hair from there The edges the browser gives of a map are a hair outside its quadrangle. The quadrangles around a map whose middle is on the edge two share (every other map of Alaska) were those around the map west of it, and one of them was the map itself. An edge a hair south of the equator was 0 degrees south, a map which ended where the UTM zones do had no grid, and a sheet dated in the last year there is could not be made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export is removed when it is over, and its work stops when the API does The images and the PDF of an export were kept until the next export began, however long that was. The browser now has the export removed however it ends, and old exports are removed when a PDF is made too. The work of a Job which ended because the API was stopping went on to the end of the PDF, with the API waiting for it. What is said of an export, and each image, is written whole. Text which is no text is taken out when an export begins, not found by the Job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An export stops with its map, and waits for a page which can not be seen Leaving the map while it was exported left the export going, to fail or to hand a PDF to another page; so did closing the picker, which is now left open. A PDF which arrives after the export was stopped is not saved. The time a page is behind another tab is not counted against a map which is drawing. The name of a road is one line. A photograph which ends a little inside the map is not made a JPEG with a black strip. An accent in the name of a quadrangle is not a gap in the name of its file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its water over its parks A layer of the PDF was one image, drawn where the topmost of its layers is. The parks of Land Cover are under the water on the map and its piers are over it, so all of Land Cover was drawn over the water: a lake in a park, or among houses, was not on the PDF. A second basemap file put its water over the first's buildings. A layer is now as many images as it must be, each where it is on the map, in one layer of the PDF: a part which fills an area stays where it is, and a part which is only lines is drawn with the next. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A PDF is not kept from who made it by a server slow to remove the export Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A map file which is of somewhere else is not drawn when a map is exported Each basemap file is several images of an exported map, and most files of a library are of other places: each was an image of nothing, counted against how many images an export may be and how sharp it may be. A file whose own edges are outside the quadrangle is now left out before the layers are counted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map has its streams (#991) A basemap draws streams from zoom 14, and service roads and taxiways from 13. A quadrangle is drawn a little short of that (zoom 13.8 at 40 degrees, 13.2 at 61), from tiles which have them: none were on the PDF. What is drawn from a zoom no deeper than a quadrangle's detail is drawn. Names are left as they are. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An export which is cancelled stops at once, in the middle of a request (#993) * An export which is cancelled stops at once, in the middle of a request An export was stopped between two requests. The image of a layer is tens of megabytes, which is a long request on a slow connection, and a request to a server which has stopped answering never ends: the export said it was stopping until then. Cancel, and leaving the map, now end the request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The requests an export makes after its layers are sent are seen to be stopped too Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A map is exported as it is printed: on white, in dark lines (#996) * A map is exported as it is printed: on white, in dark lines The light and dark maps are made for a screen. On paper their roads are white on pale gray and their streams half a pixel of pale blue. The printed map is a third look, of the map's own: white ground, dark road edges and names, blue streams wide enough to see, paths drawn, brown contours. It is what a map is exported in unless Light or Dark is chosen where the quadrangle is, and the choice is remembered in the browser. While a quadrangle is chosen the map is shown in the look it will be exported in. The light and dark maps are as they were. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * Changing the look of the map does not move it What is done when a new style is in place was asked for after the style was set. A style which only differs from the one the map has is in place before that, so it was done at the next change of style instead, with where the map had been at this one: the map went back there when a quadrangle was chosen, and again when it was not. It is asked for first, and the map is not moved at all. An export no longer waits for the map to be still, which it need not and which nothing ended. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The colors of the printed map are chosen where its layers are (#997) * The colors of the printed map are chosen where its layers are While a quadrangle is chosen and the map is shown as it is printed, each layer of the layer control has its color beside it, to be changed: one for most, three for the land (what grows, what was built, sand and ice) and two for names (the name, and what is around it). A basemap has several colors where one is chosen, which are shades of it. The edge of a road stays dark. What is chosen is remembered in the browser, and can be put back. The map on the screen is as it was. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A ramp on a bridge is the color of a major road, as it is off one A basemap draws a ramp on a bridge in the color of a minor road on a bridge: on the printed map it was white where the rest of the ramp is yellow, and followed the color chosen for minor roads. What puts the colors back is a button, which a keyboard reaches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A layer with nothing in it does not make an exported map less sharp (#1001) * A layer with nothing in it does not make an exported map less sharp How sharp a map may be depends on how many images it is, and every group of layers was counted: a basemap file with no runway, highway or boundary in the quadrangle was images of nothing, drawn, sent, and counted against the rest. A map of 23 images asked for at 400 DPI was made at 330. The groups are now looked at first, on a small map, and only those with something in them are drawn, as sharp as that many may be. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * An image which arrives after its export was removed is not kept, and one mil is a mil Stopping an export while an image was on its way left the image behind it, in a directory nothing would remove for an hour. An angle of one mil was "1 mils" on the sheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The map which is exported from is made as sharp as it is to be (#1002) * The map which is exported from is made as sharp as it is to be The groups of a map are looked at on a small map, which was then made larger to draw them. A browser lets a canvas be larger when it is made than it lets one be made larger afterwards: a quadrangle asked for at 400 DPI was 33 million pixels, 288 DPI at 40 degrees, less than before the groups were looked at first. The small map is now removed, and the map which is exported from is made in its place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A canvas the browser stopped drawing on is not a layer with nothing in it A canvas whose drawing was taken away by the browser reads as clear, and a group looked at then was left out of the PDF without a word: the export fails instead. An export stopped as the last group is looked at does not make the map it would have been drawn on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * An exported map says where it is in a projection Adobe Acrobat knows (#1003) * An exported map says where it is in a projection Adobe Acrobat knows The page was said to be in Web Mercator, which it is drawn in. Acrobat does not know Web Mercator, in the words of the standard or in Esri's: it took the page for a map, and put every place on it at 0, 0. The page is now said to be Mercator on the WGS 84 ellipsoid, which it reads, with the same corners. Between the corners the two differ by under three centimeters on the ground. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * How well a page is said to be where it is, is measured from what the PDF says The test of it measured two formulas of its own. It now reads the corners and the projection from the PDF and does a reader's sum with them. The few centimeters are of a quadrangle: a taller page is less well said, by the square of how tall it is, which the comment now says and a test measures. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The help says how a map is exported as a PDF (#1004) The help of the map is five pages, one of them the PDF export. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 17:22:21 -07:00
@map_bp.get('/quad')
@openapi.description('The name of the USGS quadrangle of an area of the map')
async def get_quad(request: Request):
"""What the USGS calls the quadrangle between `west`, `south`, `east` and `north` (degrees): `quad` is its
`name`, its `state`, and whether it is `exact`ly that area (and not a larger quadrangle which has the middle
of it); or null where there is no name, which is most of the world."""
try:
west, south, east, north = (float(request.args.get(i)) for i in ('west', 'south', 'east', 'north'))
except (TypeError, ValueError):
return response.json({'error': 'The edges of the area are four numbers'}, HTTPStatus.BAD_REQUEST)
if not (-180 <= west < east <= 180 and -90 <= south < north <= 90):
# Not so of a number which is not one, either.
return response.json({'error': 'The edges are not those of an area of the map'}, HTTPStatus.BAD_REQUEST)
# The index is read from its file the first time, which is not for the event loop.
name = await asyncio.to_thread(quads.quad_name, west, south, east, north)
return json_response({'quad': name.__json__() if name else None})
# How much may be written on the sheet of an exported map.
SHEET_TEXT_LENGTH = 300
SHEET_CREDITS = 40
def _export_text(value) -> str:
"""What was sent as text of an exported map (its title, the name of a layer), as it can be written in a PDF:
no longer than a line of a sheet, and with nothing in it which is not a character."""
text = str(value or '').replace('\x00', '')
return text.encode('utf-8', 'replace').decode('utf-8')[:SHEET_TEXT_LENGTH]
def _sheet_contours(contours) -> dict:
"""How far apart the contour lines of a map are, as the browser says it, for `export.Sheet`. A map with no
contour lines says nothing; what is said is written on the sheet only when it is an interval (see
`modules.map.sheet`)."""
if not isinstance(contours, dict):
return {}
interval = contours.get('interval')
if isinstance(interval, bool) or not isinstance(interval, (int, float)):
return {}
return dict(contour_interval=float(interval), contour_unit=str(contours.get('unit') or '')[:SHEET_TEXT_LENGTH])
def _export_error(e: Exception):
"""The response for an export which could not go on."""
if isinstance(e, export_job.ExportNotFound):
return response.json({'error': str(e)}, HTTPStatus.NOT_FOUND)
if isinstance(e, export_job.ExportNotReady):
return response.json({'error': str(e)}, HTTPStatus.CONFLICT)
if isinstance(e, export_job.ExportStorageError):
return response.json({'error': str(e)}, HTTPStatus.INTERNAL_SERVER_ERROR)
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
EXPORT_ERRORS = (export.InvalidExport, export_job.ExportNotFound, export_job.ExportNotReady,
export_job.ExportStorageError)
@map_bp.post('/export')
@openapi.description('Begin the export of a map as a PDF')
async def post_export(request: Request):
"""The browser draws the map, one image for each layer; the API puts them in a PDF, each in a layer of its own.
That takes a minute or two on a Raspberry Pi, so it is a Job:
1. This request describes the map, and is answered with an `export_id`.
2. `POST /api/map/export/<export_id>/layer/<index>` sends the image of each layer.
3. `POST /api/map/export/<export_id>/start` is answered with a `job_id`, to watch at `/api/jobs/<job_id>`.
4. `GET /api/map/export/<export_id>/pdf` is the PDF, once the Job is complete.
`DELETE /api/map/export/<export_id>` stops an export at any of those steps, and removes what was sent.
The JSON body: `width` and `height` in pixels, `dpi`, `title`, `layers`: the name of each image from the bottom
up (images of one name are one layer of the PDF), `bounds`: the west, south, east and north edges of the images in degrees, with which the PDF says where it
is, and `sheet`: with which the map is put on a sheet with a margin and a grid; `name`, `credits` and `date`
are written on it, `contours` (`{"interval": 40, "unit": "feet"}`, or "meters") when the map has contour
lines, and `legend`: the lines of the map as they are drawn (see `modules.map.sheet.Sheet`)."""
try:
meta = request.json
width, height, dpi = int(meta['width']), int(meta['height']), float(meta['dpi'])
names = [_export_text(i) for i in meta['layers']]
title = _export_text(meta.get('title')) or None
bounds = meta.get('bounds')
sheet = meta.get('sheet')
if sheet is not None:
sheet = export.Sheet(
name=_export_text(sheet.get('name')) or None,
credits=[_export_text(i) for i in (sheet.get('credits') or [])[:SHEET_CREDITS]],
date=_export_text(sheet.get('date')) or None,
**_sheet_contours(sheet.get('contours')),
legend=legend_as_sent(sheet.get('legend')),
)
except Exception: # noqa Whatever is made of a body which is not the description of a map.
return response.json({'error': 'The description of the map is not valid'}, HTTPStatus.BAD_REQUEST)
try:
# Old exports are removed from the disk here, which is not for the event loop.
export_id = await asyncio.to_thread(export_job.create_export, names, width, height, dpi, title, bounds, sheet)
except EXPORT_ERRORS as e:
return _export_error(e)
return json_response({'export_id': export_id}, HTTPStatus.CREATED)
@map_bp.post('/export/<export_id:str>/layer/<index:int>')
@openapi.description('Send the image (PNG or JPEG) of one layer of a map which is being exported')
async def post_export_layer(request: Request, export_id: str, index: int):
try:
await asyncio.to_thread(export_job.save_layer, export_id, index, request.body)
except EXPORT_ERRORS as e:
return _export_error(e)
return response.empty()
@map_bp.post('/export/<export_id:str>/start')
@openapi.description('Queue the Job which makes the PDF of a map, all of whose layers have been sent')
async def post_export_start(_: Request, export_id: str):
try:
job_id = await asyncio.to_thread(export_job.start_export, export_id)
except EXPORT_ERRORS as e:
return _export_error(e)
return json_response({'job_id': job_id}, HTTPStatus.ACCEPTED)
@map_bp.delete('/export/<export_id:str>')
@openapi.description('Stop the export of a map: cancel its Job, if it has one, and remove what was sent')
async def delete_export(_: Request, export_id: str):
try:
await asyncio.to_thread(export_job.remove_export, export_id)
except EXPORT_ERRORS as e:
return _export_error(e)
return response.empty()
@map_bp.get('/export/<export_id:str>/pdf')
@openapi.description('The PDF of an exported map, once the Job which makes it is complete')
async def get_export_pdf(_: Request, export_id: str):
try:
pdf = await asyncio.to_thread(export_job.get_export_pdf, export_id)
except EXPORT_ERRORS as e:
return _export_error(e)
return await response.file(pdf, mime_type='application/pdf', filename='map.pdf')
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007) * A fallout model, checked against six Nevada tests The local fallout of a surface burst lands where layered winds carry particles of every size from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC; the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's predictions of the same contours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A prototype fallout panel on the map Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one wind or in the winds aloft of one of the six Nevada tests. Nothing is saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout lands where it meets the ground A particle stops falling at the first level where it is at or below the ground under it, not at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The map panel reads the ground from the terrain files the user has downloaded; the Nevada tests are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout falls from the cloud's cap, skirt and stem The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt burst now draws a 1000 R/hr contour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Close-in fallout measured after three Nevada surface bursts Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10 predicted them, with each shot's winds. The deposition grid can look closely at part of the fallout, and measures hotlines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout rises with the cloud, and heavy particles drop out low All of the activity starts in the early fireball and rises with the cloud, whose base and top climb with the square root of time (SIMFIC). Each particle rises with the air less its own settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a light one rides to the top. A burst above the ground puts down less, by its scaled height. Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel offers the weapons in service today Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026 Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry for each published setting. Fission shares are not public; they are assumed as Glasstone and Dolan plan for, and the user may change them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's dropdowns open above it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A variable-yield weapon is named once, with each setting's yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel uses the forecast winds aloft WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels (about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places the map does not show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A nuclear mode on the map: targets, and fallout A radiation button under the print button turns nuclear mode on and off. In it, targets (likely detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin without one is a plain pin, as every pin was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets keep their weapon, and nuclear mode shows the fallout of all of them A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast winds aloft fetched most recently; a burst tried out from the map can be saved as a target. A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a pin's label and color may be left out of an update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * An improvised device is named once, with each yield beside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout of many targets is calculated in seconds, and shown as it goes A particle size's settling speed is read from a table by altitude rather than solved again for every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms, through a message channel, which a browser does not hold back in a hidden tab as it does timers; it says how far it has got, and draws the fallout on flat ground while the terrain is read. A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets every target's weapon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout grid covers where fallout shows, not past the poles The faintest particles of a burst are carried thousands of km in two days; with many targets the grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid now covers the spots which can reach the faintest band drawn, the image's corners stay within Web Mercator's 85 degrees, and so does the area whose terrain is read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout across a continent is drawn where it lands The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and the southern part of the image was drawn far from its targets. Each image row now takes the grid row at its own latitude. A burst far from the first target keeps its plume as wide, east to west, as at its own latitude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Terrain across the antimeridian, and ground with no number, do not break the fallout Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic read past the tile's pixels; one sample with no number made every target's lowest ground NaN and every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map is left out of the grid rather than breaking it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Every target's weapon is set in one change Setting it target by target, eight at once, lost most of the changes: each request wrote the whole pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives every target the weapon in one change of the config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The every-target weapon picker starts empty and always applies It showed the first target's weapon, so choosing that weapon for all of them did nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fallout is carried by the winds where it is, region by region A field of forecasts on a grid over the targets replaces the one forecast for all of them. Each particle rises and falls through the wind at its place, height and hour, read between the surrounding grid points, hours and heights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The winds aloft are fetched as a Job, ninety places a minute The free forecast service allows 600 calls a minute and a place costs six, so a field of up to 540 points is fetched in paced batches by a Job, which the fallout panel follows, instead of inside one request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A small burst's hot fallout is kept on a grid over many, and the panel says what it shows - Each burst's narrow close-in fallout is also put on a fine grid, so the lethal zone of a small target is not averaged away in the cells kilometers wide of a grid over targets far apart. - The legend says the dose rate is as at one hour, with all the fallout down, and what R/hr is; the error quoted is the unscaled model's. - The TNA's yield is 150 kt: its source gives only an upper bound below 300. - Weapons show their fission share beside their yield. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout can be watched landing, hour by hour A timeline under the legend plays, or steps through, the 48 hours after the bursts: each hour shows only the fallout which has landed by then, at its dose rate then (t^-1.2 from H+1), on the same cells as the whole of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The map can show the total dose of someone outdoors, hour by hour A "Show" picker switches from the dose rate to the total dose (R) someone outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's arrival to the hour on the timeline, or over the first two weeks. Its bands say what each dose does to a person. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against the Army's fallout manuals - FM 3-3-1's worked decay and dose problems are tests. - FM 3-11.3's cloud and Zone I nomograms, read from their images, are a fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt, and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of modern weapons, which the test shots do not reach. - The legend says real fallout may decay faster or slower than usual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The model is checked against two megaton bursts in the Pacific Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot fallout goes where it went and about as far. Castle Bravo (15 Mt), whose winds were measured only below its cloud: its fallout arrives when it did, and its hot fallout reaching a third as far is kept in view as a known gap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Winds are read from the right points at every spacing, and cover the landing - A field's points were filed by rounding (lat + 90) / spacing but looked up by flooring it: at 4 and 8 degrees, which do not divide 90, every point read half its neighbor's wind. Both now count whole spacings from the equator. - The forecast starts at midnight UTC, so two days could end before the fallout of a burst this hour was down; three are fetched (the same call weight), and the panel says when the last hour's winds are held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bravo's known gap is not its unmeasured upper winds Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees of the measured one but do not lengthen its hot contours; the fixture's caveat and the test's explanation said otherwise, and now say what was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rain takes fallout out of the air where it falls A falling particle in rain loses a share of its activity every step: fast inside the rain cloud ("rainout"), slower below it, by how hard it rains ("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none above it. What is taken out comes down where the particle was. The forecast now asks for relative humidity at 14 levels, and each hour's rain cloud is taken as HYSPLIT takes it: from the lowest level 80% humid to the first above it less than 60%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * With no forecast, the fallout of 30 past days of the month - wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis, the winds aloft of 30 days of each month (one from each year 1991-2020) over the whole world: a gzip file a month, about 4 MB, for the release download location. - WROLPi fetches the months it lacks once, while there is the Internet, each checked against a sha256 pinned in modules/map/climatology.py (none pinned until the files are published), and serves them to the panel. - The panel's "Past days of a month" wind runs the bursts in each day and shows on what share of the days each place had the chosen dose rate; it is chosen for us when there is no forecast, or it has run out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology's months are published, and their sha256 pinned Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The climatology worker waits for the Internet and the drive on startup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Counting the past days says flat ground at once, not the forecast's terrain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout reuses each yield's paths, about 10 times faster On flat ground in a day's held winds, how each parcel rises with the cloud and falls does not depend on the wind, so it is worked out once per yield and kept for every burst and day. The rising cloud is carried by the winds over ground zero (it drifts about 10 km); the fall still reads the winds where the particle is. A field of one hour is read without its hours, and the nearest point to a cell past the field is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rising cloud reads the winds over ground zero from arrays, by level Each parcel's rise is kept as the levels of the column it passes through (steps in the same level as one) and their seconds, so a burst reads the column once and sums. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel shows a progress bar while it calculates At the top of the panel, filled as far as the bursts are done, or moving without a count until there is one. A calculation stopped by removing the last target no longer leaves the panel busy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Past days' fallout runs in Web Workers, with a Cancel button The days are spread over workers, one for each core but one (left for the page), at most 6, and at most 2 where the browser says it has 2 GB or less. A worker is given the next day as it finishes one, and sends back only the cells reached. Where workers cannot be made, or fail, the days are calculated on the page as before. The days are counted on cells as wide as the coarsest day's grid, so the count does not depend on which day finishes first. Cancel, beside the progress bar, stops a calculation (and its workers) at once; Calculate starts it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's bursts are spread over Web Workers too The workers now take any task: a past day, or a burst. The page and the workers build each burst's winds and terrain with the same functions (work.js), so the fallout is the same either way; the flat pass and the terrain pass each run on their own workers, and Cancel stops them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The bursts' grid is made in parts by the Web Workers The grid is a sum over the bursts' spots, sharpened by the most any burst raises a cell, so it is made in a fixed number of parts (a burst's spots in one) on one frame, and joined on the page. The page makes the same parts when there are no workers, so the grid is the same either way. The forecast's warnings (bursts outside the winds, rain) are no longer worked out again on every progress update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast's hours are labeled once an hour, not on every progress update Writing each hour's label (toLocaleString) took most of the page's time while the workers calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent - Outside the forecast's field, the nearest point is looked for only among the points which can be nearest somewhere in the grid cell (kept for each cell); the same point as looking through them all. Longitudes are wrapped however far round the world a particle is carried. - The progress is shown at most ten times a second. - The workers are sent the forecast's arrays, not the forecast as fetched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel in steps: the targets, then the fallout hour by hour or in total Nuclear mode opens on the targets; nothing is calculated until the user goes on. The winds and terrain wait under Options, with what is used said beside it. The timeline runs from the first hour to two weeks, saying how much the fallout has weakened since H+1; the view of all the fallout as if landed at H+1 is gone. Going back and on again with nothing changed draws what was calculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is a step of its own, between the targets and the fallout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel says it is an estimate; how it compares with the test bursts goes in the help Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Targets are tried out until saved; the saved ones are loaded first, and saved all at once Nuclear mode starts with no targets. Targets added are tried out, and the saved targets join them when the user loads them. Saving replaces the saved targets with the list, in one change, and is refused until they were loaded (or there are none), so none are lost unseen. A target can be taken out of the list. The burst tried out from the map's menu is gone: a target tried out does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins The pins are plain pins again. The targets have their own endpoints, and their own table on the Pins tab, where one can be deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table The commit before this one was missing these files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The weather is a subscription: a forecast around the saved targets, downloaded every day The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel starts. The Manage tab has a Weather section: turning it on or off, what it downloads, how its downloads went, and the forecast kept. Only the newest forecast is kept, and it covers four days. The wind step asks the user to turn the download on, and warns, there and beside the fallout, when the forecast runs out before the fallout is down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The forecast service may take three minutes to answer, and a timeout says so A batch of four days' forecasts took 43 seconds, near the old 60-second limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The fallout panel's targets step has an Add a target button: the next click on the map places it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
@map_bp.get('/fallout/climatology')
@openapi.description('Which months of the fallout climatology (30 past days of winds each) are kept')
def get_fallout_climatology(_: Request):
return json_response(climatology.status(), HTTPStatus.OK)
@map_bp.get('/fallout/climatology/<month:int>')
@openapi.description('One month of the fallout climatology, as kept (gzip)')
async def get_fallout_climatology_month(_: Request, month: int):
path = climatology.month_path(month)
if not path:
return response.json({'error': f'Month {month} of the climatology is not kept'}, HTTPStatus.NOT_FOUND)
return await response.file(path, mime_type='application/octet-stream')
@map_bp.get('/fallout/winds/latest')
@openapi.description('The field of forecast winds aloft fetched most recently')
def get_latest_fallout_winds(_: Request):
return json_response(dict(winds=winds.latest_field()), HTTPStatus.OK)
@map_bp.get('/weather')
@openapi.description('The weather subscription: whether it is on, its download, and the forecast kept')
def get_weather(request: Request):
return json_response(winds.weather_status(request.ctx.session), HTTPStatus.OK)
@map_bp.put('/weather')
@openapi.description('Subscribe to the weather (a forecast around the nuclear targets, every day), or not')
@validate(schema.MapWeatherRequest)
@wrol_mode_check
async def put_weather(request: Request, body: schema.MapWeatherRequest):
with request.ctx.db.write() as session:
winds.set_weather_subscription(session, bool(body.enabled))
return json_response(winds.weather_status(request.ctx.session), HTTPStatus.OK)
@map_bp.post('/weather/download')
@openapi.description('Download the weather now, rather than when it is next due')
@wrol_mode_check
async def post_weather_download(request: Request):
with request.ctx.db.write() as session:
if not winds.download_weather_now(session):
return response.json({'error': 'The weather is not subscribed to'}, HTTPStatus.BAD_REQUEST)
return json_response(winds.weather_status(request.ctx.session), HTTPStatus.OK)