@johnmorrisdotca/kyogijo-stadiums 0.0.0-stage → 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 (321) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE.md +293 -0
  4. package/README.md +600 -2
  5. package/dist/annotate.d.ts +47 -0
  6. package/dist/annotate.js +349 -0
  7. package/dist/atlas-entry.d.ts +4 -0
  8. package/dist/atlas-entry.js +3 -0
  9. package/dist/atlas.d.ts +131 -0
  10. package/dist/atlas.js +149 -0
  11. package/dist/background.d.ts +56 -0
  12. package/dist/background.js +127 -0
  13. package/dist/ballpark.d.ts +48 -0
  14. package/dist/ballpark.js +129 -0
  15. package/dist/canvas-entry.d.ts +2 -0
  16. package/dist/canvas-entry.js +2 -0
  17. package/dist/canvas.d.ts +85 -0
  18. package/dist/canvas.js +279 -0
  19. package/dist/charts-entry.d.ts +10 -0
  20. package/dist/charts-entry.js +8 -0
  21. package/dist/charts.baseball.d.ts +30 -0
  22. package/dist/charts.baseball.js +152 -0
  23. package/dist/charts.curling.d.ts +52 -0
  24. package/dist/charts.curling.js +196 -0
  25. package/dist/charts.d.ts +172 -0
  26. package/dist/charts.js +508 -0
  27. package/dist/charts.network.d.ts +66 -0
  28. package/dist/charts.network.js +64 -0
  29. package/dist/charts.soccer.d.ts +43 -0
  30. package/dist/charts.soccer.js +191 -0
  31. package/dist/charts.types.d.ts +396 -0
  32. package/dist/charts.types.js +1 -0
  33. package/dist/colour.d.ts +29 -0
  34. package/dist/colour.js +97 -0
  35. package/dist/common.d.ts +14 -0
  36. package/dist/common.js +32 -0
  37. package/dist/court.d.ts +89 -0
  38. package/dist/court.js +248 -0
  39. package/dist/courts.style.d.ts +20 -0
  40. package/dist/courts.style.js +54 -0
  41. package/dist/cricket.board.d.ts +18 -0
  42. package/dist/cricket.board.js +67 -0
  43. package/dist/curling.board.d.ts +24 -0
  44. package/dist/curling.board.js +147 -0
  45. package/dist/d3-entry.d.ts +3 -0
  46. package/dist/d3-entry.js +2 -0
  47. package/dist/d3.d.ts +45 -0
  48. package/dist/d3.js +56 -0
  49. package/dist/draw.d.ts +52 -0
  50. package/dist/draw.js +705 -0
  51. package/dist/element-define.d.ts +2 -0
  52. package/dist/element-define.js +4 -0
  53. package/dist/element-entry.d.ts +1 -0
  54. package/dist/element-entry.js +2 -0
  55. package/dist/element.d.ts +39 -0
  56. package/dist/element.js +321 -0
  57. package/dist/eras-entry.d.ts +2 -0
  58. package/dist/eras-entry.js +2 -0
  59. package/dist/eras.d.ts +204 -0
  60. package/dist/eras.js +396 -0
  61. package/dist/events-entry.d.ts +3 -0
  62. package/dist/events-entry.js +3 -0
  63. package/dist/events.d.ts +54 -0
  64. package/dist/events.data.d.ts +59 -0
  65. package/dist/events.data.js +297 -0
  66. package/dist/events.js +127 -0
  67. package/dist/features.d.ts +31 -0
  68. package/dist/features.js +284 -0
  69. package/dist/field.score.d.ts +5 -0
  70. package/dist/field.score.js +33 -0
  71. package/dist/fields/afl.d.ts +11 -0
  72. package/dist/fields/afl.js +103 -0
  73. package/dist/fields/cricket.d.ts +9 -0
  74. package/dist/fields/cricket.js +81 -0
  75. package/dist/fields/fieldhockey.d.ts +6 -0
  76. package/dist/fields/fieldhockey.js +81 -0
  77. package/dist/fields/gaelic.d.ts +10 -0
  78. package/dist/fields/gaelic.js +86 -0
  79. package/dist/fields/handball.d.ts +6 -0
  80. package/dist/fields/handball.js +85 -0
  81. package/dist/fields/lacrosse.d.ts +17 -0
  82. package/dist/fields/lacrosse.js +169 -0
  83. package/dist/fields/rugby.d.ts +10 -0
  84. package/dist/fields/rugby.js +130 -0
  85. package/dist/fields.d.ts +12 -0
  86. package/dist/fields.js +44 -0
  87. package/dist/fields.kit.d.ts +63 -0
  88. package/dist/fields.kit.js +108 -0
  89. package/dist/fields.style.d.ts +4 -0
  90. package/dist/fields.style.js +19 -0
  91. package/dist/fields.types.d.ts +155 -0
  92. package/dist/fields.types.js +1 -0
  93. package/dist/format.d.ts +10 -0
  94. package/dist/format.js +28 -0
  95. package/dist/formations.d.ts +18 -0
  96. package/dist/formations.js +211 -0
  97. package/dist/frames-entry.d.ts +8 -0
  98. package/dist/frames-entry.js +7 -0
  99. package/dist/frames.d.ts +199 -0
  100. package/dist/frames.js +271 -0
  101. package/dist/frames.providers.d.ts +16 -0
  102. package/dist/frames.providers.js +302 -0
  103. package/dist/geojson-entry.d.ts +2 -0
  104. package/dist/geojson-entry.js +2 -0
  105. package/dist/geojson.d.ts +79 -0
  106. package/dist/geojson.js +147 -0
  107. package/dist/geometry-entry.d.ts +7 -0
  108. package/dist/geometry-entry.js +5 -0
  109. package/dist/geometry.d.ts +295 -0
  110. package/dist/geometry.js +361 -0
  111. package/dist/grounds-entry.d.ts +4 -0
  112. package/dist/grounds-entry.js +3 -0
  113. package/dist/grounds.d.ts +134 -0
  114. package/dist/grounds.data.d.ts +2 -0
  115. package/dist/grounds.data.js +1849 -0
  116. package/dist/grounds.js +74 -0
  117. package/dist/heat.colour.d.ts +37 -0
  118. package/dist/heat.colour.js +54 -0
  119. package/dist/heat.d.ts +43 -0
  120. package/dist/heat.js +614 -0
  121. package/dist/heat.stats.d.ts +123 -0
  122. package/dist/heat.stats.js +413 -0
  123. package/dist/heat.types.d.ts +145 -0
  124. package/dist/heat.types.js +1 -0
  125. package/dist/heat.zones.d.ts +54 -0
  126. package/dist/heat.zones.js +424 -0
  127. package/dist/homeside.d.ts +16 -0
  128. package/dist/homeside.js +43 -0
  129. package/dist/index.d.ts +47 -0
  130. package/dist/index.js +29 -0
  131. package/dist/layers-entry.d.ts +19 -0
  132. package/dist/layers-entry.js +11 -0
  133. package/dist/layers.d.ts +41 -0
  134. package/dist/layers.env.d.ts +72 -0
  135. package/dist/layers.env.js +79 -0
  136. package/dist/layers.js +533 -0
  137. package/dist/layers.marks.d.ts +45 -0
  138. package/dist/layers.marks.js +168 -0
  139. package/dist/layers.types.d.ts +226 -0
  140. package/dist/layers.types.js +1 -0
  141. package/dist/layout.d.ts +97 -0
  142. package/dist/layout.js +381 -0
  143. package/dist/layout.style.d.ts +6 -0
  144. package/dist/layout.style.js +17 -0
  145. package/dist/layouts-entry.d.ts +5 -0
  146. package/dist/layouts-entry.js +4 -0
  147. package/dist/leagues/aussie.d.ts +57 -0
  148. package/dist/leagues/aussie.js +36 -0
  149. package/dist/leagues/baseball.d.ts +58 -0
  150. package/dist/leagues/baseball.js +171 -0
  151. package/dist/leagues/basketball.d.ts +67 -0
  152. package/dist/leagues/basketball.js +128 -0
  153. package/dist/leagues/courts.d.ts +212 -0
  154. package/dist/leagues/courts.js +114 -0
  155. package/dist/leagues/cricket.d.ts +45 -0
  156. package/dist/leagues/cricket.js +34 -0
  157. package/dist/leagues/curling.d.ts +64 -0
  158. package/dist/leagues/curling.js +53 -0
  159. package/dist/leagues/fieldhockey.d.ts +48 -0
  160. package/dist/leagues/fieldhockey.js +29 -0
  161. package/dist/leagues/fields.d.ts +10 -0
  162. package/dist/leagues/fields.js +6 -0
  163. package/dist/leagues/football.d.ts +8 -0
  164. package/dist/leagues/football.js +82 -0
  165. package/dist/leagues/gaelic.d.ts +50 -0
  166. package/dist/leagues/gaelic.js +29 -0
  167. package/dist/leagues/handball.d.ts +45 -0
  168. package/dist/leagues/handball.js +32 -0
  169. package/dist/leagues/hockey.d.ts +63 -0
  170. package/dist/leagues/hockey.js +166 -0
  171. package/dist/leagues/lacrosse.d.ts +103 -0
  172. package/dist/leagues/lacrosse.js +175 -0
  173. package/dist/leagues/rugby.d.ts +59 -0
  174. package/dist/leagues/rugby.js +72 -0
  175. package/dist/leagues/sources.d.ts +18 -0
  176. package/dist/leagues/sources.js +95 -0
  177. package/dist/leagues/types.d.ts +43 -0
  178. package/dist/leagues/types.js +5 -0
  179. package/dist/leagues-entry.d.ts +23 -0
  180. package/dist/leagues-entry.js +15 -0
  181. package/dist/leagues.d.ts +172 -0
  182. package/dist/leagues.js +462 -0
  183. package/dist/look.d.ts +50 -0
  184. package/dist/look.js +186 -0
  185. package/dist/mark.d.ts +35 -0
  186. package/dist/mark.js +59 -0
  187. package/dist/mount-entry.d.ts +2 -0
  188. package/dist/mount-entry.js +2 -0
  189. package/dist/mount.d.ts +63 -0
  190. package/dist/mount.js +167 -0
  191. package/dist/mow.d.ts +36 -0
  192. package/dist/mow.js +111 -0
  193. package/dist/names.d.ts +77 -0
  194. package/dist/names.js +97 -0
  195. package/dist/outline.d.ts +25 -0
  196. package/dist/outline.js +112 -0
  197. package/dist/parks-entry.d.ts +4 -0
  198. package/dist/parks-entry.js +3 -0
  199. package/dist/parks.d.ts +200 -0
  200. package/dist/parks.data.d.ts +2 -0
  201. package/dist/parks.data.js +4489 -0
  202. package/dist/parks.js +92 -0
  203. package/dist/plot-entry.d.ts +2 -0
  204. package/dist/plot-entry.js +2 -0
  205. package/dist/plot.d.ts +74 -0
  206. package/dist/plot.js +68 -0
  207. package/dist/png-entry.d.ts +2 -0
  208. package/dist/png-entry.js +2 -0
  209. package/dist/png.d.ts +26 -0
  210. package/dist/png.js +46 -0
  211. package/dist/ranges.d.ts +33 -0
  212. package/dist/ranges.js +178 -0
  213. package/dist/ranges.names.d.ts +31 -0
  214. package/dist/ranges.names.js +65 -0
  215. package/dist/react-entry.d.ts +2 -0
  216. package/dist/react-entry.js +2 -0
  217. package/dist/react.d.ts +53 -0
  218. package/dist/react.js +58 -0
  219. package/dist/replay-entry.d.ts +5 -0
  220. package/dist/replay-entry.js +4 -0
  221. package/dist/replay.control.d.ts +47 -0
  222. package/dist/replay.control.js +184 -0
  223. package/dist/replay.d.ts +170 -0
  224. package/dist/replay.dom.d.ts +21 -0
  225. package/dist/replay.dom.js +388 -0
  226. package/dist/replay.js +579 -0
  227. package/dist/replay.types.d.ts +152 -0
  228. package/dist/replay.types.js +1 -0
  229. package/dist/restyle.d.ts +21 -0
  230. package/dist/restyle.js +70 -0
  231. package/dist/road.d.ts +26 -0
  232. package/dist/road.draw.d.ts +6 -0
  233. package/dist/road.draw.js +269 -0
  234. package/dist/road.js +59 -0
  235. package/dist/road.model.d.ts +63 -0
  236. package/dist/road.model.js +215 -0
  237. package/dist/road.style.d.ts +7 -0
  238. package/dist/road.style.js +26 -0
  239. package/dist/road.types.d.ts +122 -0
  240. package/dist/road.types.js +1 -0
  241. package/dist/scene-entry.d.ts +7 -0
  242. package/dist/scene-entry.js +5 -0
  243. package/dist/scene.css.d.ts +44 -0
  244. package/dist/scene.css.js +296 -0
  245. package/dist/scene.d.ts +27 -0
  246. package/dist/scene.fit.d.ts +12 -0
  247. package/dist/scene.fit.js +18 -0
  248. package/dist/scene.flat.d.ts +38 -0
  249. package/dist/scene.flat.js +167 -0
  250. package/dist/scene.js +420 -0
  251. package/dist/scene.path.d.ts +40 -0
  252. package/dist/scene.path.js +357 -0
  253. package/dist/scene.types.d.ts +172 -0
  254. package/dist/scene.types.js +1 -0
  255. package/dist/scene.xml.d.ts +31 -0
  256. package/dist/scene.xml.js +81 -0
  257. package/dist/score.d.ts +70 -0
  258. package/dist/score.js +212 -0
  259. package/dist/sets.board.d.ts +22 -0
  260. package/dist/sets.board.js +89 -0
  261. package/dist/sheet.d.ts +18 -0
  262. package/dist/sheet.js +38 -0
  263. package/dist/special.d.ts +44 -0
  264. package/dist/special.js +204 -0
  265. package/dist/special.style.d.ts +8 -0
  266. package/dist/special.style.js +36 -0
  267. package/dist/strings.d.ts +581 -0
  268. package/dist/strings.js +411 -0
  269. package/dist/style.d.ts +35 -0
  270. package/dist/style.js +177 -0
  271. package/dist/surfaces/baseball.d.ts +33 -0
  272. package/dist/surfaces/baseball.js +208 -0
  273. package/dist/surfaces/baseball.walls.d.ts +16 -0
  274. package/dist/surfaces/baseball.walls.js +150 -0
  275. package/dist/surfaces/basketball.d.ts +8 -0
  276. package/dist/surfaces/basketball.js +199 -0
  277. package/dist/surfaces/curling.d.ts +23 -0
  278. package/dist/surfaces/curling.js +128 -0
  279. package/dist/surfaces/field.d.ts +12 -0
  280. package/dist/surfaces/field.js +163 -0
  281. package/dist/surfaces/football.d.ts +12 -0
  282. package/dist/surfaces/football.js +208 -0
  283. package/dist/surfaces/hockey.d.ts +10 -0
  284. package/dist/surfaces/hockey.js +166 -0
  285. package/dist/surfaces/net.d.ts +7 -0
  286. package/dist/surfaces/net.js +151 -0
  287. package/dist/surfaces/soccer-providers.d.ts +124 -0
  288. package/dist/surfaces/soccer-providers.js +334 -0
  289. package/dist/surfaces/soccer-spec.d.ts +138 -0
  290. package/dist/surfaces/soccer-spec.js +175 -0
  291. package/dist/surfaces/soccer.d.ts +25 -0
  292. package/dist/surfaces/soccer.js +270 -0
  293. package/dist/surfaces/surface.d.ts +180 -0
  294. package/dist/surfaces/surface.js +49 -0
  295. package/dist/team.common.d.ts +75 -0
  296. package/dist/team.common.js +97 -0
  297. package/dist/team.formation.d.ts +24 -0
  298. package/dist/team.formation.js +121 -0
  299. package/dist/team.geometry.d.ts +66 -0
  300. package/dist/team.geometry.js +304 -0
  301. package/dist/team.layers.d.ts +16 -0
  302. package/dist/team.layers.js +32 -0
  303. package/dist/team.motion.d.ts +9 -0
  304. package/dist/team.motion.js +325 -0
  305. package/dist/team.network.d.ts +43 -0
  306. package/dist/team.network.js +215 -0
  307. package/dist/team.shape.d.ts +12 -0
  308. package/dist/team.shape.js +217 -0
  309. package/dist/team.types.d.ts +189 -0
  310. package/dist/team.types.js +1 -0
  311. package/dist/text.d.ts +31 -0
  312. package/dist/text.js +88 -0
  313. package/dist/themes.d.ts +14 -0
  314. package/dist/themes.js +24 -0
  315. package/dist/types.d.ts +565 -0
  316. package/dist/types.js +1 -0
  317. package/dist/units.d.ts +45 -0
  318. package/dist/units.js +90 -0
  319. package/dist/version.d.ts +2 -0
  320. package/dist/version.js +2 -0
  321. package/package.json +234 -4
package/dist/mow.js ADDED
@@ -0,0 +1,111 @@
1
+ // How grass is mown: the lighter tone of a pattern as one path, for a rectangle of turf (a football field, a soccer pitch) and for the fair ground of a
2
+ // ballpark. Written from the patterns themselves (alternate bands, a chequerboard, 45-degree bands, rings and wedges); a pattern is cells of one tone laid
3
+ // on the other, and every cell is a plain rectangle, polygon or annulus.
4
+ import { num } from "./format.js";
5
+ const NONE = { path: "", clip: false, evenodd: false };
6
+ /** An odd whole number of cells nearest to a length over a cell: odd, so that both ends of the turf are mown alike. */
7
+ export const oddCells = (length, cell) => Math.max(3, 2 * Math.round((length / cell - 1) / 2) + 1);
8
+ const box = (x, y, w, h) => `M${num(x)} ${num(y)}h${num(w)}v${num(h)}h${num(-w)}z`;
9
+ /** An annulus between two radii about a centre, as two circles of one path. */
10
+ const ring = (cx, cy, inner, outer) => {
11
+ const circle = (r) => `M${num(cx - r)} ${num(cy)}a${num(r)} ${num(r)} 0 1 0 ${num(2 * r)} 0a${num(r)} ${num(r)} 0 1 0 ${num(-2 * r)} 0z`;
12
+ return inner <= 0 ? circle(outer) : `${circle(outer)}${circle(inner)}`;
13
+ };
14
+ /**
15
+ * The lighter tone of a pattern on a rectangle of turf. `band` is the width of the usual stripe, along x; `wide` and `narrow` are twice and half of it.
16
+ * `bands` run across the turf (side by side along x), `lengthwise` along it, `checks` are squares of about `band`, `diagonal` are 45-degree stripes
17
+ * `band` wide across, and `circles` are rings `band` wide about the middle. A pattern that is not one of these (`none`, `rings`, `fan`) has no tone here.
18
+ */
19
+ export function mowTurf(pattern, turf, band) {
20
+ const { x, y, w, h } = turf;
21
+ const parts = [];
22
+ switch (pattern) {
23
+ case "bands":
24
+ case "wide":
25
+ case "narrow": {
26
+ const b = pattern === "wide" ? band * 2 : pattern === "narrow" ? band / 2 : band;
27
+ for (let k = 1; k * b < w - 1e-6; k += 2)
28
+ parts.push(box(x + k * b, y, Math.min(b, w - k * b), h));
29
+ return { path: parts.join(""), clip: false, evenodd: false };
30
+ }
31
+ case "lengthwise": {
32
+ const rows = oddCells(h, band);
33
+ for (let j = 1; j < rows; j += 2)
34
+ parts.push(box(x, y + (h / rows) * j, w, h / rows));
35
+ return { path: parts.join(""), clip: false, evenodd: false };
36
+ }
37
+ case "checks": {
38
+ const cols = oddCells(w, band);
39
+ const rows = oddCells(h, band);
40
+ for (let i = 0; i < cols; i += 1)
41
+ for (let j = 0; j < rows; j += 1)
42
+ if ((i + j) % 2 === 1)
43
+ parts.push(box(x + (w / cols) * i, y + (h / rows) * j, w / cols, h / rows));
44
+ return { path: parts.join(""), clip: false, evenodd: false };
45
+ }
46
+ case "diagonal": {
47
+ const across = band * Math.SQRT2;
48
+ for (let a = x - h; a < x + w; a += 2 * across)
49
+ parts.push(`M${num(a)} ${num(y + h)}L${num(a + h)} ${num(y)}L${num(a + h + across)} ${num(y)}L${num(a + across)} ${num(y + h)}z`);
50
+ return { path: parts.join(""), clip: true, evenodd: false };
51
+ }
52
+ case "circles": {
53
+ const cx = x + w / 2;
54
+ const cy = y + h / 2;
55
+ const reach = Math.hypot(w / 2, h / 2);
56
+ for (let k = 1; k * band < reach; k += 2)
57
+ parts.push(ring(cx, cy, k * band, (k + 1) * band));
58
+ return { path: parts.join(""), clip: true, evenodd: true };
59
+ }
60
+ default:
61
+ return NONE;
62
+ }
63
+ }
64
+ /**
65
+ * The lighter tone of a pattern on a ballpark: coordinates are the field's screen frame (x across, y minus the distance out from home plate). `band` is
66
+ * 30 feet, the width of a stripe of the usual rings. `bands` run across the field at fixed distances out from home, `lengthwise` along the line to centre
67
+ * field, `checks` are squares, `diagonal` run at 45 degrees, `fan` is wedges out from home plate, 6 degrees each. `rings` and `circles` are the park's own
68
+ * arcs about home plate (drawn by the field itself) and `none` is plain, so they have no tone here. The path runs past the fence and must be cut to the fair ground.
69
+ */
70
+ export function mowPark(pattern, park, band = 30) {
71
+ const { umin, umax, vmax } = park;
72
+ const parts = [];
73
+ const reach = vmax + band;
74
+ const b = pattern === "wide" ? band * 2 : pattern === "narrow" ? band / 2 : band;
75
+ switch (pattern) {
76
+ case "bands":
77
+ case "wide":
78
+ case "narrow":
79
+ for (let k = 1; k * b < reach; k += 2)
80
+ parts.push(box(umin - band, -(k + 1) * b, umax - umin + 2 * band, b));
81
+ return { path: parts.join(""), clip: true, evenodd: false };
82
+ case "lengthwise":
83
+ for (let k = Math.floor(umin / b); k * b < umax; k += 1)
84
+ if (Math.abs(k) % 2 === 1)
85
+ parts.push(box(k * b, -reach, b, reach));
86
+ return { path: parts.join(""), clip: true, evenodd: false };
87
+ case "checks":
88
+ for (let i = Math.floor(umin / band); i * band < umax; i += 1)
89
+ for (let j = 0; j * band < reach; j += 1)
90
+ if ((Math.abs(i) + j) % 2 === 1)
91
+ parts.push(box(i * band, -(j + 1) * band, band, band));
92
+ return { path: parts.join(""), clip: true, evenodd: false };
93
+ case "diagonal": {
94
+ const across = band * Math.SQRT2;
95
+ for (let a = umin - reach; a < umax; a += 2 * across)
96
+ parts.push(`M${num(a)} 0L${num(a + reach)} ${num(-reach)}L${num(a + reach + across)} ${num(-reach)}L${num(a + across)} 0z`);
97
+ return { path: parts.join(""), clip: true, evenodd: false };
98
+ }
99
+ case "fan": {
100
+ const step = (6 * Math.PI) / 180;
101
+ const R = reach * 1.5;
102
+ const at = (angle) => `${num(R * Math.sin(angle))} ${num(-R * Math.cos(angle))}`;
103
+ for (let k = 0; k < 15; k += 1)
104
+ if (k % 2 === 1)
105
+ parts.push(`M0 0L${at(-Math.PI / 4 + k * step)}L${at(-Math.PI / 4 + (k + 1) * step)}z`);
106
+ return { path: parts.join(""), clip: true, evenodd: false };
107
+ }
108
+ default:
109
+ return NONE;
110
+ }
111
+ }
@@ -0,0 +1,77 @@
1
+ import type { Language } from "./types.ts";
2
+ /** What an alias is. `official` is the name the owner or operator gives it (when it is not the everyday one), `wikipedia` the title of an article that is cited, `sponsor` a naming-rights name, `former` an earlier name and `nickname` a short form or a name people use. */
3
+ export type PlaceNameKind = "official" | "wikipedia" | "sponsor" | "former" | "nickname";
4
+ /** Another name of a place: a title, an earlier or a sponsor's name, a nickname. */
5
+ export interface PlaceAlias {
6
+ name: string;
7
+ /** The language of the name: `en`, `ja`, `es`, `de`... */
8
+ lang: string;
9
+ kind: PlaceNameKind;
10
+ /** The first and the last year the name was in use, where a source dates it. */
11
+ from?: number;
12
+ to?: number;
13
+ /** Where the name was read: an article and its revision, or a Wikidata item and property (`Wikidata Q49136 P1448`). */
14
+ source?: string;
15
+ /** For a `wikipedia` alias, the revision of the article that is cited. */
16
+ revision?: number;
17
+ /** The reading of a name in Japanese that has kanji, in kana (`よこはまこくさいそうごうきょうぎじょう`); given for the cited and official names of the places of Japan. */
18
+ reading?: string;
19
+ }
20
+ /** The names a place carries. */
21
+ export interface PlaceNames {
22
+ /** The everyday name in English, the one English sports media use. */
23
+ name: string;
24
+ /** The everyday name in Japanese. */
25
+ nameJa?: string;
26
+ /** The reading of `nameJa` in hiragana and katakana, given wherever `nameJa` has kanji. */
27
+ readingJa?: string;
28
+ /** The everyday name in the language of the place. */
29
+ localName?: string;
30
+ /** The language of `localName`: `es`, `pt`, `de`, `ja`, ... */
31
+ localLanguage?: string;
32
+ /** Every other name: the cited titles of Wikipedia, the official, sponsor and former names with their years, the nicknames. */
33
+ aliases?: readonly PlaceAlias[];
34
+ /** Names the place had for some years, first to last: where two share a year the later one is the name at the end of it. */
35
+ names?: readonly {
36
+ name: string;
37
+ from: number;
38
+ to: number;
39
+ }[];
40
+ }
41
+ /**
42
+ * A name made fit to compare: width, case, accents, kana (hiragana is katakana), the old and new forms of the same sound (ヂ, ヅ, ヴ), the long vowel mark and every space, dot
43
+ * and mark of punctuation put aside, so that `Estádio Maracanã` and `estadio maracana` are one name, as are `ヤンキー・スタジアム` and `ヤンキースタジアム`.
44
+ */
45
+ export declare function plainName(text: string): string;
46
+ /** Every name a place answers to, with how close to the everyday name it is: 0 the everyday names, 1 the official, cited and sponsor names, 2 the former names and nicknames. */
47
+ export interface NameEntry {
48
+ name: string;
49
+ lang: string;
50
+ rank: 0 | 1 | 2;
51
+ from?: number;
52
+ to?: number;
53
+ }
54
+ /** The names of a place, in order of rank: its everyday names, its dated names, then its aliases. */
55
+ export declare function nameEntries(place: PlaceNames): NameEntry[];
56
+ /** How well a query matches a place: the lowest rank of any of its names that is the query once made plain (with or without a leading `The`), or `undefined` for no name. */
57
+ export declare function nameRank(place: PlaceNames, query: string): 0 | 1 | 2 | undefined;
58
+ /** Whether every word of a text is found in some name of the place (made plain), for a search box. */
59
+ export declare function nameContainsAll(place: PlaceNames, words: readonly string[]): boolean;
60
+ /**
61
+ * The places that answer to a name, best match first: the everyday names, then the official, cited and sponsor names and the dated names, then the former names and the
62
+ * nicknames; places of the same rank keep the order of the list given.
63
+ */
64
+ export declare function placesNamed<T extends PlaceNames>(places: readonly T[], query: string | undefined): T[];
65
+ /**
66
+ * The name a place officially has, in a language, when it is not the everyday name: the `official` alias in that language that stands in `year` (without a year, the one that
67
+ * stands today). In English, where there is none in English, a name in the place's own language that is written in Latin letters stands for it (`Estadio Banorte`). `undefined` when
68
+ * there is none or when it is the name shown.
69
+ * @example
70
+ * ```ts
71
+ * import { PARKS, officialName } from "@johnmorrisdotca/kyogijo-stadiums/parks";
72
+ * const koshien = PARKS["hanshin-koshien-stadium"];
73
+ * console.log(officialName(koshien, "en"), "/", officialName(koshien, "ja"));
74
+ * // Hanshin Koshien Stadium / 阪神甲子園球場
75
+ * ```
76
+ */
77
+ export declare function officialName(place: PlaceNames, language: Language, shown?: string, year?: number): string | undefined;
package/dist/names.js ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * A name made fit to compare: width, case, accents, kana (hiragana is katakana), the old and new forms of the same sound (ヂ, ヅ, ヴ), the long vowel mark and every space, dot
3
+ * and mark of punctuation put aside, so that `Estádio Maracanã` and `estadio maracana` are one name, as are `ヤンキー・スタジアム` and `ヤンキースタジアム`.
4
+ */
5
+ export function plainName(text) {
6
+ return text
7
+ .normalize("NFKC")
8
+ .toLowerCase()
9
+ .normalize("NFD")
10
+ .replace(/[̀-ͯ]/g, "")
11
+ .normalize("NFC")
12
+ .replace(/[ぁ-ゖ]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 0x60))
13
+ .replace(/ヴァ/g, "バ")
14
+ .replace(/ヴィ/g, "ビ")
15
+ .replace(/ヴェ/g, "ベ")
16
+ .replace(/ヴォ/g, "ボ")
17
+ .replace(/ヴ/g, "ブ")
18
+ .replace(/ヂ/g, "ジ")
19
+ .replace(/ヅ/g, "ズ")
20
+ .replace(/ー/g, "")
21
+ .replace(/[^\p{L}\p{N}]/gu, "");
22
+ }
23
+ /** The names of a place, in order of rank: its everyday names, its dated names, then its aliases. */
24
+ export function nameEntries(place) {
25
+ const out = [{ name: place.name, lang: "en", rank: 0 }];
26
+ if (place.nameJa !== undefined)
27
+ out.push({ name: place.nameJa, lang: "ja", rank: 0 });
28
+ if (place.localName !== undefined)
29
+ out.push({ name: place.localName, lang: place.localLanguage ?? "", rank: 0 });
30
+ for (const period of place.names ?? [])
31
+ out.push({ name: period.name, lang: "en", rank: 1, from: period.from, to: period.to });
32
+ for (const alias of place.aliases ?? []) {
33
+ const rank = alias.kind === "former" || alias.kind === "nickname" ? 2 : 1;
34
+ const years = { ...(alias.from === undefined ? {} : { from: alias.from }), ...(alias.to === undefined ? {} : { to: alias.to }) };
35
+ out.push({ name: alias.name, lang: alias.lang, rank, ...years });
36
+ if (alias.reading !== undefined)
37
+ out.push({ name: alias.reading, lang: "ja", rank, ...years });
38
+ }
39
+ if (place.readingJa !== undefined)
40
+ out.push({ name: place.readingJa, lang: "ja", rank: 1 });
41
+ return out;
42
+ }
43
+ /** The same name without its article in English (`The Big Egg` is `Big Egg`), as both are said. */
44
+ const withoutThe = (text) => text.replace(/^the\s+/i, "");
45
+ /** How well a query matches a place: the lowest rank of any of its names that is the query once made plain (with or without a leading `The`), or `undefined` for no name. */
46
+ export function nameRank(place, query) {
47
+ const wanted = plainName(withoutThe(query));
48
+ if (wanted === "")
49
+ return undefined;
50
+ let best;
51
+ for (const entry of nameEntries(place))
52
+ if ((best === undefined || entry.rank < best) && plainName(withoutThe(entry.name)) === wanted)
53
+ best = entry.rank;
54
+ return best;
55
+ }
56
+ /** Whether every word of a text is found in some name of the place (made plain), for a search box. */
57
+ export function nameContainsAll(place, words) {
58
+ const haystack = nameEntries(place).map((entry) => plainName(entry.name)).join(" ");
59
+ return words.every((word) => haystack.includes(plainName(word)));
60
+ }
61
+ /**
62
+ * The places that answer to a name, best match first: the everyday names, then the official, cited and sponsor names and the dated names, then the former names and the
63
+ * nicknames; places of the same rank keep the order of the list given.
64
+ */
65
+ export function placesNamed(places, query) {
66
+ if (query === undefined)
67
+ return [];
68
+ const ranked = [];
69
+ places.forEach((place, index) => {
70
+ const rank = nameRank(place, query);
71
+ if (rank !== undefined)
72
+ ranked.push([rank, index, place]);
73
+ });
74
+ return ranked.sort((a, b) => a[0] - b[0] || a[1] - b[1]).map((row) => row[2]);
75
+ }
76
+ const covers = (alias, year) => (year === undefined ? alias.to === undefined : (alias.from === undefined || alias.from <= year) && (alias.to === undefined || year <= alias.to));
77
+ /**
78
+ * The name a place officially has, in a language, when it is not the everyday name: the `official` alias in that language that stands in `year` (without a year, the one that
79
+ * stands today). In English, where there is none in English, a name in the place's own language that is written in Latin letters stands for it (`Estadio Banorte`). `undefined` when
80
+ * there is none or when it is the name shown.
81
+ * @example
82
+ * ```ts
83
+ * import { PARKS, officialName } from "@johnmorrisdotca/kyogijo-stadiums/parks";
84
+ * const koshien = PARKS["hanshin-koshien-stadium"];
85
+ * console.log(officialName(koshien, "en"), "/", officialName(koshien, "ja"));
86
+ * // Hanshin Koshien Stadium / 阪神甲子園球場
87
+ * ```
88
+ */
89
+ export function officialName(place, language, shown, year) {
90
+ const current = shown ?? (language === "ja" ? place.nameJa : place.name);
91
+ const fits = (alias) => alias.kind === "official" && covers(alias, year) && (current === undefined || plainName(alias.name) !== plainName(current));
92
+ const aliases = place.aliases ?? [];
93
+ const own = aliases.find((alias) => fits(alias) && alias.lang === language);
94
+ if (own !== undefined || language !== "en")
95
+ return own?.name;
96
+ return aliases.find((alias) => fits(alias) && alias.lang === place.localLanguage && /^[\p{Script=Latin}\d\s.,'’()&–-]+$/u.test(alias.name))?.name;
97
+ }
@@ -0,0 +1,25 @@
1
+ import type { SurfaceOptions } from "./types.ts";
2
+ /** A surface's outline as a path, with the box round it. */
3
+ export interface Outline {
4
+ /** The path of the playing surface's edge: the boards for a rink, the lines of a court, the fence and the foul lines for a ballpark. */
5
+ d: string;
6
+ box: {
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ };
12
+ /** True when a point (in the drawing's frame, feet) is on the surface, or on its edge. */
13
+ contains(x: number, y: number): boolean;
14
+ }
15
+ /** The size a provider's frame is fitted to: the drawn surface's own `box`, for a soccer pitch, a curling sheet, a net sport's court and a league's surface; none for a sport's own fixed one. */
16
+ export declare const frameSizeOf: (o: Pick<SurfaceOptions, "sport" | "league">, box: {
17
+ w: number;
18
+ h: number;
19
+ }) => {
20
+ length: number;
21
+ width: number;
22
+ unit: "ft";
23
+ } | undefined;
24
+ /** The outline of the surface the options draw. */
25
+ export declare function outlineOf(o: Pick<SurfaceOptions, "sport" | "park" | "fence" | "units" | "pitch" | "league" | "year" | "sheet" | "net"> & Partial<Pick<SurfaceOptions, "field" | "detail">>): Outline;
@@ -0,0 +1,112 @@
1
+ // The outline of a playing surface in the drawing's own frame (feet, x along the surface from the left, y across it from the top;
2
+ // a ballpark's x is across the field and its y minus the distance out from home plate): where a data layer is cut, and the size
3
+ // its marks follow.
4
+ import { FEET_PER_METRE, FOOTBALL, NBA, NHL, footballLength, surfaceSize } from "./geometry.js";
5
+ import { chooseLeague, courtOf, diamondOf, fieldOf, rinkOf } from "./leagues.js";
6
+ import { diamondFence } from "./leagues/baseball.js";
7
+ import { fenceFor, parkById } from "./parks.js";
8
+ import { fenceOutline } from "./surfaces/baseball.js";
9
+ import { soccerSpec } from "./surfaces/soccer-spec.js";
10
+ import { roundedRect } from "./surfaces/surface.js";
11
+ import { feetFence, lengthUnit } from "./common.js";
12
+ import { num } from "./format.js";
13
+ import { courtFor, courtSize, isNetSport } from "./court.js";
14
+ import { fieldPlan, isFieldSport } from "./fields.js";
15
+ import { inOutline, outlineD } from "./fields.kit.js";
16
+ import { sheetFor } from "./sheet.js";
17
+ const inBox = (box, x, y) => x >= box.x && x <= box.x + box.w && y >= box.y && y <= box.y + box.h;
18
+ const rect = (w, h) => {
19
+ const box = { x: 0, y: 0, w, h };
20
+ return { d: `M0 0H${num(w)}V${num(h)}H0Z`, box, contains: (x, y) => inBox(box, x, y) };
21
+ };
22
+ /** Whether a point is in a polygon (even-odd). */
23
+ function inPolygon(points, x, y) {
24
+ let inside = false;
25
+ for (let i = 0, j = points.length - 1; i < points.length; j = i, i += 1) {
26
+ const [xi, yi] = points[i];
27
+ const [xj, yj] = points[j];
28
+ if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi)
29
+ inside = !inside;
30
+ }
31
+ return inside;
32
+ }
33
+ /** The size a provider's frame is fitted to: the drawn surface's own `box`, for a soccer pitch, a curling sheet, a net sport's court and a league's surface; none for a sport's own fixed one. */
34
+ export const frameSizeOf = (o, box) => o.sport === "soccer" || o.sport === "curling" || isNetSport(o.sport) || isFieldSport(o.sport) || chooseLeague(o).league !== undefined ? { length: box.w, width: box.h, unit: "ft" } : undefined;
35
+ /** The outline of the surface the options draw. */
36
+ export function outlineOf(o) {
37
+ const { sport, league } = chooseLeague(o);
38
+ switch (sport) {
39
+ case "nfl":
40
+ case "cfl":
41
+ case "ifaf": {
42
+ if (league?.family === "football") {
43
+ const field = fieldOf(league, o.year);
44
+ return rect(footballLength(field), field.width);
45
+ }
46
+ return rect(footballLength(FOOTBALL[sport]), FOOTBALL[sport].width);
47
+ }
48
+ case "nhl": {
49
+ const rink = league?.family === "hockey" ? rinkOf(league, o.year) : undefined;
50
+ const [length, width, r] = rink === undefined ? [NHL.length, NHL.width, NHL.cornerRadius] : [rink.length, rink.width, rink.cornerRadius];
51
+ const box = { x: 0, y: 0, w: length, h: width };
52
+ // A rectangle with quarter-circle corners: outside only when a point is in a corner's square but beyond its arc.
53
+ const contains = (x, y) => {
54
+ if (!inBox(box, x, y))
55
+ return false;
56
+ const cx = x < r ? r : x > box.w - r ? box.w - r : x;
57
+ const cy = y < r ? r : y > box.h - r ? box.h - r : y;
58
+ return (x - cx) ** 2 + (y - cy) ** 2 <= r * r;
59
+ };
60
+ return { d: roundedRect(0, 0, length, width, r), box, contains };
61
+ }
62
+ case "nba": {
63
+ if (league?.family === "basketball") {
64
+ const court = courtOf(league, o.year);
65
+ return rect(court.length, court.width);
66
+ }
67
+ return rect(NBA.length, NBA.width);
68
+ }
69
+ case "mlb": {
70
+ const generic = league?.family === "baseball" ? diamondFence(diamondOf(league, o.year)) : undefined;
71
+ const outline = fenceOutline(fenceFor(parkById(o.park), feetFence(o.fence, lengthUnit(o)), o.year, generic));
72
+ const us = outline.map(([u]) => u);
73
+ const vs = outline.map(([, v]) => v);
74
+ const x = Math.min(...us);
75
+ const vmax = Math.max(...vs);
76
+ const d = `M0 0L${outline.map(([u, v]) => `${num(u)} ${num(-v)}`).join("L")}Z`;
77
+ const polygon = [[0, 0], ...outline.map(([u, v]) => [u, -v])];
78
+ return { d, box: { x, y: -vmax, w: Math.max(...us) - x, h: vmax }, contains: (px, py) => inPolygon(polygon, px, py) };
79
+ }
80
+ case "soccer": {
81
+ const spec = soccerSpec(o.pitch, o.units === undefined ? "m" : lengthUnit(o));
82
+ return rect(spec.length * FEET_PER_METRE, spec.width * FEET_PER_METRE);
83
+ }
84
+ case "curling": {
85
+ const { spec } = sheetFor(o);
86
+ return rect(spec.length, spec.width);
87
+ }
88
+ case "tennis":
89
+ case "volleyball":
90
+ case "badminton":
91
+ case "pickleball":
92
+ case "tabletennis": {
93
+ const { length, width } = courtSize(courtFor({ ...o, sport }));
94
+ return rect(length, width);
95
+ }
96
+ case "lacrosse":
97
+ case "rugby":
98
+ case "afl":
99
+ case "gaelic":
100
+ case "cricket":
101
+ case "fieldhockey":
102
+ case "handball": {
103
+ const plan = fieldPlan({ ...o, sport });
104
+ return { d: outlineD(plan.length, plan.width, plan.outline), box: { x: 0, y: 0, w: plan.length, h: plan.width }, contains: (x, y) => inOutline(plan.length, plan.width, plan.outline, x, y) };
105
+ }
106
+ default: {
107
+ // A surface added later with one size is a rectangle until it says otherwise.
108
+ const size = surfaceSize(o.sport, "ft");
109
+ return rect(size.length, size.width);
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,4 @@
1
+ export { PARKS, PARK_IDS, fenceFor, parkById, parkByName, parkByWikidata, parkNameIn, parkOfficialName, parkPointsIn, parkQuirksIn, parkSourceUrl, parkUnit, parkWallsIn, parksByName } from "./parks.ts";
2
+ export { officialName, plainName } from "./names.ts";
3
+ export type { PlaceAlias, PlaceNameKind } from "./names.ts";
4
+ export type { CoverQuirk, DugoutSide, HillQuirk, OverhangQuirk, Park, ParkData, ParkDugouts, ParkPeriod, ParkPeriodData, ParkQuirk, ParkSource, ParkWall, ParkWallData, PointQuirk, QuirkKind, WallPlace } from "./parks.ts";
@@ -0,0 +1,3 @@
1
+ // The ballparks: their fence distances, with the article each was read from.
2
+ export { PARKS, PARK_IDS, fenceFor, parkById, parkByName, parkByWikidata, parkNameIn, parkOfficialName, parkPointsIn, parkQuirksIn, parkSourceUrl, parkUnit, parkWallsIn, parksByName } from "./parks.js";
3
+ export { officialName, plainName } from "./names.js";
@@ -0,0 +1,200 @@
1
+ import { type FencePoint } from "./geometry.ts";
2
+ import { type PlaceAlias } from "./names.ts";
3
+ import type { Fence, Language } from "./types.ts";
4
+ import type { Unit } from "./units.ts";
5
+ /** Where a park's figures were read: an article of Wikipedia at a revision. */
6
+ export interface ParkSource {
7
+ title: string;
8
+ revision: number;
9
+ }
10
+ /** A fence that stood for some seasons of a past park: the figures an article dates, from the first season to the last. */
11
+ export interface ParkPeriodData {
12
+ from: number;
13
+ to: number;
14
+ /** [angle from dead centre, distance in the park's unit], from the left field line to the right. */
15
+ points: [number, number][];
16
+ }
17
+ /** Where a stretch of wall stands, in words: a key of the words of `ballpark.sections` (`left`, `leftCorner`, `deadCenter`, `centerToRight`...). */
18
+ export type WallPlace = "outfield" | "left" | "leftCenter" | "center" | "deadCenter" | "rightCenter" | "right" | "leftToCenter" | "centerToRight" | "leftCorner" | "rightCorner";
19
+ /** A stretch of the fence and how high it stands, as the figures give it (the height in the park's unit). */
20
+ export interface ParkWallData {
21
+ /** The stretch's angles from dead centre: the left field line is -45 and the right field line 45 (our reading of the article's words, see docs/references.md). */
22
+ from: number;
23
+ to: number;
24
+ /** The height of the wall in the park's unit. */
25
+ height: number;
26
+ /** A name the wall has in the article (`Green Monster`); a wall without one is named by its place in the field. */
27
+ label?: string;
28
+ /** Where the article says the wall stands. */
29
+ place?: WallPlace;
30
+ /** The first and the last season the height stood, where the article dates it. A wall with no `last` is the one standing today (or when the park closed). */
31
+ first?: number;
32
+ last?: number;
33
+ }
34
+ /** A stretch of the fence and how high it stands, in feet. */
35
+ export interface ParkWall extends Omit<ParkWallData, "height"> {
36
+ height_ft: number;
37
+ }
38
+ /** The sides of the field a dugout is on: along the first base line or the third. */
39
+ export type DugoutSide = "first" | "third";
40
+ /** Which dugout is on which line, where the article says. */
41
+ export interface ParkDugouts {
42
+ home?: DugoutSide;
43
+ visitors?: DugoutSide;
44
+ }
45
+ /** What a quirk of a ballpark is. */
46
+ export type QuirkKind = "hill" | "overhang" | "pole" | "flagpole" | "bullpen" | "ivy" | "basket";
47
+ interface QuirkBase {
48
+ /** A name the article gives it (`Tal's Hill`, `Pesky's Pole`); a quirk without one is named by its kind. */
49
+ label?: string;
50
+ /** The first and the last season it stood, where the article dates it; with no `last` it is there today (or when the park closed). */
51
+ first?: number;
52
+ last?: number;
53
+ }
54
+ /** An incline in the field: against the fence at an angle and a distance, as wide as the article says (`width_ft`), and as steep as it says. */
55
+ export interface HillQuirk extends QuirkBase {
56
+ kind: "hill";
57
+ angle: number;
58
+ feet: number;
59
+ width_ft: number;
60
+ slope_deg?: number;
61
+ }
62
+ /** A stand that hangs over the fence into the field by `depth_ft`, along a stretch of it. */
63
+ export interface OverhangQuirk extends QuirkBase {
64
+ kind: "overhang";
65
+ from: number;
66
+ to: number;
67
+ depth_ft: number;
68
+ }
69
+ /** A foul pole, a flagpole or a bullpen at an angle and a distance from home plate. */
70
+ export interface PointQuirk extends QuirkBase {
71
+ kind: "pole" | "flagpole" | "bullpen";
72
+ angle: number;
73
+ feet: number;
74
+ /** The height of a pole, where the article gives it. */
75
+ height_ft?: number;
76
+ /** Whose bullpen it is, where the article says. */
77
+ side?: "home" | "visitors";
78
+ }
79
+ /** Ivy on the wall, or a basket on top of it, along a stretch of the fence. */
80
+ export interface CoverQuirk extends QuirkBase {
81
+ kind: "ivy" | "basket";
82
+ from: number;
83
+ to: number;
84
+ }
85
+ /** A quirk of a ballpark that its article describes with figures. */
86
+ export type ParkQuirk = HillQuirk | OverhangQuirk | PointQuirk | CoverQuirk;
87
+ /** A ballpark's fence as the figures give it. */
88
+ export interface ParkData {
89
+ /** The key: `fenway-park`. */
90
+ id: string;
91
+ /** The Wikidata item of the ground (`Q49136`), the key to join a park to other data. */
92
+ wikidata: string;
93
+ /** The everyday name in English, the one English sports media use (`Koshien Stadium`, `Oracle Park`); the title of the Wikipedia article is one of the `aliases`. */
94
+ name: string;
95
+ /** The everyday name in Japanese (`甲子園球場`, `マツダスタジアム`), as Japanese media say it; for a park of the United States and Canada the title of the Japanese Wikipedia article. */
96
+ nameJa: string;
97
+ /** The reading of `nameJa` in kana, given wherever `nameJa` has kanji (`こうしえんきゅうじょう`). */
98
+ readingJa?: string;
99
+ /** The everyday name in the language of the place (`ja` for the parks of Japan, `fr` for two in Montreal); the parks of English-speaking places have none. */
100
+ localName?: string;
101
+ /** The language of `localName`. */
102
+ localLanguage?: string;
103
+ /** Every other name, each with where it was read: the cited articles' titles (`wikipedia`, with the revision), the `official` name when it is not the everyday one, `sponsor` and `former` names with their years, `nickname`s. */
104
+ aliases?: PlaceAlias[];
105
+ team: string;
106
+ teamJa?: string;
107
+ city: string;
108
+ country: "US" | "CA" | "JP";
109
+ /** Wikidata's coordinates of the ground (P625), in degrees. */
110
+ lat: number;
111
+ lon: number;
112
+ league: "MLB" | "NPB";
113
+ /** The unit of `points`: feet for MLB, metres for NPB. */
114
+ unit: "ft" | "m";
115
+ /** `current` is a club's home today, `secondary` a ground a club also uses, `past` one a club has left. */
116
+ status: "current" | "secondary" | "past";
117
+ /** For a past MLB park, the first and the last season an MLB club called it home. */
118
+ from?: number;
119
+ to?: number;
120
+ /** The year the ground opened and the year it closed, as Wikidata gives them where it does (a current park has no `closed`). */
121
+ opened?: number;
122
+ closed?: number;
123
+ /** [angle from dead centre, distance in `unit`], from the left field line to the right: the last fence the park had. */
124
+ points: [number, number][];
125
+ /** Earlier fences, where the article dates them. A season in none of the periods has `points`. */
126
+ periods?: ParkPeriodData[];
127
+ /** The label the article gives some of the `points`, as [angle, words]: kept for the points beyond the usual five that were read from its text. */
128
+ labels?: [number, string][];
129
+ /** How high the fence stands along stretches of it, where the article gives the figures. */
130
+ walls?: ParkWallData[];
131
+ /** The quirks the article describes with figures: a hill, an overhang, a pole, the bullpens, ivy. */
132
+ quirks?: ParkQuirk[];
133
+ /** The width of the warning track in feet, where the article gives it (the rule of thumb of 15 feet is drawn without it). */
134
+ track_ft?: number;
135
+ /** The distance from home plate to the backstop in feet, where the article gives it. */
136
+ backstop_ft?: number;
137
+ /** Which dugout is on which side, where the article says. */
138
+ dugouts?: ParkDugouts;
139
+ /** The article in English the figures were read from. */
140
+ en?: ParkSource;
141
+ /** The article in Japanese. */
142
+ ja?: ParkSource;
143
+ note?: string;
144
+ }
145
+ /** A fence of some seasons, in feet. */
146
+ export interface ParkPeriod {
147
+ from: number;
148
+ to: number;
149
+ points: FencePoint[];
150
+ }
151
+ /** A ballpark, with its fence in feet. */
152
+ export interface Park extends Omit<ParkData, "points" | "unit" | "periods" | "walls"> {
153
+ /** [angle from dead centre, distance in feet]. */
154
+ points: FencePoint[];
155
+ periods?: ParkPeriod[];
156
+ /** How high the fence stands along stretches of it, in feet. */
157
+ walls?: ParkWall[];
158
+ }
159
+ /** The address of the revision of an article that a park's figures were read from. */
160
+ export declare function parkSourceUrl(source: ParkSource, language?: "en" | "ja"): string;
161
+ /** Every park by its key: the thirty current MLB ballparks, forty-three past ones, the twelve NPB home parks, and eight secondary or past NPB grounds. */
162
+ export declare const PARKS: Readonly<Record<string, Park>>;
163
+ /** The keys of `PARKS`: the current MLB parks, then the past ones by their first season, then the NPB's, each in the order of the sources. */
164
+ export declare const PARK_IDS: readonly string[];
165
+ /** The unit a park's figures were published in: metres for the parks of Japan (converted to feet once, in `PARKS`), feet for the rest. `undefined` for a key that is not a park. */
166
+ export declare const parkUnit: (id: string | undefined) => Unit | undefined;
167
+ /**
168
+ * The parks that answer to a name, best match first: the everyday names, then the official and cited names and the sponsors', then the former names and the nicknames. A name is
169
+ * compared without case, accents, spaces or punctuation, in full-width or half-width, and in Japanese with hiragana or katakana and with or without the long vowel mark.
170
+ * @example
171
+ * ```ts
172
+ * import { parksByName } from "@johnmorrisdotca/kyogijo-stadiums/parks";
173
+ * console.log(parksByName("Camden Yards")[0]?.id, parksByName("甲子園")[0]?.id, parksByName("ハマスタ")[0]?.id);
174
+ * // oriole-park-at-camden-yards hanshin-koshien-stadium yokohama-stadium
175
+ * ```
176
+ */
177
+ export declare const parksByName: (name: string | undefined) => Park[];
178
+ /** The park a name belongs to (see `parksByName`; the best match when several answer to it), or `undefined`. */
179
+ export declare const parkByName: (name: string | undefined) => Park | undefined;
180
+ /** A park's name in a language: the everyday name in English, or in Japanese. */
181
+ export declare const parkNameIn: (park: Park, language?: Language) => string;
182
+ /** The name a park officially has in a language, when it is not the everyday name (`Hanshin Koshien Stadium` for `Koshien Stadium`), in the year given or today; else `undefined`. */
183
+ export declare const parkOfficialName: (park: Park, language?: Language, year?: number) => string | undefined;
184
+ /** The park with a key, or `undefined`. */
185
+ export declare const parkById: (id: string | undefined) => Park | undefined;
186
+ /** The park whose Wikidata item is `Q49136`, or `undefined`. */
187
+ export declare const parkByWikidata: (wikidata: string | undefined) => Park | undefined;
188
+ /** A park's fence in a season: the period that names the season, else the park's last fence. */
189
+ export declare function parkPointsIn(park: Park, year: number | undefined): FencePoint[];
190
+ /** The stretches of fence a park has in a season, with their heights in feet: the heights the article dates for that season, else those of today. */
191
+ export declare function parkWallsIn(park: Park, year?: number): ParkWall[];
192
+ /** The quirks a park has in a season: those the article dates for that season, else those of today. */
193
+ export declare function parkQuirksIn(park: Park, year?: number): ParkQuirk[];
194
+ /**
195
+ * The fence points a drawing uses: a park's (as it stood in `year`, when the park has dated fences), with any of the
196
+ * five usual distances in `fence` laid over them, or the usual 330, 375, 400, 375 and 330 feet of a generic field (or the
197
+ * `generic` points a league's rules give).
198
+ */
199
+ export declare function fenceFor(park: Park | undefined, fence: Partial<Fence> | undefined, year?: number, generic?: readonly FencePoint[]): FencePoint[];
200
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ParkData } from "./parks.ts";
2
+ export declare const PARK_DATA: ParkData[];