@procedures/geo 0.2.3 → 0.4.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +21 -2
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/distance.d.ts +14 -0
  5. package/dist/distance.d.ts.map +1 -0
  6. package/dist/distance.js +20 -0
  7. package/dist/distance.js.map +1 -0
  8. package/dist/geo.d.ts +15 -0
  9. package/dist/geo.d.ts.map +1 -1
  10. package/dist/geo.js +5 -4
  11. package/dist/geo.js.map +1 -1
  12. package/dist/geohash.d.ts +30 -0
  13. package/dist/geohash.d.ts.map +1 -0
  14. package/dist/geohash.js +87 -0
  15. package/dist/geohash.js.map +1 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/procedures/geo/distance.d.ts +12 -0
  21. package/dist/procedures/geo/distance.d.ts.map +1 -0
  22. package/dist/procedures/geo/distance.js +14 -0
  23. package/dist/procedures/geo/distance.js.map +1 -0
  24. package/dist/procedures/geo/geohash.d.ts +11 -0
  25. package/dist/procedures/geo/geohash.d.ts.map +1 -0
  26. package/dist/procedures/geo/geohash.js +14 -0
  27. package/dist/procedures/geo/geohash.js.map +1 -0
  28. package/dist/procedures/geo/index.d.ts +3 -0
  29. package/dist/procedures/geo/index.d.ts.map +1 -0
  30. package/dist/procedures/geo/index.js +3 -0
  31. package/dist/procedures/geo/index.js.map +1 -0
  32. package/dist/procedures.d.ts +3 -1
  33. package/dist/procedures.d.ts.map +1 -1
  34. package/dist/procedures.js +34 -2
  35. package/dist/procedures.js.map +1 -1
  36. package/dist/types.d.ts +33 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +29 -0
  39. package/dist/types.js.map +1 -0
  40. package/package.json +5 -3
  41. package/src/distance.ts +23 -0
  42. package/src/geo.ts +23 -7
  43. package/src/geohash.ts +97 -0
  44. package/src/index.ts +3 -0
  45. package/src/procedures/geo/distance.ts +16 -0
  46. package/src/procedures/geo/geohash.ts +16 -0
  47. package/src/procedures/geo/index.ts +2 -0
  48. package/src/procedures.ts +47 -2
  49. package/src/types.ts +67 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
1
+ # @procedures/geo
2
+
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0f1d06e: New functions without the network: `greatCircleKm(a, b)` gives the great-circle distance in kilometres, and `geohash(point, precision)` gives the geohash of a point. `decodeGeohash(hash)` gives the edges and the center of the cell of a geohash.
8
+
9
+ - `greatCircleKm` uses the haversine formula on a sphere of 6371 km (`EARTH_RADIUS_KM`). It does not round the result.
10
+ - `geohash` gives 1 to 12 characters. The default is 7. A coordinate on the middle of a range goes to the upper half.
11
+ - The pure procedures `geo.distance` and `geo.geohash` give the same values.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [d919678]
16
+ - Updated dependencies [057d69a]
17
+ - Updated dependencies [b2a1a1e]
18
+ - Updated dependencies [057d69a]
19
+ - Updated dependencies [057d69a]
20
+ - Updated dependencies [057d69a]
21
+ - Updated dependencies [057d69a]
22
+ - Updated dependencies [057d69a]
23
+ - Updated dependencies [afd6a19]
24
+ - Updated dependencies [057d69a]
25
+ - Updated dependencies [4e751da]
26
+ - @procedures/client@0.4.0
27
+
28
+ ## 0.3.0
29
+
30
+ ### Minor Changes
31
+
32
+ - 2a754ee: The functions `geocode`, `drivingRoute` and `getJson` of `@procedures/geo` and `sendNotification` of `@procedures/notify` take an optional `fetch`. A host can give its own fetch, for example a fetch with a cache, a recorder or a test double. The default is the global `fetch`. The types `FetchJson` and `FetchPost` give the part of `fetch` that each package uses.
33
+
34
+ When a request fails, the error keeps the error of `fetch` as its `cause`, so the caller can read the code of the failure (for example `ECONNREFUSED`).
35
+ - 5e2ba76: New package: `geo.geocode` finds the coordinates of an address (Nominatim), and `geo.route` gives the time and the distance of a drive (OSRM).
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [ddea529]
40
+ - Updated dependencies [b2a3e3a]
41
+ - Updated dependencies [a8c47f1]
42
+ - Updated dependencies [381ce3a]
43
+ - Updated dependencies [0c627f8]
44
+ - Updated dependencies [ae7f05f]
45
+ - Updated dependencies [7873940]
46
+ - Updated dependencies [a70d445]
47
+ - Updated dependencies [bc70357]
48
+ - Updated dependencies [07cc998]
49
+ - Updated dependencies [a6b01a9]
50
+ - Updated dependencies [c799cdd]
51
+ - Updated dependencies [540f8d9]
52
+ - Updated dependencies [b6daaec]
53
+ - Updated dependencies [5b9264e]
54
+ - Updated dependencies [956e88b]
55
+ - Updated dependencies [ff62281]
56
+ - Updated dependencies [d81d0ed]
57
+ - Updated dependencies [aa67cc7]
58
+ - Updated dependencies [061fa22]
59
+ - Updated dependencies [cfb9d69]
60
+ - Updated dependencies [43f7de5]
61
+ - Updated dependencies [b07bb50]
62
+ - Updated dependencies [4a3bfa1]
63
+ - Updated dependencies [bd0b626]
64
+ - Updated dependencies [a6be873]
65
+ - Updated dependencies [fb30718]
66
+ - Updated dependencies [c5528e4]
67
+ - Updated dependencies [fee5d9c]
68
+ - Updated dependencies [21f7743]
69
+ - Updated dependencies [31a0b46]
70
+ - @procedures/client@0.3.0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@procedures/geo?color=2346c4&label=npm)](https://www.npmjs.com/package/@procedures/geo)
4
4
 
5
- Map procedures: the coordinates of an address (OpenStreetMap Nominatim) and the time and the distance of a drive (OSRM).
5
+ Map procedures. They give the coordinates of an address (OpenStreetMap Nominatim) and the time and the distance of a drive (OSRM). They also give the great-circle distance and the geohash.
6
6
 
7
7
  ## Install
8
8
 
@@ -18,6 +18,8 @@ A host registers the procedures with `createRegistry(geoModule)`, or with `impor
18
18
  | --- | --- | --- |
19
19
  | `geo.geocode` | reads `network` | Finds the coordinates of an address or a place name. |
20
20
  | `geo.route` | reads `network` | Gives the kilometres and the minutes of a drive between two points. |
21
+ | `geo.distance` | none | Gives the great-circle distance between two points, in kilometres. |
22
+ | `geo.geohash` | none | Gives the geohash of a point and the cell of that geohash. |
21
23
 
22
24
  ## Example
23
25
 
@@ -28,6 +30,23 @@ const { found, result } = await client.exec(["geo", "geocode"], {
28
30
  });
29
31
  ```
30
32
 
33
+ ## Distance and geohash
34
+
35
+ These functions use no network:
36
+
37
+ ```ts
38
+ import { decodeGeohash, geohash, greatCircleKm } from "@procedures/geo";
39
+
40
+ greatCircleKm({ lat: 48.8584, lon: 2.2945 }, { lat: 52.5163, lon: 13.3777 }); // 879.0864603595937
41
+ geohash({ lat: 48.8584, lon: 2.2945 }); // "u09tunq"
42
+ decodeGeohash("u09tunq"); // { south, west, north, east, center }
43
+ ```
44
+
45
+ - `greatCircleKm(a, b)` uses the haversine formula on a sphere with the mean radius of the Earth (`EARTH_RADIUS_KM`, 6371 km). It does not round the result. A road is longer than this distance.
46
+ - `geohash(point, precision)` gives `precision` characters (1 to 12, default 7). The first bit is the longitude. A coordinate on the middle of a range goes to the upper half.
47
+ - `decodeGeohash(hash)` gives the edges and the center of the cell of a geohash. It reads upper case letters.
48
+ - The functions throw a `RangeError` for a point off the map and for a precision out of range.
49
+
31
50
  ## The policy of the public servers
32
51
 
33
- The Nominatim policy permits at most one request each second, and it requires a `User-Agent` that names your application. `geo.geocode` requires `userAgent` for this reason. The OSRM demonstration server has a fair-use limit. Give `baseUrl` to use your own server of either kind.
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.