@procedures/geo 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @procedures/geo
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 715ce03: Two additions for maps and forecasts.
8
+
9
+ - `@procedures/weather`: new `weatherCodeGroup(code)` gives the group of a WMO weather code, for example `clear`, `fog`, `rain-showers` or `thunderstorm`. It gives `undefined` for a code that Open-Meteo does not use.
10
+ - `@procedures/geo`: new Node entry `@procedures/geo/tiles` with `cachedTile`, `isTile`, `tileUrl` and `OSM_TILES`. `cachedTile` gets a map tile one time with a real `User-Agent`, keeps it in a folder, and gives the kept file after that. The root of the package stays safe for a browser.
11
+ - Updated dependencies [4b09a03]
12
+ - Updated dependencies [4b09a03]
13
+ - Updated dependencies [aa6e3aa]
14
+ - Updated dependencies [698e24d]
15
+ - Updated dependencies [4b09a03]
16
+ - Updated dependencies [600c497]
17
+ - Updated dependencies [7c2e7f7]
18
+ - Updated dependencies [90ea741]
19
+ - Updated dependencies [c4cfa34]
20
+ - Updated dependencies [d25805a]
21
+ - @procedures/client@0.8.0
22
+
23
+ ## 0.7.0
24
+
25
+ ### Minor Changes
26
+
27
+ - 01dce14: The Web Mercator helpers of the slippy maps: `project(lat, lon, zoom)` gives the pixel of a point, `fitZoom(points, width, height)` the zoom that fits the points into a box, and `tilesFor(topLeft, width, height, zoom)` the tiles of a view. They are pure, so a browser bundle can use them.
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [841d083]
32
+ - Updated dependencies [389b054]
33
+ - @procedures/client@0.7.0
34
+
3
35
  ## 0.6.0
4
36
 
5
37
  ### Patch Changes
package/README.md CHANGED
@@ -50,3 +50,22 @@ decodeGeohash("u09tunq"); // { south, west, north, east, center }
50
50
  ## The policy of the public servers
51
51
 
52
52
  The Nominatim policy permits at most one request each second. A `User-Agent` that names your application is necessary, so `geo.geocode` has the field `userAgent`. The OSRM demonstration server has a fair-use limit. Give `baseUrl` to use your own server of either kind.
53
+
54
+ ## Map tiles on disk
55
+
56
+ The entry `@procedures/geo/tiles` is for Node only. The root of the package stays safe for a browser.
57
+
58
+ ```ts
59
+ import { cachedTile, isTile } from "@procedures/geo/tiles";
60
+
61
+ const tile = { z: 12, x: 1205, y: 1539 };
62
+ if (isTile(tile)) {
63
+ const png = await cachedTile(tile, { dir: "var/tiles", userAgent: "my-app/1.0 (me@example.com)" });
64
+ }
65
+ ```
66
+
67
+ - `cachedTile` gets a tile from the server one time and keeps it as `<dir>/<z>/<x>/<y>.png`. After that, it gives the kept file without a request.
68
+ - The default server is `OSM_TILES`, the standard tiles of OpenStreetMap. Their policy asks for a real `User-Agent` and for a cache, so `userAgent` is necessary.
69
+ - The options `source`, `extension`, `timeoutMs`, `maxBytes` and `fetch` change the server, the file extension, the time limit, the largest tile and the fetch function.
70
+ - An HTTP error, no answer, or a body larger than `maxBytes` throws an error, and nothing is kept. Each file is written to a temporary name and then renamed.
71
+ - `isTile(tile, maxZoom)` tells if a tile exists at its zoom level. `tileUrl(template, tile)` fills `{z}`, `{x}` and `{y}`.