pgg-engineering commited on
Commit
c8ac3a2
·
verified ·
1 Parent(s): 1d80fe8

Release EdgeChime 0.1.0 with source, install tarball, simulator examples and two-host benchmarks

Browse files
README.md CHANGED
@@ -12,7 +12,28 @@ tags: [geofencing, spatial-index, multi-agent, simulation]
12
 
13
  Emit the zone IDs that a moving agent entered or left. One immutable index serves every agent. Supply the previous and current position and a callback. The index keeps no per-agent membership sets.
14
 
15
- **[Try the live demo](https://edgechime.tancurl3.chatgpt.site) · [Download source, tests and benchmarks](https://edgechime.tancurl3.chatgpt.site/source.zip)**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ## Use it
18
 
@@ -56,6 +77,10 @@ printf '%s\n' '{"agent":"a","x":4,"y":3}' '{"agent":"a","x":6,"y":3}' \
56
 
57
  The CLI consumes newline-delimited JSON in arrival order. It stores a pair of coordinates for each live agent, skips empty change records, respects stdout backpressure and releases an agent on `forget`. Applications with event-time ordering should order each agent’s samples before passing them in. The in-process API avoids parsing, serialization and I/O for latency-sensitive workloads.
58
 
 
 
 
 
59
  ## Reproduce
60
 
61
  From the source checkout, run `npm test`, `npm run bench` and `node bench/fleet.mjs`. The comparison harness includes pinned Flatbush 4.7.0 and its dependency, a specialized perimeter-grid baseline and a historical taxi replay. The benchmark can run offline. Source, selection and license for the Porto positions are in [the trace note](bench/trace.md). Zone subscriptions are generated.
@@ -64,4 +89,4 @@ From the source checkout, run `npm test`, `npm run bench` and `node bench/fleet.
64
 
65
  Range monitoring and sweep-and-prune have a long history. EdgeChime specializes endpoint changes for moving points in immutable 2D half-open rectangles. Flatbush offers a packed Hilbert R-tree for general spatial searches. Tile38 supplies server-side geofencing, network delivery and separate enter, exit and cross events. Polygon geometry, frequent zone edits, segment crossings and persistent network delivery fall outside the interface. [Flatbush](https://github.com/mourner/flatbush) · [Tile38 geofencing](https://tile38.com/topics/geofencing) · [Continuous range monitoring](https://mcn.cse.psu.edu/paper/other/cai06.pdf).
66
 
67
- The runtime, CLI, tests and demo are MIT-licensed. Benchmark dependencies and movement data retain the licenses identified in `bench/`.
 
12
 
13
  Emit the zone IDs that a moving agent entered or left. One immutable index serves every agent. Supply the previous and current position and a callback. The index keeps no per-agent membership sets.
14
 
15
+ **[Try it on Hugging Face](https://huggingface.co/spaces/pgg-engineering/edgechime) · [Download the source](https://edgechime.tancurl3.chatgpt.site/source.zip) · [Use the labeled replay](https://huggingface.co/datasets/pgg-engineering/edgechime-bench)**
16
+
17
+ ## Measured performance
18
+
19
+ At **100,000 broad, overlapping rectangles**, short moves took **4.66 µs/update**. Upstream Flatbush with one cached point query and a membership diff took **535.75 µs**, and an independent boundary grid took **48.58 µs**. All three produced the same 84,551 enter and exit events. On the full Porto GPS replay with 8,192 generated zones the times were **0.34, 1.31 and 0.49 µs/update**. The GPS observations are real. The subscriptions are synthetic.
20
+
21
+ | Workload | EdgeChime | Flatbush 4.7.0 + diff | Perimeter grid |
22
+ | --- | ---: | ---: | ---: |
23
+ | Short moves, 100k broad zones | **4.66** | 535.75 | 48.58 |
24
+ | Porto, 4,469 moves, 8,192 zones | **0.34** | 1.31 | 0.49 |
25
+ | Short moves, 8,192 sparse zones | 0.22 | 0.29 | **0.14** |
26
+ | Random jumps, 8,192 broad zones | 88.46 | **41.58** | 112.87 |
27
+
28
+ Values are median run means in microseconds per update on Node 24.22.3, AMD EPYC 9V74, one pinned logical CPU. They include delivering every changed ID to the same callback. Build time for the 100k index was 210 ms. Relative speed depends on subscription geometry, movement and runtime. On three additional seeds with 8,192 broad zones and short moves, EdgeChime was 55.8–70.4× faster than the Flatbush adapter and 3.5–4.3× faster than the perimeter grid. [Method and raw timings](bench/README.md) · [100k run](bench/wide-100k.json) · [Full Porto run](bench/porto-full.json) · [Default workloads](bench/results.json).
29
+
30
+ A separate in-process replay interleaved 10,000 moving agents through 100,000 zones. The median was 1.36 million position updates/second, with five passes ranging from 0.32 to 2.09 million. This figure covers the move loop after initialization. [Fleet replay](bench/fleet-results.json).
31
+
32
+ A second run on a Hugging Face CPU job (Intel Xeon Platinum 8375C, Node 22.23.5) clocked the 100k-zone short moves at **3.99 µs/update**, versus **457.04 µs** for Flatbush and **38.89 µs** for the grid. On full Porto the three times were **0.44, 1.97 and 0.58 µs**. Flatbush again won on random jumps. Both hosts ran the same project-maintained harness. [Second-host measurements](bench/hf-cpu.json).
33
+
34
+ ## How it works
35
+
36
+ The index sorts horizontal and vertical boundary coordinates. A short move visits coordinates between the sampled endpoints and tests the other dimension only for candidate boxes. The two axes share ownership of diagonal transitions, so a corner never causes duplicate callbacks. A coordinate lookup table and optional orthogonal strips narrow the candidate search. Strip construction has a posting budget. For large candidate sets and initial point queries a packed bounding-box tree prunes rectangles away from both endpoints. Large moves can still cost linear time in dense scenes.
37
 
38
  ## Use it
39
 
 
77
 
78
  The CLI consumes newline-delimited JSON in arrival order. It stores a pair of coordinates for each live agent, skips empty change records, respects stdout backpressure and releases an agent on `forget`. Applications with event-time ordering should order each agent’s samples before passing them in. The in-process API avoids parsing, serialization and I/O for latency-sensitive workloads.
79
 
80
+ ## Integrations
81
+
82
+ Stream vehicle positions from Eclipse SUMO floating-car data and route them to matching zones. The runnable example includes a versioned upstream regression fixture and expected events. Game developers can import rectangular triggers from a named Tiled object layer. Both examples run from the source checkout. [SUMO adapter](examples/sumo/README.md) · [Tiled adapter](examples/tiled/README.md).
83
+
84
  ## Reproduce
85
 
86
  From the source checkout, run `npm test`, `npm run bench` and `node bench/fleet.mjs`. The comparison harness includes pinned Flatbush 4.7.0 and its dependency, a specialized perimeter-grid baseline and a historical taxi replay. The benchmark can run offline. Source, selection and license for the Porto positions are in [the trace note](bench/trace.md). Zone subscriptions are generated.
 
89
 
90
  Range monitoring and sweep-and-prune have a long history. EdgeChime specializes endpoint changes for moving points in immutable 2D half-open rectangles. Flatbush offers a packed Hilbert R-tree for general spatial searches. Tile38 supplies server-side geofencing, network delivery and separate enter, exit and cross events. Polygon geometry, frequent zone edits, segment crossings and persistent network delivery fall outside the interface. [Flatbush](https://github.com/mourner/flatbush) · [Tile38 geofencing](https://tile38.com/topics/geofencing) · [Continuous range monitoring](https://mcn.cse.psu.edu/paper/other/cai06.pdf).
91
 
92
+ The runtime, CLI, tests and demo are MIT-licensed. Benchmark dependencies and movement data retain the licenses identified in `bench/`. The SUMO fixture retains its accompanying Eclipse Public License.
bench/README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reproducing the comparison
2
+
3
+ Run from the repository root with Node.js 18 or newer. The script writes JSON to standard output and uses the vendored comparison code and track data. These commands require no network access or package installation.
4
+
5
+ ```sh
6
+ node bench/run.js > results.json
7
+ node bench/run.js --scenario porto --steps 4469 > porto.json
8
+ node bench/run.js --scenario wide-local --boxes 100000 --steps 1024 --repeats 5 --seed 270114 > scale.json
9
+ ```
10
+
11
+ Defaults are 8,192 static rectangles, at most 2,048 interleaved moves per scenario, five timed passes, and seed 270113. Use the same Node version, CPU, and command to compare changes. On Linux, prefix the command with `taskset -c CPU` using a CPU available to the process. Use an idle machine for timing.
12
+
13
+ ## Workloads
14
+
15
+ A move emits the IDs of boxes whose endpoint membership changed and the corresponding enter or exit direction. Each rectangle includes its minimum edges and excludes its maximum edges. Rectangle centers are uniform over the coordinate extent. Width and height are independent uniform draws from the listed range, scaled separately by each axis span. Rectangles may extend beyond the coordinate extent.
16
+
17
+ | Scenario | Positions | Box width and height |
18
+ | --- | --- | --- |
19
+ | `wide-local` | 16 agents, each axis moves by a uniform random step of up to ±0.0006 in the unit square | 15–55% |
20
+ | `sparse-local` | Same local walks | 0.1–1% |
21
+ | `wide-teleport` | Each new position is independent and uniform in the unit square | 15–55% |
22
+ | `stationary` | Repeated coordinates, with an exact no-op fast path in all three implementations | 15–55% |
23
+ | `porto` | Up to 4,469 recorded movements, 99 taxi trip prefixes, interleaved one observation per active trip per round | 2–12% of the trace's longitude and latitude spans |
24
+
25
+ Synthetic agents start in the central 60% of each axis. Local walks clamp to the unit square. Porto trajectories preserve the order and stationary updates within trips. Its subscription geometry is synthetic. The trace ships with [selection, coordinate units, checksums, and attribution](trace.md).
26
+
27
+ ## Methods
28
+
29
+ | JSON method | Work per move | Retained state |
30
+ | --- | --- | --- |
31
+ | `edgechime` | Enumerate candidate axis-aligned edges crossed between endpoints and verify membership. A packed bounding-box hierarchy handles large candidate sets on larger indexes. Small indexes may use a scan. | Box coordinates, two sorted edge indexes, coordinate directories, a packed bounding hierarchy and optional bounded strip indexes. Receives both endpoints per call. |
32
+ | `flatbush` | Query upstream Flatbush 4.7.0 once at the new point and diff against the agent’s cached previous hits. Upper bounds are converted at build time to their immediate Float64 predecessor for exact half-open lookup. | Packed Hilbert R-tree, one previous hit array and one membership bit per box per agent, and one shared 32-bit stamp per box. |
33
+ | `perimeterGrid` | Follow a horizontal and vertical path between endpoints through a uniform grid of box perimeters. Verify candidate boxes on the original endpoints, with a scan fallback. | Box coordinates, cell offsets, four bytes per posted box ID, and reusable deduplication stamps when needed. Grid resolution is reduced to fit the posting budget. |
34
+
35
+ The two delta methods can operate directly on the movement records. Each Flatbush runner initializes membership for every agent before replay. JSON stores this in `runnerSetupMs` for each timed pass. `buildMs` is the elapsed time of one index construction per scenario. The source releases and licenses are listed in [vendor/README.md](vendor/README.md).
36
+
37
+ ## Verification and timing
38
+
39
+ Before timing, the harness sorts all emitted pairs of box ID and direction and compares the full arrays for **every move across all three methods**. It also checks approximately 16 evenly spaced moves and the last move against a direct scan of all boxes. Timed runs use identical callbacks that count events and accumulate signed IDs. Every pass verifies these totals.
40
+
41
+ Each method gets one additional full warm-up pass. Timed passes rotate the execution order and start each trajectory from its original coordinates. Results include each pass’s mean microseconds per update, the median of those means, and the 95th percentile of complete 64-update block means pooled across passes. The block statistic measures short-window throughput variation. Individual-request latency, startup membership delivery, NDJSON parsing, networking, and downstream notification delivery lie outside the query timing. `meanStartMembers` is the average number of containing rectangles at the initial positions. `events` counts all enter and exit callbacks for one full replay.
42
+
43
+ ## Published runs
44
+
45
+ - [Default scenarios](results.json), [full Porto replay](porto-full.json) and [100,000-zone run](wide-100k.json).
46
+ - Three additional broad-zone seeds each used 8,192 boxes and 8,192 updates. [514229](holdout-514229.json), [2718281](holdout-2718281.json), [8675309](holdout-8675309.json).
47
+ - [Fleet replay](fleet-results.json). Run `node bench/fleet.mjs` to interleave 10,000 agents over 100,000 boxes. This measures only EdgeChime's in-process move loop, starting from known positions. Initial snapshots, I/O, simulation and downstream delivery are excluded. The JSON reports every pass and its event checksum.
48
+ - Each published local run used Node 24.22.3 and `taskset -c 2`. Omit the sample scale command's seed override to reproduce the default-seed 100,000-zone result, and use `--steps 2048`. Full Porto uses `--repeats 7`.
49
+ - [Second-host replay](hf-cpu.json). Four targeted workloads ran in a Hugging Face CPU-basic job on Intel Xeon Platinum 8375C, Node 22.23.5. Each run records its exact arguments and every sample.
bench/data/trace.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ [[-8585676,41148522],[-8585712,41148639],[-8585685,41148855],[-8585730,41148927],[-8585982,41148963],[-8586396,41148954],[-8586072,41148720],[-8586324,41147847],[-8586999,41147460],[-8586576,41147154],[-8584884,41146623]],
3
+ [[-8610876,41145570],[-8610858,41145579],[-8610903,41145768],[-8610444,41146191],[-8609445,41146758],[-8608896,41147118],[-8608968,41147127],[-8608707,41147532],[-8608347,41148117],[-8608149,41148351],[-8608041,41148576],[-8607654,41149260],[-8607348,41149899],[-8607393,41149899],[-8607357,41149962],[-8606817,41150979],[-8606358,41151915],[-8605719,41152788],[-8604981,41153319],[-8604783,41154345],[-8604828,41154372],[-8604801,41155353],[-8604648,41156775],[-8604522,41158197],[-8604513,41159943],[-8604378,41160555],[-8604378,41160600],[-8604369,41160645],[-8604360,41160807],[-8604162,41161176],[-8604126,41161248],[-8604090,41161293],[-8604090,41161266],[-8604108,41161239],[-8604126,41161194],[-8604135,41161275],[-8603910,41162049],[-8602929,41162832],[-8602551,41163111],[-8601894,41163597]],
4
+ [[-8585739,41148558],[-8585730,41148828],[-8585721,41148972],[-8586288,41149017],[-8586117,41148567],[-8586198,41148315],[-8586279,41147919],[-8587152,41147325],[-8585685,41146839],[-8584281,41146200],[-8583075,41145111],[-8581365,41144850],[-8579511,41145651],[-8579349,41145858],[-8579232,41146308],[-8579700,41147847],[-8578728,41150241],[-8580024,41152077],[-8581518,41153292],[-8582022,41153832],[-8582409,41154390],[-8582679,41154903],[-8582895,41155578],[-8582985,41156487],[-8582949,41156991],[-8582742,41157774],[-8582508,41158386],[-8582346,41158773],[-8582130,41159295],[-8581500,41160816],[-8580978,41162715],[-8580411,41163966],[-8579871,41164038],[-8578791,41164767],[-8577621,41165361],[-8577513,41165415],[-8577342,41165739],[-8576946,41166441],[-8575902,41167233],[-8574903,41167719]],
5
+ [[-8613963,41141169],[-8614125,41141124],[-8615088,41140926],[-8615277,41140818],[-8615259,41140809],[-8615241,41140800],[-8615052,41140818],[-8614638,41140980]],
6
+ [[-8619903,41148036],[-8619894,41148036]],
7
+ [[-8630613,41178249],[-8630613,41178249],[-8630739,41178231],[-8631513,41178141],[-8631306,41178114],[-8630028,41177889],[-8629425,41177817],[-8629173,41177970],[-8629056,41178042],[-8628660,41177394],[-8627958,41176152],[-8627967,41176125],[-8627985,41176107],[-8627778,41175684],[-8627157,41174127],[-8626275,41172588],[-8626221,41171922],[-8626419,41171895],[-8626419,41171904],[-8626428,41171913],[-8626428,41171913],[-8626419,41171913],[-8626410,41171922],[-8626401,41171922],[-8626410,41171931],[-8626410,41171931],[-8626419,41171931],[-8626419,41171922],[-8626419,41171922],[-8626419,41171913],[-8626437,41171913],[-8626446,41171922],[-8626446,41171913],[-8626446,41171913],[-8626437,41171913],[-8626428,41171913],[-8626437,41171913],[-8626437,41171904],[-8626437,41171904],[-8626428,41171913],[-8626428,41171904],[-8626437,41171895],[-8626446,41171895],[-8626446,41171886],[-8626446,41171886],[-8626437,41171886],[-8626437,41171877],[-8626446,41171877],[-8626446,41171895],[-8626446,41171895],[-8626446,41171895],[-8626446,41171913],[-8626446,41171913],[-8626437,41171922],[-8626446,41171922],[-8626455,41171931],[-8626464,41171922],[-8626464,41171922],[-8626464,41171931],[-8626464,41171922],[-8626455,41171922],[-8626455,41171922],[-8626446,41171931],[-8626446,41171922],[-8626437,41171922],[-8626437,41171913],[-8626437,41171913],[-8626446,41171913],[-8626455,41171913],[-8626464,41171913],[-8626464,41171913],[-8626464,41171904],[-8626455,41171904],[-8626455,41171904],[-8626446,41171913],[-8626446,41171913],[-8626437,41171922],[-8626437,41171922],[-8626446,41171922],[-8626446,41171913],[-8626446,41171904],[-8626455,41171904],[-8626464,41171895],[-8626464,41171895],[-8626464,41171895],[-8626473,41171895],[-8626473,41171895],[-8626464,41171904],[-8626464,41171913],[-8626455,41171913],[-8626455,41171913],[-8626455,41171913],[-8626455,41171904],[-8626446,41171904],[-8626437,41171913],[-8626437,41171922],[-8626437,41171922],[-8626446,41171931],[-8626446,41171931],[-8626446,41171940],[-8626446,41171949],[-8626455,41171949],[-8626455,41171949],[-8626464,41171940],[-8626473,41171931],[-8626473,41171931],[-8626473,41171931],[-8626509,41171931],[-8626689,41171895],[-8626698,41171895],[-8626680,41171868],[-8626662,41171859],[-8626878,41171886],[-8626842,41171859],[-8626833,41171886],[-8626842,41171904],[-8626842,41171904],[-8626851,41171904],[-8626842,41171904],[-8626833,41171904],[-8626824,41171859],[-8626779,41171832],[-8626509,41171886],[-8626455,41171904],[-8626455,41171904],[-8626455,41171904],[-8626428,41171913],[-8626410,41171922],[-8626410,41171922],[-8626419,41171913],[-8626419,41171913],[-8626428,41171913],[-8626419,41171922],[-8626401,41171940],[-8626392,41171958],[-8626401,41171967],[-8626410,41171958]],
8
+ [[-8585622,41148918],[-8585640,41148900],[-8585919,41148945],[-8586369,41148927],[-8586126,41148558],[-8586288,41147928],[-8586747,41147613],[-8586792,41147217],[-8584992,41146749],[-8583660,41145840],[-8582364,41144841],[-8580339,41145219],[-8579412,41145885],[-8579178,41145948],[-8579745,41146515],[-8579502,41148090],[-8578701,41150106],[-8579304,41151312],[-8580069,41152005],[-8580681,41152500],[-8581185,41152923],[-8581563,41153274],[-8581806,41153517],[-8582049,41153778]],
9
+ [[-8582922,41181057],[-8582004,41181813],[-8581077,41182965],[-8580114,41184018],[-8579214,41184774],[-8578341,41185557],[-8577549,41186097],[-8576793,41186178],[-8575443,41186664],[-8575200,41186700],[-8575200,41186682],[-8575173,41186673],[-8575155,41186664],[-8575884,41186520],[-8577027,41186070],[-8577531,41186097],[-8578773,41185242]],
10
+ [[-8606529,41144670],[-8606673,41144724],[-8606799,41144706],[-8606790,41144679],[-8606709,41144724],[-8607249,41144436],[-8607807,41143662],[-8607960,41143401],[-8607996,41143392],[-8608014,41143365],[-8608041,41143329],[-8607249,41142447],[-8605341,41143005],[-8605323,41143131],[-8605188,41143446],[-8605170,41143536],[-8604954,41143788],[-8603271,41143266],[-8601993,41142087],[-8601381,41139477],[-8601237,41137704],[-8601246,41137731],[-8601282,41137677],[-8602092,41136399],[-8601840,41133996],[-8599536,41132952],[-8597637,41132097],[-8597142,41130747],[-8597862,41129145],[-8598303,41126769],[-8598717,41125113],[-8599995,41125014],[-8600310,41125005],[-8600850,41124996],[-8602668,41124987],[-8603118,41124996],[-8603739,41124996],[-8603775,41125005],[-8604513,41125095],[-8604990,41125104],[-8605485,41125716],[-8605494,41125779],[-8605494,41125770]],
11
+ [[-8585658,41148576],[-8585703,41148603],[-8585730,41148603],[-8585739,41148603],[-8585730,41148612],[-8585721,41148621],[-8585730,41148648],[-8585775,41148936],[-8586297,41148990],[-8586126,41148720],[-8586207,41148243],[-8586306,41147865],[-8586603,41147685],[-8586621,41147694],[-8586657,41147694],[-8586837,41147577],[-8587035,41147253],[-8585865,41146911],[-8584137,41146128],[-8582904,41144985],[-8580690,41145066],[-8579574,41145705],[-8579313,41145903],[-8579844,41146587],[-8579151,41148621],[-8579286,41151339],[-8581302,41153103],[-8582616,41154732],[-8582751,41155038],[-8582805,41155218],[-8582931,41155794],[-8582985,41156406],[-8582922,41157045],[-8582625,41158071],[-8582256,41159025],[-8582085,41159439],[-8581725,41160321],[-8581266,41161500],[-8581122,41161923],[-8581041,41162274],[-8581032,41162688],[-8581122,41163102],[-8581239,41163390],[-8581797,41164290],[-8582463,41165424],[-8583003,41166027],[-8583624,41166405],[-8584263,41166612],[-8584749,41166711],[-8585037,41166738],[-8585334,41166756],[-8585577,41166774],[-8585640,41166783],[-8585901,41166810],[-8586333,41166918],[-8586918,41167116],[-8586873,41167161],[-8587224,41167350],[-8587485,41167548],[-8587593,41167710],[-8587827,41167800],[-8588403,41167962],[-8588817,41168124],[-8588898,41168232],[-8589150,41168448],[-8589528,41168655],[-8590302,41169024],[-8590959,41169393],[-8591508,41169753],[-8592570,41170392],[-8594325,41171760],[-8594217,41174244],[-8593290,41177484],[-8593011,41181741],[-8594334,41186313],[-8593956,41190444],[-8591166,41194206],[-8588259,41197401],[-8586306,41199273]],
12
+ [[-8591229,41162706],[-8591229,41162715],[-8591220,41162715],[-8591004,41162571],[-8591130,41162337],[-8590815,41162409],[-8590248,41163147],[-8589843,41163651],[-8589816,41163678],[-8589816,41163696],[-8589726,41163786],[-8589222,41164398],[-8589177,41164578],[-8589168,41164587],[-8589150,41164677],[-8589141,41164695],[-8588979,41165118],[-8588943,41165118],[-8588952,41165118],[-8588952,41165118],[-8588898,41165361],[-8588826,41165523],[-8588799,41165559],[-8588835,41165541],[-8588844,41165550],[-8588808,41165640],[-8588691,41165811],[-8588556,41166180],[-8588574,41166162],[-8588601,41166126],[-8588601,41166126],[-8588484,41166405],[-8588466,41166441],[-8588457,41166450],[-8588484,41166450],[-8588475,41166477],[-8588448,41166504],[-8588295,41166846],[-8588304,41166846],[-8588277,41166927],[-8588241,41166981],[-8588214,41167053],[-8588133,41167224],[-8588097,41167305],[-8588061,41167377],[-8588052,41167386],[-8587998,41167494],[-8587989,41167503],[-8587863,41167782],[-8587845,41167809],[-8587845,41167809],[-8587845,41167818],[-8587836,41167827],[-8587818,41167872],[-8587638,41168277],[-8587620,41168277],[-8587602,41168268],[-8587593,41168259],[-8587602,41168250],[-8587602,41168268],[-8587674,41168718],[-8588097,41168880],[-8588232,41168889]],
13
+ [[-8585694,41148603],[-8585757,41148684],[-8585712,41148882],[-8585757,41148963],[-8585838,41148954],[-8586063,41148972],[-8586171,41148972],[-8587323,41149152],[-8588007,41149386],[-8588736,41149602],[-8591031,41150187],[-8592165,41150484],[-8592201,41150493],[-8593389,41150844],[-8594550,41150664],[-8595918,41149872],[-8596647,41149431]],
14
+ [[-8580105,41159394],[-8580231,41159358],[-8581518,41159349],[-8582517,41158872],[-8584335,41158296]],
15
+ [[-8665353,41186160],[-8666892,41188311],[-8667045,41190705],[-8665812,41194017],[-8662734,41197158],[-8658774,41199975],[-8654013,41202090],[-8650035,41201604],[-8651241,41204358],[-8651556,41208696],[-8653446,41213394],[-8656920,41217732],[-8661051,41222061],[-8664867,41226093],[-8668134,41229180],[-8666919,41232420],[-8667621,41235633],[-8667918,41237955],[-8667927,41238621],[-8667216,41238432],[-8666289,41238144],[-8665461,41237226],[-8663400,41238288],[-8660601,41238819],[-8659701,41238972],[-8659755,41239071],[-8661654,41238846],[-8663553,41238432],[-8664327,41239179],[-8664984,41239629],[-8664993,41239638],[-8665209,41239881],[-8665722,41240826],[-8666172,41242203],[-8665929,41242941],[-8665812,41243004],[-8665794,41242995],[-8665794,41242986],[-8665794,41242986],[-8665785,41242977],[-8665794,41242977],[-8665785,41242977],[-8665794,41242968],[-8665794,41242977],[-8665812,41242977],[-8665812,41242986],[-8665812,41242986],[-8665794,41242986],[-8665785,41242977],[-8665776,41242977],[-8665776,41242977],[-8665785,41242986],[-8665785,41242986],[-8665785,41242986],[-8665785,41242986],[-8665776,41242986],[-8665776,41242986],[-8665785,41242977],[-8665794,41242986],[-8665794,41242986],[-8665794,41242977],[-8665785,41242959],[-8665794,41242950],[-8665893,41243013],[-8665992,41242752],[-8665857,41241177],[-8666433,41239566],[-8666793,41238702],[-8667441,41238567],[-8669502,41239278],[-8671086,41239458],[-8670339,41237874],[-8669709,41235615],[-8668944,41235165],[-8669259,41236641],[-8669475,41237415]],
16
+ [[-8649423,41154354],[-8650197,41154138],[-8650323,41153832],[-8649045,41154084],[-8648730,41154147],[-8647011,41154210],[-8644194,41154471],[-8641512,41153760],[-8638578,41153031],[-8636490,41152527],[-8633637,41152554],[-8631342,41152608],[-8631018,41152617],[-8631027,41152626],[-8630514,41152563],[-8627796,41152410],[-8626455,41152509],[-8626473,41152500],[-8626473,41152500],[-8626401,41152518],[-8625843,41151312],[-8625807,41150106],[-8625699,41149521],[-8625717,41149251],[-8625690,41149287],[-8625573,41148774],[-8624061,41148153],[-8623359,41147937],[-8622324,41147658],[-8621100,41147424],[-8620551,41147361],[-8620362,41147118],[-8620236,41146470],[-8620209,41146281],[-8618166,41146326],[-8617383,41145327],[-8616222,41145192],[-8615403,41145561],[-8614278,41145930],[-8613630,41145975],[-8613639,41145966],[-8613666,41145966],[-8613639,41145921],[-8613405,41145849],[-8612469,41145966],[-8612442,41146002],[-8612415,41146020],[-8611830,41146056],[-8610858,41145570],[-8610912,41145399],[-8610912,41145354],[-8610534,41143914],[-8610480,41143788],[-8610174,41143275]],
17
+ [[-8618373,41136003],[-8618382,41135877],[-8618445,41135022],[-8618445,41134122],[-8618148,41133249],[-8618103,41132340],[-8617608,41131395],[-8617698,41130621],[-8619129,41129883],[-8619975,41129433],[-8620650,41129091],[-8622234,41128281],[-8622621,41127867],[-8621910,41127471],[-8621829,41126751],[-8623053,41126274],[-8624439,41127498],[-8625492,41129217],[-8625645,41129586],[-8625420,41130558],[-8626509,41131548],[-8627121,41133051],[-8627184,41133231],[-8627391,41133762],[-8628120,41135589],[-8628606,41136732],[-8629101,41137965],[-8630982,41139423],[-8633781,41140422],[-8635401,41142591],[-8637597,41143761],[-8638884,41143554],[-8639136,41143698],[-8639235,41143797],[-8639343,41143986],[-8639640,41144940],[-8639937,41146227],[-8640234,41147433],[-8640540,41148666],[-8641008,41150322],[-8642646,41151879],[-8643942,41152824],[-8644797,41153976],[-8645166,41154921],[-8645517,41155848],[-8645688,41156244],[-8646075,41157045],[-8646336,41157450],[-8646534,41157693],[-8646624,41157801],[-8646795,41157999],[-8646813,41158017],[-8647002,41158233],[-8647083,41158332],[-8647434,41158737],[-8647776,41159151],[-8647803,41159178],[-8648235,41159691],[-8648433,41159916],[-8648685,41160231],[-8649054,41160843],[-8649225,41161860],[-8649180,41162274],[-8648973,41162868],[-8648235,41163831],[-8646615,41164767],[-8644671,41165532],[-8642403,41166693],[-8640972,41167539],[-8640738,41167377],[-8640846,41166900],[-8641827,41167089],[-8643123,41168115],[-8645265,41169753],[-8647965,41171958],[-8650683,41174172],[-8653293,41176296],[-8656524,41178942],[-8658378,41180463],[-8659926,41181732],[-8661555,41183055],[-8663301,41184477],[-8664876,41185755],[-8666694,41187510],[-8667468,41189571],[-8666352,41191668],[-8665749,41194071],[-8663940,41196240],[-8661411,41198049],[-8658594,41200065],[-8655570,41201748],[-8652375,41202144],[-8649936,41201766],[-8650854,41203800],[-8651646,41206311],[-8651664,41209362],[-8652870,41212242]],
18
+ [[-8627094,41166936],[-8627049,41166900],[-8626644,41166900],[-8626626,41166909],[-8626617,41166909],[-8626617,41166900],[-8626608,41166900],[-8626599,41166891],[-8626923,41166504],[-8628075,41166135],[-8629461,41165577],[-8630802,41165019],[-8632548,41164155],[-8633538,41163345],[-8632764,41162292],[-8631945,41161248],[-8630604,41159493],[-8630343,41158908],[-8630406,41158854],[-8630217,41158629],[-8630325,41158305],[-8630451,41157567],[-8629542,41156883],[-8629731,41155731],[-8629218,41155128],[-8629074,41155146],[-8629065,41155137]],
19
+ [[-8607861,41146236],[-8607915,41146236],[-8607924,41146236],[-8607924,41146245],[-8607924,41146245],[-8607924,41146227],[-8607906,41146236],[-8607933,41146263],[-8607933,41146254],[-8607933,41146245],[-8607951,41146245],[-8607969,41146254],[-8607978,41146254],[-8607996,41146236],[-8608005,41146227],[-8608032,41146236],[-8608032,41146263],[-8608005,41146236],[-8608014,41146191],[-8607996,41146218],[-8607960,41146245],[-8607933,41146272],[-8607924,41146254],[-8607915,41146236],[-8607906,41146227],[-8607888,41146227],[-8607915,41146236],[-8607915,41146263],[-8607933,41146326],[-8607951,41146353],[-8607987,41146344],[-8607969,41146317],[-8607951,41146236],[-8607942,41146218],[-8607933,41146218],[-8607951,41146236],[-8607969,41146227],[-8607996,41146218],[-8608113,41146200],[-8609490,41146101],[-8610399,41146065],[-8610201,41146362],[-8610003,41146515],[-8609697,41146668],[-8609283,41146794],[-8609085,41146812],[-8608824,41147163],[-8609292,41147658],[-8610246,41147811],[-8610381,41147802],[-8610552,41147820],[-8612163,41147991],[-8621712,41147559],[-8622342,41147757],[-8623818,41148189],[-8624997,41148612],[-8625690,41149710],[-8625996,41151591],[-8626176,41152473],[-8626716,41154192],[-8626977,41154930],[-8627355,41155407],[-8627949,41156136]],
20
+ [[-8585667,41148567],[-8585694,41148639],[-8585712,41148747],[-8585775,41148945],[-8586036,41148981],[-8586963,41149071],[-8588466,41149449],[-8589996,41149872],[-8591787,41150349],[-8593299,41150736],[-8593515,41150763],[-8593497,41150763],[-8593488,41150772],[-8593497,41150772],[-8593533,41150772],[-8593506,41150790],[-8593911,41150916],[-8594541,41151807],[-8595036,41153301],[-8595396,41154354],[-8595405,41154417],[-8595261,41155281],[-8595036,41155749],[-8594244,41157135],[-8593560,41158350],[-8592786,41159619],[-8592282,41160492],[-8591688,41161455],[-8590464,41162877],[-8589807,41163660],[-8589789,41163687]],
21
+ [[-8667414,41161671],[-8667423,41161662],[-8667414,41161671],[-8667405,41161653],[-8667414,41161653],[-8667414,41161653],[-8667405,41161662],[-8667405,41161662],[-8667396,41161662],[-8667396,41161680],[-8667387,41161689],[-8667378,41161689],[-8667378,41161698],[-8667387,41161698],[-8667396,41161698],[-8667396,41161698],[-8667405,41161698],[-8667405,41161698],[-8667396,41161698],[-8667387,41161689],[-8667171,41161140],[-8666307,41159844],[-8665479,41158674],[-8665398,41158062],[-8665092,41158062],[-8662995,41158917],[-8660637,41159853],[-8658306,41160753],[-8657604,41161104],[-8656128,41161860],[-8654697,41162103],[-8653149,41161887],[-8651790,41161662],[-8651565,41161635],[-8651520,41161635],[-8650512,41161464],[-8648766,41161158],[-8646696,41160816],[-8644320,41160402],[-8642124,41160078],[-8641440,41160087],[-8641440,41160213],[-8641566,41160375],[-8641521,41160447],[-8641503,41160447],[-8641467,41160429],[-8641458,41160474],[-8641476,41160465],[-8641512,41160483],[-8641476,41160465],[-8641476,41160447],[-8641503,41160429],[-8641503,41160438],[-8641530,41160456],[-8641521,41160474],[-8641476,41160483],[-8641422,41160402],[-8641467,41160447],[-8641422,41160519],[-8641413,41160546],[-8641467,41160429],[-8641386,41160384],[-8641350,41160402],[-8641350,41160402],[-8641395,41160393],[-8641404,41160393],[-8641440,41160393],[-8641422,41160429],[-8641359,41160447],[-8641359,41160429],[-8641368,41160402],[-8641422,41160375],[-8641422,41160384],[-8641404,41160402],[-8641395,41160411],[-8641431,41160384],[-8641440,41160366],[-8641449,41160366],[-8641476,41160366],[-8641422,41160357],[-8641377,41160348],[-8641395,41160348],[-8641404,41160375],[-8641440,41160393],[-8641422,41160384],[-8641449,41160420],[-8641458,41160411],[-8641476,41160420],[-8641476,41160411],[-8641467,41160411],[-8641476,41160420],[-8641512,41160411],[-8641485,41160411],[-8641449,41160393],[-8641422,41160393],[-8641431,41160420],[-8641413,41160429],[-8641332,41160420],[-8641368,41160420],[-8641413,41160438],[-8641377,41160393],[-8641287,41160339],[-8641287,41160339],[-8641359,41160366],[-8641404,41160402],[-8641404,41160420],[-8641413,41160465],[-8641458,41160483],[-8641386,41160474],[-8641395,41160465],[-8641449,41160447],[-8641467,41160447],[-8641440,41160438],[-8641458,41160420],[-8641476,41160429],[-8641485,41160429],[-8641530,41160420],[-8641539,41160411],[-8641584,41160411],[-8641593,41160411],[-8641548,41160393],[-8641512,41160411],[-8641530,41160438],[-8641530,41160411],[-8641521,41160384],[-8641494,41160402],[-8641512,41160411],[-8641530,41160393],[-8641503,41160339],[-8641485,41160312],[-8641458,41160294],[-8641422,41160294],[-8641422,41160294],[-8641485,41160321],[-8641494,41160348],[-8641494,41160366],[-8641494,41160384],[-8641485,41160402],[-8641476,41160402],[-8641467,41160393],[-8641467,41160393],[-8641467,41160393],[-8641485,41160393],[-8641476,41160411],[-8641476,41160420],[-8641476,41160402],[-8641476,41160366],[-8641467,41160312],[-8641476,41160330],[-8641485,41160339],[-8641467,41160348],[-8641485,41160366],[-8641503,41160366],[-8641530,41160393],[-8641539,41160429],[-8641512,41160429],[-8641512,41160438],[-8641521,41160447],[-8641521,41160438],[-8641530,41160420],[-8641521,41160429],[-8641539,41160438],[-8641521,41160456],[-8641521,41160456]],
22
+ [[-8585712,41148540],[-8585703,41148549],[-8585712,41148558],[-8585721,41148558],[-8585766,41148549],[-8585757,41148738]],
23
+ [[-8612757,41137722],[-8612658,41137785],[-8612631,41137812],[-8612460,41137866],[-8611506,41138073],[-8610273,41138523],[-8609697,41138874],[-8609625,41138910],[-8609472,41138964],[-8610030,41138397],[-8610246,41138055],[-8611146,41137110],[-8611560,41135634]],
24
+ [[-8625816,41151294],[-8625942,41151330],[-8626113,41151294],[-8626284,41151222],[-8626248,41151249],[-8626158,41151276],[-8626167,41151285],[-8626194,41151276],[-8626311,41151537],[-8626500,41152959],[-8626653,41154228],[-8626608,41154255],[-8626608,41154300],[-8626626,41154390],[-8626905,41155128],[-8627301,41155686],[-8628597,41156559],[-8628768,41156640]],
25
+ [[-8585658,41148486],[-8585658,41148486],[-8585658,41148486],[-8585658,41148513]],
26
+ [[-8630667,41154867],[-8630928,41154660],[-8632386,41153166],[-8633241,41151528],[-8636139,41150943],[-8639496,41149620],[-8642646,41149413],[-8644698,41151141],[-8642727,41151690],[-8641116,41150142]],
27
+ [[-8602830,41179644],[-8603163,41179716],[-8604648,41180139],[-8604990,41180238],[-8605746,41179185],[-8607132,41177718],[-8608068,41176827],[-8608437,41175558],[-8607861,41175279],[-8606223,41174451],[-8605836,41173506],[-8606718,41172876]],
28
+ [[-8592120,41160735],[-8591499,41161689],[-8592093,41161581],[-8593029,41162517],[-8593488,41162679]],
29
+ [[-8585685,41148900],[-8586018,41148990],[-8587017,41149098]],
30
+ [[-8628777,41160978],[-8628741,41160969],[-8628750,41160960],[-8628777,41160906],[-8628489,41160519],[-8628903,41159178],[-8629821,41158692],[-8630334,41157828],[-8629740,41157072],[-8628750,41156946],[-8628066,41156226],[-8627832,41155947],[-8627400,41155407],[-8627247,41155236],[-8627256,41155236],[-8627229,41155245],[-8626923,41154624],[-8626518,41153634],[-8626392,41153166],[-8626401,41153166],[-8626410,41153157],[-8626158,41152392],[-8625897,41151087],[-8625924,41150727],[-8625618,41149440],[-8625024,41148450],[-8623305,41147901],[-8622981,41147874],[-8622630,41147784],[-8621415,41147469],[-8620398,41147163],[-8620380,41146542],[-8620389,41146380],[-8620380,41146317],[-8619795,41146092],[-8617770,41146344],[-8617455,41145273],[-8616951,41144823],[-8615763,41145399],[-8614539,41145858],[-8614359,41145912],[-8614107,41146011],[-8614035,41146056],[-8613765,41146083],[-8613738,41146101],[-8613594,41146029],[-8613567,41145867],[-8612829,41145993],[-8612550,41146065],[-8612316,41146038],[-8611380,41146110]],
31
+ [[-8585730,41148513],[-8585748,41148846],[-8586198,41149044],[-8586234,41148900],[-8586063,41148729],[-8586171,41148189],[-8586864,41147568],[-8587125,41147289],[-8585910,41146947],[-8584317,41146461],[-8583255,41145453],[-8581869,41144742],[-8579835,41145345],[-8579520,41145723],[-8579439,41145894],[-8578890,41146056],[-8579970,41146695],[-8579430,41148198],[-8578728,41149800],[-8579223,41151249],[-8580312,41152284],[-8581446,41153220],[-8582562,41154633],[-8582922,41155560],[-8582985,41156172],[-8582967,41156757],[-8582913,41157162],[-8582805,41157540],[-8582679,41157918],[-8582544,41158287],[-8582274,41158926],[-8582022,41159682],[-8581743,41160348],[-8581617,41160609],[-8581509,41160915],[-8581347,41161329],[-8581194,41161788],[-8581158,41161923],[-8581095,41162238],[-8581104,41162382]],
32
+ [[-8585658,41148585],[-8585730,41148756],[-8585721,41148954],[-8586063,41148981],[-8586153,41148801],[-8586180,41148306],[-8586567,41147703],[-8587161,41147379],[-8585829,41146866],[-8583786,41145831],[-8582220,41144796],[-8579862,41145327],[-8579664,41145534],[-8579619,41145606],[-8579349,41145885],[-8579727,41146497],[-8579583,41148009],[-8578746,41150214],[-8579745,41151807],[-8581158,41152941],[-8581761,41153472],[-8582067,41153805],[-8582256,41154075],[-8582391,41154246],[-8582670,41154759],[-8582886,41155344],[-8582958,41155641],[-8583030,41156298],[-8583039,41156775],[-8583012,41156991],[-8583003,41157063],[-8582859,41157603],[-8582796,41157810],[-8582598,41158359],[-8582490,41158620],[-8582310,41159052],[-8582094,41159592],[-8581779,41160339],[-8581644,41160672],[-8581383,41161329],[-8581113,41162022],[-8581077,41162319],[-8581068,41162589],[-8581068,41162706],[-8581212,41163174]],
33
+ [[-8610939,41145642],[-8610957,41145660],[-8610840,41145903],[-8610723,41146020],[-8610219,41146362],[-8609958,41146542],[-8609670,41146695],[-8609346,41146767],[-8608851,41147136],[-8608860,41147199],[-8608860,41147199],[-8609013,41147433],[-8609589,41147676],[-8610660,41147856],[-8610714,41147802],[-8610777,41147694],[-8610903,41148297],[-8610687,41148864],[-8610642,41148909],[-8610291,41149557],[-8610147,41150511],[-8609850,41150970],[-8609769,41151843],[-8610021,41153040],[-8609832,41154282],[-8609805,41155146],[-8609814,41155200]],
34
+ [[-8606484,41149944],[-8607114,41150133],[-8606808,41150961],[-8606070,41152239],[-8605656,41152896],[-8605530,41153166],[-8606169,41153535],[-8608104,41153580],[-8610219,41153598],[-8611920,41153625],[-8612091,41153922],[-8612298,41155146],[-8612919,41155173],[-8612964,41155137],[-8613648,41155398],[-8615808,41155794],[-8617887,41156127],[-8619759,41156496],[-8621640,41156829],[-8623557,41157243],[-8625564,41157576],[-8627409,41157846],[-8627607,41157846],[-8627643,41157801],[-8627661,41157783],[-8628003,41157999],[-8627967,41158206],[-8628867,41158980],[-8628687,41159664],[-8628606,41159997],[-8628219,41161239],[-8627832,41162409],[-8627616,41163120],[-8627580,41163210],[-8627589,41163201],[-8627580,41163201],[-8627418,41163741],[-8627202,41164758]],
35
+ [[-8579853,41161869],[-8580762,41162211],[-8580051,41163408],[-8578512,41164839],[-8578134,41165010],[-8577162,41165640],[-8578206,41165298],[-8578953,41164686],[-8579907,41164092],[-8581329,41164407],[-8582220,41163363],[-8581320,41162121],[-8582112,41160060],[-8583147,41157261],[-8582643,41154219],[-8580096,41151663],[-8580141,41149548],[-8581266,41147343],[-8579538,41146209],[-8578458,41145336],[-8578098,41144616],[-8579664,41144013],[-8581842,41143761],[-8584371,41143626],[-8586549,41143248],[-8587854,41141916],[-8589726,41140530],[-8592174,41140098],[-8595036,41139963],[-8597574,41140989],[-8600850,41142087],[-8603811,41141817],[-8606277,41141619],[-8608860,41141025],[-8609481,41140872],[-8610804,41141268],[-8613513,41141448],[-8614233,41141205],[-8614503,41141871],[-8614449,41142024],[-8614413,41142150],[-8614350,41142375],[-8614341,41142816],[-8615223,41142825],[-8616150,41142708],[-8617095,41142744],[-8617464,41143473],[-8617095,41143959]],
36
+ [[-8689203,41173407],[-8688420,41172993],[-8688753,41173947],[-8688825,41174739],[-8688663,41174712],[-8688366,41174775],[-8686962,41174793],[-8686818,41173650],[-8687745,41173551],[-8688222,41173569],[-8689149,41173569],[-8688384,41173047],[-8686557,41173461],[-8684352,41173578],[-8682201,41172768],[-8681886,41172588],[-8681895,41172588],[-8681688,41172489],[-8680104,41171787],[-8677422,41171634],[-8675109,41172120],[-8674641,41172489],[-8673093,41173650],[-8671167,41175009],[-8670753,41175702],[-8668944,41176530],[-8667432,41178132],[-8665416,41179203],[-8663526,41178582],[-8663229,41178159],[-8663256,41178141],[-8662806,41177673],[-8662329,41177088],[-8661951,41176827],[-8661960,41176836],[-8661753,41176800],[-8661456,41176791],[-8661330,41176818],[-8660925,41176863],[-8659719,41177034],[-8658585,41177187],[-8658540,41177196],[-8658324,41177241],[-8658144,41177259],[-8657874,41177304],[-8657379,41177007],[-8656686,41175999],[-8656047,41174937],[-8655354,41173767],[-8654850,41172885],[-8654409,41172264],[-8653167,41171490],[-8652114,41170842],[-8651997,41170860],[-8651502,41171247],[-8650611,41171364],[-8649252,41170203],[-8648442,41170320],[-8647416,41170293],[-8646075,41169312],[-8645328,41169537],[-8645337,41169546],[-8645283,41169528],[-8644527,41168961],[-8643618,41167215],[-8642394,41166153],[-8641440,41166252],[-8640549,41166612],[-8640405,41167782],[-8640063,41168511],[-8638335,41169834],[-8635779,41171112],[-8631999,41171967],[-8628120,41172786],[-8624160,41173245],[-8619570,41173695],[-8614971,41174244],[-8611596,41174388],[-8608446,41173497],[-8606331,41171715],[-8605971,41171490],[-8605953,41171472],[-8605962,41171472],[-8605845,41171355],[-8606565,41170590],[-8606007,41169636],[-8603901,41170005],[-8603541,41169078],[-8603523,41168232],[-8603478,41167584],[-8603541,41167431],[-8603343,41166549],[-8602776,41165559],[-8602074,41164434],[-8601786,41164011],[-8601174,41164137],[-8600301,41163858],[-8599644,41163264],[-8599680,41163228],[-8599698,41163228],[-8599653,41163174],[-8599644,41163183],[-8599671,41163183],[-8599671,41163192],[-8599698,41163192],[-8599689,41163192],[-8599671,41163201],[-8599653,41163201],[-8599635,41163210],[-8599635,41163228],[-8599635,41163228],[-8599626,41163228],[-8599617,41163237],[-8599617,41163237],[-8599626,41163228],[-8599635,41163228],[-8599635,41163228],[-8599626,41163219],[-8599617,41163228],[-8599617,41163219],[-8599617,41163210],[-8599626,41163201],[-8599626,41163201],[-8599635,41163192],[-8599626,41163210],[-8599626,41163201],[-8599626,41163210],[-8599617,41163210],[-8599626,41163201],[-8599617,41163201],[-8599599,41163210],[-8599608,41163201],[-8599608,41163192],[-8599599,41163201],[-8599617,41163192],[-8599617,41163183],[-8599617,41163183],[-8599635,41163228],[-8599626,41163282],[-8599626,41163273],[-8599626,41163237],[-8599626,41163246],[-8599608,41163201],[-8599950,41162364],[-8600229,41161644],[-8600544,41160861],[-8600976,41159718],[-8600985,41159619],[-8601192,41158827],[-8601966,41157288],[-8602722,41155353],[-8602965,41154714],[-8602956,41154732],[-8602956,41154732],[-8602974,41154714],[-8603793,41154723],[-8604504,41154822]],
37
+ [[-8640594,41160105],[-8640648,41160033],[-8640765,41159871],[-8640576,41160096],[-8640576,41160051],[-8640621,41159925],[-8640675,41159835],[-8640729,41159736],[-8640936,41159817],[-8641449,41160069],[-8641557,41160384],[-8640738,41161230],[-8639631,41162256],[-8638974,41162796],[-8637615,41163615],[-8637174,41163840],[-8637192,41163831],[-8637201,41163822],[-8636850,41164029],[-8636661,41164155],[-8636616,41164137],[-8636589,41164119],[-8636598,41164110],[-8636553,41164137],[-8637363,41164614],[-8639541,41165118],[-8641575,41166747],[-8643987,41168700],[-8646705,41170959],[-8649630,41173335],[-8652384,41175585],[-8655021,41177709],[-8656407,41178906],[-8657019,41179311],[-8658567,41180589],[-8660736,41182335],[-8663004,41184216],[-8665002,41185845],[-8667432,41187762],[-8669799,41189211],[-8668557,41189013],[-8670168,41187186],[-8673489,41186574],[-8675811,41184207],[-8678142,41181759],[-8680509,41180778],[-8681769,41180733],[-8682381,41180832],[-8683704,41180607],[-8685423,41180472],[-8686926,41180355],[-8687430,41180301],[-8688546,41180247],[-8688591,41180211],[-8689122,41180166],[-8689617,41180166],[-8690643,41180175],[-8691354,41180823],[-8692101,41181579],[-8692992,41181246],[-8692524,41180598],[-8692389,41180373],[-8692434,41180355],[-8692470,41180337],[-8692461,41180346],[-8692452,41180355],[-8692425,41180355],[-8692434,41180346],[-8692452,41180346],[-8692461,41180355]],
38
+ [[-8609634,41151267],[-8609652,41151276],[-8609841,41151753],[-8610183,41151789],[-8610867,41150583],[-8611263,41149422],[-8611308,41149350],[-8611794,41149062],[-8612118,41148567],[-8612154,41148549],[-8612460,41148099],[-8621829,41147550],[-8623665,41148054],[-8624988,41148576],[-8625636,41149692],[-8625924,41151096],[-8626113,41152329],[-8626824,41152509],[-8628813,41152572],[-8630352,41152626],[-8630379,41152599],[-8631756,41152761],[-8632143,41153616],[-8630982,41154624]],
39
+ [[-8585694,41148567],[-8585739,41148648],[-8585748,41148747],[-8585847,41148963],[-8585910,41148972],[-8586315,41148882],[-8586135,41148360]],
40
+ [[-8615529,41140692],[-8615286,41140818],[-8615070,41140881],[-8614638,41140989],[-8614071,41141187],[-8613540,41141439],[-8610723,41141043],[-8610219,41140917],[-8609409,41140845],[-8608050,41141169],[-8606646,41141529],[-8607249,41141394],[-8609472,41140899],[-8610021,41140962],[-8610975,41141394],[-8613504,41141439],[-8614404,41141142],[-8614746,41141052],[-8615106,41140926],[-8615367,41140809],[-8616168,41140539]],
41
+ [[-8604135,41161140],[-8604162,41161113],[-8604072,41161311],[-8604036,41161383],[-8603955,41161491],[-8603973,41161464],[-8604090,41161338],[-8604081,41161365],[-8604009,41161464],[-8604018,41161446],[-8604144,41161761],[-8604981,41161950],[-8605152,41161833],[-8605350,41162004],[-8606439,41162148],[-8606655,41162202],[-8606682,41162913],[-8606250,41164137],[-8606421,41164704],[-8606448,41166018],[-8606457,41167557],[-8606070,41169429],[-8605044,41170779],[-8605053,41170779],[-8605008,41170797],[-8604450,41171463],[-8605116,41172957],[-8605728,41173533],[-8604000,41173668],[-8601534,41173740],[-8600076,41174442],[-8600067,41174460],[-8599806,41174766],[-8599986,41176449],[-8599050,41178312],[-8600067,41178807],[-8602515,41179482],[-8603451,41179968],[-8603262,41180661],[-8603658,41180328],[-8604000,41180184],[-8604189,41180274],[-8604144,41180319],[-8604126,41180337],[-8604117,41180346],[-8604279,41180418],[-8604630,41180427],[-8604405,41180346]],
42
+ [[-8584029,41169852],[-8584029,41169852],[-8583930,41170059],[-8583876,41170104],[-8583822,41170131],[-8584065,41169942],[-8585568,41170347]],
43
+ [[-8597817,41162517],[-8598006,41161725],[-8598915,41161419],[-8600112,41161455],[-8600517,41160591],[-8600886,41159898],[-8600904,41159880],[-8600985,41159700],[-8601228,41158890],[-8601705,41157756],[-8602353,41156280],[-8602758,41155083],[-8602875,41154921],[-8602920,41154885],[-8602929,41154867],[-8603127,41154633],[-8604099,41154786],[-8604324,41154786],[-8604567,41154804],[-8604657,41154210],[-8605278,41153697],[-8607249,41153625],[-8609103,41153742],[-8609382,41153688],[-8609814,41153283],[-8610057,41152041],[-8610633,41151033],[-8610858,41150637],[-8611659,41150493],[-8612919,41150061],[-8613549,41150070],[-8614017,41149728],[-8614143,41149188],[-8614296,41148576],[-8614215,41147739],[-8613396,41147235],[-8613729,41145966],[-8613693,41145894],[-8613621,41145903],[-8613495,41145930]],
44
+ [[-8606502,41144643],[-8606475,41144688],[-8606493,41144688],[-8606502,41144697],[-8606520,41144697],[-8606502,41144688],[-8606799,41144805],[-8607249,41145237],[-8607402,41145507],[-8607231,41145795],[-8607213,41145795],[-8607096,41145885],[-8607033,41146137],[-8607015,41146353],[-8607015,41146524],[-8606979,41146677],[-8606925,41146812],[-8606889,41146821],[-8606889,41146848],[-8606880,41146866],[-8606853,41146911],[-8607006,41147127],[-8607960,41147415],[-8608113,41147397],[-8608194,41147406],[-8609166,41147757],[-8610309,41147973],[-8610381,41147919],[-8610885,41148270],[-8610768,41148603],[-8610651,41148864],[-8610273,41149899],[-8610327,41150421],[-8610291,41150412],[-8610228,41150556],[-8609769,41151150],[-8609499,41151510],[-8609904,41151924],[-8610021,41153004],[-8610012,41153877],[-8609409,41155281],[-8609373,41156775],[-8609337,41157108],[-8608905,41158377],[-8608014,41160231],[-8606394,41164074],[-8606322,41164137],[-8606376,41165253],[-8606484,41166666],[-8606466,41168394],[-8605368,41170212],[-8603217,41171337],[-8599239,41171148],[-8596431,41170905],[-8594982,41172507],[-8593749,41175351],[-8593209,41178483],[-8593137,41182524],[-8594487,41186952]],
45
+ [[-8627193,41152005],[-8627202,41152014],[-8626401,41152221],[-8625852,41151420],[-8625969,41150727],[-8625942,41150574],[-8625618,41149152],[-8625591,41148909],[-8625600,41148900],[-8624916,41148333],[-8623026,41147739],[-8622297,41147595],[-8620542,41147271],[-8620236,41146416],[-8619282,41146155],[-8617680,41146290]],
46
+ [[-8599248,41149125],[-8599185,41149116],[-8598636,41148567],[-8598609,41148558],[-8598636,41148549],[-8598627,41148540],[-8597952,41148603],[-8596008,41149809],[-8595045,41150403],[-8594991,41150412],[-8594991,41150448],[-8594955,41150448],[-8594433,41150637]],
47
+ [[-8656821,41161473],[-8656821,41161482],[-8655921,41161959],[-8654787,41162139],[-8652861,41161806],[-8651592,41161599],[-8650485,41161410],[-8650224,41160159],[-8648379,41159088],[-8646795,41157684],[-8645679,41155731],[-8644797,41153481],[-8644761,41151159],[-8642799,41149350],[-8639352,41149521],[-8636166,41150700],[-8633088,41151258],[-8632521,41152248],[-8632521,41152221],[-8632521,41152230],[-8631891,41152617],[-8631018,41152590],[-8629002,41152473],[-8627337,41152392],[-8626563,41152185],[-8624763,41152716],[-8622801,41152797],[-8620596,41152599],[-8618670,41152347],[-8618013,41152284],[-8617716,41151852]],
48
+ [[-8649720,41167503],[-8649657,41167449],[-8649837,41166738],[-8648784,41166144],[-8647227,41165856],[-8645310,41165478],[-8644563,41165442],[-8643006,41165154],[-8641188,41164506],[-8639190,41164461],[-8637633,41164452],[-8637534,41164479],[-8637525,41164488],[-8637030,41164380],[-8635320,41163894],[-8633736,41163291],[-8632962,41162472],[-8632881,41162292]],
49
+ [[-8584344,41163111],[-8584371,41163075],[-8585370,41162940],[-8585469,41162625],[-8585370,41161203],[-8583345,41160231],[-8582715,41159448],[-8582922,41158881],[-8581869,41159169],[-8581158,41159331],[-8580285,41159295],[-8578566,41159394],[-8576712,41160042],[-8575542,41160267],[-8573724,41160915],[-8572518,41161635],[-8570817,41162409],[-8570268,41163768],[-8570934,41164839],[-8571033,41165496],[-8569728,41166144],[-8568045,41166342],[-8566254,41166531],[-8565120,41166918],[-8564130,41167269],[-8562924,41167557],[-8561736,41166549],[-8559684,41166531],[-8558604,41167557],[-8557884,41168016],[-8557101,41168457],[-8556417,41168646],[-8554635,41168763],[-8553771,41168853],[-8552916,41168412],[-8552889,41168394],[-8552889,41168394],[-8552898,41168394],[-8552907,41168385]],
50
+ [[-8591328,41162715],[-8591292,41162715],[-8591040,41162553],[-8591247,41162166],[-8591238,41162049],[-8590887,41162355],[-8589780,41163759],[-8582184,41163399],[-8580969,41163651],[-8581950,41164848],[-8582490,41165550],[-8582841,41165874],[-8583615,41166360],[-8583669,41166378],[-8584335,41166594],[-8586360,41166846],[-8587827,41167566],[-8589078,41168286],[-8590698,41169276],[-8593056,41170815],[-8596476,41171886],[-8600589,41171229],[-8605269,41171832],[-8609103,41174001],[-8613441,41174586],[-8617257,41174028],[-8621568,41173587],[-8625447,41173191],[-8629281,41172669],[-8632647,41171940],[-8636040,41171148],[-8639712,41169042],[-8643276,41166477],[-8647119,41164695],[-8649270,41162724],[-8648568,41159718],[-8646543,41157333],[-8645454,41155119],[-8644707,41152752],[-8644050,41149971],[-8639964,41149359],[-8636130,41150718],[-8633727,41151024],[-8632566,41152113],[-8632557,41152104],[-8632557,41152113],[-8631999,41152599],[-8631252,41152572],[-8629128,41152410],[-8627481,41152356],[-8626545,41152473],[-8626554,41152473],[-8626545,41152491],[-8626563,41152482],[-8626005,41151780],[-8626005,41150682],[-8625798,41149791]],
51
+ [[-8628264,41157684],[-8628201,41157702],[-8627058,41157756],[-8625474,41157441],[-8625285,41157333],[-8624898,41157126],[-8625303,41155884],[-8624403,41155524],[-8623251,41155749],[-8622207,41155902],[-8621046,41155668],[-8619471,41155308],[-8617428,41154903],[-8614971,41154552],[-8613585,41154237],[-8613351,41153967],[-8613333,41154012],[-8613297,41153805],[-8612100,41153652],[-8610561,41153544],[-8608383,41153499],[-8606538,41153427],[-8606547,41153454],[-8606547,41153454],[-8606421,41152419],[-8606646,41152365],[-8606853,41152239],[-8607348,41151285],[-8607114,41150997],[-8606889,41150952],[-8606997,41150313],[-8607078,41150268],[-8607105,41150223],[-8607753,41148999],[-8607843,41148756],[-8607789,41148729],[-8607771,41148693],[-8607537,41148675],[-8607330,41148693],[-8607042,41148549],[-8607024,41148558],[-8607024,41148540],[-8606619,41148324],[-8606322,41148279],[-8606340,41148252],[-8606331,41148252],[-8605512,41147937],[-8604630,41147649],[-8604207,41147667],[-8604018,41147586],[-8603793,41146812],[-8603856,41146641],[-8603874,41146623],[-8603865,41146605],[-8604144,41146434],[-8604639,41146020],[-8604990,41145588],[-8604837,41145525],[-8604738,41145453],[-8604603,41144805],[-8604864,41144211],[-8603649,41143572],[-8602083,41142789],[-8601723,41140989]],
52
+ [[-8606988,41150313],[-8607114,41150250],[-8607231,41150205],[-8607384,41149881],[-8607843,41148945],[-8608266,41148207],[-8608563,41147721],[-8608851,41147559],[-8609067,41147802],[-8609895,41147937],[-8610309,41147838],[-8610372,41147838],[-8610876,41147757],[-8611344,41147415],[-8611398,41147037],[-8611434,41146821],[-8611488,41146587],[-8611488,41146578],[-8611560,41146245],[-8611443,41145912],[-8611191,41146056],[-8611182,41146101],[-8610930,41146110]],
53
+ [[-8609688,41151339],[-8609697,41151339],[-8609652,41151348],[-8609544,41151447],[-8609976,41152023],[-8610003,41153166],[-8609949,41153976],[-8609256,41155524],[-8609229,41156523],[-8608995,41157405],[-8607483,41157603],[-8606601,41158548],[-8605611,41159025],[-8604549,41158845],[-8604531,41159961],[-8603433,41160096],[-8601552,41159583],[-8599293,41158980],[-8598924,41158890]],
54
+ [[-8585640,41148918],[-8585766,41148981],[-8586054,41148990],[-8586594,41149035],[-8588115,41149476],[-8589753,41149926],[-8591688,41150493],[-8593056,41150808],[-8593155,41150673],[-8593164,41150664],[-8593155,41150664],[-8593758,41150934],[-8594577,41151771],[-8595108,41153418],[-8595378,41154399],[-8595315,41154435],[-8595270,41154453],[-8595414,41154651],[-8595234,41155272],[-8594982,41155758],[-8594784,41156163],[-8594298,41157099],[-8593128,41159025],[-8592237,41160510],[-8591463,41161662],[-8590734,41162571],[-8590032,41163408],[-8589690,41163768],[-8589699,41163750],[-8589672,41163777],[-8589303,41164200],[-8589231,41164308],[-8589141,41164560],[-8589123,41164632],[-8589087,41164740],[-8588907,41165217],[-8588475,41166315],[-8588106,41167152],[-8588079,41167197],[-8587728,41168025],[-8587359,41168799],[-8587341,41168817],[-8587269,41168970],[-8586369,41170689]],
55
+ [[-8585685,41148558],[-8585757,41148666],[-8585721,41148801],[-8585973,41148972],[-8586486,41148990],[-8587404,41149197],[-8588664,41149557],[-8590347,41150007],[-8592021,41150475],[-8593083,41150781],[-8593353,41150709],[-8593353,41150691],[-8593353,41150700],[-8593335,41150736],[-8593326,41150745],[-8593515,41150808],[-8594370,41151240],[-8594757,41152329],[-8595189,41153445],[-8595468,41154390],[-8595180,41155398],[-8594730,41156190],[-8594091,41157351],[-8593407,41158620],[-8594082,41158926],[-8594757,41159151],[-8595783,41159475],[-8595774,41159808],[-8594397,41160258],[-8594433,41160600],[-8596755,41160906],[-8598960,41161176],[-8600112,41161293],[-8600094,41161320],[-8600463,41161086],[-8600859,41160006],[-8601039,41159646],[-8601066,41159610],[-8601084,41159556]],
56
+ [[-8611110,41149440],[-8611137,41149404],[-8610858,41149278],[-8610867,41149269],[-8610858,41149287],[-8610237,41149575],[-8610183,41149962],[-8610309,41150520],[-8610129,41150727],[-8610129,41150745],[-8610129,41150754],[-8610120,41150763],[-8609499,41151510],[-8610003,41152302],[-8610048,41153373],[-8609400,41154525],[-8609265,41155380],[-8609445,41156280],[-8609238,41157387],[-8608860,41157990],[-8608275,41159277],[-8607492,41160924],[-8606295,41164110]],
57
+ [[-8606286,41144625],[-8606664,41144724],[-8607123,41145030],[-8607123,41145048],[-8607312,41145246],[-8607411,41145588],[-8607078,41145939],[-8607051,41146407],[-8607051,41146425],[-8606997,41146515],[-8606934,41146668],[-8606907,41146659],[-8606961,41146650],[-8606943,41146659],[-8606943,41146668],[-8606889,41146866],[-8607348,41147136],[-8607942,41147244],[-8608113,41147307],[-8609229,41147595],[-8610336,41147784],[-8610390,41147766],[-8610876,41148207],[-8610759,41148567],[-8610651,41148846],[-8610219,41149926],[-8610336,41150394],[-8610354,41150394],[-8610318,41150547],[-8609778,41151168],[-8609517,41151465],[-8609868,41151888],[-8609994,41153022],[-8609724,41154165],[-8609292,41155281],[-8609310,41156946],[-8609202,41157423],[-8608554,41158755],[-8607753,41160474],[-8606367,41163885],[-8606295,41164182],[-8606412,41166054],[-8606412,41168610],[-8604792,41170716],[-8602056,41171238],[-8599068,41171202],[-8596854,41171157],[-8595270,41171931],[-8594055,41174694],[-8593191,41178447],[-8593038,41182218],[-8594046,41185557],[-8594568,41189256]],
58
+ [[-8649531,41167197],[-8649630,41167170],[-8649810,41166648],[-8649909,41166639],[-8649909,41166621],[-8649882,41166603],[-8648982,41166144],[-8647731,41165991],[-8646651,41165748],[-8644860,41165451],[-8644059,41165325],[-8642241,41164965],[-8640180,41164650],[-8638452,41164551],[-8637372,41164488],[-8637345,41164497],[-8637354,41164488],[-8636499,41164290],[-8634717,41163705],[-8633331,41163012],[-8632647,41162265],[-8632728,41162229]],
59
+ [[-8630667,41207364],[-8634771,41206716],[-8638641,41205555],[-8642457,41204475],[-8646651,41203467],[-8650701,41203737],[-8651664,41206455],[-8651790,41209713],[-8653086,41212719],[-8654841,41215662],[-8657433,41218380],[-8660115,41221152],[-8662779,41223951],[-8665191,41226516],[-8667801,41228559],[-8667477,41231349],[-8666604,41233680],[-8667666,41235849],[-8667900,41237955],[-8667837,41238630],[-8667045,41238387],[-8666082,41237946],[-8665875,41237424],[-8665227,41237397],[-8664714,41237811],[-8664714,41237802],[-8664723,41237802],[-8665146,41238072],[-8666883,41238432],[-8667315,41238585],[-8667297,41238576],[-8667306,41238567],[-8667306,41238567],[-8667297,41238567],[-8667279,41238558],[-8667279,41238558],[-8667279,41238558],[-8667279,41238558],[-8667279,41238558],[-8667279,41238558],[-8667279,41238558],[-8667279,41238567],[-8667288,41238567],[-8667288,41238576],[-8667297,41238567],[-8667288,41238567],[-8667279,41238567],[-8667279,41238558],[-8667288,41238558],[-8667288,41238567],[-8667279,41238576],[-8667279,41238585],[-8667270,41238585],[-8667261,41238576],[-8667261,41238576],[-8667261,41238567],[-8667270,41238558],[-8667279,41238558],[-8667279,41238567],[-8667288,41238576],[-8667288,41238576],[-8667288,41238576],[-8667279,41238576],[-8667288,41238585],[-8667288,41238585],[-8667288,41238585],[-8667288,41238576],[-8667288,41238567],[-8667279,41238567],[-8667279,41238567],[-8667279,41238576],[-8667279,41238576],[-8667279,41238576],[-8667288,41238585],[-8667288,41238585],[-8667288,41238585],[-8667279,41238594],[-8667270,41238585],[-8667270,41238576],[-8667279,41238576],[-8667279,41238576],[-8667279,41238567],[-8667630,41238612],[-8669457,41239215],[-8670663,41239692],[-8670555,41238702],[-8670051,41236542],[-8669268,41235003],[-8669169,41236263],[-8669556,41237586],[-8669646,41237847],[-8670006,41236956],[-8669673,41235867],[-8669340,41235030],[-8669034,41235840],[-8669349,41237118],[-8668926,41238333],[-8667909,41236416],[-8666775,41233680],[-8667774,41230872],[-8668665,41227677],[-8668953,41224419],[-8664759,41223681],[-8660871,41221674],[-8657793,41218407],[-8654814,41215230],[-8652879,41211702],[-8651709,41207949],[-8651610,41204439],[-8652366,41202549],[-8656542,41201613],[-8659971,41199363],[-8663616,41196726],[-8666199,41193468],[-8667720,41190138],[-8670411,41189022],[-8668908,41187015],[-8666046,41186403],[-8665173,41185746],[-8664111,41184882],[-8662419,41183514],[-8660709,41182119],[-8659602,41181219],[-8658027,41179950],[-8656272,41178564],[-8654706,41177241],[-8653536,41176314],[-8652681,41175612],[-8652114,41175171],[-8651322,41174559],[-8650035,41173488],[-8648019,41171859],[-8645670,41169942],[-8642916,41167746]],
60
+ [[-8619264,41167620],[-8619300,41167620],[-8619264,41167629],[-8619255,41167629],[-8619255,41167638],[-8619552,41167611],[-8620245,41167404],[-8620299,41166936],[-8620416,41165982],[-8620587,41164749],[-8620668,41164254],[-8620794,41163255],[-8620164,41162679],[-8618463,41162544],[-8617356,41162436],[-8615997,41162292],[-8614548,41162112],[-8612595,41161851],[-8611866,41161788],[-8611866,41161806],[-8611686,41161779],[-8610066,41161572],[-8608239,41161203],[-8607186,41161014],[-8606133,41160789],[-8605233,41160609],[-8605737,41159772],[-8606070,41159232],[-8605053,41158881],[-8604477,41158962],[-8604513,41159079],[-8604531,41159097],[-8604639,41159070],[-8604639,41159052],[-8604684,41159025],[-8604693,41159025],[-8604747,41158989],[-8604711,41158998]],
61
+ [[-8585748,41148495],[-8585748,41148594],[-8585766,41148774],[-8585694,41148882],[-8585766,41148954],[-8585883,41148963],[-8586405,41149008],[-8587791,41149296],[-8589546,41149773],[-8591427,41150286],[-8592075,41150466],[-8592840,41150673],[-8594019,41150925],[-8595531,41150142],[-8596098,41149818],[-8597484,41148945]],
62
+ [[-8574696,41142708],[-8574669,41142888],[-8575254,41142951],[-8575857,41143275],[-8575308,41143887],[-8573616,41143950],[-8574363,41144067],[-8576559,41144364],[-8578071,41144652],[-8579961,41143905]],
63
+ [[-8582184,41180058],[-8582301,41179671],[-8582850,41177871],[-8583912,41175666],[-8584092,41175369],[-8584533,41174550],[-8585523,41172471],[-8586324,41170968],[-8586747,41170104],[-8587161,41169339],[-8587206,41169312],[-8587206,41169321],[-8587404,41168943],[-8587701,41168826],[-8587728,41168826],[-8587881,41168835],[-8588025,41168853],[-8588574,41168835],[-8588853,41168682],[-8589078,41168592]],
64
+ [[-8601183,41181885],[-8601165,41181903],[-8601165,41181903],[-8601093,41182047],[-8601363,41182668],[-8600985,41183055],[-8599185,41182560],[-8597691,41182146],[-8597637,41182128],[-8597655,41182128],[-8597637,41182128],[-8597637,41182137],[-8597034,41182074],[-8594892,41181516],[-8592264,41180454],[-8590113,41179734],[-8588421,41179581],[-8586387,41179860],[-8584218,41181291],[-8583534,41181237],[-8583516,41181210],[-8583543,41181192],[-8583534,41181147],[-8583552,41181156]],
65
+ [[-8606403,41144814],[-8606394,41144805],[-8606529,41144706],[-8606493,41144724],[-8606475,41144724],[-8606565,41144625],[-8606556,41144643],[-8606754,41144760],[-8606691,41144787],[-8607015,41144796],[-8608050,41143383],[-8608140,41143167],[-8608140,41143158],[-8606673,41142312],[-8605098,41143482],[-8604720,41143977],[-8603316,41143455],[-8602029,41142447],[-8601489,41139936],[-8601228,41137884],[-8601246,41137911],[-8601264,41137875],[-8601804,41137389]],
66
+ [[-8606538,41144778],[-8606529,41144733],[-8606502,41144742],[-8606529,41144715],[-8606529,41144697],[-8606502,41144697],[-8606988,41144895],[-8607357,41145309],[-8607357,41145633],[-8607204,41145795],[-8607222,41145777],[-8607087,41145984],[-8607150,41146308],[-8607015,41146569],[-8606970,41146659],[-8606916,41146803],[-8606817,41146911],[-8606781,41146911],[-8606817,41146911],[-8606853,41146938],[-8606853,41146956],[-8607348,41147280],[-8608176,41147379],[-8608257,41147379],[-8608545,41147532],[-8609481,41147757],[-8610399,41147838],[-8610678,41147730],[-8610921,41148387],[-8610930,41148567],[-8610822,41148864],[-8610363,41149989],[-8610354,41150430],[-8610372,41150448],[-8610210,41150655],[-8609679,41151249],[-8609544,41151600],[-8610003,41152068],[-8610039,41153202],[-8609769,41154192],[-8609418,41155452],[-8609391,41156937],[-8609211,41157405],[-8608446,41158863],[-8607519,41160762],[-8606286,41164587],[-8606367,41165694],[-8606421,41166117],[-8606502,41166891],[-8606439,41168790],[-8604810,41170680],[-8602029,41171193],[-8598186,41171355],[-8596152,41170959],[-8594928,41172669],[-8593731,41175531],[-8593146,41179068],[-8593164,41182821],[-8594433,41186727]],
67
+ [[-8585712,41148603],[-8585712,41148612],[-8585748,41148765],[-8585694,41148927],[-8586018,41148981],[-8587188,41149143],[-8589195,41149674],[-8591616,41150331],[-8593092,41150718],[-8593083,41150727],[-8593101,41150718],[-8593191,41150745],[-8593281,41150772],[-8594109,41150655],[-8593740,41149485],[-8594505,41149071],[-8595918,41148765],[-8595990,41148621],[-8595468,41147613],[-8595189,41146227],[-8596215,41146065],[-8598708,41145948],[-8601444,41145741],[-8601723,41145705],[-8601732,41145678],[-8601714,41145687]],
68
+ [[-8613522,41162148],[-8613522,41162121],[-8613540,41162022],[-8613486,41161968],[-8613396,41162031],[-8612991,41161896],[-8612631,41162058],[-8612181,41162841],[-8612505,41162994],[-8614161,41163273],[-8614638,41163219],[-8616042,41163426],[-8618121,41163669],[-8620254,41164002],[-8620362,41163993],[-8620956,41164101],[-8623494,41164407],[-8624538,41164488],[-8624628,41164353],[-8624655,41164290],[-8625303,41164866],[-8626437,41164875],[-8627823,41164929],[-8629452,41165145]],
69
+ [[-8613972,41134086],[-8613972,41134077],[-8613981,41134077],[-8613990,41134095],[-8614062,41134293],[-8614080,41134293],[-8614224,41134671],[-8614386,41135292],[-8613981,41135814],[-8614728,41136489],[-8614926,41136903],[-8614953,41137119],[-8614737,41137362],[-8613855,41137596],[-8613360,41137704],[-8612883,41137839],[-8612766,41137866],[-8611911,41138055],[-8611056,41138262],[-8610237,41138658],[-8609832,41138856],[-8609400,41138982],[-8609211,41139216],[-8609607,41140359],[-8609661,41140638],[-8610390,41141079],[-8613054,41141565],[-8613504,41141421],[-8613999,41141268],[-8614305,41141727],[-8614089,41142771],[-8612910,41143698],[-8612307,41144139],[-8612271,41144157],[-8612055,41144319],[-8611974,41144382],[-8611839,41144472],[-8611839,41144481],[-8611848,41144481],[-8611668,41144652],[-8611218,41144967]],
70
+ [[-8628201,41157378],[-8628210,41157387],[-8628246,41157369],[-8628264,41157351],[-8628174,41157513],[-8627013,41157576],[-8625411,41157324],[-8625150,41157234],[-8624907,41157081]],
71
+ [[-8624304,41179689],[-8624043,41179698],[-8623629,41178978],[-8624403,41178015],[-8625150,41177007],[-8626149,41176323],[-8627391,41175981],[-8627634,41175936],[-8627643,41175945],[-8627643,41175963],[-8627643,41175972],[-8628255,41176530],[-8628858,41177817],[-8629416,41178969],[-8629488,41179167],[-8629488,41179158],[-8629488,41179158],[-8629488,41179149],[-8629470,41179149],[-8628678,41179455],[-8625960,41179779],[-8624151,41180040],[-8624160,41180040],[-8622783,41180310],[-8620884,41180958],[-8620848,41180967],[-8620848,41180958],[-8620767,41180994],[-8621262,41181651],[-8622486,41182992],[-8623557,41184675],[-8624781,41186511],[-8626032,41188419],[-8627148,41190102],[-8628219,41192469],[-8628300,41194944],[-8627580,41197545],[-8627184,41200218],[-8626986,41202468],[-8624079,41202648],[-8620641,41203251],[-8617239,41202297],[-8613198,41201136],[-8608968,41200497],[-8604828,41199480],[-8600967,41198724],[-8596890,41197500],[-8592660,41196690],[-8589708,41196249],[-8588637,41195376],[-8588538,41196942],[-8586684,41199687],[-8583948,41202639],[-8582454,41207040],[-8579574,41210865],[-8576280,41214627],[-8575020,41218848],[-8573202,41222898],[-8571672,41226813],[-8568972,41230566],[-8566047,41233788],[-8564400,41237379],[-8564103,41240925],[-8564931,41243967],[-8566254,41246352],[-8567973,41249871],[-8568270,41254434],[-8566470,41258988],[-8564031,41263290],[-8561610,41267610],[-8559792,41271831],[-8560674,41276367],[-8560908,41280939],[-8558406,41285088],[-8553384,41288184],[-8548092,41290794],[-8542431,41293602],[-8538885,41297166],[-8537553,41301990],[-8532774,41304573],[-8527923,41307057],[-8525304,41311341],[-8520210,41313726],[-8516304,41317110],[-8516889,41322024],[-8517510,41327019],[-8514576,41331159],[-8510031,41334372],[-8507835,41338728],[-8505900,41343417],[-8506062,41347899],[-8506953,41352318],[-8504658,41356053],[-8501076,41358996],[-8499960,41363334],[-8501985,41367690],[-8503344,41371722],[-8501661,41375673],[-8500968,41380236],[-8497971,41384547],[-8495010,41388768],[-8495739,41393772],[-8495982,41398425],[-8493705,41402673],[-8493426,41406660],[-8495586,41410233],[-8494605,41414346],[-8493471,41418684],[-8494434,41423346],[-8496882,41427576],[-8497665,41431860],[-8495892,41436324],[-8493516,41440725],[-8492877,41445261],[-8490600,41449275],[-8488485,41453622],[-8483598,41456511],[-8479017,41459715],[-8474562,41462883],[-8470638,41465457],[-8469207,41469111],[-8465706,41471991],[-8461989,41474916],[-8458911,41477994],[-8460279,41481648],[-8464590,41484015],[-8466453,41487669],[-8464707,41491467],[-8466183,41495013],[-8469927,41497992],[-8472087,41502276],[-8471745,41505912],[-8469099,41506281],[-8466579,41507730],[-8463528,41507892],[-8459532,41507712],[-8454483,41507559],[-8449920,41507973],[-8445888,41507532],[-8444529,41510133],[-8444601,41513400],[-8444502,41516712],[-8445564,41520429],[-8446203,41523912],[-8444349,41526720],[-8443161,41529411],[-8443494,41531868],[-8445987,41534478],[-8444439,41537682],[-8441721,41540391],[-8439552,41543361],[-8436951,41546331],[-8434773,41549139],[-8432136,41551263],[-8431200,41552514],[-8429526,41554710],[-8427708,41556699],[-8425044,41557392],[-8422470,41558436],[-8420364,41559804],[-8418510,41561019],[-8415810,41561748],[-8413155,41562009],[-8410194,41562351],[-8407521,41561487],[-8407476,41558877],[-8407305,41557311],[-8407143,41555664],[-8407071,41554386],[-8406918,41553027],[-8406945,41552928],[-8406954,41552901],[-8406369,41552613],[-8404380,41553567],[-8401221,41554899],[-8398629,41555925],[-8396685,41556213],[-8394237,41556015],[-8392770,41557788],[-8389935,41557320],[-8388342,41555574],[-8385840,41555565],[-8385435,41554071],[-8383032,41553369],[-8381349,41551731],[-8380485,41552676],[-8379927,41553252],[-8379675,41551929],[-8379414,41552811],[-8379144,41554269],[-8378586,41555340],[-8378082,41557023],[-8377335,41558310],[-8376975,41557599],[-8377506,41556843],[-8377173,41556879],[-8377524,41556465],[-8377380,41555772],[-8377407,41555628],[-8377290,41555664],[-8377119,41555952],[-8377056,41556114],[-8377047,41556114],[-8376966,41556267],[-8376921,41556393],[-8376930,41556420],[-8376930,41556420],[-8376921,41556420],[-8376894,41556393],[-8376903,41556384],[-8376903,41556402],[-8376894,41556375],[-8376912,41556393],[-8376894,41556357],[-8376903,41556393],[-8376903,41556393],[-8376885,41556366],[-8376876,41556375],[-8376876,41556384],[-8376885,41556393],[-8376894,41556384],[-8376903,41556375],[-8376885,41556384],[-8376876,41556375],[-8376876,41556384],[-8376876,41556375],[-8376894,41556393],[-8376903,41556402],[-8376894,41556393],[-8376903,41556402],[-8376912,41556402],[-8376894,41556348],[-8376876,41556339],[-8376885,41556357],[-8376885,41556357],[-8376894,41556357],[-8376903,41556348],[-8376894,41556357],[-8376912,41556393],[-8376930,41556393],[-8376912,41556321],[-8376903,41556321],[-8376858,41556312],[-8376876,41556339],[-8376912,41556384],[-8376921,41556402],[-8376957,41556429],[-8376957,41556429],[-8376957,41556420],[-8376966,41556402],[-8376957,41556393],[-8376921,41556366],[-8376921,41556393],[-8376921,41556393],[-8376921,41556393],[-8376921,41556384],[-8376894,41556357],[-8376894,41556366],[-8376921,41556366],[-8376957,41556312],[-8376984,41556294],[-8376993,41556312],[-8376975,41556330],[-8376993,41556321],[-8376966,41556330],[-8376948,41556339],[-8376957,41556330],[-8376948,41556330],[-8376930,41556339],[-8376930,41556348],[-8376921,41556366],[-8376912,41556375],[-8376921,41556384],[-8376912,41556375],[-8376903,41556357],[-8376921,41556366],[-8376921,41556393],[-8376912,41556393],[-8376912,41556375],[-8376912,41556375],[-8376894,41556366],[-8376903,41556357],[-8376885,41556357],[-8376867,41556348],[-8376885,41556339],[-8376894,41556348],[-8376912,41556339],[-8376930,41556303],[-8376921,41556303],[-8376903,41556312],[-8376876,41556303],[-8376849,41556285],[-8376876,41556330],[-8376894,41556357],[-8376903,41556357],[-8376903,41556357],[-8376903,41556357],[-8376903,41556339],[-8376912,41556339],[-8376912,41556339],[-8376894,41556321],[-8376912,41556348],[-8376894,41556348],[-8376903,41556339],[-8376930,41556339],[-8376939,41556357],[-8376921,41556339],[-8376948,41556321],[-8376957,41556330],[-8376930,41556348],[-8376948,41556348],[-8376939,41556348],[-8376921,41556357],[-8376912,41556384],[-8376930,41556375],[-8376921,41556366],[-8376912,41556348],[-8376930,41556339],[-8376948,41556330],[-8376930,41556357],[-8376912,41556366],[-8376849,41556330],[-8376822,41556339],[-8376840,41556348],[-8376831,41556375],[-8376849,41556393],[-8376858,41556411],[-8376867,41556411],[-8376867,41556420],[-8376876,41556420],[-8376894,41556438],[-8376876,41556438],[-8376885,41556429],[-8376885,41556411],[-8376921,41556420],[-8376939,41556411],[-8376921,41556402],[-8376894,41556375],[-8376912,41556384],[-8376885,41556384],[-8376867,41556402],[-8376858,41556411],[-8376867,41556402],[-8376867,41556375],[-8376876,41556438],[-8376885,41556429],[-8376876,41556420],[-8376876,41556429],[-8376858,41556402],[-8376876,41556447],[-8376831,41556420],[-8376777,41556438],[-8376822,41556501],[-8376813,41556483],[-8376732,41556447],[-8376696,41556465],[-8376768,41556492],[-8376831,41556483],[-8376867,41556456],[-8376831,41556411],[-8376831,41556411],[-8376813,41556429],[-8376831,41556438],[-8376849,41556420],[-8376831,41556456],[-8376813,41556438],[-8376795,41556438],[-8376786,41556429],[-8376795,41556411],[-8376741,41556438],[-8376777,41556411],[-8376804,41556402],[-8376822,41556402],[-8376858,41556393],[-8376858,41556429],[-8376831,41556447],[-8376840,41556465],[-8376867,41556384],[-8376876,41556375],[-8376858,41556375],[-8376858,41556366],[-8376831,41556384],[-8376831,41556375],[-8376849,41556375],[-8376831,41556384],[-8376831,41556384],[-8376804,41556393],[-8376795,41556420],[-8376804,41556402],[-8376768,41556420],[-8376786,41556420],[-8376822,41556375],[-8376813,41556357],[-8376804,41556348],[-8376813,41556357],[-8376831,41556366],[-8376858,41556375],[-8376867,41556375],[-8376867,41556366],[-8376858,41556375],[-8376867,41556384],[-8376867,41556384],[-8376876,41556384],[-8376903,41556357],[-8376930,41556330],[-8376885,41556330],[-8376885,41556366],[-8376903,41556348],[-8376912,41556330],[-8376957,41556366],[-8376939,41556357],[-8376903,41556330],[-8376912,41556366],[-8376921,41556384],[-8376939,41556375],[-8376939,41556357],[-8376921,41556321],[-8376939,41556321],[-8376903,41556339],[-8376939,41556339],[-8376966,41556366],[-8376975,41556357],[-8376957,41556357],[-8376948,41556348],[-8376930,41556321],[-8376930,41556321],[-8376912,41556348],[-8376885,41556393],[-8376885,41556429],[-8376903,41556438],[-8376903,41556375],[-8376912,41556339],[-8376921,41556357],[-8376876,41556330],[-8376849,41556339],[-8376858,41556339],[-8376903,41556366],[-8376858,41556321],[-8376876,41556348],[-8376867,41556366],[-8376831,41556393],[-8376849,41556393],[-8376876,41556339],[-8376912,41556249],[-8376948,41556213],[-8376912,41556321],[-8376903,41556402],[-8376903,41556411],[-8376885,41556375],[-8376885,41556348],[-8376885,41556348],[-8376885,41556357],[-8376903,41556366],[-8376921,41556375],[-8376939,41556357],[-8376948,41556366],[-8376921,41556393],[-8376921,41556411],[-8376948,41556393],[-8376966,41556402],[-8376966,41556384],[-8376948,41556375],[-8376939,41556348],[-8376930,41556357],[-8376930,41556366],[-8376939,41556375],[-8376939,41556339],[-8376930,41556357],[-8376912,41556366],[-8376903,41556375]],
72
+ [[-8663877,41163660],[-8663301,41163642],[-8662473,41164227],[-8660979,41166000],[-8659422,41167863],[-8658297,41169195],[-8657460,41170140],[-8657244,41170446],[-8657244,41170599],[-8658711,41171346],[-8660115,41172138],[-8660511,41173524],[-8660718,41175189],[-8661015,41175576],[-8661033,41175558],[-8661213,41175729],[-8661231,41175720],[-8661339,41175846],[-8661402,41175954],[-8661411,41175963],[-8661384,41175981],[-8661456,41176062],[-8661456,41176062],[-8661465,41176053],[-8661465,41176053],[-8661456,41176053],[-8661537,41176152],[-8661672,41176305],[-8661798,41176458],[-8661870,41176593],[-8661861,41176692],[-8661834,41176719],[-8661762,41176764],[-8661375,41176827],[-8660709,41176917],[-8660097,41176998],[-8659674,41177052],[-8658765,41177214],[-8658666,41177205],[-8658180,41177268],[-8657388,41177394],[-8656659,41177637],[-8656416,41177700],[-8656290,41177745],[-8656065,41177790],[-8655804,41177772],[-8655435,41178402],[-8657010,41179419],[-8657802,41180013],[-8659809,41181579],[-8662338,41183631],[-8664336,41185260],[-8666883,41187321],[-8670852,41189058],[-8675901,41189787],[-8679591,41192118],[-8682813,41195295],[-8686017,41198427],[-8689383,41201829],[-8690292,41205807],[-8690373,41210199],[-8690472,41214708],[-8691003,41218830],[-8692425,41222457],[-8694450,41225940],[-8695197,41229603],[-8695503,41233419],[-8695881,41237460],[-8694675,41241177],[-8694306,41244723],[-8695737,41248728],[-8698698,41252292],[-8701137,41255874],[-8701659,41260095],[-8701452,41264280],[-8701911,41268114],[-8701785,41272209],[-8699967,41276448],[-8698995,41280984],[-8701101,41285259],[-8703783,41289075],[-8706186,41292936],[-8705619,41297139],[-8702352,41299938],[-8699643,41301630],[-8699058,41300847],[-8700813,41302629],[-8702073,41304573],[-8702748,41305590],[-8703792,41307183],[-8704647,41308488],[-8705349,41309730],[-8706069,41310621],[-8707527,41312817],[-8709021,41315058],[-8709939,41316408],[-8710560,41316255],[-8712072,41315265],[-8713782,41314608],[-8715384,41314536],[-8717760,41313987],[-8719686,41313519],[-8720586,41314302],[-8721882,41315850],[-8722521,41317398],[-8723259,41318415],[-8723574,41320224],[-8724492,41322114],[-8725590,41324409],[-8727156,41326578],[-8728263,41328657],[-8729766,41330565]],
73
+ [[-8585595,41148531],[-8585676,41148666],[-8585703,41148846],[-8585820,41148963],[-8585955,41148972],[-8587026,41149053],[-8589357,41149683],[-8591895,41150385],[-8593443,41150754],[-8593416,41150745],[-8593407,41150772]],
74
+ [[-8660421,41172516],[-8660421,41172516],[-8660286,41172282],[-8660142,41172084],[-8660124,41172075],[-8660313,41172426],[-8660502,41173623],[-8660709,41175207],[-8660592,41175621],[-8659458,41176197],[-8657766,41176224],[-8656704,41175990],[-8655606,41176251],[-8654814,41175855],[-8653761,41174991],[-8653293,41174991],[-8652078,41174991],[-8651943,41174928],[-8651763,41174802],[-8651673,41174739],[-8650665,41173965],[-8649792,41173254],[-8648298,41172066],[-8647209,41171166],[-8645967,41170167],[-8644446,41168925],[-8643474,41167044],[-8641512,41166144],[-8640405,41168178],[-8639019,41169330],[-8637426,41170356],[-8634555,41171364],[-8631603,41172003],[-8628066,41172750],[-8624313,41173182],[-8620155,41173587],[-8616078,41174028],[-8612559,41174451],[-8608986,41173812],[-8607447,41172867],[-8606421,41172165],[-8605197,41171679],[-8604450,41171526],[-8603334,41171409],[-8601336,41171193],[-8599401,41171211],[-8598852,41171301],[-8597880,41171490],[-8595864,41171796],[-8594973,41171715],[-8594127,41171337],[-8592930,41170509],[-8590878,41169195],[-8588565,41167845],[-8585541,41166549],[-8582805,41165370],[-8582193,41163471],[-8581752,41163210],[-8581644,41163210],[-8581518,41163210],[-8581392,41163237],[-8580888,41163588],[-8580654,41163903],[-8579943,41164020],[-8578791,41164749],[-8577396,41165667],[-8577072,41166198],[-8576955,41166396],[-8576946,41166405],[-8576946,41166405],[-8576937,41166414],[-8576784,41166621],[-8576019,41167179],[-8574714,41167836],[-8573526,41168754],[-8572113,41169375],[-8570700,41169924],[-8570601,41169717]],
75
+ [[-8654733,41173542],[-8654724,41173569],[-8654760,41173560],[-8654814,41173506],[-8655336,41172849],[-8655444,41172768],[-8655318,41172750],[-8655210,41172750],[-8655201,41172759],[-8655192,41172759],[-8655192,41172777],[-8654958,41173119],[-8654202,41174019],[-8653455,41174856],[-8652996,41175009],[-8652672,41174937],[-8652438,41174919],[-8652357,41174928],[-8652078,41174982],[-8651997,41174982],[-8650827,41174118],[-8648748,41172480],[-8646507,41170662],[-8644032,41168610],[-8641818,41166810],[-8640135,41165379],[-8640018,41165154],[-8640000,41165028],[-8639973,41164911],[-8639703,41164677],[-8639559,41164641],[-8639361,41164632],[-8639235,41164632],[-8639199,41164632],[-8639127,41164623],[-8637849,41164551],[-8636985,41164452],[-8636985,41164443],[-8636994,41164434],[-8636409,41164281],[-8634672,41163705],[-8633691,41163345],[-8633025,41162535],[-8632233,41161554],[-8631666,41160879],[-8630766,41159754],[-8630514,41159457],[-8630325,41159277],[-8629866,41158656],[-8630235,41158116],[-8630037,41157477],[-8629695,41157153],[-8628714,41157027],[-8628453,41157126],[-8628174,41157378],[-8627418,41157567],[-8627094,41157513],[-8627049,41157522],[-8626932,41157477],[-8626221,41157423],[-8625096,41157261],[-8625051,41157243],[-8625015,41157234],[-8625825,41157414],[-8627193,41157684],[-8627247,41157630],[-8627229,41157585],[-8627238,41157648]],
76
+ [[-8626788,41173119],[-8626158,41171427],[-8626104,41171247],[-8626077,41170977],[-8625879,41170410],[-8626032,41170428],[-8625942,41170104],[-8625753,41169645],[-8625636,41169636],[-8625618,41169492],[-8625627,41169420]],
77
+ [[-8612361,41145858],[-8611866,41146002]],
78
+ [[-8660421,41150007],[-8660349,41150034],[-8660349,41150043],[-8660340,41150043],[-8660331,41150043],[-8660169,41150052],[-8660268,41150043],[-8660313,41150070],[-8660340,41150070],[-8660655,41150142],[-8659908,41150547],[-8657802,41150961],[-8654661,41152149],[-8652303,41152194],[-8650791,41153283],[-8650197,41153769],[-8648865,41154138],[-8648253,41154120],[-8646867,41154228],[-8646093,41154273],[-8646003,41154264],[-8647065,41154237],[-8647281,41154129],[-8647254,41154120],[-8647236,41154165],[-8647200,41154192],[-8647209,41154192],[-8647218,41154201],[-8647245,41154237],[-8647299,41154228],[-8647236,41154282],[-8647533,41154219],[-8648055,41154390]],
79
+ [[-8609238,41180256],[-8609391,41183622],[-8609328,41184504],[-8606358,41184396],[-8604612,41184000],[-8604540,41184009],[-8604369,41184000],[-8602686,41183451],[-8600346,41182866],[-8598780,41182425],[-8597700,41182146],[-8596809,41184063]],
80
+ [[-8656344,41175477],[-8656317,41175486],[-8656299,41175468],[-8656299,41175450],[-8656281,41175450],[-8656317,41175459],[-8656335,41175441],[-8656290,41175468],[-8656299,41175477],[-8656254,41175459],[-8656200,41175324],[-8655633,41174451],[-8655048,41173362],[-8654976,41173128],[-8654958,41173137],[-8654931,41173137],[-8654949,41173137],[-8654967,41173056],[-8656074,41171994],[-8656524,41171418],[-8656578,41171373],[-8657172,41170608],[-8658153,41169420],[-8659116,41168241],[-8660205,41166945],[-8660916,41166081],[-8661573,41165307],[-8662221,41164542],[-8662725,41163939],[-8662716,41163903],[-8662707,41163903],[-8662572,41163822],[-8662491,41163795],[-8662464,41163813],[-8662509,41163786],[-8663238,41163165],[-8663733,41162310],[-8664885,41161752],[-8665704,41161581],[-8667072,41161455],[-8667954,41161131],[-8669826,41161113],[-8671230,41161545],[-8672499,41161014],[-8673354,41160744],[-8674722,41160042],[-8677098,41159070],[-8678799,41158485],[-8680275,41158134],[-8680977,41158971],[-8680986,41158989],[-8681013,41158989],[-8681022,41158980],[-8681022,41158989],[-8681022,41158998],[-8681022,41159079],[-8681472,41160348],[-8679852,41160960],[-8678160,41161752],[-8676756,41162535],[-8675730,41162931],[-8674884,41162886],[-8673489,41162544],[-8672346,41162238],[-8670897,41161509],[-8669115,41161068],[-8667522,41161311],[-8666253,41161554],[-8664417,41161986],[-8663814,41162301],[-8663742,41162319],[-8663247,41162832],[-8662626,41163993],[-8661474,41165388],[-8660025,41167161],[-8658630,41168853],[-8657892,41169690],[-8657865,41169645],[-8657415,41170212],[-8656389,41171463]],
81
+ [[-8609949,41157558],[-8609940,41157540],[-8609940,41157540],[-8610003,41157171],[-8609940,41155101],[-8609940,41153868],[-8609859,41153832],[-8609805,41153841],[-8609913,41153571],[-8611290,41153625],[-8611875,41154084],[-8612307,41155110],[-8612982,41155137],[-8613144,41155155],[-8614395,41155407],[-8616447,41155929],[-8618301,41156190],[-8618868,41156352],[-8620236,41156532],[-8620425,41156532],[-8620434,41156541],[-8620461,41156550],[-8621001,41156640],[-8622522,41156982],[-8624286,41157234],[-8624619,41157252],[-8625456,41157378],[-8625510,41157396],[-8625510,41157414],[-8625528,41157423],[-8625510,41157423],[-8625510,41157414],[-8625519,41157405]],
82
+ [[-8640549,41161410],[-8640738,41161509],[-8640567,41161680],[-8639766,41162094],[-8639019,41162724],[-8638902,41162823],[-8638686,41162985],[-8637768,41163543],[-8637111,41163957],[-8637093,41163966],[-8637093,41163975],[-8636598,41164389],[-8638407,41164767],[-8638659,41164794],[-8638857,41164911],[-8639325,41165388],[-8640414,41165955],[-8640477,41167476],[-8639658,41168835]],
83
+ [[-8623656,41157882],[-8623701,41157873],[-8623764,41157873],[-8623827,41157225],[-8623791,41157216],[-8623800,41157126],[-8625204,41157297],[-8627292,41157621],[-8627616,41157702],[-8627607,41157711],[-8627625,41157729],[-8627922,41157918],[-8627922,41157954],[-8628165,41158422],[-8629020,41158836],[-8629290,41158899],[-8630874,41158233],[-8632935,41158539],[-8633664,41158674],[-8634762,41158845],[-8635266,41158917],[-8635311,41158989],[-8635320,41158998],[-8635581,41159016],[-8635617,41159016],[-8636022,41159079],[-8637219,41159259],[-8637669,41159340],[-8637669,41159358],[-8637669,41159376],[-8637678,41159367],[-8637678,41159358],[-8637660,41159340],[-8637849,41159376],[-8638083,41159412],[-8638569,41159484],[-8639784,41159673],[-8641296,41159997],[-8643537,41160384],[-8643627,41160384],[-8643582,41160357],[-8643501,41160312],[-8645508,41160726],[-8646363,41160843],[-8646345,41160825],[-8646354,41160825],[-8648586,41161185],[-8650584,41161545],[-8652528,41161815]],
84
+ [[-8564283,41158665],[-8563716,41158566],[-8562753,41158188],[-8562258,41157540],[-8561763,41155839],[-8562591,41155281],[-8565228,41154939],[-8567820,41154786],[-8568945,41155785],[-8571447,41156181],[-8571996,41157999],[-8571330,41159439],[-8570070,41160654],[-8568558,41161842],[-8566857,41161995],[-8567307,41161707],[-8567271,41161698],[-8567433,41161680],[-8567406,41161653],[-8567460,41161644],[-8567469,41161653],[-8567721,41161482],[-8568216,41160978],[-8568666,41160393],[-8569314,41160681],[-8569467,41161167],[-8570385,41160303],[-8571924,41159538],[-8574030,41161077],[-8575371,41163066],[-8576388,41164686],[-8577090,41165514],[-8577666,41165811],[-8577090,41165766],[-8576811,41166540],[-8575317,41167440],[-8573670,41168619],[-8571312,41168763],[-8570484,41168700],[-8570187,41168673],[-8569539,41169024],[-8569557,41169186],[-8569683,41169366],[-8569818,41169492],[-8569800,41170167],[-8568315,41170779],[-8568063,41170887],[-8567811,41170950],[-8567793,41170950],[-8567793,41170932],[-8567388,41171148],[-8567037,41172003],[-8567118,41172255],[-8567145,41172318],[-8567307,41172696],[-8567307,41172741],[-8567325,41172732],[-8567649,41173380],[-8567586,41174244],[-8567505,41174298],[-8567415,41174370],[-8567334,41174478],[-8567136,41174667],[-8566749,41175009],[-8566506,41175216],[-8566029,41175657],[-8566083,41176080],[-8566344,41176278],[-8566461,41176359],[-8567316,41176989],[-8567793,41177349],[-8567793,41177340],[-8567946,41177457],[-8568036,41177538],[-8568270,41177709],[-8568288,41177736],[-8568270,41177736],[-8568261,41177736],[-8568414,41177835],[-8568414,41177844],[-8568558,41177934],[-8568783,41178078],[-8568990,41178222],[-8569575,41178636],[-8569872,41178852],[-8570259,41179239],[-8570295,41179329],[-8570457,41179671],[-8570808,41179797],[-8571321,41180049],[-8572689,41180139],[-8573175,41180130],[-8574174,41180166],[-8575209,41180589],[-8575605,41180796],[-8576415,41181048],[-8577774,41180913]],
85
+ [[-8641647,41159835],[-8640684,41159538],[-8641215,41157846],[-8641746,41156172],[-8642223,41154741],[-8642385,41154237],[-8641386,41153679],[-8639190,41153166],[-8636724,41152608],[-8634636,41152410],[-8634114,41152545],[-8633412,41152608],[-8633286,41152644],[-8632611,41152662],[-8632566,41152644],[-8632557,41152644],[-8632566,41152644],[-8632584,41152653],[-8632530,41152653],[-8632053,41152653],[-8630460,41152590],[-8627094,41152410],[-8626437,41152527],[-8625924,41151681],[-8625573,41149314]],
86
+ [[-8615574,41176404],[-8615637,41176431],[-8615637,41176449],[-8616240,41176305],[-8616510,41175531],[-8616285,41175432],[-8614269,41175684],[-8613738,41175207],[-8613486,41174307],[-8611641,41174235],[-8608824,41173686],[-8605269,41171706],[-8601183,41171193],[-8597574,41171571],[-8596206,41171814],[-8595009,41171769],[-8593992,41171301],[-8592192,41170104],[-8589681,41168529],[-8586738,41166873],[-8583615,41166216],[-8581770,41163912],[-8581437,41161509],[-8582625,41158827],[-8583309,41156280],[-8582589,41154012],[-8582544,41152590],[-8582310,41151681],[-8582166,41151519],[-8582076,41151492],[-8582130,41151519],[-8582175,41151537],[-8582238,41151411],[-8583210,41150898],[-8583813,41150025],[-8584155,41148954],[-8584209,41148828],[-8584209,41148819],[-8584209,41148819],[-8584209,41148819],[-8584200,41148855],[-8584191,41148918]],
87
+ [[-8612784,41147433],[-8613639,41146101],[-8613504,41146002],[-8612712,41146065],[-8612577,41146020],[-8610984,41147793],[-8611047,41147820],[-8611173,41147937],[-8610669,41148783],[-8610282,41150322],[-8610210,41150511],[-8609688,41151699],[-8609922,41153796],[-8609283,41154930],[-8609175,41156604],[-8608275,41158989],[-8607861,41160114],[-8606223,41164650],[-8606313,41164920],[-8606385,41165775],[-8606439,41167827],[-8605881,41169627],[-8605053,41170707],[-8604162,41172129],[-8606880,41172777],[-8609022,41173956],[-8611596,41174505],[-8614584,41174433],[-8618697,41173902],[-8621703,41173911],[-8622387,41176512],[-8622252,41180283],[-8623197,41184153],[-8625159,41187060],[-8627292,41190255],[-8628435,41194053],[-8627445,41198310],[-8627382,41202729],[-8627247,41207373],[-8626986,41214240],[-8626905,41217471],[-8626779,41220540],[-8626725,41222952]],
88
+ [[-8585685,41148648],[-8585721,41148954],[-8586108,41148990],[-8586396,41148990],[-8587170,41149125],[-8588403,41149449],[-8590851,41150133],[-8592156,41150475],[-8592102,41150457],[-8592102,41150457],[-8592129,41150484],[-8592426,41150547],[-8592453,41150538],[-8592462,41150547],[-8592480,41150538],[-8592480,41150538],[-8592570,41150574],[-8592894,41150664],[-8593083,41150475],[-8593155,41150466],[-8593128,41150493],[-8593119,41150511],[-8593956,41150889],[-8594109,41150943],[-8594640,41152230],[-8595063,41153634],[-8595207,41153985],[-8595279,41155074],[-8595378,41155164],[-8594964,41155758],[-8594694,41156082],[-8593983,41157234],[-8592777,41159376],[-8591742,41161176],[-8590320,41163003],[-8589114,41164488],[-8588853,41165118]],
89
+ [[-8627661,41175342],[-8627625,41175243],[-8627148,41174001],[-8625996,41170977],[-8625861,41170374],[-8625888,41170338],[-8625816,41170023],[-8627040,41169618],[-8626680,41168070],[-8626428,41167170],[-8626464,41167206],[-8626464,41167215],[-8626455,41167206],[-8626419,41167170],[-8629137,41165721],[-8630613,41165100],[-8630982,41164983],[-8631261,41164758],[-8633610,41163714],[-8633502,41163237],[-8632935,41162445],[-8632863,41162355],[-8632719,41162310],[-8631783,41160069],[-8630217,41158674],[-8630370,41157810],[-8630181,41157198],[-8630109,41157144],[-8629740,41156955],[-8630289,41154966],[-8630613,41152581],[-8630253,41151591],[-8631036,41149008],[-8632701,41147478],[-8631423,41145930]],
90
+ [[-8665452,41173416],[-8665488,41173272],[-8665758,41172822],[-8666253,41172003],[-8665686,41171589],[-8662185,41174442],[-8661258,41175234],[-8660556,41175621],[-8658783,41176260],[-8657145,41176224],[-8656452,41176152],[-8655165,41176233],[-8653464,41174955],[-8652240,41175018],[-8651880,41174955],[-8650422,41173794],[-8648658,41172336],[-8646750,41170797],[-8644365,41168889],[-8642214,41167233],[-8641080,41166315],[-8640612,41165946],[-8640612,41165937],[-8640216,41165604],[-8638821,41164695],[-8638740,41164677],[-8638731,41164668],[-8638065,41164605],[-8636391,41164326],[-8634987,41163822],[-8634393,41163615],[-8634339,41163597],[-8633619,41163309],[-8633250,41162850],[-8631657,41160852],[-8630964,41159880],[-8630559,41159466],[-8630271,41159142],[-8630028,41158512],[-8630316,41157810],[-8630181,41157450],[-8629425,41157045]],
91
+ [[-8606961,41145093],[-8606673,41145732],[-8606628,41145732],[-8606556,41145714],[-8607231,41146695],[-8608536,41147424],[-8609049,41147550],[-8609319,41147577],[-8609445,41147658],[-8610300,41147910],[-8610471,41147946],[-8610606,41148513],[-8610480,41148855],[-8610444,41148945],[-8610165,41149818],[-8610147,41150556],[-8609580,41151348],[-8610021,41152428],[-8609913,41154003],[-8609373,41155839],[-8608644,41159304],[-8607726,41160771],[-8606376,41163912],[-8606484,41164164],[-8606394,41165631],[-8606475,41167566],[-8606124,41169348],[-8604558,41170887],[-8600958,41171094],[-8597808,41171427],[-8596098,41170959],[-8594955,41172543],[-8593884,41175000],[-8593200,41177817],[-8592903,41180931],[-8593515,41183982],[-8594478,41186943],[-8594253,41189904],[-8592102,41192343],[-8590275,41194980],[-8588151,41197536],[-8586495,41199372],[-8587818,41198427],[-8591211,41197797],[-8594451,41196942],[-8598222,41198103],[-8601921,41199120],[-8605782,41199993],[-8609526,41200812],[-8613603,41201415],[-8617419,41202585],[-8621019,41204151],[-8624457,41205645],[-8627868,41206968],[-8631783,41207310],[-8635698,41206428],[-8639496,41205303],[-8643402,41204223],[-8647443,41203332],[-8650971,41203989],[-8651601,41206725],[-8651826,41209758],[-8653140,41212791],[-8654850,41215608],[-8657289,41218155],[-8659674,41220657],[-8661897,41222988],[-8664084,41225328],[-8666397,41227434],[-8668053,41229666]],
92
+ [[-8613198,41154453],[-8613216,41154390],[-8613225,41154390],[-8613243,41154120],[-8611992,41153850],[-8611848,41154831],[-8613333,41155290],[-8616087,41155650],[-8617266,41155821],[-8617797,41156001],[-8619219,41156271],[-8620209,41156379],[-8620470,41156451],[-8620524,41156460],[-8620578,41156433],[-8621190,41156370],[-8622558,41156694],[-8624952,41157180],[-8626905,41157540],[-8627616,41157693],[-8627616,41157693],[-8627589,41157675],[-8627805,41157864],[-8627940,41158242],[-8629119,41158809],[-8629506,41158827],[-8629587,41158809],[-8631621,41158386],[-8633709,41158674],[-8635401,41158935],[-8635815,41159034],[-8636454,41159178],[-8637093,41159268],[-8637264,41159304],[-8638290,41159466],[-8639352,41159628],[-8640981,41159952],[-8643096,41160312],[-8646318,41160843],[-8646606,41160879],[-8649333,41161329],[-8652114,41161779]],
93
+ [[-8636283,41170968],[-8640063,41168673],[-8643870,41166180],[-8647929,41164083],[-8649117,41159754],[-8650143,41157234],[-8651052,41157855],[-8652627,41156253],[-8656083,41154597],[-8653176,41154570],[-8653734,41153769],[-8653680,41153715],[-8653734,41153733],[-8653941,41153760],[-8653860,41153796],[-8653734,41153868],[-8653707,41153868],[-8653698,41153868],[-8654958,41152536],[-8650854,41153049],[-8643987,41154507],[-8643807,41154570],[-8643789,41154561],[-8643780,41154570],[-8643771,41154561],[-8643798,41154552],[-8643816,41154552],[-8643807,41154543],[-8643807,41154525]],
94
+ [[-8621028,41150016],[-8617590,41154921],[-8606394,41153355]],
95
+ [[-8609589,41151303],[-8609625,41151582],[-8610021,41151717],[-8610615,41151051],[-8610831,41150700],[-8610876,41150529],[-8611200,41149620],[-8611209,41148198],[-8611236,41147919],[-8611875,41147973],[-8621478,41147604],[-8622216,41147640],[-8622387,41147721],[-8622387,41147757],[-8623260,41148018],[-8625465,41148918],[-8625933,41150556],[-8626176,41152248],[-8627904,41152410],[-8629389,41152563],[-8629866,41152635],[-8630010,41152662],[-8630244,41152743],[-8631216,41152824],[-8631207,41152716],[-8631234,41152680],[-8632458,41152734],[-8633943,41152545],[-8635392,41152464],[-8635446,41152464],[-8636004,41152518],[-8636616,41152725],[-8636760,41152743],[-8637354,41152869],[-8639109,41153193],[-8640738,41153571],[-8642736,41154174],[-8644779,41154444],[-8646129,41154273],[-8647605,41154255],[-8647605,41154210],[-8647983,41154210],[-8649405,41154291],[-8650458,41153616],[-8652114,41152140],[-8653311,41152059],[-8653743,41152140],[-8653815,41152167],[-8654463,41152212],[-8654616,41152194],[-8655156,41152077],[-8656182,41151654],[-8656452,41151537],[-8656452,41151519],[-8656470,41151510],[-8656821,41151303],[-8658297,41151177],[-8660412,41151339],[-8661312,41150664],[-8661456,41150619],[-8662887,41150610],[-8664840,41150835],[-8666568,41151240],[-8667036,41151375],[-8668512,41151996],[-8670159,41152905],[-8670618,41153301],[-8670609,41153310],[-8670618,41153310],[-8670717,41153391],[-8671977,41154444],[-8672022,41155200],[-8670231,41156073],[-8667522,41157135],[-8665209,41158026],[-8663787,41158575],[-8661321,41159556],[-8658567,41160609],[-8657235,41161293],[-8657235,41161302],[-8657037,41161374],[-8657001,41161392],[-8656821,41161482],[-8656794,41161473],[-8656452,41161455],[-8656524,41161518],[-8656605,41161599],[-8656119,41161365],[-8655975,41161329],[-8656011,41161212],[-8656002,41161149],[-8656065,41161230],[-8656020,41161365],[-8656128,41161653],[-8655615,41162049],[-8654526,41162085],[-8654364,41162076],[-8654211,41162058],[-8652816,41161833],[-8651475,41161599],[-8650935,41161527],[-8650890,41161554],[-8650908,41161545],[-8650611,41161527],[-8649261,41161257],[-8647065,41160906],[-8645427,41160627],[-8645427,41160618],[-8645427,41160618],[-8644662,41160474],[-8642970,41160294],[-8640855,41160312],[-8640873,41158791],[-8639811,41158629],[-8639712,41158719],[-8639154,41158566],[-8638947,41158449],[-8638812,41158449],[-8638587,41158449],[-8638236,41158422],[-8638065,41158431],[-8637786,41158359],[-8637687,41158323],[-8637408,41158188],[-8637318,41158206],[-8637327,41158188],[-8637255,41158206],[-8636877,41158071],[-8636877,41158062],[-8636823,41158053],[-8636805,41158080],[-8636706,41158098],[-8636490,41157990],[-8636328,41157945],[-8635608,41157855],[-8633592,41157513],[-8632386,41157711],[-8631288,41156532],[-8630721,41155965],[-8630568,41155236],[-8630613,41154291],[-8630307,41153661],[-8630172,41153607],[-8629803,41153553],[-8629047,41153571],[-8628246,41154561],[-8627391,41154687],[-8627085,41154696],[-8626635,41155173],[-8624808,41155614],[-8622729,41155947],[-8620605,41155578],[-8618634,41155200],[-8618076,41155119],[-8617716,41155038],[-8616726,41154876],[-8614494,41154579],[-8613468,41154291],[-8613279,41154012],[-8612208,41153841],[-8611929,41155470],[-8611542,41157018],[-8610300,41157261],[-8610327,41157306],[-8610282,41157270],[-8609769,41157432],[-8609220,41157576],[-8608518,41158881],[-8607969,41159844],[-8607411,41161104],[-8606151,41164452],[-8606331,41165757],[-8606439,41167332],[-8606358,41169123],[-8605431,41170284],[-8605359,41170329],[-8605359,41170338],[-8604648,41171238],[-8604999,41172804],[-8607564,41173173],[-8610201,41174298],[-8614044,41174514],[-8618400,41173902],[-8622693,41173452],[-8626131,41173110],[-8629740,41172552],[-8632188,41172048],[-8634726,41171481],[-8637156,41170671],[-8638695,41169690],[-8640063,41168853],[-8642277,41168277],[-8643339,41168259],[-8644563,41169231],[-8647074,41171265],[-8650224,41173794],[-8653212,41176233],[-8656731,41179068],[-8659359,41181255],[-8661915,41183325],[-8664192,41185170],[-8666406,41186970],[-8669232,41188698],[-8668602,41189418],[-8670024,41187267],[-8673687,41186457],[-8676162,41184297],[-8676873,41183919],[-8677656,41184630],[-8678304,41185746],[-8678358,41185935],[-8678619,41186079],[-8679807,41185602],[-8680518,41186160],[-8680626,41186322],[-8680635,41186322],[-8680635,41186313],[-8680635,41186304],[-8680635,41186304],[-8680626,41186304],[-8680626,41186313],[-8680626,41186331],[-8680626,41186340],[-8680626,41186340],[-8680635,41186349]],
96
+ [[-8619345,41147586],[-8620515,41147649],[-8620812,41149044],[-8621073,41150025],[-8621154,41150232],[-8621145,41150268],[-8621145,41150340],[-8621154,41150358],[-8621127,41150250],[-8621118,41150205],[-8621082,41150133],[-8621091,41150178],[-8621136,41150439],[-8621127,41150511],[-8621109,41150628],[-8621271,41151600],[-8620812,41152896],[-8620866,41154687],[-8620398,41155551],[-8619426,41155380],[-8618688,41155281],[-8616789,41154966],[-8614440,41154471],[-8613729,41154399],[-8613261,41154048],[-8613252,41154030],[-8613198,41153787],[-8612190,41153751],[-8611992,41154480],[-8611929,41155776],[-8611767,41156829],[-8610246,41157261],[-8609148,41157432],[-8608365,41159250],[-8608014,41160069],[-8607600,41160888],[-8606412,41164317],[-8606304,41164695],[-8606385,41167251],[-8605800,41169690],[-8603766,41171328],[-8600535,41171094],[-8597160,41171454],[-8595531,41171535],[-8594163,41174334],[-8593200,41178015],[-8593092,41182398],[-8594532,41186925],[-8593227,41191128],[-8590302,41194980],[-8587575,41198454],[-8586324,41198625],[-8590329,41198130],[-8593866,41196870],[-8598105,41198040],[-8603091,41199273],[-8608734,41200659],[-8614818,41201667],[-8620497,41203854],[-8626014,41206248],[-8632008,41207247],[-8638209,41205663],[-8643780,41204133],[-8648082,41203242],[-8651601,41205087],[-8651727,41209389],[-8653734,41213979],[-8657199,41218011],[-8660979,41221971],[-8664732,41225958],[-8668053,41229054],[-8667045,41232132],[-8667216,41234832],[-8667981,41237379],[-8669574,41238945],[-8670366,41238063],[-8670168,41236875],[-8670105,41236857],[-8670105,41236866],[-8670060,41236875],[-8670114,41236884],[-8670132,41236893],[-8670114,41236875],[-8670087,41236848],[-8670069,41236830],[-8670069,41236803],[-8669799,41235822],[-8668710,41235390],[-8669493,41237685],[-8668134,41237217],[-8666919,41234121],[-8667909,41230521],[-8668953,41226390],[-8667297,41223699],[-8662392,41223078],[-8659260,41219946],[-8655858,41216373],[-8653248,41212593],[-8651718,41208453],[-8651673,41204556],[-8652888,41202486],[-8657550,41201100],[-8661150,41198463],[-8665443,41195169],[-8667009,41191047],[-8670069,41189382],[-8669052,41187024],[-8665569,41186088],[-8664480,41185242],[-8662734,41183829],[-8660448,41181948],[-8657829,41179815],[-8654670,41177259],[-8651313,41174541],[-8648964,41172651],[-8646300,41170446],[-8643186,41167917],[-8640432,41165676],[-8639712,41164713],[-8639280,41164632],[-8639532,41165424],[-8639442,41166009],[-8638434,41166486],[-8637327,41168178],[-8636490,41168601],[-8636463,41168583],[-8636193,41168709],[-8634636,41167161],[-8632593,41166072],[-8631738,41164596],[-8633250,41163615],[-8633268,41162949],[-8632368,41161824],[-8631198,41160375],[-8630892,41159862],[-8630388,41159322],[-8630316,41159304],[-8630289,41159322]],
97
+ [[-8656299,41152203],[-8655273,41152446],[-8654904,41152392],[-8654688,41152095],[-8652951,41151870],[-8647236,41154147],[-8642817,41154183],[-8640918,41153661],[-8635617,41152419],[-8632935,41152662],[-8632899,41152653],[-8632629,41152671],[-8628327,41152401],[-8626671,41152104],[-8626581,41152086],[-8621802,41152797],[-8609229,41153607]],
98
+ [[-8597124,41182200],[-8596917,41183172],[-8596917,41184405],[-8596890,41185359],[-8596863,41186232],[-8596863,41187141],[-8597331,41187645],[-8597763,41187744],[-8597889,41187501],[-8597952,41186151],[-8596962,41186088],[-8596908,41185116],[-8598366,41184864],[-8599104,41183775],[-8600697,41184567],[-8603064,41186187],[-8603721,41185647],[-8604657,41184513],[-8604972,41184279],[-8607069,41184747],[-8609229,41184666],[-8609211,41184666],[-8609517,41184594],[-8611065,41184126],[-8612478,41183604],[-8612559,41183514],[-8612559,41183523],[-8612559,41183532],[-8612784,41183451],[-8615331,41183091],[-8618715,41182164],[-8620200,41181327],[-8620182,41181354],[-8620830,41181057],[-8623674,41180211],[-8627067,41179806],[-8628057,41179734],[-8628039,41179761],[-8628597,41179635],[-8630757,41179392],[-8633196,41179644],[-8635797,41181093],[-8638506,41182587],[-8641179,41184072],[-8643213,41184117],[-8645391,41183190],[-8645760,41182974],[-8646381,41182668],[-8648037,41181723],[-8648487,41181471],[-8648469,41181471],[-8649522,41180868],[-8651637,41179653],[-8652204,41179347],[-8652204,41179347],[-8652195,41179347],[-8652213,41179356],[-8653950,41178564],[-8654607,41178348],[-8655075,41178285],[-8656578,41177727],[-8659530,41177214],[-8662167,41177250],[-8662599,41177655],[-8663157,41177853],[-8663418,41177610],[-8663427,41177619]],
99
+ [[-8600517,41157081],[-8600499,41157099],[-8600175,41157702],[-8601102,41157927],[-8601849,41157432],[-8602119,41156892],[-8602191,41156604],[-8602542,41155902],[-8602659,41155452],[-8602893,41154876],[-8602920,41154885],[-8602929,41154894],[-8603082,41154633],[-8604342,41154786],[-8604720,41154705],[-8604936,41153526],[-8606016,41153535],[-8607807,41153670],[-8609922,41152878],[-8610057,41151987],[-8610741,41150466],[-8611146,41148090]],
100
+ [[-8623053,41149530],[-8622873,41148972],[-8622891,41148855],[-8622927,41148774],[-8621739,41147586],[-8620299,41147064],[-8620011,41146155],[-8617770,41146308],[-8615835,41145300],[-8613081,41145894],[-8613009,41145975],[-8610885,41145993],[-8610804,41145291],[-8610462,41143194],[-8608176,41143140],[-8605566,41142798],[-8605449,41142996],[-8605080,41143338],[-8604756,41143986],[-8605647,41144148]]
101
+ ]
bench/dataset-card.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: Porto Geofence Membership Changes
3
+ license: cc-by-4.0
4
+ size_categories:
5
+ - 1K<n<10K
6
+ tags:
7
+ - benchmark
8
+ - geospatial
9
+ - geofencing
10
+ - trajectories
11
+ - multi-agent
12
+ configs:
13
+ - config_name: porto-256
14
+ default: true
15
+ data_files:
16
+ - split: test
17
+ path: moves.jsonl.gz
18
+ ---
19
+
20
+ # Porto Geofence Membership Changes
21
+
22
+ Given two consecutive taxi positions, which subscribed regions gained or lost the taxi? This correctness fixture pairs {{moves}} historical GPS updates from {{trips}} Porto trip prefixes with {{zones}} reproducible synthetic rectangles. You can test a geofencing engine, a spatial subscription router, or your own implementation against exact per-update labels.
23
+
24
+ **{{changed}}** updates change at least one membership. **{{unchanged}}** change none, including **{{stationary}}** stationary updates. Across the full replay there are **{{entered}}** entries and **{{exited}}** exits. The dataset fits in memory and has a single test split.
25
+
26
+ | File | Contents |
27
+ | --- | --- |
28
+ | `moves.jsonl.gz` | Gzip-compressed UTF-8 JSON Lines, one movement per line |
29
+ | `zones.json` | Array of 256 rectangles in zone-ID order, each given as `[xmin, ymin, xmax, ymax]` |
30
+
31
+ ## Load and score a geofencing engine
32
+
33
+ ```python
34
+ from datasets import load_dataset
35
+ from huggingface_hub import hf_hub_download
36
+ import json
37
+
38
+ repo = "pgg-engineering/edgechime-bench"
39
+ moves = load_dataset(repo, "porto-256", split="test")
40
+ with open(hf_hub_download(repo, "zones.json", repo_type="dataset")) as file:
41
+ zones = json.load(file)
42
+
43
+ def predict(row):
44
+ def contains(box, x, y):
45
+ x_lo, y_lo, x_hi, y_hi = box
46
+ return x_lo <= x < x_hi and y_lo <= y < y_hi
47
+
48
+ old = {i for i, box in enumerate(zones) if contains(box, row["x0"], row["y0"])}
49
+ new = {i for i, box in enumerate(zones) if contains(box, row["x1"], row["y1"])}
50
+ return new - old, old - new
51
+
52
+ def exact_match(row):
53
+ entered, exited = predict(row)
54
+ return sorted(entered) == row["entered"] and sorted(exited) == row["exited"]
55
+
56
+ print(sum(map(exact_match, moves)) / len(moves)) # 1.0 for this reference
57
+ ```
58
+
59
+ Replace `predict` with your engine. Return all callbacks, including repeats, when checking an event emitter. The scorer accepts any order and counts a row as correct only if both directions and their multiplicities match. For timing, build the index before replay and report build time, steady-state query time, and correctness separately. A local clone can read the split with Python's `gzip.open("moves.jsonl.gz", "rt")` and `json.loads(line)`.
60
+
61
+ ## Schema and geometry
62
+
63
+ | Field | Meaning |
64
+ | --- | --- |
65
+ | `trip`, `step` | Zero-based trip ordinal in the selected sample and move ordinal within the trip. Each trip has its own sequence. |
66
+ | `x0`, `y0`, `x1`, `y1` | Previous and current longitude/latitude as signed integer microdegrees (WGS84). Divide each by 1,000,000 for degrees. |
67
+ | `prior_count` | Number of zones containing the previous position, including memberships retained at the next position. |
68
+ | `entered`, `exited` | Ascending lists of zero-based zone IDs whose membership changed between endpoints. |
69
+
70
+ A point belongs to a zone when both coordinates meet its lower bounds and are strictly below its upper bounds. A move that passes through a zone with both endpoints outside yields no event for that zone. The ordering of rows is trip-major, then chronological within trip.
71
+
72
+ ## Provenance, generation and scope
73
+
74
+ The fixture takes the first 100 data records in file order from UCI's `Porto_taxi_data_test_partial_trajectories.csv`, retains records with `MISSING_DATA=False` and at least two positions, and rounds longitude and latitude to integer microdegrees. It retains all {{positions}} positions from the {{trips}} selected partial tracks, including repeated observations. The source describes a nominal 15-second sample cadence. Only coordinates and a new trip ordinal are published.
75
+
76
+ PGG Engineering generated overlapping subscriptions at three sizes. A 32-bit linear congruential generator starts at {{seed}}, selects observed positions uniformly with replacement, and draws independent half-widths and half-heights in integer microdegrees. For zone ID modulo three, the full ranges of possible half-extents are 250–499, 1,500–2,999, or 6,000–11,999 respectively. Every fourth box places an X edge at its sampled longitude, alternating left and right edges, to exercise boundary ties. Labels were generated by testing both endpoints against every rectangle. The exporter checks the full label stream against EdgeChime's index.
77
+
78
+ This fixture measures endpoint membership on one small nonrandom sample from one city. The rectangular zones are synthetic and depend on the sampled positions. The taxi source supplies movements only. Accuracy on this replay gives no production latency or accuracy guarantee for polygons, moving regions, or intermediate path crossings.
79
+
80
+ From the source archive, run `node bench/export-dataset.mjs ./porto-export` with Node 18+. The exporter uses the included trace. To regenerate the trace from UCI first, run `python3 bench/trace_porto.py`. SHA-256 of `zones.json` is `{{zones_sha256}}`. SHA-256 of the **decompressed** JSON Lines is `{{uncompressed_label_sha256}}`.
81
+
82
+ [Interactive Space](https://huggingface.co/spaces/pgg-engineering/edgechime) · [EdgeChime source and benchmark](https://edgechime.tancurl3.chatgpt.site/source.zip)
83
+
84
+ ## Attribution and license
85
+
86
+ Original data by Luis Moreira-Matias, Michel Ferreira, Joao Mendes-Moreira, L. L., and J. J. (2013), *Taxi Service Trajectory – Prediction Challenge, ECML PKDD 2015*, UCI Machine Learning Repository. PGG Engineering selected partial trajectories, quantized coordinates, generated zones and computed the labels. This adapted dataset is distributed under Creative Commons Attribution 4.0 International. [Original UCI record](https://doi.org/10.24432/C55W25) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
bench/export-dataset.mjs ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import { createHash } from 'node:crypto';
3
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { resolve, join } from 'node:path';
5
+ import { gzipSync } from 'node:zlib';
6
+ import { EdgeChime } from '../index.js';
7
+
8
+ const output = resolve(process.argv[2] ?? 'edgechime-hfdata');
9
+ const trace = readFileSync(new URL('./data/trace.json', import.meta.url));
10
+ const traceHash = '4197da9bf36caf10235da69b073d503d2c6404c74541e5a94942225cf8c5d134';
11
+ assert.equal(createHash('sha256').update(trace).digest('hex'), traceHash);
12
+
13
+ const trips = JSON.parse(trace);
14
+ const points = trips.flat();
15
+ const seed = 270113;
16
+ let state = seed;
17
+ function randomInt(size) {
18
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
19
+ return Math.floor(state / 4294967296 * size);
20
+ }
21
+
22
+ // Center subscriptions around a repeatable sample of positions. Every fourth
23
+ // zone anchors a lower or upper X edge at a measured longitude for tie cases.
24
+ const boxes = Array.from({ length: 256 }, (_, id) => {
25
+ const [x, y] = points[randomInt(points.length)];
26
+ const extent = [250, 1500, 6000][id % 3];
27
+ const halfWidth = extent + randomInt(extent);
28
+ const halfHeight = extent + randomInt(extent);
29
+ const centerX = x + (id % 8 === 0 ? halfWidth : id % 8 === 4 ? -halfWidth : 0);
30
+ return [centerX - halfWidth, y - halfHeight, centerX + halfWidth, y + halfHeight];
31
+ });
32
+
33
+ const rows = [];
34
+ let stationary = 0;
35
+ let changed = 0;
36
+ let nEnter = 0;
37
+ let nExit = 0;
38
+ for (const [trip, track] of trips.entries()) {
39
+ for (let step = 0; step < track.length - 1; step++) {
40
+ const [x0, y0] = track[step];
41
+ const [x1, y1] = track[step + 1];
42
+ const entered = [], exited = [];
43
+ let priorCount = 0;
44
+ for (const [id, [left, bottom, right, top]] of boxes.entries()) {
45
+ const before = left <= x0 && x0 < right && bottom <= y0 && y0 < top;
46
+ const after = left <= x1 && x1 < right && bottom <= y1 && y1 < top;
47
+ if (before) priorCount++;
48
+ if (!before && after) entered.push(id);
49
+ if (before && !after) exited.push(id);
50
+ }
51
+ rows.push({ trip, step, x0, y0, x1, y1, prior_count: priorCount, entered, exited });
52
+ if (x0 === x1 && y0 === y1) stationary++;
53
+ if (entered.length || exited.length) changed++;
54
+ nEnter += entered.length;
55
+ nExit += exited.length;
56
+ }
57
+ }
58
+
59
+ // The independent endpoint oracle above defines the labels. Check each actual
60
+ // callback below, including its direction and multiplicity, before exporting.
61
+ const engine = new EdgeChime(boxes);
62
+ for (const row of rows) {
63
+ const entered = [], exited = [];
64
+ engine.move(row.x0, row.y0, row.x1, row.y1, (id, inside) => {
65
+ (inside ? entered : exited).push(id);
66
+ });
67
+ assert.deepEqual(entered.sort((a, b) => a - b), row.entered);
68
+ assert.deepEqual(exited.sort((a, b) => a - b), row.exited);
69
+ assert.equal(engine.at(row.x0, row.y0, () => {}), row.prior_count);
70
+ }
71
+
72
+ assert.equal(rows.length, 4469);
73
+ const payload = rows.map(row => JSON.stringify(row)).join('\n') + '\n';
74
+ const compressed = gzipSync(payload, { level: 9 });
75
+ const zones = '[\n' + boxes.map(box => JSON.stringify(box)).join(',\n') + '\n]\n';
76
+ const stats = {
77
+ seed, zones: boxes.length, trips: trips.length, positions: points.length, moves: rows.length,
78
+ stationary, changed, unchanged: rows.length - changed, entered: nEnter, exited: nExit,
79
+ compressed_bytes: compressed.length,
80
+ zones_sha256: createHash('sha256').update(zones).digest('hex'),
81
+ uncompressed_label_sha256: createHash('sha256').update(payload).digest('hex'),
82
+ };
83
+ const cardTemplate = readFileSync(new URL('./dataset-card.md', import.meta.url), 'utf8');
84
+ const card = cardTemplate.replace(/\{\{(\w+)\}\}/g, (_, field) => {
85
+ assert.ok(Object.hasOwn(stats, field), 'unknown dataset card field ' + field);
86
+ return String(stats[field]);
87
+ });
88
+
89
+ mkdirSync(output, { recursive: true });
90
+ writeFileSync(join(output, 'zones.json'), zones);
91
+ writeFileSync(join(output, 'moves.jsonl.gz'), compressed);
92
+ writeFileSync(join(output, 'README.md'), card);
93
+ console.log(JSON.stringify(stats, null, 2));
bench/fleet-results.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "node": "v24.22.3",
3
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
4
+ "fences": 100000,
5
+ "agents": 10000,
6
+ "rounds": 10,
7
+ "updates": 100000,
8
+ "coordinateBytes": 160000,
9
+ "buildMs": 238.019298,
10
+ "samples": [
11
+ {
12
+ "ms": 74.57145400000002,
13
+ "edges": 139493,
14
+ "checksum": -32790721
15
+ },
16
+ {
17
+ "ms": 48.86913400000003,
18
+ "edges": 139493,
19
+ "checksum": -32790721
20
+ },
21
+ {
22
+ "ms": 47.87459100000001,
23
+ "edges": 139493,
24
+ "checksum": -32790721
25
+ },
26
+ {
27
+ "ms": 73.79684099999997,
28
+ "edges": 139493,
29
+ "checksum": -32790721
30
+ },
31
+ {
32
+ "ms": 316.13375499999995,
33
+ "edges": 139493,
34
+ "checksum": -32790721
35
+ }
36
+ ],
37
+ "medianUpdatesPerSecond": 1355071.55380811
38
+ }
bench/fleet.mjs ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { EdgeChime } from '../index.js';
2
+ import { cpus } from 'node:os';
3
+ import { performance } from 'node:perf_hooks';
4
+
5
+ // Interleaved updates to independent agents. Points and fences use a unit square.
6
+ // This measures the in-process move API. Initial memberships and NDJSON I/O are excluded.
7
+ const agents = Number(process.env.AGENTS || 10_000);
8
+ const fences = Number(process.env.FENCES || 100_000);
9
+ const rounds = Number(process.env.ROUNDS || 10);
10
+ if (![agents, fences, rounds].every(v => Number.isSafeInteger(v) && v > 0)) throw Error('expected positive integers');
11
+ let seed = 0xa7fd1b01;
12
+ function random() {
13
+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
14
+ return seed / 4294967296;
15
+ }
16
+ const rects = Array.from({length:fences}, () => {
17
+ const x = random(), y = random();
18
+ const w = 0.02 + random() * 0.28, h = 0.02 + random() * 0.28;
19
+ return [x - w/2, y - h/2, x + w/2, y + h/2];
20
+ });
21
+ const start = new Float64Array(agents * 2);
22
+ const velocity = new Float64Array(start.length);
23
+ for (let i = 0; i < start.length; i++) {
24
+ start[i] = random();
25
+ velocity[i] = (random() - 0.5) * 0.0001;
26
+ }
27
+ const buildStart = performance.now();
28
+ const index = new EdgeChime(rects);
29
+ const buildMs = performance.now() - buildStart;
30
+ const sample = () => {
31
+ const positions = start.slice();
32
+ let edges = 0, checksum = 0;
33
+ const report = (id, entered) => { edges++; checksum = (checksum + (entered ? id + 1 : -id - 1)) | 0; };
34
+ const begin = performance.now();
35
+ for (let t = 0; t < rounds; ++t) {
36
+ for (let i = 0; i < positions.length; i += 2) {
37
+ const x = positions[i], y = positions[i+1];
38
+ const nx = x + velocity[i], ny = y + velocity[i+1];
39
+ index.move(x, y, nx, ny, report);
40
+ positions[i] = nx; positions[i+1] = ny;
41
+ }
42
+ }
43
+ return { ms:performance.now() - begin, edges, checksum };
44
+ };
45
+ sample();
46
+ const samples = Array.from({length:5}, sample);
47
+ if (!samples.every(s => s.edges === samples[0].edges && s.checksum === samples[0].checksum)) {
48
+ throw Error('replay mismatch');
49
+ }
50
+ const medianMs = samples.map(s => s.ms).sort((a,b)=>a-b)[2];
51
+ console.log(JSON.stringify({
52
+ node:process.version, cpu:cpus()[0]?.model, fences, agents, rounds,
53
+ updates:agents * rounds, coordinateBytes:start.byteLength, buildMs,
54
+ samples, medianUpdatesPerSecond:agents * rounds * 1000 / medianMs
55
+ }, null, 2));
bench/grid.mjs ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Independent uniform-grid comparator. Store a rectangle ID once per grid cell
2
+ // on its perimeter. A changed endpoint membership implies a boundary on any
3
+ // connecting path, including a horizontal leg followed by a vertical leg.
4
+ const maxPostings = 16 * 1024 * 1024; // 64 MiB of 32-bit rectangle IDs
5
+
6
+ function cell(value, min, inverseSize, side) {
7
+ if (inverseSize === 0) return 0;
8
+ return Math.max(0, Math.min(side - 1, Math.floor((value - min) * inverseSize)));
9
+ }
10
+
11
+ function inside(r, i, x, y) {
12
+ return r[i] <= x && x < r[i + 2] && r[i + 1] <= y && y < r[i + 3];
13
+ }
14
+
15
+ function visitPerimeter(x0, y0, x1, y1, side, visit) {
16
+ const first = y0 * side;
17
+ const last = y1 * side;
18
+ for (let x = x0; x <= x1; x++) {
19
+ visit(first + x);
20
+ if (first !== last) visit(last + x);
21
+ }
22
+ for (let y = y0 + 1; y < y1; y++) {
23
+ const row = y * side;
24
+ visit(row + x0);
25
+ if (x0 !== x1) visit(row + x1);
26
+ }
27
+ }
28
+
29
+ export class GridBaseline {
30
+ constructor(boxes) {
31
+ const n = boxes.length;
32
+ this.rects = new Float64Array(4 * n);
33
+ let xmin = Infinity, ymin = Infinity, xmax = -Infinity, ymax = -Infinity;
34
+ for (let id = 0; id < n; id++) {
35
+ const box = boxes[id];
36
+ this.rects.set(box, id * 4);
37
+ xmin = Math.min(xmin, box[0]);
38
+ ymin = Math.min(ymin, box[1]);
39
+ xmax = Math.max(xmax, box[2]);
40
+ ymax = Math.max(ymax, box[3]);
41
+ }
42
+ this.xmin = xmin;
43
+ this.ymin = ymin;
44
+ this.scratch = [];
45
+ this.depth = 0;
46
+
47
+ // Start near one cell per box and reduce resolution when extensive
48
+ // subscriptions would replicate too many edges. Raw coordinates remain
49
+ // available for an exact scan even when a dataset exceeds the hard cap.
50
+ this.side = Math.max(1, Math.min(512, Math.ceil(Math.sqrt(2 * n))));
51
+ this.postingCount = 0;
52
+ if (!n || n > maxPostings) return;
53
+ const budget = Math.min(maxPostings, 128 * n);
54
+ const bins = new Uint16Array(n * 4);
55
+ while (true) {
56
+ const side = this.side;
57
+ const sx = side / (xmax - xmin), sy = side / (ymax - ymin);
58
+ this.sx = Number.isFinite(sx) ? sx : 0;
59
+ this.sy = Number.isFinite(sy) ? sy : 0;
60
+ let total = 0;
61
+ for (let i = 0; i < this.rects.length; i += 4) {
62
+ const x0 = bins[i] = cell(this.rects[i], xmin, this.sx, side);
63
+ const y0 = bins[i + 1] = cell(this.rects[i + 1], ymin, this.sy, side);
64
+ const x1 = bins[i + 2] = cell(this.rects[i + 2], xmin, this.sx, side);
65
+ const y1 = bins[i + 3] = cell(this.rects[i + 3], ymin, this.sy, side);
66
+ const w = x1 - x0, h = y1 - y0;
67
+ total += w && h ? 2 * (w + h) : w + h + 1;
68
+ }
69
+ if (total <= budget) {
70
+ this.postingCount = total;
71
+ break;
72
+ }
73
+ this.side = Math.max(1, Math.min(side - 1, Math.floor(side * budget / total)));
74
+ }
75
+ const side = this.side;
76
+ const offsets = this.offsets = new Uint32Array(side * side + 1);
77
+ const countCell = key => { offsets[key + 1]++; };
78
+ for (let i = 0; i < bins.length; i += 4) {
79
+ visitPerimeter(bins[i], bins[i + 1], bins[i + 2], bins[i + 3], side, countCell);
80
+ }
81
+ for (let k = 1; k < offsets.length; k++) offsets[k] += offsets[k - 1];
82
+ const positions = offsets.slice(0, -1);
83
+ const ids = this.ids = new Uint32Array(this.postingCount);
84
+ let id = 0;
85
+ const insert = key => { ids[positions[key]++] = id; };
86
+ for (; id < n; id++) {
87
+ const i = id * 4;
88
+ visitPerimeter(bins[i], bins[i + 1], bins[i + 2], bins[i + 3], side, insert);
89
+ }
90
+ }
91
+
92
+ at(x, y, emit) {
93
+ let count = 0;
94
+ const r = this.rects;
95
+ for (let i = 0; i < r.length; i += 4) {
96
+ if (inside(r, i, x, y)) { emit(i / 4); count++; }
97
+ }
98
+ return count;
99
+ }
100
+
101
+ scan(x0, y0, x1, y1, emit) {
102
+ let count = 0;
103
+ const r = this.rects;
104
+ for (let i = 0; i < r.length; i += 4) {
105
+ const after = inside(r, i, x1, y1);
106
+ if (after !== inside(r, i, x0, y0)) { emit(i / 4, after); count++; }
107
+ }
108
+ return count;
109
+ }
110
+
111
+ move(x0, y0, x1, y1, emit) {
112
+ if (x0 === x1 && y0 === y1) return 0;
113
+ const r = this.rects;
114
+ if (!this.offsets || r.length <= 64) return this.scan(x0, y0, x1, y1, emit);
115
+ const side = this.side, offsets = this.offsets, ids = this.ids;
116
+ const a = cell(x0, this.xmin, this.sx, side);
117
+ const b = cell(y0, this.ymin, this.sy, side);
118
+ const c = cell(x1, this.xmin, this.sx, side);
119
+ const d = cell(y1, this.ymin, this.sy, side);
120
+ const key = b * side + a;
121
+ let count = 0;
122
+ if (a === c && b === d) {
123
+ // Perimeter construction emits each box only once in each cell.
124
+ for (let j = offsets[key], end = offsets[key + 1]; j < end; j++) {
125
+ const id = ids[j], i = id * 4;
126
+ const after = inside(r, i, x1, y1);
127
+ if (after !== inside(r, i, x0, y0)) { emit(id, after); count++; }
128
+ }
129
+ return count;
130
+ }
131
+ const xlo = Math.min(a, c), xhi = Math.max(a, c);
132
+ const ylo = Math.min(b, d), yhi = Math.max(b, d);
133
+ const row = b * side;
134
+ // Horizontal cells occupy a contiguous posting range. Exclude the elbow
135
+ // from the vertical leg because we already visited it horizontally.
136
+ const yStart = ylo + (b === ylo ? 1 : 0);
137
+ const yEnd = yhi - (b === yhi ? 1 : 0);
138
+ const first = offsets[row + xlo], last = offsets[row + xhi + 1];
139
+ let candidates = last - first;
140
+ for (let y = yStart; y <= yEnd; y++) {
141
+ const k = y * side + c;
142
+ candidates += offsets[k + 1] - offsets[k];
143
+ }
144
+ if (candidates > r.length / 6) return this.scan(x0, y0, x1, y1, emit);
145
+
146
+ // Per-depth scratch preserves callback reentrancy without allocating the
147
+ // whole stamp array per move. Common one-cell moves need no scratch at all.
148
+ const depth = this.depth++;
149
+ try {
150
+ const scratch = this.scratch[depth] ??= { marks: new Uint32Array(r.length / 4), generation: 0 };
151
+ if (++scratch.generation > 0xffffffff) {
152
+ scratch.marks.fill(0);
153
+ scratch.generation = 1;
154
+ }
155
+ const marks = scratch.marks, stamp = scratch.generation;
156
+ function visit(start, end) {
157
+ for (let j = start; j < end; j++) {
158
+ const id = ids[j];
159
+ if (marks[id] === stamp) continue;
160
+ marks[id] = stamp;
161
+ const i = id * 4, after = inside(r, i, x1, y1);
162
+ if (after !== inside(r, i, x0, y0)) { emit(id, after); count++; }
163
+ }
164
+ }
165
+ visit(first, last);
166
+ for (let y = yStart; y <= yEnd; y++) {
167
+ const k = y * side + c;
168
+ visit(offsets[k], offsets[k + 1]);
169
+ }
170
+ return count;
171
+ } finally {
172
+ this.depth--;
173
+ }
174
+ }
175
+ }
bench/holdout-2718281.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:23:10.993Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 8192,
10
+ "steps": 8192,
11
+ "repeats": 5,
12
+ "scenario": "wide-local",
13
+ "seed": 2718281
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "wide-local",
20
+ "updates": 8192,
21
+ "agents": 16,
22
+ "events": 27052,
23
+ "meanStartMembers": 1002.1875,
24
+ "bounds": [
25
+ 0,
26
+ 0,
27
+ 1,
28
+ 1
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.15,
32
+ 0.55
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 47.353876000000014,
37
+ "runnerSetupMs": [
38
+ 0.0045070000001032895,
39
+ 0.004897000000028129,
40
+ 0.006378999999924417,
41
+ 0.002774000000044907,
42
+ 0.0027039999999942665
43
+ ],
44
+ "meanUsPerUpdateSamples": [
45
+ 0.4108824462890903,
46
+ 0.6261668701174894,
47
+ 0.6557261962892025,
48
+ 0.40891528320316506,
49
+ 0.40906335449225617
50
+ ],
51
+ "medianMeanUsPerUpdate": 0.4108824462890903,
52
+ "p95BlockMeanUsPerUpdate": 0.7811562499995262
53
+ },
54
+ "flatbush": {
55
+ "buildMs": 24.942285,
56
+ "runnerSetupMs": [
57
+ 1.1219069999999647,
58
+ 1.1784060000002228,
59
+ 3.445654000000104,
60
+ 0.6602379999999357,
61
+ 0.8785910000001422
62
+ ],
63
+ "meanUsPerUpdateSamples": [
64
+ 30.665862426757617,
65
+ 31.777878051758023,
66
+ 28.92086206054703,
67
+ 27.954571899413942,
68
+ 27.60059033203105
69
+ ],
70
+ "medianMeanUsPerUpdate": 28.92086206054703,
71
+ "p95BlockMeanUsPerUpdate": 42.14889062500049
72
+ },
73
+ "perimeterGrid": {
74
+ "buildMs": 40.271862,
75
+ "runnerSetupMs": [
76
+ 0.003806000000167842,
77
+ 0.005277999999862004,
78
+ 0.013680000000022119,
79
+ 0.00421600000026956,
80
+ 0.0036359999999149295
81
+ ],
82
+ "meanUsPerUpdateSamples": [
83
+ 1.7569990234374833,
84
+ 2.5142867431640905,
85
+ 2.4922972412109443,
86
+ 1.6145550537111641,
87
+ 1.651397338867211
88
+ ],
89
+ "medianMeanUsPerUpdate": 1.7569990234374833,
90
+ "p95BlockMeanUsPerUpdate": 2.9559062500013056,
91
+ "gridSide": 128,
92
+ "gridPostings": 957304
93
+ }
94
+ }
95
+ }
96
+ ]
97
+ }
bench/holdout-514229.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:23:08.567Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 8192,
10
+ "steps": 8192,
11
+ "repeats": 5,
12
+ "scenario": "wide-local",
13
+ "seed": 514229
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "wide-local",
20
+ "updates": 8192,
21
+ "agents": 16,
22
+ "events": 27781,
23
+ "meanStartMembers": 966.625,
24
+ "bounds": [
25
+ 0,
26
+ 0,
27
+ 1,
28
+ 1
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.15,
32
+ 0.55
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 47.953619,
37
+ "runnerSetupMs": [
38
+ 0.0030740000001969747,
39
+ 0.0019829999998819403,
40
+ 0.0015220000000226719,
41
+ 0.0023530000000846485,
42
+ 0.003014999999777501
43
+ ],
44
+ "meanUsPerUpdateSamples": [
45
+ 0.4037332763672241,
46
+ 0.4080582275391986,
47
+ 0.40895214843739147,
48
+ 0.42785437011716443,
49
+ 0.6017976074221276
50
+ ],
51
+ "medianMeanUsPerUpdate": 0.40895214843739147,
52
+ "p95BlockMeanUsPerUpdate": 0.7421874999984368
53
+ },
54
+ "flatbush": {
55
+ "buildMs": 27.731150999999983,
56
+ "runnerSetupMs": [
57
+ 1.1902760000000399,
58
+ 1.2061899999998786,
59
+ 1.975259000000051,
60
+ 0.6950899999999365,
61
+ 0.854363999999805
62
+ ],
63
+ "meanUsPerUpdateSamples": [
64
+ 24.8172939453124,
65
+ 29.97078808593756,
66
+ 27.775792602539205,
67
+ 25.785746093749868,
68
+ 31.7079802246093
69
+ ],
70
+ "medianMeanUsPerUpdate": 27.775792602539205,
71
+ "p95BlockMeanUsPerUpdate": 41.93732812499462
72
+ },
73
+ "perimeterGrid": {
74
+ "buildMs": 37.166304999999994,
75
+ "runnerSetupMs": [
76
+ 0.0026229999998577114,
77
+ 0.002312999999958265,
78
+ 0.0030249999999796273,
79
+ 0.002664000000095257,
80
+ 0.0027340000001458975
81
+ ],
82
+ "meanUsPerUpdateSamples": [
83
+ 1.6054858398439065,
84
+ 1.6075748291017045,
85
+ 1.6105333251954512,
86
+ 2.0799222412108964,
87
+ 2.050267944336104
88
+ ],
89
+ "medianMeanUsPerUpdate": 1.6105333251954512,
90
+ "p95BlockMeanUsPerUpdate": 2.609140624997508,
91
+ "gridSide": 128,
92
+ "gridPostings": 949620
93
+ }
94
+ }
95
+ }
96
+ ]
97
+ }
bench/holdout-8675309.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:23:13.434Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 8192,
10
+ "steps": 8192,
11
+ "repeats": 5,
12
+ "scenario": "wide-local",
13
+ "seed": 8675309
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "wide-local",
20
+ "updates": 8192,
21
+ "agents": 16,
22
+ "events": 28496,
23
+ "meanStartMembers": 1025.0625,
24
+ "bounds": [
25
+ 0,
26
+ 0,
27
+ 1,
28
+ 1
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.15,
32
+ 0.55
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 46.85236599999999,
37
+ "runnerSetupMs": [
38
+ 0.003885999999965861,
39
+ 0.003535000000056243,
40
+ 0.004085999999915657,
41
+ 0.0037250000000312866,
42
+ 0.001573000000007596
43
+ ],
44
+ "meanUsPerUpdateSamples": [
45
+ 0.5444107666014719,
46
+ 0.5040643310547654,
47
+ 0.5098406982418369,
48
+ 0.5029802246094561,
49
+ 0.4021868896481595
50
+ ],
51
+ "medianMeanUsPerUpdate": 0.5040643310547654,
52
+ "p95BlockMeanUsPerUpdate": 0.8030625000010616
53
+ },
54
+ "flatbush": {
55
+ "buildMs": 24.151477,
56
+ "runnerSetupMs": [
57
+ 1.747288000000026,
58
+ 0.7571110000001227,
59
+ 0.9525209999999333,
60
+ 6.737370000000055,
61
+ 0.5303859999999077
62
+ ],
63
+ "meanUsPerUpdateSamples": [
64
+ 26.851899291992137,
65
+ 33.540043212890446,
66
+ 31.742714111328148,
67
+ 28.106207031250108,
68
+ 24.84320092773462
69
+ ],
70
+ "medianMeanUsPerUpdate": 28.106207031250108,
71
+ "p95BlockMeanUsPerUpdate": 44.00362500000199
72
+ },
73
+ "perimeterGrid": {
74
+ "buildMs": 35.78335899999999,
75
+ "runnerSetupMs": [
76
+ 0.0029640000000199507,
77
+ 0.0035950000001321314,
78
+ 0.009703999999828739,
79
+ 0.003796000000420463,
80
+ 0.003315000000384316
81
+ ],
82
+ "meanUsPerUpdateSamples": [
83
+ 1.6638874511720192,
84
+ 1.8976918945313725,
85
+ 1.978514282226257,
86
+ 1.755553588867087,
87
+ 1.7834411621096002
88
+ ],
89
+ "medianMeanUsPerUpdate": 1.7834411621096002,
90
+ "p95BlockMeanUsPerUpdate": 2.736234374999924,
91
+ "gridSide": 128,
92
+ "gridPostings": 954700
93
+ }
94
+ }
95
+ }
96
+ ]
97
+ }
bench/porto-full.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:22:57.676Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 8192,
10
+ "steps": 4469,
11
+ "repeats": 7,
12
+ "scenario": "porto",
13
+ "seed": 270113
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "porto",
20
+ "updates": 4469,
21
+ "agents": 99,
22
+ "events": 16414,
23
+ "meanStartMembers": 35.717171717171716,
24
+ "bounds": [
25
+ -8729766,
26
+ 41124987,
27
+ -8376696,
28
+ 41562351
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.02,
32
+ 0.12
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 37.51009099999999,
37
+ "runnerSetupMs": [
38
+ 0.015533000000004904,
39
+ 0.0015720000000101209,
40
+ 0.0004410000000234504,
41
+ 0.002113000000008469,
42
+ 0.00026000000002568413,
43
+ 0.00024099999995996768,
44
+ 0.000891000000024178
45
+ ],
46
+ "meanUsPerUpdateSamples": [
47
+ 0.42188856567464994,
48
+ 1.9242562094429119,
49
+ 0.37001051689407993,
50
+ 0.3383636160214874,
51
+ 0.33950145446403024,
52
+ 0.30709129559189163,
53
+ 0.31257708659660466
54
+ ],
55
+ "medianMeanUsPerUpdate": 0.33950145446403024,
56
+ "p95BlockMeanUsPerUpdate": 0.6065156249999148
57
+ },
58
+ "flatbush": {
59
+ "buildMs": 19.337777000000017,
60
+ "runnerSetupMs": [
61
+ 0.2596939999999677,
62
+ 0.2640610000000265,
63
+ 0.2638099999999781,
64
+ 0.25673000000000457,
65
+ 0.24404099999998152,
66
+ 0.27624900000000707,
67
+ 0.23951400000004242
68
+ ],
69
+ "meanUsPerUpdateSamples": [
70
+ 1.962077646005795,
71
+ 1.3539805325576253,
72
+ 2.428581338106965,
73
+ 1.2437679570374467,
74
+ 1.306815842470306,
75
+ 1.2309257104497178,
76
+ 1.3093685388229999
77
+ ],
78
+ "medianMeanUsPerUpdate": 1.3093685388229999,
79
+ "p95BlockMeanUsPerUpdate": 1.677625000000127
80
+ },
81
+ "perimeterGrid": {
82
+ "buildMs": 15.347283999999974,
83
+ "runnerSetupMs": [
84
+ 0.0014920000000415712,
85
+ 0.001021999999977652,
86
+ 0.003784999999993488,
87
+ 0.0012219999999842912,
88
+ 0.0009719999999902029,
89
+ 0.00031999999998788553,
90
+ 0.0016230000000518885
91
+ ],
92
+ "meanUsPerUpdateSamples": [
93
+ 1.1703421347057612,
94
+ 1.3692170507943626,
95
+ 0.4900246140076272,
96
+ 0.4904703513090309,
97
+ 0.47958200939811785,
98
+ 0.4580669053479521,
99
+ 0.47649809800855975
100
+ ],
101
+ "medianMeanUsPerUpdate": 0.4900246140076272,
102
+ "p95BlockMeanUsPerUpdate": 0.8334218749999067,
103
+ "gridSide": 128,
104
+ "gridPostings": 263280
105
+ }
106
+ }
107
+ }
108
+ ]
109
+ }
bench/results.json ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:22:51.461Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 8192,
10
+ "steps": 2048,
11
+ "repeats": 5,
12
+ "scenario": "all",
13
+ "seed": 270113
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "wide-local",
20
+ "updates": 2048,
21
+ "agents": 16,
22
+ "events": 6800,
23
+ "meanStartMembers": 1002.625,
24
+ "bounds": [
25
+ 0,
26
+ 0,
27
+ 1,
28
+ 1
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.15,
32
+ 0.55
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 42.826288000000005,
37
+ "runnerSetupMs": [
38
+ 0.0022639999999682914,
39
+ 0.0025729999999839492,
40
+ 0.0012619999999969878,
41
+ 0.0025040000000444707,
42
+ 0.0022639999999682914
43
+ ],
44
+ "meanUsPerUpdateSamples": [
45
+ 4.197629394531388,
46
+ 1.3689052734375817,
47
+ 0.49266259765606835,
48
+ 3.723561035156475,
49
+ 0.5133955078125974
50
+ ],
51
+ "medianMeanUsPerUpdate": 1.3689052734375817,
52
+ "p95BlockMeanUsPerUpdate": 1.959015624997562
53
+ },
54
+ "flatbush": {
55
+ "buildMs": 25.98600399999998,
56
+ "runnerSetupMs": [
57
+ 1.8529859999999871,
58
+ 1.1232400000000098,
59
+ 1.7980440000000044,
60
+ 0.7692739999999958,
61
+ 1.3585599999998976
62
+ ],
63
+ "meanUsPerUpdateSamples": [
64
+ 37.34063476562505,
65
+ 29.353967285156212,
66
+ 29.174525390624872,
67
+ 39.57774707031303,
68
+ 34.20458300781271
69
+ ],
70
+ "medianMeanUsPerUpdate": 34.20458300781271,
71
+ "p95BlockMeanUsPerUpdate": 50.06165625000136
72
+ },
73
+ "perimeterGrid": {
74
+ "buildMs": 79.85532999999998,
75
+ "runnerSetupMs": [
76
+ 0.0036250000000563887,
77
+ 0.0031549999999924694,
78
+ 0.006218999999987318,
79
+ 0.0031350000001566514,
80
+ 0.0023029999999835127
81
+ ],
82
+ "meanUsPerUpdateSamples": [
83
+ 3.471761230468662,
84
+ 1.9292338867186731,
85
+ 1.9336464843750512,
86
+ 1.7139365234373205,
87
+ 4.047909667969418
88
+ ],
89
+ "medianMeanUsPerUpdate": 1.9336464843750512,
90
+ "p95BlockMeanUsPerUpdate": 4.209390625000253,
91
+ "gridSide": 128,
92
+ "gridPostings": 955642
93
+ }
94
+ }
95
+ },
96
+ {
97
+ "name": "sparse-local",
98
+ "updates": 2048,
99
+ "agents": 16,
100
+ "events": 188,
101
+ "meanStartMembers": 0.4375,
102
+ "bounds": [
103
+ 0,
104
+ 0,
105
+ 1,
106
+ 1
107
+ ],
108
+ "boxDimensionsAsFractionOfBounds": [
109
+ 0.001,
110
+ 0.01
111
+ ],
112
+ "timings": {
113
+ "edgechime": {
114
+ "buildMs": 37.22294299999999,
115
+ "runnerSetupMs": [
116
+ 0.00035000000002582965,
117
+ 0.0008110000001124718,
118
+ 0.0001199999999244028,
119
+ 0.0007009999999354477,
120
+ 0.004235999999991691
121
+ ],
122
+ "meanUsPerUpdateSamples": [
123
+ 0.2003325195312211,
124
+ 0.1977885742189267,
125
+ 4.204372070312545,
126
+ 0.2517324218750394,
127
+ 0.21451367187463877
128
+ ],
129
+ "medianMeanUsPerUpdate": 0.21451367187463877,
130
+ "p95BlockMeanUsPerUpdate": 0.36006249999687157
131
+ },
132
+ "flatbush": {
133
+ "buildMs": 34.777736000000004,
134
+ "runnerSetupMs": [
135
+ 0.0443960000000061,
136
+ 0.023856000000023414,
137
+ 0.09571199999982127,
138
+ 0.04212299999994684,
139
+ 0.036813999999822045
140
+ ],
141
+ "meanUsPerUpdateSamples": [
142
+ 0.22574853515644477,
143
+ 0.5720874023437128,
144
+ 0.29148828124947457,
145
+ 0.2885107421872757,
146
+ 0.21984130859387108
147
+ ],
148
+ "medianMeanUsPerUpdate": 0.2885107421872757,
149
+ "p95BlockMeanUsPerUpdate": 0.31749999999775014
150
+ },
151
+ "perimeterGrid": {
152
+ "buildMs": 14.16032099999984,
153
+ "runnerSetupMs": [
154
+ 0.00022100000001046283,
155
+ 0.0007719999998698768,
156
+ 0.00012999999989915523,
157
+ 0.0005210000001625303,
158
+ 0.0005010000002130255
159
+ ],
160
+ "meanUsPerUpdateSamples": [
161
+ 0.13734277343735446,
162
+ 0.16968310546849885,
163
+ 0.1262080078123784,
164
+ 0.17089941406245313,
165
+ 0.13005224609352606
166
+ ],
167
+ "medianMeanUsPerUpdate": 0.13734277343735446,
168
+ "p95BlockMeanUsPerUpdate": 0.18057812500060777,
169
+ "gridSide": 128,
170
+ "gridPostings": 23540
171
+ }
172
+ }
173
+ },
174
+ {
175
+ "name": "wide-teleport",
176
+ "updates": 2048,
177
+ "agents": 16,
178
+ "events": 2902347,
179
+ "meanStartMembers": 1002.625,
180
+ "bounds": [
181
+ 0,
182
+ 0,
183
+ 1,
184
+ 1
185
+ ],
186
+ "boxDimensionsAsFractionOfBounds": [
187
+ 0.15,
188
+ 0.55
189
+ ],
190
+ "timings": {
191
+ "edgechime": {
192
+ "buildMs": 16.577125999999907,
193
+ "runnerSetupMs": [
194
+ 0.0034949999999298598,
195
+ 0.0021839999999428983,
196
+ 0.0023339999997915584,
197
+ 0.0038560000002689776,
198
+ 0.002373999999690568
199
+ ],
200
+ "meanUsPerUpdateSamples": [
201
+ 88.4560048828138,
202
+ 95.10059033203166,
203
+ 78.56599414062427,
204
+ 113.95798925781308,
205
+ 68.85009716796775
206
+ ],
207
+ "medianMeanUsPerUpdate": 88.4560048828138,
208
+ "p95BlockMeanUsPerUpdate": 120.13740624999514
209
+ },
210
+ "flatbush": {
211
+ "buildMs": 2.9006039999999302,
212
+ "runnerSetupMs": [
213
+ 1.067529000000377,
214
+ 0.9223050000000512,
215
+ 0.8670830000000933,
216
+ 3.5319650000001275,
217
+ 5.489790999999968
218
+ ],
219
+ "meanUsPerUpdateSamples": [
220
+ 41.5833901367193,
221
+ 40.31909082031282,
222
+ 42.72857714843914,
223
+ 38.930808593750314,
224
+ 59.75374365234476
225
+ ],
226
+ "medianMeanUsPerUpdate": 41.5833901367193,
227
+ "p95BlockMeanUsPerUpdate": 64.36646874999497
228
+ },
229
+ "perimeterGrid": {
230
+ "buildMs": 10.129044999999905,
231
+ "runnerSetupMs": [
232
+ 0.002543000000059692,
233
+ 0.006308999999873777,
234
+ 0.0021729999998569838,
235
+ 0.0020530000001599547,
236
+ 0.0022330000001602457
237
+ ],
238
+ "meanUsPerUpdateSamples": [
239
+ 113.35500488281181,
240
+ 135.2525961914055,
241
+ 112.87135644531254,
242
+ 102.15944531249966,
243
+ 101.79743994140634
244
+ ],
245
+ "medianMeanUsPerUpdate": 112.87135644531254,
246
+ "p95BlockMeanUsPerUpdate": 157.91985937501352,
247
+ "gridSide": 128,
248
+ "gridPostings": 955642
249
+ }
250
+ }
251
+ },
252
+ {
253
+ "name": "stationary",
254
+ "updates": 2048,
255
+ "agents": 16,
256
+ "events": 0,
257
+ "meanStartMembers": 1002.625,
258
+ "bounds": [
259
+ 0,
260
+ 0,
261
+ 1,
262
+ 1
263
+ ],
264
+ "boxDimensionsAsFractionOfBounds": [
265
+ 0.15,
266
+ 0.55
267
+ ],
268
+ "timings": {
269
+ "edgechime": {
270
+ "buildMs": 15.631545000000187,
271
+ "runnerSetupMs": [
272
+ 0.00021100000049045775,
273
+ 0.0005110000001877779,
274
+ 0.00011999999969702912,
275
+ 0.0003999999998995918,
276
+ 0.00020000000040454324
277
+ ],
278
+ "meanUsPerUpdateSamples": [
279
+ 0.4754355468756799,
280
+ 0.6619653320312224,
281
+ 0.08873925781349712,
282
+ 0.03348730468655248,
283
+ 0.09862792968640122
284
+ ],
285
+ "medianMeanUsPerUpdate": 0.09862792968640122,
286
+ "p95BlockMeanUsPerUpdate": 0.09264062499880765
287
+ },
288
+ "flatbush": {
289
+ "buildMs": 3.828173999999308,
290
+ "runnerSetupMs": [
291
+ 0.6531270000004952,
292
+ 0.5030239999996411,
293
+ 0.5660479999996824,
294
+ 0.557875000000422,
295
+ 0.49545300000045245
296
+ ],
297
+ "meanUsPerUpdateSamples": [
298
+ 0.021398437499708933,
299
+ 0.022425292968808463,
300
+ 0.021921875000607827,
301
+ 0.02010449218747823,
302
+ 0.02362402343747405
303
+ ],
304
+ "medianMeanUsPerUpdate": 0.021921875000607827,
305
+ "p95BlockMeanUsPerUpdate": 0.0345781249961874
306
+ },
307
+ "perimeterGrid": {
308
+ "buildMs": 23.496538999999757,
309
+ "runnerSetupMs": [
310
+ 0.0004400000007080962,
311
+ 0.00034099999993486563,
312
+ 0.0006210000001374283,
313
+ 0.00038099999983387534,
314
+ 0.0002300000005561742
315
+ ],
316
+ "meanUsPerUpdateSamples": [
317
+ 0.11917578124798212,
318
+ 0.8443105468738388,
319
+ 0.03166406249865972,
320
+ 0.03168261718888843,
321
+ 0.06101806640490537
322
+ ],
323
+ "medianMeanUsPerUpdate": 0.06101806640490537,
324
+ "p95BlockMeanUsPerUpdate": 0.07510937500398995,
325
+ "gridSide": 128,
326
+ "gridPostings": 955642
327
+ }
328
+ }
329
+ },
330
+ {
331
+ "name": "porto",
332
+ "updates": 2048,
333
+ "agents": 99,
334
+ "events": 6672,
335
+ "meanStartMembers": 35.717171717171716,
336
+ "bounds": [
337
+ -8729766,
338
+ 41124987,
339
+ -8376696,
340
+ 41562351
341
+ ],
342
+ "boxDimensionsAsFractionOfBounds": [
343
+ 0.02,
344
+ 0.12
345
+ ],
346
+ "timings": {
347
+ "edgechime": {
348
+ "buildMs": 27.529645999999957,
349
+ "runnerSetupMs": [
350
+ 0.00044100000013713725,
351
+ 0.0003299999998489511,
352
+ 0.00012000000060652383,
353
+ 0.0014919999994162936,
354
+ 0.00023099999998521525
355
+ ],
356
+ "meanUsPerUpdateSamples": [
357
+ 2.8497773437510254,
358
+ 0.38199169922048526,
359
+ 0.3370708007808254,
360
+ 0.5595478515636465,
361
+ 0.3747094726582745
362
+ ],
363
+ "medianMeanUsPerUpdate": 0.38199169922048526,
364
+ "p95BlockMeanUsPerUpdate": 0.5650625000015452
365
+ },
366
+ "flatbush": {
367
+ "buildMs": 4.9174739999998565,
368
+ "runnerSetupMs": [
369
+ 0.21991500000058295,
370
+ 0.47413200000028155,
371
+ 0.27684899999985646,
372
+ 0.27681899999970483,
373
+ 0.20366200000080426
374
+ ],
375
+ "meanUsPerUpdateSamples": [
376
+ 1.4786962890616095,
377
+ 3.090864746094102,
378
+ 2.2890644531234905,
379
+ 1.5497387695311282,
380
+ 1.45411474609336
381
+ ],
382
+ "medianMeanUsPerUpdate": 1.5497387695311282,
383
+ "p95BlockMeanUsPerUpdate": 2.227828125000997
384
+ },
385
+ "perimeterGrid": {
386
+ "buildMs": 7.344986000000063,
387
+ "runnerSetupMs": [
388
+ 0.000940999999329506,
389
+ 0.0008820000002742745,
390
+ 0.00010000000020227162,
391
+ 0.000691000000188069,
392
+ 0.000871999999617401
393
+ ],
394
+ "meanUsPerUpdateSamples": [
395
+ 2.8600180664066777,
396
+ 0.5448037109374582,
397
+ 0.4799638671872941,
398
+ 0.5302128906263803,
399
+ 0.5085747070321389
400
+ ],
401
+ "medianMeanUsPerUpdate": 0.5302128906263803,
402
+ "p95BlockMeanUsPerUpdate": 0.8625312500072368,
403
+ "gridSide": 128,
404
+ "gridPostings": 263280
405
+ }
406
+ }
407
+ }
408
+ ]
409
+ }
bench/run.js ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { cpus } from 'node:os';
5
+ import { performance } from 'node:perf_hooks';
6
+ import { EdgeChime } from '../index.js';
7
+ import { GridBaseline } from './grid.mjs';
8
+ import Flatbush from './vendor/flatbush.js';
9
+
10
+ const config = { boxes: 8192, steps: 2048, repeats: 5, scenario: 'all', seed: 270113 };
11
+ const scenarios = ['wide-local', 'sparse-local', 'wide-teleport', 'stationary', 'porto'];
12
+ for (let i = 2; i < process.argv.length; i += 2) {
13
+ const key = process.argv[i].slice(2);
14
+ if (!process.argv[i].startsWith('--') || !Object.hasOwn(config, key)) throw Error('Unknown option ' + process.argv[i]);
15
+ const value = process.argv[i + 1];
16
+ if (key === 'scenario') {
17
+ if (value !== 'all' && !scenarios.includes(value)) throw Error('Expected one of all, ' + scenarios.join(', '));
18
+ config.scenario = value;
19
+ } else {
20
+ config[key] = Number(value);
21
+ if (!Number.isSafeInteger(config[key]) || config[key] < 1) throw Error('Expected positive integer for --' + key);
22
+ }
23
+ }
24
+ function rng(seed) {
25
+ return () => {
26
+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
27
+ return seed / 4294967296;
28
+ };
29
+ }
30
+
31
+ function syntheticTracks(name) {
32
+ const random = rng(config.seed + 1);
33
+ const count = Math.min(16, config.steps);
34
+ const tracks = Array.from({ length: count }, () => [[0.2 + 0.6 * random(), 0.2 + 0.6 * random()]]);
35
+ for (let step = 0; step < config.steps; step++) {
36
+ const track = tracks[step % count];
37
+ let [x, y] = track.at(-1);
38
+ if (name === 'wide-teleport') {
39
+ x = random();
40
+ y = random();
41
+ } else if (name !== 'stationary') {
42
+ x = Math.max(0, Math.min(1, x + 0.0006 * (2 * random() - 1)));
43
+ y = Math.max(0, Math.min(1, y + 0.0006 * (2 * random() - 1)));
44
+ }
45
+ track.push([x, y]);
46
+ }
47
+ return tracks;
48
+ }
49
+
50
+ function makeWorkload(name) {
51
+ const measured = name === 'porto';
52
+ const tracks = measured ? JSON.parse(readFileSync(new URL('./data/trace.json', import.meta.url))) : syntheticTracks(name);
53
+ const starts = tracks.map(track => track[0]);
54
+ const bounds = measured ? [Infinity, Infinity, -Infinity, -Infinity] : [0, 0, 1, 1];
55
+ if (measured) {
56
+ for (const track of tracks) for (const [x, y] of track) {
57
+ bounds[0] = Math.min(bounds[0], x);
58
+ bounds[1] = Math.min(bounds[1], y);
59
+ bounds[2] = Math.max(bounds[2], x);
60
+ bounds[3] = Math.max(bounds[3], y);
61
+ }
62
+ }
63
+ const moves = [];
64
+ for (let pos = 1; moves.length < config.steps; pos++) {
65
+ const previous = moves.length;
66
+ for (let id = 0; id < tracks.length && moves.length < config.steps; id++) {
67
+ if (pos < tracks[id].length) moves.push([id, ...tracks[id][pos - 1], ...tracks[id][pos]]);
68
+ }
69
+ if (moves.length === previous) break;
70
+ }
71
+ const widthRange = name === 'sparse-local' ? [0.001, 0.010] : measured ? [0.02, 0.12] : [0.15, 0.55];
72
+ const random = rng(config.seed);
73
+ const extentX = bounds[2] - bounds[0], extentY = bounds[3] - bounds[1];
74
+ const width = () => widthRange[0] + random() * (widthRange[1] - widthRange[0]);
75
+ const boxes = Array.from({ length: config.boxes }, () => {
76
+ const x = bounds[0] + extentX * random(), y = bounds[1] + extentY * random();
77
+ const hw = 0.5 * extentX * width(), hh = 0.5 * extentY * width();
78
+ return [x - hw, y - hh, x + hw, y + hh];
79
+ });
80
+ return { starts, moves, boxes, widthRange, bounds };
81
+ }
82
+
83
+ // Store the predecessor of each exclusive upper bound. Flatbush's inclusive
84
+ // intersection now gives exact half-open point membership without a JS filter.
85
+ const bits = new DataView(new ArrayBuffer(8));
86
+ function nextDown(x) {
87
+ if (x === 0) return -Number.MIN_VALUE;
88
+ bits.setFloat64(0, x);
89
+ const hi = bits.getUint32(0), lo = bits.getUint32(4);
90
+ if (x > 0) {
91
+ bits.setUint32(4, lo - 1);
92
+ if (lo === 0) bits.setUint32(0, hi - 1);
93
+ } else {
94
+ bits.setUint32(4, lo + 1);
95
+ if (lo === 0xffffffff) bits.setUint32(0, hi + 1);
96
+ }
97
+ return bits.getFloat64(0);
98
+ }
99
+
100
+ function packedTree(boxes) {
101
+ const tree = new Flatbush(boxes.length);
102
+ for (const [x, y, xx, yy] of boxes) tree.add(x, y, nextDown(xx), nextDown(yy));
103
+ tree.finish();
104
+ return tree;
105
+ }
106
+
107
+ // Cache each agent's previous hit list and N/8 bytes of membership bits.
108
+ // A shared stamp table identifies exits in O(oldHits + newHits), without sets,
109
+ // sorting, a second point query, or clearing the whole table between moves.
110
+ function pointDiff(tree, starts) {
111
+ const marks = new Uint32Array(tree.numItems);
112
+ const agents = starts.map(([x, y]) => {
113
+ const hits = tree.search(x, y, x, y);
114
+ const membership = new Uint8Array(Math.ceil(tree.numItems / 8));
115
+ for (const id of hits) membership[id >>> 3] |= 1 << (id & 7);
116
+ return { hits, membership };
117
+ });
118
+ let generation = 0;
119
+ return (actor, x0, y0, x, y, emit) => {
120
+ if (x0 === x && y0 === y) return;
121
+ if (++generation > 0xffffffff) { marks.fill(0); generation = 1; }
122
+ const agent = agents[actor], membership = agent.membership;
123
+ const hits = tree.search(x, y, x, y);
124
+ for (const id of hits) {
125
+ marks[id] = generation;
126
+ const byte = id >>> 3, mask = 1 << (id & 7);
127
+ if (!(membership[byte] & mask)) {
128
+ membership[byte] |= mask;
129
+ emit(id, true);
130
+ }
131
+ }
132
+ for (const id of agent.hits) {
133
+ if (marks[id] !== generation) {
134
+ membership[id >>> 3] &= ~(1 << (id & 7));
135
+ emit(id, false);
136
+ }
137
+ }
138
+ agent.hits = hits;
139
+ };
140
+ }
141
+
142
+ function scanEvents(boxes, move) {
143
+ const [, x0, y0, x, y] = move;
144
+ const events = [];
145
+ for (let id = 0; id < boxes.length; id++) {
146
+ const [a, b, c, d] = boxes[id];
147
+ const old = a <= x0 && x0 < c && b <= y0 && y0 < d;
148
+ const now = a <= x && x < c && b <= y && y < d;
149
+ if (old !== now) events.push(id * 2 + Number(now));
150
+ }
151
+ return events;
152
+ }
153
+ function validate(methods, w) {
154
+ const runners = methods.map(method => method.runner());
155
+ const directEvery = Math.max(1, Math.floor(w.moves.length / 16));
156
+ let total = 0;
157
+ for (let i = 0; i < w.moves.length; i++) {
158
+ const move = w.moves[i];
159
+ const results = runners.map(run => {
160
+ const events = [];
161
+ run(...move, (id, entered) => events.push(id * 2 + Number(entered)));
162
+ return events.sort((a, b) => a - b);
163
+ });
164
+ for (let j = 1; j < results.length; j++) {
165
+ assert.deepEqual(results[j], results[0], 'Event IDs or directions differ on move ' + i);
166
+ }
167
+ if (i % directEvery === 0 || i === w.moves.length - 1) assert.deepEqual(results[0], scanEvents(w.boxes, move));
168
+ total += results[0].length;
169
+ }
170
+ return total;
171
+ }
172
+ function quantile(values, q) {
173
+ const sorted = values.slice().sort((a, b) => a - b);
174
+ return sorted[Math.ceil(q * sorted.length) - 1];
175
+ }
176
+ const blockSize = 64;
177
+ function measure(method, moves, blocks) {
178
+ const before = performance.now(), run = method.runner();
179
+ const setupMs = performance.now() - before;
180
+ let events = 0, sum = 0, elapsed = 0;
181
+ const emit = (id, entered) => { events++; sum = (sum + (entered ? id + 1 : -id - 1)) | 0; };
182
+ for (let start = 0; start < moves.length; start += blockSize) {
183
+ const end = Math.min(start + blockSize, moves.length);
184
+ const t0 = performance.now();
185
+ for (let i = start; i < end; i++) {
186
+ const m = moves[i];
187
+ run(m[0], m[1], m[2], m[3], m[4], emit);
188
+ }
189
+ const duration = performance.now() - t0;
190
+ elapsed += duration;
191
+ if (end - start === blockSize) blocks.push(1000 * duration / blockSize);
192
+ }
193
+ return { events, sum, setupMs, meanUs: elapsed * 1000 / moves.length };
194
+ }
195
+
196
+ function benchmark(name) {
197
+ const w = makeWorkload(name);
198
+ const methods = [];
199
+ for (const [label, build] of [['edgechime', boxes => new EdgeChime(boxes)],
200
+ ['flatbush', packedTree], ['perimeterGrid', boxes => new GridBaseline(boxes)]]) {
201
+ const t0 = performance.now();
202
+ const index = build(w.boxes);
203
+ const buildMs = performance.now() - t0;
204
+ const runner = label === 'flatbush' ? () => pointDiff(index, w.starts) :
205
+ () => (_actor, x, y, xx, yy, emit) => index.move(x, y, xx, yy, emit);
206
+ methods.push({ label, buildMs, runner, index, samples: [], blocks: [] });
207
+ }
208
+ const tree = methods.find(m => m.label === 'flatbush').index;
209
+ const meanStartMembers = w.starts.reduce((sum, [x, y]) => sum + tree.search(x, y, x, y).length, 0) / w.starts.length;
210
+ const verifiedEvents = validate(methods, w);
211
+ for (const method of methods) measure(method, w.moves, []);
212
+ for (let rep = 0; rep < config.repeats; rep++) {
213
+ for (let offset = 0; offset < methods.length; offset++) {
214
+ const method = methods[(rep + offset) % methods.length];
215
+ const sample = measure(method, w.moves, method.blocks);
216
+ assert.equal(sample.events, verifiedEvents);
217
+ if (methods[0].samples.length) assert.equal(sample.sum, methods[0].samples[0].sum);
218
+ method.samples.push(sample);
219
+ }
220
+ }
221
+ const timings = {};
222
+ for (const method of methods) {
223
+ const samples = method.samples.map(s => s.meanUs);
224
+ const g = method.index;
225
+ timings[method.label] = {
226
+ buildMs: method.buildMs, runnerSetupMs: method.samples.map(s => s.setupMs),
227
+ meanUsPerUpdateSamples: samples, medianMeanUsPerUpdate: quantile(samples, 0.5),
228
+ p95BlockMeanUsPerUpdate: method.blocks.length ? quantile(method.blocks, 0.95) : null,
229
+ ...(method.label === 'perimeterGrid' ? { gridSide: g.side, gridPostings: g.postingCount } : {})
230
+ };
231
+ }
232
+ return { name, updates: w.moves.length, agents: w.starts.length, events: verifiedEvents, meanStartMembers,
233
+ bounds: w.bounds, boxDimensionsAsFractionOfBounds: w.widthRange, timings };
234
+ }
235
+
236
+ const report = { formatVersion: 1, timestamp: new Date().toISOString(), node: process.version, cpu: cpus()[0]?.model,
237
+ platform: process.platform, arch: process.arch, config, blockSize, flatbushVersion: '4.7.0',
238
+ scenarios: (config.scenario === 'all' ? scenarios : [config.scenario]).map(benchmark) };
239
+ console.log(JSON.stringify(report, null, 2));
bench/trace.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Porto movement trace
2
+
3
+ The replay uses GPS samples from taxis in Porto, Portugal. Each inner array in `data/trace.json` is one trip prefix, in recording order. The coordinates are WGS84 longitude and latitude in signed integer microdegrees. UCI describes a nominal sampling cadence of 15 seconds. Compare adjacent observations within an array. A new array starts a new trip, and equal consecutive observations represent legitimate updates.
4
+
5
+ | Quantity | Count |
6
+ | --- | ---: |
7
+ | Trip prefixes | 99 |
8
+ | Positions | 4,568 |
9
+ | Within-trip moves | 4,469 |
10
+ | Stationary moves after quantization | 116 |
11
+
12
+ ## Selection and reproduction
13
+
14
+ Take the first 100 data records in file order from `Porto_taxi_data_test_partial_trajectories.csv`. Keep trips flagged `MISSING_DATA=False` with at least two observations. Keep the full polyline from each selected record. Multiply each coordinate by one million and round to the nearest integer. This removes floating-point formatting noise and all identifying metadata. The benchmark uses generated rectangles. The source has no zone subscriptions or notification logs. These trip prefixes represent a historical sample from one city.
15
+
16
+ From the repository root, regenerate the file with Python 3 and compare its digest. Use `--input path/to/Porto_taxi_data_test_partial_trajectories.csv` for an offline rebuild.
17
+
18
+ ```sh
19
+ python3 bench/trace_porto.py
20
+ sha256sum bench/data/trace.json
21
+ ```
22
+
23
+ | File | SHA-256 |
24
+ | --- | --- |
25
+ | [Original CSV](https://archive.ics.uci.edu/ml/machine-learning-databases/00339/Porto_taxi_data_test_partial_trajectories.csv) | `f376cca6839ec7a16c46d8619b28230114b9bba5e9b0dec7e4abae44e82b542f` |
26
+ | Derived JSON | `4197da9bf36caf10235da69b073d503d2c6404c74541e5a94942225cf8c5d134` |
27
+
28
+ ## Data attribution
29
+
30
+ The original creators credited by UCI are Luis Moreira-Matias, Michel Ferreira, Joao Mendes-Moreira, L. L., and J. J. (2013). *Taxi Service Trajectory – Prediction Challenge, ECML PKDD 2015*. UCI Machine Learning Repository. [Dataset record and citation](https://doi.org/10.24432/C55W25).
31
+
32
+ The original dataset and the selected, quantized trajectories in `data/trace.json` are distributed under [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/). The repository's code license applies to the sampler.
bench/trace_porto.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Regenerate the committed Porto trajectory sample from the original UCI CSV."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import csv
6
+ import hashlib
7
+ import io
8
+ import itertools
9
+ import json
10
+ from pathlib import Path
11
+ from urllib.request import urlopen
12
+
13
+ SOURCE = (
14
+ "https://archive.ics.uci.edu/ml/machine-learning-databases/"
15
+ "00339/Porto_taxi_data_test_partial_trajectories.csv"
16
+ )
17
+ SOURCE_SHA256 = "f376cca6839ec7a16c46d8619b28230114b9bba5e9b0dec7e4abae44e82b542f"
18
+ OUTPUT = Path(__file__).resolve().parent / "data" / "trace.json"
19
+
20
+
21
+ def main():
22
+ parser = argparse.ArgumentParser(description=__doc__)
23
+ parser.add_argument("--input", type=Path, help="use a locally downloaded UCI CSV")
24
+ parser.add_argument("--output", type=Path, default=OUTPUT)
25
+ args = parser.parse_args()
26
+ if args.input:
27
+ data = args.input.read_bytes()
28
+ else:
29
+ with urlopen(SOURCE, timeout=45) as response:
30
+ data = response.read()
31
+ if hashlib.sha256(data).hexdigest() != SOURCE_SHA256:
32
+ parser.error("input differs from the documented UCI source digest")
33
+
34
+ rows = csv.DictReader(io.StringIO(data.decode("utf-8")))
35
+ tracks = []
36
+ for row in itertools.islice(rows, 100):
37
+ if row["MISSING_DATA"].lower() != "false":
38
+ continue
39
+ locations = json.loads(row["POLYLINE"])
40
+ if len(locations) < 2:
41
+ continue
42
+ track = [[round(lon * 1_000_000), round(lat * 1_000_000)] for lon, lat in locations]
43
+ tracks.append(json.dumps(track, separators=(",", ":")))
44
+
45
+ args.output.write_bytes(("[\n" + ",\n".join(tracks) + "\n]\n").encode("ascii"))
46
+
47
+
48
+ if __name__ == "__main__":
49
+ main()
bench/vendor/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Benchmark dependencies
2
+
3
+ Flatbush 4.7.0 and FlatQueue 3.1.0 are used only to reproduce the packed R-tree comparison. Each project’s ISC license is included alongside its code. Both source files are from the release tag. The only source change is the Flatbush import path pointing to the adjacent FlatQueue module.
4
+
5
+ - [Flatbush v4.7.0](https://github.com/mourner/flatbush/tree/v4.7.0)
6
+ - [FlatQueue v3.1.0](https://github.com/mourner/flatqueue/tree/v3.1.0)
bench/vendor/flatbush.LICENSE ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ISC License
2
+
3
+ Copyright (c) 2022, Vladimir Agafonkin
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose
6
+ with or without fee is hereby granted, provided that the above copyright notice
7
+ and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
13
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
15
+ THIS SOFTWARE.
bench/vendor/flatbush.js ADDED
@@ -0,0 +1,564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import FlatQueue from './flatqueue.js';
2
+
3
+ const ARRAY_TYPES = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];
4
+ const VERSION = 3; // serialized format version
5
+
6
+ /** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */
7
+ /** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */
8
+
9
+ export default class Flatbush {
10
+
11
+ /**
12
+ * Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
13
+ * @param {ArrayBufferLike} data
14
+ * @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
15
+ * @returns {Flatbush} index
16
+ */
17
+ static from(data, byteOffset = 0) {
18
+ if (byteOffset % 8 !== 0) {
19
+ throw new Error('byteOffset must be 8-byte aligned.');
20
+ }
21
+
22
+ if (!data || data.byteLength === undefined || 'buffer' in data) {
23
+ throw new Error('Data must be an instance of ArrayBuffer or SharedArrayBuffer.');
24
+ }
25
+
26
+ const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
27
+ if (magic !== 0xfb) {
28
+ throw new Error('Data does not appear to be in a Flatbush format.');
29
+ }
30
+ const version = versionAndType >> 4;
31
+ if (version !== VERSION) {
32
+ throw new Error(`Got v${version} data when expected v${VERSION}.`);
33
+ }
34
+ const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];
35
+ if (!ArrayType) {
36
+ throw new Error('Unrecognized array type.');
37
+ }
38
+ const [nodeSize] = new Uint16Array(data, byteOffset + 2, 1);
39
+ const [numItems] = new Uint32Array(data, byteOffset + 4, 1);
40
+
41
+ return new Flatbush(numItems, nodeSize, ArrayType, undefined, data, byteOffset);
42
+ }
43
+
44
+ /**
45
+ * Create a Flatbush index that will hold a given number of items.
46
+ * @param {number} numItems
47
+ * @param {number} [nodeSize=16] Size of the tree node (16 by default).
48
+ * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
49
+ * @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used to store data (`ArrayBuffer` by default).
50
+ * @param {ArrayBufferLike} [data] (Only used internally)
51
+ * @param {number} [byteOffset=0] (Only used internally)
52
+ */
53
+ constructor(numItems, nodeSize = 16, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data, byteOffset = 0) {
54
+ if (numItems === undefined) throw new Error('Missing required argument: numItems.');
55
+ if (isNaN(numItems) || numItems <= 0) throw new Error(`Unexpected numItems value: ${numItems}.`);
56
+
57
+ this.numItems = +numItems;
58
+ this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
59
+ this.byteOffset = byteOffset;
60
+
61
+ // calculate the total number of nodes in the R-tree to allocate space for
62
+ // and the index of each tree level (used in search later)
63
+ let n = numItems;
64
+ let numNodes = n;
65
+ this._levelBounds = [n * 4];
66
+ do {
67
+ n = Math.ceil(n / this.nodeSize);
68
+ numNodes += n;
69
+ this._levelBounds.push(numNodes * 4);
70
+ } while (n !== 1);
71
+
72
+ this.ArrayType = ArrayType;
73
+ this.IndexArrayType = numNodes < 16384 ? Uint16Array : Uint32Array;
74
+
75
+ const arrayTypeIndex = ARRAY_TYPES.indexOf(ArrayType);
76
+ const nodesByteSize = numNodes * 4 * ArrayType.BYTES_PER_ELEMENT;
77
+
78
+ if (arrayTypeIndex < 0) {
79
+ throw new Error(`Unexpected typed array class: ${ArrayType}.`);
80
+ }
81
+
82
+ /** @type {new(b: ArrayBufferLike, o: number, l: number) => TypedArray} */
83
+ const BoxCtor = ArrayType;
84
+ /** @type {new(b: ArrayBufferLike, o: number, l: number) => Uint16Array | Uint32Array} */
85
+ const IdxCtor = this.IndexArrayType;
86
+
87
+ if (data) {
88
+ this.data = data;
89
+ this._boxes = new BoxCtor(data, byteOffset + 8, numNodes * 4);
90
+ this._indices = new IdxCtor(data, byteOffset + 8 + nodesByteSize, numNodes);
91
+
92
+ this._pos = numNodes * 4;
93
+ this.minX = this._boxes[this._pos - 4];
94
+ this.minY = this._boxes[this._pos - 3];
95
+ this.maxX = this._boxes[this._pos - 2];
96
+ this.maxY = this._boxes[this._pos - 1];
97
+
98
+ } else {
99
+ const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
100
+ this._boxes = new BoxCtor(data, 8, numNodes * 4);
101
+ this._indices = new IdxCtor(data, 8 + nodesByteSize, numNodes);
102
+ this._pos = 0;
103
+ this.minX = Infinity;
104
+ this.minY = Infinity;
105
+ this.maxX = -Infinity;
106
+ this.maxY = -Infinity;
107
+
108
+ new Uint8Array(data, 0, 2).set([0xfb, (VERSION << 4) + arrayTypeIndex]);
109
+ new Uint16Array(data, 2, 1)[0] = this.nodeSize;
110
+ new Uint32Array(data, 4, 1)[0] = numItems;
111
+ }
112
+
113
+ // a priority queue for k-nearest-neighbors queries
114
+ /** @type FlatQueue<number> */
115
+ this._queue = new FlatQueue();
116
+ }
117
+
118
+ /**
119
+ * Add a given rectangle to the index.
120
+ * @param {number} minX
121
+ * @param {number} minY
122
+ * @param {number} maxX
123
+ * @param {number} maxY
124
+ * @returns {number} A zero-based, incremental number that represents the newly added rectangle.
125
+ */
126
+ add(minX, minY, maxX = minX, maxY = minY) {
127
+ const pos = this._pos;
128
+ const index = pos >> 2;
129
+ const boxes = this._boxes;
130
+ this._indices[index] = index;
131
+ boxes[pos] = minX;
132
+ boxes[pos + 1] = minY;
133
+ boxes[pos + 2] = maxX;
134
+ boxes[pos + 3] = maxY;
135
+ this._pos = pos + 4;
136
+
137
+ if (minX < this.minX) this.minX = minX;
138
+ if (minY < this.minY) this.minY = minY;
139
+ if (maxX > this.maxX) this.maxX = maxX;
140
+ if (maxY > this.maxY) this.maxY = maxY;
141
+
142
+ return index;
143
+ }
144
+
145
+ /** Perform indexing of the added rectangles. */
146
+ finish() {
147
+ if (this._pos >> 2 !== this.numItems) {
148
+ throw new Error(`Added ${this._pos >> 2} items when expected ${this.numItems}.`);
149
+ }
150
+ const boxes = this._boxes;
151
+
152
+ if (this.numItems <= this.nodeSize) {
153
+ // only one node, skip sorting and just fill the root box
154
+ boxes[this._pos++] = this.minX;
155
+ boxes[this._pos++] = this.minY;
156
+ boxes[this._pos++] = this.maxX;
157
+ boxes[this._pos++] = this.maxY;
158
+ return;
159
+ }
160
+
161
+ const {numItems, minX, minY, nodeSize, _indices: indices, _levelBounds: levelBounds} = this;
162
+ const width = (this.maxX - minX) || 1;
163
+ const height = (this.maxY - minY) || 1;
164
+ const hilbertValues = new Int32Array(numItems);
165
+ const hilbertMax = (1 << 16) - 1;
166
+ const sx = hilbertMax / width;
167
+ const sy = hilbertMax / height;
168
+
169
+ // map item centers into Hilbert coordinate space and calculate Hilbert values
170
+ for (let i = 0, pos = 0; i < numItems; i++) {
171
+ const itemMinX = boxes[pos++];
172
+ const itemMinY = boxes[pos++];
173
+ const itemMaxX = boxes[pos++];
174
+ const itemMaxY = boxes[pos++];
175
+ const x = (sx * ((itemMinX + itemMaxX) / 2 - minX)) | 0;
176
+ const y = (sy * ((itemMinY + itemMaxY) / 2 - minY)) | 0;
177
+ hilbertValues[i] = hilbert(x, y);
178
+ }
179
+
180
+ // sort items by their Hilbert value (for packing later)
181
+ sort(hilbertValues, boxes, indices, 0, numItems - 1, nodeSize);
182
+
183
+ // generate nodes at each tree level, bottom-up
184
+ let pos = numItems * 4;
185
+ for (let i = 0, readPos = 0; i < levelBounds.length - 1; i++) {
186
+ const end = levelBounds[i];
187
+
188
+ // generate a parent node for each block of consecutive <nodeSize> nodes
189
+ while (readPos < end) {
190
+ const nodeIndex = readPos;
191
+
192
+ // calculate bbox for the new node
193
+ let nodeMinX = boxes[readPos++];
194
+ let nodeMinY = boxes[readPos++];
195
+ let nodeMaxX = boxes[readPos++];
196
+ let nodeMaxY = boxes[readPos++];
197
+ for (let j = 1; j < nodeSize && readPos < end; j++) {
198
+ nodeMinX = Math.min(nodeMinX, boxes[readPos++]);
199
+ nodeMinY = Math.min(nodeMinY, boxes[readPos++]);
200
+ nodeMaxX = Math.max(nodeMaxX, boxes[readPos++]);
201
+ nodeMaxY = Math.max(nodeMaxY, boxes[readPos++]);
202
+ }
203
+
204
+ // add the new node to the tree data
205
+ indices[pos >> 2] = nodeIndex;
206
+ boxes[pos++] = nodeMinX;
207
+ boxes[pos++] = nodeMinY;
208
+ boxes[pos++] = nodeMaxX;
209
+ boxes[pos++] = nodeMaxY;
210
+ }
211
+ }
212
+ this._pos = pos;
213
+ }
214
+
215
+ /**
216
+ * Search the index by a bounding box.
217
+ * @param {number} minX
218
+ * @param {number} minY
219
+ * @param {number} maxX
220
+ * @param {number} maxY
221
+ * @param {(index: number, x0: number, y0: number, x1: number, y1: number) => boolean} [filterFn] An optional function that is called on every found item; if supplied, only items for which this function returns true will be included in the results array.
222
+ * @returns {number[]} An array of indices of items intersecting or touching the given bounding box.
223
+ */
224
+ search(minX, minY, maxX, maxY, filterFn) {
225
+ if (this._pos !== this._boxes.length) {
226
+ throw new Error('Data not yet indexed - call index.finish().');
227
+ }
228
+ const {_boxes: boxes, _levelBounds: levelBounds, _indices: indices, nodeSize} = this;
229
+ const numItems4 = this.numItems * 4;
230
+
231
+ /** @type number | undefined */
232
+ let nodeIndex = boxes.length - 4;
233
+ let level = levelBounds.length - 1; // start at the root level
234
+ const q = [];
235
+ const results = [];
236
+
237
+ let contained = false; // whether the current node's bbox is fully inside the query
238
+
239
+ while (nodeIndex !== undefined) {
240
+ // find the end index of the node, capped at the level boundary
241
+ const end = Math.min(nodeIndex + nodeSize * 4, levelBounds[level]);
242
+ const isNode = nodeIndex >= numItems4;
243
+
244
+ if (contained) {
245
+ this._collectContained(nodeIndex, end, level, numItems4, results, filterFn);
246
+
247
+ } else {
248
+ // search through child nodes
249
+ for (let /** @type {number} */ pos = nodeIndex; pos < end; pos += 4) {
250
+ // check if node bbox intersects with query bbox
251
+ const x0 = boxes[pos];
252
+ if (maxX < x0) continue;
253
+ const y0 = boxes[pos + 1];
254
+ if (maxY < y0) continue;
255
+ const x1 = boxes[pos + 2];
256
+ if (minX > x1) continue;
257
+ const y1 = boxes[pos + 3];
258
+ if (minY > y1) continue;
259
+
260
+ const index = indices[pos >> 2] | 0;
261
+
262
+ if (isNode) {
263
+ // node intersects; flag it as contained if its bbox is fully inside the query
264
+ const c = +(minX <= x0 && minY <= y0 && maxX >= x1 && maxY >= y1);
265
+ q.push(index | c, level - 1); // node; add it and its level to the search queue
266
+
267
+ } else if (filterFn === undefined || filterFn(index, x0, y0, x1, y1)) {
268
+ results.push(index); // leaf item
269
+ }
270
+ }
271
+ }
272
+
273
+ level = /** @type {number} */ (q.pop());
274
+ nodeIndex = q.pop();
275
+ if (nodeIndex !== undefined) {
276
+ contained = (nodeIndex & 1) === 1;
277
+ nodeIndex &= ~1;
278
+ }
279
+ }
280
+
281
+ return results;
282
+ }
283
+
284
+ /**
285
+ * Collect all leaves of a subtree that's fully inside the query, skipping intersection tests.
286
+ * Because the tree is packed bottom-up, those leaves occupy one contiguous block of the leaf
287
+ * level, so we skip traversal entirely: descend to the first leaf, then sweep the flat range.
288
+ * @param {number} nodeIndex
289
+ * @param {number} end
290
+ * @param {number} level
291
+ * @param {number} numItems4
292
+ * @param {number[]} results
293
+ * @param {((index: number, x0: number, y0: number, x1: number, y1: number) => boolean) | undefined} filterFn
294
+ */
295
+ _collectContained(nodeIndex, end, level, numItems4, results, filterFn) {
296
+ const boxes = this._boxes;
297
+ const indices = this._indices;
298
+ let pos = nodeIndex;
299
+ for (let l = level; l > 0; l--) pos = indices[pos >> 2];
300
+ const leafEnd = Math.min(pos + (end - nodeIndex) * this.nodeSize ** level, numItems4);
301
+ if (filterFn === undefined) {
302
+ for (; pos < leafEnd; pos += 4) results.push(indices[pos >> 2] | 0);
303
+ } else {
304
+ for (; pos < leafEnd; pos += 4) {
305
+ const index = indices[pos >> 2] | 0;
306
+ if (filterFn(index, boxes[pos], boxes[pos + 1], boxes[pos + 2], boxes[pos + 3])) results.push(index);
307
+ }
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Check whether any item intersects or touches a bounding box, stopping at the first match.
313
+ * @param {number} minX
314
+ * @param {number} minY
315
+ * @param {number} maxX
316
+ * @param {number} maxY
317
+ * @param {(index: number, x0: number, y0: number, x1: number, y1: number) => boolean} [filterFn] An optional function that is called on found items; if supplied, only items for which this function returns true count as a match.
318
+ * @returns {boolean} Whether a matching item was found.
319
+ */
320
+ collides(minX, minY, maxX, maxY, filterFn) {
321
+ if (this._pos !== this._boxes.length) {
322
+ throw new Error('Data not yet indexed - call index.finish().');
323
+ }
324
+ const {_boxes: boxes, _levelBounds: levelBounds, _indices: indices, nodeSize} = this;
325
+ const numItems4 = this.numItems * 4;
326
+ /** @type number | undefined */
327
+ let nodeIndex = boxes.length - 4;
328
+ let level = levelBounds.length - 1; // start at the root level
329
+ const q = [];
330
+
331
+ while (nodeIndex !== undefined) {
332
+ const end = Math.min(nodeIndex + nodeSize * 4, levelBounds[level]);
333
+ const isNode = nodeIndex >= numItems4;
334
+ for (let /** @type {number} */ pos = nodeIndex; pos < end; pos += 4) {
335
+ const x0 = boxes[pos];
336
+ if (maxX < x0) continue;
337
+ const y0 = boxes[pos + 1];
338
+ if (maxY < y0) continue;
339
+ const x1 = boxes[pos + 2];
340
+ if (minX > x1) continue;
341
+ const y1 = boxes[pos + 3];
342
+ if (minY > y1) continue;
343
+ const index = indices[pos >> 2] | 0;
344
+ if (isNode) {
345
+ q.push(index, level - 1);
346
+ } else if (filterFn === undefined || filterFn(index, x0, y0, x1, y1)) {
347
+ return true;
348
+ }
349
+ }
350
+ level = /** @type {number} */ (q.pop());
351
+ nodeIndex = q.pop();
352
+ }
353
+ return false;
354
+ }
355
+
356
+ /**
357
+ * Search items in order of distance from the given point.
358
+ * @param {number} x
359
+ * @param {number} y
360
+ * @param {number} [maxResults=Infinity]
361
+ * @param {number} [maxDistance=Infinity]
362
+ * @param {(index: number) => boolean} [filterFn] An optional function for filtering the results.
363
+ * @returns {number[]} An array of indices of items found.
364
+ */
365
+ neighbors(x, y, maxResults = Infinity, maxDistance = Infinity, filterFn) {
366
+ if (this._pos !== this._boxes.length) {
367
+ throw new Error('Data not yet indexed - call index.finish().');
368
+ }
369
+ const {_boxes: boxes, _levelBounds: levelBounds, _indices: indices, _queue: q, nodeSize} = this;
370
+ const numItems4 = this.numItems * 4;
371
+ const nodeSize4 = nodeSize * 4;
372
+ const results = [];
373
+ const maxDistSquared = maxDistance * maxDistance;
374
+
375
+ // For a single nearest neighbor (maxResults === 1), track the closest leaf seen so far and use
376
+ // it as a tightened distance bound, skipping pushes of nodes/leaves that can't beat it
377
+ const trackNearest = maxResults === 1;
378
+ let bound = maxDistSquared;
379
+
380
+ // Tree nodes and leaves share the queue; encode leaves with LSB = 1 so we can tell them
381
+ // apart with `& 1`. Seed with the root node — any priority works since the queue is empty.
382
+ q.push((boxes.length - 4) << 1, 0);
383
+
384
+ while (q.length) {
385
+ const top = q.ids[0];
386
+ // if the closest queued entry is a leaf, it's the next result in distance order
387
+ if (top & 1) {
388
+ q.pop();
389
+ results.push(top >> 1);
390
+ if (results.length === maxResults) break;
391
+ continue;
392
+ }
393
+
394
+ q.pop();
395
+ const nodeIndex = top >> 1;
396
+ const isLeafLevel = nodeIndex < numItems4;
397
+ const end = Math.min(nodeIndex + nodeSize4, upperBound(nodeIndex, levelBounds));
398
+
399
+ for (let pos = nodeIndex; pos < end; pos += 4) {
400
+ const minX = boxes[pos];
401
+ const minY = boxes[pos + 1];
402
+ const maxX = boxes[pos + 2];
403
+ const maxY = boxes[pos + 3];
404
+ const dx = Math.max(Math.max(minX - x, x - maxX), 0);
405
+ const dy = Math.max(Math.max(minY - y, y - maxY), 0);
406
+ const dist = dx * dx + dy * dy;
407
+ if (dist > bound) continue;
408
+
409
+ const childIndex = indices[pos >> 2] | 0;
410
+ if (isLeafLevel) {
411
+ if (filterFn === undefined || filterFn(childIndex)) {
412
+ q.push((childIndex << 1) | 1, dist); // leaf item (odd id)
413
+ if (trackNearest && dist < bound) bound = dist; // tighten bound to the closest leaf so far
414
+ }
415
+ } else {
416
+ q.push(childIndex << 1, dist); // node (even id)
417
+ }
418
+ }
419
+ }
420
+
421
+ q.clear();
422
+ return results;
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Binary search for the first value in the array bigger than the given.
428
+ * @param {number} value
429
+ * @param {number[]} arr
430
+ */
431
+ function upperBound(value, arr) {
432
+ let i = 0;
433
+ let j = arr.length - 1;
434
+ while (i < j) {
435
+ const m = (i + j) >> 1;
436
+ if (arr[m] > value) {
437
+ j = m;
438
+ } else {
439
+ i = m + 1;
440
+ }
441
+ }
442
+ return arr[i];
443
+ }
444
+
445
+ /**
446
+ * Custom quicksort that partially sorts bbox data alongside the hilbert values.
447
+ * @param {Int32Array} values
448
+ * @param {TypedArray} boxes
449
+ * @param {Uint16Array | Uint32Array} indices
450
+ * @param {number} left
451
+ * @param {number} right
452
+ * @param {number} nodeSize
453
+ */
454
+ function sort(values, boxes, indices, left, right, nodeSize) {
455
+ const stack = [left, right];
456
+
457
+ while (stack.length) {
458
+ const r = stack.pop() || 0;
459
+ const l = stack.pop() || 0;
460
+
461
+ if (r - l <= nodeSize && Math.floor(l / nodeSize) >= Math.floor(r / nodeSize)) continue;
462
+
463
+ const a = values[l];
464
+ const b = values[(l + r) >> 1];
465
+ const c = values[r];
466
+ const pivot = ((a > b) !== (a > c)) ? a :
467
+ ((b < a) !== (b < c)) ? b : c;
468
+
469
+ let i = l - 1;
470
+ let j = r + 1;
471
+
472
+ while (true) {
473
+ do i++; while (values[i] < pivot);
474
+ do j--; while (values[j] > pivot);
475
+ if (i >= j) break;
476
+ swap(values, boxes, indices, i, j);
477
+ }
478
+
479
+ stack.push(l, j, j + 1, r);
480
+ }
481
+ }
482
+
483
+ /**
484
+ * Swap two values and two corresponding boxes.
485
+ * @param {Int32Array} values
486
+ * @param {TypedArray} boxes
487
+ * @param {Uint16Array | Uint32Array} indices
488
+ * @param {number} i
489
+ * @param {number} j
490
+ */
491
+ function swap(values, boxes, indices, i, j) {
492
+ const temp = values[i];
493
+ values[i] = values[j];
494
+ values[j] = temp;
495
+
496
+ const k = 4 * i;
497
+ const m = 4 * j;
498
+
499
+ const a = boxes[k];
500
+ const b = boxes[k + 1];
501
+ const c = boxes[k + 2];
502
+ const d = boxes[k + 3];
503
+ boxes[k] = boxes[m];
504
+ boxes[k + 1] = boxes[m + 1];
505
+ boxes[k + 2] = boxes[m + 2];
506
+ boxes[k + 3] = boxes[m + 3];
507
+ boxes[m] = a;
508
+ boxes[m + 1] = b;
509
+ boxes[m + 2] = c;
510
+ boxes[m + 3] = d;
511
+
512
+ const e = indices[i];
513
+ indices[i] = indices[j];
514
+ indices[j] = e;
515
+ }
516
+
517
+ /**
518
+ * Fast Hilbert curve algorithm by http://threadlocalmutex.com/
519
+ * Ported from C++ https://github.com/rawrunprotected/hilbert_curves (public domain)
520
+ * @param {number} x
521
+ * @param {number} y
522
+ */
523
+ function hilbert(x, y) {
524
+ let a = x ^ y;
525
+ let b = 0xFFFF ^ a;
526
+ let c = 0xFFFF ^ (x | y);
527
+ let d = x & (y ^ 0xFFFF);
528
+
529
+ let A = a | (b >> 1);
530
+ let B = (a >> 1) ^ a;
531
+ let C = c ^ ((c >> 1) ^ (b & (d >> 1)));
532
+ let D = d ^ ((a & (c >> 1)) ^ (d >> 1));
533
+
534
+ a = (A & (A >> 2)) ^ (B & (B >> 2));
535
+ b = (A & (B >> 2)) ^ (B & ((A ^ B) >> 2));
536
+ c = C ^ ((A & (C >> 2)) ^ (B & (D >> 2)));
537
+ d = D ^ ((B & (C >> 2)) ^ ((A ^ B) & (D >> 2)));
538
+
539
+ A = (a & (a >> 4)) ^ (b & (b >> 4));
540
+ B = (a & (b >> 4)) ^ (b & ((a ^ b) >> 4));
541
+ C = c ^ ((a & (c >> 4)) ^ (b & (d >> 4)));
542
+ D = d ^ ((b & (c >> 4)) ^ ((a ^ b) & (d >> 4)));
543
+
544
+ c = C ^ ((A & (C >> 8)) ^ (B & (D >> 8)));
545
+ d = D ^ ((B & (C >> 8)) ^ ((A ^ B) & (D >> 8)));
546
+
547
+ c ^= c >> 1;
548
+ d ^= d >> 1;
549
+ a = x ^ y;
550
+ b = d | (0xFFFF ^ (a | c));
551
+
552
+ a = (a | (a << 8)) & 0x00FF00FF;
553
+ a = (a | (a << 4)) & 0x0F0F0F0F;
554
+ a = (a | (a << 2)) & 0x33333333;
555
+ a = (a | (a << 1)) & 0x55555555;
556
+
557
+ b = (b | (b << 8)) & 0x00FF00FF;
558
+ b = (b | (b << 4)) & 0x0F0F0F0F;
559
+ b = (b | (b << 2)) & 0x33333333;
560
+ b = (b | (b << 1)) & 0x55555555;
561
+
562
+ // shift into signed SMI range for performance
563
+ return (((b << 1) | a) >>> 0) - 0x80000000;
564
+ }
bench/vendor/flatqueue.LICENSE ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ISC License
2
+
3
+ Copyright (c) 2025, Volodymyr Agafonkin
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose
6
+ with or without fee is hereby granted, provided that the above copyright notice
7
+ and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
13
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
15
+ THIS SOFTWARE.
bench/vendor/flatqueue.js ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
4
+ * Uint32ArrayConstructor | Int32ArrayConstructor | Uint16ArrayConstructor |
5
+ * Int16ArrayConstructor | Uint8ArrayConstructor | Int8ArrayConstructor} TypedArrayConstructor
6
+ */
7
+
8
+ /** @template [T=number] */
9
+ export default class FlatQueue {
10
+
11
+ /**
12
+ * Creates an empty queue. If `capacity` is provided, the queue is backed by fixed-size typed
13
+ * arrays for better performance and memory use, but can't grow beyond `capacity`. `values` uses
14
+ * `ValuesArray` (default `Float64Array`) and `ids` uses `IdsArray` (default `Uint32Array`); pass
15
+ * narrower constructors like `Uint16Array` if your values or ids are known to fit them.
16
+ *
17
+ * @param {number} [capacity]
18
+ * @param {TypedArrayConstructor} [ValuesArray]
19
+ * @param {TypedArrayConstructor} [IdsArray]
20
+ */
21
+ constructor(capacity = Infinity, ValuesArray = Float64Array, IdsArray = Uint32Array) {
22
+ const fixed = capacity !== Infinity;
23
+
24
+ /** @type {T[]} */
25
+ this.ids = fixed ? /** @type {T[]} */ (/** @type {unknown} */ (new IdsArray(capacity))) : [];
26
+
27
+ /** @type {number[]} */
28
+ this.values = fixed ? /** @type {number[]} */ (/** @type {unknown} */ (new ValuesArray(capacity))) : [];
29
+
30
+ /** Maximum number of items the queue can hold; `Infinity` for regular-array queues, which grow on demand. */
31
+ this.capacity = capacity;
32
+
33
+ /** Number of items in the queue. */
34
+ this.length = 0;
35
+ }
36
+
37
+ /** Removes all items from the queue. */
38
+ clear() {
39
+ this.length = 0;
40
+ }
41
+
42
+ /**
43
+ * Adds `item` to the queue with the specified `priority`.
44
+ *
45
+ * `priority` must be a number. Items are sorted and returned from low to high priority. Multiple items
46
+ * with the same priority value can be added to the queue, but there is no guaranteed order between these items.
47
+ *
48
+ * For fixed-capacity queues, throws a `RangeError` if the queue is already full.
49
+ *
50
+ * @param {T} item
51
+ * @param {number} priority
52
+ */
53
+ push(item, priority) {
54
+ if (this.length === this.capacity) throw new RangeError('Queue is at capacity.');
55
+
56
+ let pos = this.length++;
57
+
58
+ while (pos > 0) {
59
+ const parent = (pos - 1) >> 1;
60
+ const parentValue = this.values[parent];
61
+ if (priority >= parentValue) break;
62
+ this.ids[pos] = this.ids[parent];
63
+ this.values[pos] = parentValue;
64
+ pos = parent;
65
+ }
66
+
67
+ this.ids[pos] = item;
68
+ this.values[pos] = priority;
69
+ }
70
+
71
+ /**
72
+ * Removes and returns the item from the head of this queue, which is one of
73
+ * the items with the lowest priority. If this queue is empty, returns `undefined`.
74
+ */
75
+ pop() {
76
+ if (this.length === 0) return undefined;
77
+
78
+ const ids = this.ids,
79
+ values = this.values,
80
+ top = ids[0],
81
+ last = --this.length;
82
+
83
+ if (last > 0) {
84
+ const id = ids[last];
85
+ const value = values[last];
86
+ let pos = 0;
87
+ const halfLen = last >> 1;
88
+
89
+ while (pos < halfLen) {
90
+ const left = (pos << 1) + 1;
91
+ const right = left + 1;
92
+ const child = left + (+(right < last) & +(values[right] < values[left]));
93
+ if (values[child] >= value) break;
94
+ ids[pos] = ids[child];
95
+ values[pos] = values[child];
96
+ pos = child;
97
+ }
98
+
99
+ ids[pos] = id;
100
+ values[pos] = value;
101
+ }
102
+
103
+ return top;
104
+ }
105
+
106
+ /** Returns the item from the head of this queue without removing it. If this queue is empty, returns `undefined`. */
107
+ peek() {
108
+ return this.length > 0 ? this.ids[0] : undefined;
109
+ }
110
+
111
+ /**
112
+ * Returns the priority value of the item at the head of this queue without
113
+ * removing it. If this queue is empty, returns `undefined`.
114
+ */
115
+ peekValue() {
116
+ return this.length > 0 ? this.values[0] : undefined;
117
+ }
118
+
119
+ /**
120
+ * Shrinks the internal arrays to `this.length`. No-op for queues with fixed capacity.
121
+ *
122
+ * `pop()` and `clear()` calls don't free memory automatically to avoid unnecessary resize operations.
123
+ * This also means that items that have been added to the queue can't be garbage collected until
124
+ * a new item is pushed in their place, or this method is called.
125
+ */
126
+ shrink() {
127
+ if (Array.isArray(this.ids)) this.ids.length = this.length;
128
+ if (Array.isArray(this.values)) this.values.length = this.length;
129
+ }
130
+ }
bench/wide-100k.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "formatVersion": 1,
3
+ "timestamp": "2026-11-22T20:22:58.067Z",
4
+ "node": "v24.22.3",
5
+ "cpu": "AMD EPYC 9V74 80-Core Processor",
6
+ "platform": "linux",
7
+ "arch": "x64",
8
+ "config": {
9
+ "boxes": 100000,
10
+ "steps": 2048,
11
+ "repeats": 5,
12
+ "scenario": "wide-local",
13
+ "seed": 270113
14
+ },
15
+ "blockSize": 64,
16
+ "flatbushVersion": "4.7.0",
17
+ "scenarios": [
18
+ {
19
+ "name": "wide-local",
20
+ "updates": 2048,
21
+ "agents": 16,
22
+ "events": 84551,
23
+ "meanStartMembers": 12211.6875,
24
+ "bounds": [
25
+ 0,
26
+ 0,
27
+ 1,
28
+ 1
29
+ ],
30
+ "boxDimensionsAsFractionOfBounds": [
31
+ 0.15,
32
+ 0.55
33
+ ],
34
+ "timings": {
35
+ "edgechime": {
36
+ "buildMs": 210.02586200000002,
37
+ "runnerSetupMs": [
38
+ 0.0029940000003989553,
39
+ 0.0027840000002470333,
40
+ 0.0030450000003838795,
41
+ 0.003224999999474676,
42
+ 0.0026740000012068776
43
+ ],
44
+ "meanUsPerUpdateSamples": [
45
+ 4.660038574219261,
46
+ 4.840894042966948,
47
+ 6.231734374999576,
48
+ 3.7466347656245347,
49
+ 3.863321777343387
50
+ ],
51
+ "medianMeanUsPerUpdate": 4.660038574219261,
52
+ "p95BlockMeanUsPerUpdate": 7.644937499989624
53
+ },
54
+ "flatbush": {
55
+ "buildMs": 47.50476599999996,
56
+ "runnerSetupMs": [
57
+ 14.300482999999986,
58
+ 11.02017799999976,
59
+ 15.487773000000743,
60
+ 8.754579999999805,
61
+ 13.595287999998618
62
+ ],
63
+ "meanUsPerUpdateSamples": [
64
+ 535.747411621092,
65
+ 468.8203715820305,
66
+ 593.8522915039064,
67
+ 619.7689150390602,
68
+ 509.07165283203074
69
+ ],
70
+ "medianMeanUsPerUpdate": 535.747411621092,
71
+ "p95BlockMeanUsPerUpdate": 758.2562031250006
72
+ },
73
+ "perimeterGrid": {
74
+ "buildMs": 478.490016,
75
+ "runnerSetupMs": [
76
+ 0.0031449999996766564,
77
+ 0.0033750000002328306,
78
+ 0.006478999999671942,
79
+ 0.00345500000003085,
80
+ 0.00414699999964796
81
+ ],
82
+ "meanUsPerUpdateSamples": [
83
+ 36.48445019531232,
84
+ 53.839995605469596,
85
+ 48.57788037109323,
86
+ 50.50202148437233,
87
+ 35.19372509765617
88
+ ],
89
+ "medianMeanUsPerUpdate": 48.57788037109323,
90
+ "p95BlockMeanUsPerUpdate": 75.8981562500054,
91
+ "gridSide": 141,
92
+ "gridPostings": 12771186
93
+ }
94
+ }
95
+ }
96
+ ]
97
+ }
bin/edgechime.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+ import { once } from 'node:events';
4
+ import { createInterface } from 'node:readline';
5
+ import { EdgeChime } from '../index.js';
6
+
7
+ const help = `Usage: edgechime BOXES.json < positions.ndjson
8
+ BOXES.json contains [minX,minY,maxX,maxY] arrays in zone ID order.
9
+ Each input line is {"agent":"id","x":2,"y":3} or {"agent":"id","forget":true}.
10
+ Output has agent, entered and exited fields, only when a membership changes.
11
+ The first sample enters all matching zones. Forget emits exits and removes the agent.
12
+ `;
13
+
14
+ async function run() {
15
+ const args = process.argv.slice(2);
16
+ if (args.length === 1 && ['-h', '--help'].includes(args[0])) {
17
+ process.stdout.write(help);
18
+ return;
19
+ }
20
+ if (args.length !== 1) throw new Error(help.trimEnd());
21
+ const index = new EdgeChime(JSON.parse(await readFile(args[0], 'utf8')));
22
+ const positions = new Map();
23
+ let lineNumber = 0;
24
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
25
+ try {
26
+ for await (const line of lines) {
27
+ ++lineNumber;
28
+ if (!line.trim()) continue;
29
+ const record = JSON.parse(line);
30
+ if (!record || typeof record.agent !== 'string' || !record.agent.length) {
31
+ throw new Error('agent must be a nonempty string');
32
+ }
33
+ const { agent, x, y } = record;
34
+ const previous = positions.get(agent);
35
+ const entered = [];
36
+ const exited = [];
37
+ if (record.forget === true) {
38
+ if (x !== undefined || y !== undefined) throw new Error('forget cannot include coordinates');
39
+ if (previous) {
40
+ index.at(previous[0], previous[1], id => exited.push(id));
41
+ positions.delete(agent);
42
+ }
43
+ } else {
44
+ if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error('expected finite x and y');
45
+ if (previous) {
46
+ index.move(previous[0], previous[1], x, y, (id, inside) => {
47
+ (inside ? entered : exited).push(id);
48
+ });
49
+ } else {
50
+ index.at(x, y, id => entered.push(id));
51
+ }
52
+ positions.set(agent, [x, y]);
53
+ }
54
+ if (entered.length || exited.length) {
55
+ const ready = process.stdout.write(JSON.stringify({ agent, entered, exited }) + '\n');
56
+ if (!ready) await once(process.stdout, 'drain');
57
+ }
58
+ }
59
+ } catch (error) {
60
+ throw new Error(`input line ${lineNumber}: ${error.message}`);
61
+ } finally {
62
+ lines.close();
63
+ }
64
+ }
65
+
66
+ run().catch(error => {
67
+ process.stderr.write(`edgechime: ${error.message}\n`);
68
+ process.exitCode = 1;
69
+ process.stdin.destroy();
70
+ });
edgechime-0.1.0.tgz ADDED
Binary file (9.45 kB). View file
 
examples/sumo/EPL-2.0.txt ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Eclipse Public License - v 2.0
2
+
3
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
5
+ OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6
+
7
+ 1. DEFINITIONS
8
+
9
+ "Contribution" means:
10
+
11
+ a) in the case of the initial Contributor, the initial content
12
+ Distributed under this Agreement, and
13
+
14
+ b) in the case of each subsequent Contributor:
15
+ i) changes to the Program, and
16
+ ii) additions to the Program;
17
+ where such changes and/or additions to the Program originate from
18
+ and are Distributed by that particular Contributor. A Contribution
19
+ "originates" from a Contributor if it was added to the Program by
20
+ such Contributor itself or anyone acting on such Contributor's behalf.
21
+ Contributions do not include changes or additions to the Program that
22
+ are not Modified Works.
23
+
24
+ "Contributor" means any person or entity that Distributes the Program.
25
+
26
+ "Licensed Patents" mean patent claims licensable by a Contributor which
27
+ are necessarily infringed by the use or sale of its Contribution alone
28
+ or when combined with the Program.
29
+
30
+ "Program" means the Contributions Distributed in accordance with this
31
+ Agreement.
32
+
33
+ "Recipient" means anyone who receives the Program under this Agreement
34
+ or any Secondary License (as applicable), including Contributors.
35
+
36
+ "Derivative Works" shall mean any work, whether in Source Code or other
37
+ form, that is based on (or derived from) the Program and for which the
38
+ editorial revisions, annotations, elaborations, or other modifications
39
+ represent, as a whole, an original work of authorship.
40
+
41
+ "Modified Works" shall mean any work in Source Code or other form that
42
+ results from an addition to, deletion from, or modification of the
43
+ contents of the Program, including, for purposes of clarity any new file
44
+ in Source Code form that contains any contents of the Program. Modified
45
+ Works shall not include works that contain only declarations,
46
+ interfaces, types, classes, structures, or files of the Program solely
47
+ in each case in order to link to, bind by name, or subclass the Program
48
+ or Modified Works thereof.
49
+
50
+ "Distribute" means the acts of a) distributing or b) making available
51
+ in any manner that enables the transfer of a copy.
52
+
53
+ "Source Code" means the form of a Program preferred for making
54
+ modifications, including but not limited to software source code,
55
+ documentation source, and configuration files.
56
+
57
+ "Secondary License" means either the GNU General Public License,
58
+ Version 2.0, or any later versions of that license, including any
59
+ exceptions or additional permissions as identified by the initial
60
+ Contributor.
61
+
62
+ 2. GRANT OF RIGHTS
63
+
64
+ a) Subject to the terms of this Agreement, each Contributor hereby
65
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
66
+ license to reproduce, prepare Derivative Works of, publicly display,
67
+ publicly perform, Distribute and sublicense the Contribution of such
68
+ Contributor, if any, and such Derivative Works.
69
+
70
+ b) Subject to the terms of this Agreement, each Contributor hereby
71
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
72
+ license under Licensed Patents to make, use, sell, offer to sell,
73
+ import and otherwise transfer the Contribution of such Contributor,
74
+ if any, in Source Code or other form. This patent license shall
75
+ apply to the combination of the Contribution and the Program if, at
76
+ the time the Contribution is added by the Contributor, such addition
77
+ of the Contribution causes such combination to be covered by the
78
+ Licensed Patents. The patent license shall not apply to any other
79
+ combinations which include the Contribution. No hardware per se is
80
+ licensed hereunder.
81
+
82
+ c) Recipient understands that although each Contributor grants the
83
+ licenses to its Contributions set forth herein, no assurances are
84
+ provided by any Contributor that the Program does not infringe the
85
+ patent or other intellectual property rights of any other entity.
86
+ Each Contributor disclaims any liability to Recipient for claims
87
+ brought by any other entity based on infringement of intellectual
88
+ property rights or otherwise. As a condition to exercising the
89
+ rights and licenses granted hereunder, each Recipient hereby
90
+ assumes sole responsibility to secure any other intellectual
91
+ property rights needed, if any. For example, if a third party
92
+ patent license is required to allow Recipient to Distribute the
93
+ Program, it is Recipient's responsibility to acquire that license
94
+ before distributing the Program.
95
+
96
+ d) Each Contributor represents that to its knowledge it has
97
+ sufficient copyright rights in its Contribution, if any, to grant
98
+ the copyright license set forth in this Agreement.
99
+
100
+ e) Notwithstanding the terms of any Secondary License, no
101
+ Contributor makes additional grants to any Recipient (other than
102
+ those set forth in this Agreement) as a result of such Recipient's
103
+ receipt of the Program under the terms of a Secondary License
104
+ (if permitted under the terms of Section 3).
105
+
106
+ 3. REQUIREMENTS
107
+
108
+ 3.1 If a Contributor Distributes the Program in any form, then:
109
+
110
+ a) the Program must also be made available as Source Code, in
111
+ accordance with section 3.2, and the Contributor must accompany
112
+ the Program with a statement that the Source Code for the Program
113
+ is available under this Agreement, and informs Recipients how to
114
+ obtain it in a reasonable manner on or through a medium customarily
115
+ used for software exchange; and
116
+
117
+ b) the Contributor may Distribute the Program under a license
118
+ different than this Agreement, provided that such license:
119
+ i) effectively disclaims on behalf of all other Contributors all
120
+ warranties and conditions, express and implied, including
121
+ warranties or conditions of title and non-infringement, and
122
+ implied warranties or conditions of merchantability and fitness
123
+ for a particular purpose;
124
+
125
+ ii) effectively excludes on behalf of all other Contributors all
126
+ liability for damages, including direct, indirect, special,
127
+ incidental and consequential damages, such as lost profits;
128
+
129
+ iii) does not attempt to limit or alter the recipients' rights
130
+ in the Source Code under section 3.2; and
131
+
132
+ iv) requires any subsequent distribution of the Program by any
133
+ party to be under a license that satisfies the requirements
134
+ of this section 3.
135
+
136
+ 3.2 When the Program is Distributed as Source Code:
137
+
138
+ a) it must be made available under this Agreement, or if the
139
+ Program (i) is combined with other material in a separate file or
140
+ files made available under a Secondary License, and (ii) the initial
141
+ Contributor attached to the Source Code the notice described in
142
+ Exhibit A of this Agreement, then the Program may be made available
143
+ under the terms of such Secondary Licenses, and
144
+
145
+ b) a copy of this Agreement must be included with each copy of
146
+ the Program.
147
+
148
+ 3.3 Contributors may not remove or alter any copyright, patent,
149
+ trademark, attribution notices, disclaimers of warranty, or limitations
150
+ of liability ("notices") contained within the Program from any copy of
151
+ the Program which they Distribute, provided that Contributors may add
152
+ their own appropriate notices.
153
+
154
+ 4. COMMERCIAL DISTRIBUTION
155
+
156
+ Commercial distributors of software may accept certain responsibilities
157
+ with respect to end users, business partners and the like. While this
158
+ license is intended to facilitate the commercial use of the Program,
159
+ the Contributor who includes the Program in a commercial product
160
+ offering should do so in a manner which does not create potential
161
+ liability for other Contributors. Therefore, if a Contributor includes
162
+ the Program in a commercial product offering, such Contributor
163
+ ("Commercial Contributor") hereby agrees to defend and indemnify every
164
+ other Contributor ("Indemnified Contributor") against any losses,
165
+ damages and costs (collectively "Losses") arising from claims, lawsuits
166
+ and other legal actions brought by a third party against the Indemnified
167
+ Contributor to the extent caused by the acts or omissions of such
168
+ Commercial Contributor in connection with its distribution of the Program
169
+ in a commercial product offering. The obligations in this section do not
170
+ apply to any claims or Losses relating to any actual or alleged
171
+ intellectual property infringement. In order to qualify, an Indemnified
172
+ Contributor must: a) promptly notify the Commercial Contributor in
173
+ writing of such claim, and b) allow the Commercial Contributor to control,
174
+ and cooperate with the Commercial Contributor in, the defense and any
175
+ related settlement negotiations. The Indemnified Contributor may
176
+ participate in any such claim at its own expense.
177
+
178
+ For example, a Contributor might include the Program in a commercial
179
+ product offering, Product X. That Contributor is then a Commercial
180
+ Contributor. If that Commercial Contributor then makes performance
181
+ claims, or offers warranties related to Product X, those performance
182
+ claims and warranties are such Commercial Contributor's responsibility
183
+ alone. Under this section, the Commercial Contributor would have to
184
+ defend claims against the other Contributors related to those performance
185
+ claims and warranties, and if a court requires any other Contributor to
186
+ pay any damages as a result, the Commercial Contributor must pay
187
+ those damages.
188
+
189
+ 5. NO WARRANTY
190
+
191
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
192
+ PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
193
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
194
+ IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
195
+ TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
196
+ PURPOSE. Each Recipient is solely responsible for determining the
197
+ appropriateness of using and distributing the Program and assumes all
198
+ risks associated with its exercise of rights under this Agreement,
199
+ including but not limited to the risks and costs of program errors,
200
+ compliance with applicable laws, damage to or loss of data, programs
201
+ or equipment, and unavailability or interruption of operations.
202
+
203
+ 6. DISCLAIMER OF LIABILITY
204
+
205
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
206
+ PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
207
+ SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
208
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
209
+ PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
210
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
211
+ ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
212
+ EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
213
+ POSSIBILITY OF SUCH DAMAGES.
214
+
215
+ 7. GENERAL
216
+
217
+ If any provision of this Agreement is invalid or unenforceable under
218
+ applicable law, it shall not affect the validity or enforceability of
219
+ the remainder of the terms of this Agreement, and without further
220
+ action by the parties hereto, such provision shall be reformed to the
221
+ minimum extent necessary to make such provision valid and enforceable.
222
+
223
+ If Recipient institutes patent litigation against any entity
224
+ (including a cross-claim or counterclaim in a lawsuit) alleging that the
225
+ Program itself (excluding combinations of the Program with other software
226
+ or hardware) infringes such Recipient's patent(s), then such Recipient's
227
+ rights granted under Section 2(b) shall terminate as of the date such
228
+ litigation is filed.
229
+
230
+ All Recipient's rights under this Agreement shall terminate if it
231
+ fails to comply with any of the material terms or conditions of this
232
+ Agreement and does not cure such failure in a reasonable period of
233
+ time after becoming aware of such noncompliance. If all Recipient's
234
+ rights under this Agreement terminate, Recipient agrees to cease use
235
+ and distribution of the Program as soon as reasonably practicable.
236
+ However, Recipient's obligations under this Agreement and any licenses
237
+ granted by Recipient relating to the Program shall continue and survive.
238
+
239
+ Everyone is permitted to copy and distribute copies of this Agreement,
240
+ but in order to avoid inconsistency the Agreement is copyrighted and
241
+ may only be modified in the following manner. The Agreement Steward
242
+ reserves the right to publish new versions (including revisions) of
243
+ this Agreement from time to time. No one other than the Agreement
244
+ Steward has the right to modify this Agreement. The Eclipse Foundation
245
+ is the initial Agreement Steward. The Eclipse Foundation may assign the
246
+ responsibility to serve as the Agreement Steward to a suitable separate
247
+ entity. Each new version of the Agreement will be given a distinguishing
248
+ version number. The Program (including Contributions) may always be
249
+ Distributed subject to the version of the Agreement under which it was
250
+ received. In addition, after a new version of the Agreement is published,
251
+ Contributor may elect to Distribute the Program (including its
252
+ Contributions) under the new version.
253
+
254
+ Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
255
+ receives no rights or licenses to the intellectual property of any
256
+ Contributor under this Agreement, whether expressly, by implication,
257
+ estoppel or otherwise. All rights in the Program not expressly granted
258
+ under this Agreement are reserved. Nothing in this Agreement is intended
259
+ to be enforceable by any entity that is not a Contributor or Recipient.
260
+ No third-party beneficiary rights are created under this Agreement.
261
+
262
+ Exhibit A - Form of Secondary Licenses Notice
263
+
264
+ "This Source Code may also be made available under the following
265
+ Secondary Licenses when the conditions for such availability set forth
266
+ in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
267
+ version(s), and exceptions or additional permissions here}."
268
+
269
+ Simply including a copy of this Agreement, including this Exhibit A
270
+ is not sufficient to license the Source Code under Secondary Licenses.
271
+
272
+ If it is not possible or desirable to put the notice in a particular
273
+ file, then You may include the notice in a location (such as a LICENSE
274
+ file in a relevant directory) where a recipient would be likely to
275
+ look for such a notice.
276
+
277
+ You may add additional accurate notices of copyright ownership.
examples/sumo/README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Replay SUMO vehicle positions through EdgeChime
2
+
3
+ Run these commands from the EdgeChime repository root with Python 3.8+ and Node.js 18+. The included floating-car-data (FCD) recording contains 117 positions from two simulated vehicles. Two adjoining zones cover a portion of their route.
4
+
5
+ ```sh
6
+ python3 examples/sumo/fcd.py examples/sumo/shape-filter.fcd.xml \
7
+ | node bin/edgechime.js examples/sumo/zones.json
8
+ ```
9
+
10
+ Both vehicles enter zone 0, move into zone 1, and leave it. Each ID is the original SUMO string ID.
11
+
12
+ ```jsonl
13
+ {"agent":"0","entered":[0],"exited":[]}
14
+ {"agent":"1","entered":[0],"exited":[]}
15
+ {"agent":"0","entered":[1],"exited":[0]}
16
+ {"agent":"1","entered":[1],"exited":[0]}
17
+ {"agent":"0","entered":[],"exited":[1]}
18
+ {"agent":"1","entered":[],"exited":[1]}
19
+ ```
20
+
21
+ ## Connect a running simulation
22
+
23
+ On Unix, use a named pipe to keep SUMO's normal console output separate from the FCD stream. Supply your own simulation configuration and rectangles in the simulation's coordinate system.
24
+
25
+ ```sh
26
+ stream_dir=$(mktemp -d)
27
+ mkfifo "$stream_dir/live.xml"
28
+ sumo -c your-network.sumocfg --fcd-output "$stream_dir/live.xml" &
29
+ python3 examples/sumo/fcd.py "$stream_dir/live.xml" | node bin/edgechime.js your-zones.json
30
+ wait
31
+ rm -r "$stream_dir"
32
+ ```
33
+
34
+ The adapter also accepts XML from standard input and saved `.xml.gz` files. Each vehicle produces one line with a string `agent` and numeric `x`, `y`, and `time` fields. The adapter passes through positions at the center of the front bumper and annotates them with their enclosing timestep in simulation seconds. SUMO normally writes Cartesian meters. With `--fcd-output.geo`, use longitude for x and latitude for y. The CLI consumes the stream in input order and outputs agent IDs and zone changes. Consumers needing simulation timestamps can read the adapter's position stream. [SUMO FCD format and options](https://sumo.dlr.de/docs/Simulation/Output/FCDOutput.html)
35
+
36
+ Each record is available as soon as its XML start tag arrives and the current input chunk has been parsed. The parser keeps a fixed-size input buffer and the current XML element stack. File replay runs as quickly as the consumer can read. Vehicle records are processed independently of person or container records.
37
+
38
+ SUMO can filter positions by location, equipment, or sampling period. An omitted vehicle generates no event. When it appears again, EdgeChime compares with its last observation. Likewise, an empty timestep or end of file leaves its last observed state intact. To retire a vehicle when an external lifecycle feed confirms its departure, insert `{"agent":"0","forget":true}` into the CLI input. That emits exits for its active zones and releases its state. The CLI retains one last position per distinct ID until a forget record or process exit.
39
+
40
+ ## Fixture provenance
41
+
42
+ `shape-filter.fcd.xml` is the unmodified `shape_filter/fcd.sumo` fixture from Eclipse SUMO tag `v1_24_0` (Git blob `71b67ec9668ee246c5fa46a9ea68c37bf7d61323`). Its own license notice applies. The Eclipse Public License 2.0 accompanies the fixture. The zones and adapter are part of EdgeChime. [Upstream fixture](https://github.com/eclipse-sumo/sumo/blob/v1_24_0/tests/sumo/output/fcd-output/shape_filter/fcd.sumo) · [Eclipse Public License 2.0](EPL-2.0.txt)
examples/sumo/fcd.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Stream SUMO Floating Car Data XML to EdgeChime position records."""
3
+
4
+ import argparse
5
+ import gzip
6
+ import json
7
+ import math
8
+ import sys
9
+ from contextlib import nullcontext
10
+ from xml.parsers import expat
11
+
12
+
13
+ def convert(source, destination):
14
+ parser = expat.ParserCreate()
15
+ stack = []
16
+ time = None
17
+
18
+ def fail(message):
19
+ raise ValueError(f"line {parser.CurrentLineNumber}: {message}")
20
+
21
+ def number(attrs, name, context):
22
+ try:
23
+ value = float(attrs[name])
24
+ except (KeyError, ValueError):
25
+ fail(f"{context}: expected numeric {name}")
26
+ if not math.isfinite(value):
27
+ fail(f"{context}: expected finite {name}")
28
+ return value
29
+
30
+ def start(tag, attrs):
31
+ nonlocal time
32
+ parent = stack[-1] if stack else None
33
+ if parent is None and tag != "fcd-export":
34
+ fail("expected <fcd-export> as the root")
35
+ if tag == "timestep":
36
+ if parent != "fcd-export":
37
+ fail("expected <timestep> directly within <fcd-export>")
38
+ time = number(attrs, "time", "timestep")
39
+ elif tag == "vehicle":
40
+ if parent != "timestep":
41
+ fail("expected <vehicle> directly within <timestep>")
42
+ agent = attrs.get("id")
43
+ if not agent:
44
+ fail(f"timestep {time}: expected a vehicle id")
45
+ context = f"vehicle {agent!r} at timestep {time}"
46
+ record = {"agent": agent, "x": number(attrs, "x", context),
47
+ "y": number(attrs, "y", context), "time": time}
48
+ destination.write(json.dumps(record, separators=(",", ":")) + "\n")
49
+ stack.append(tag)
50
+
51
+ parser.StartElementHandler = start
52
+ parser.EndElementHandler = lambda tag: stack.pop()
53
+ # One underlying read per chunk lets live pipes advance as soon as bytes
54
+ # arrive. No XML tree or set of previously observed vehicles accumulates.
55
+ while chunk := source.read1(65536):
56
+ parser.Parse(chunk, False)
57
+ destination.flush()
58
+ parser.Parse(b"", True)
59
+
60
+
61
+ def main():
62
+ args = argparse.ArgumentParser(description=__doc__)
63
+ args.add_argument("path", nargs="?", default="-",
64
+ help="FCD XML file, .gz file, or - for an XML stream on stdin")
65
+ path = args.parse_args().path
66
+ try:
67
+ if path == "-":
68
+ context = nullcontext(sys.stdin.buffer)
69
+ else:
70
+ opener = gzip.open if path.endswith(".gz") else open
71
+ context = opener(path, "rb")
72
+ with context as source:
73
+ convert(source, sys.stdout)
74
+ except BrokenPipeError:
75
+ # The downstream consumer closed the pipe.
76
+ return 0
77
+ except (OSError, ValueError, expat.ExpatError, EOFError) as error:
78
+ print(f"fcd: {error}", file=sys.stderr)
79
+ return 1
80
+ return 0
81
+
82
+
83
+ if __name__ == "__main__":
84
+ sys.exit(main())
examples/sumo/shape-filter.fcd.xml ADDED
@@ -0,0 +1,493 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!-- generated on 2022-06-29 10:01:37 by Eclipse SUMO GUI Version v1_13_0+1250-80064906a92
4
+ This data file and the accompanying materials
5
+ are made available under the terms of the Eclipse Public License v2.0
6
+ which accompanies this distribution, and is available at
7
+ http://www.eclipse.org/legal/epl-v20.html
8
+ This file may also be made available under the following Secondary
9
+ Licenses when the conditions for such availability set forth in the Eclipse
10
+ Public License 2.0 are satisfied: GNU General Public License, version 2
11
+ or later which is available at
12
+ https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
+ SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
+ <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
15
+
16
+ <input>
17
+ <net-file value="net.net.xml"/>
18
+ <additional-files value="input_additional.add.xml,input_routes.rou.xml"/>
19
+ </input>
20
+
21
+ <output>
22
+ <write-license value="true"/>
23
+ <fcd-output value="fcd.xml"/>
24
+ <fcd-output.filter-shapes value="po_0"/>
25
+ </output>
26
+
27
+ <processing>
28
+ <default.speeddev value="0"/>
29
+ </processing>
30
+
31
+ <report>
32
+ <xml-validation value="never"/>
33
+ <message-log value="stdout"/>
34
+ <error-log value="stderr"/>
35
+ <duration-log.disable value="true"/>
36
+ <no-step-log value="true"/>
37
+ </report>
38
+
39
+ <gui_only>
40
+ <quit-on-end value="true"/>
41
+ <start value="true"/>
42
+ </gui_only>
43
+
44
+ </configuration>
45
+ -->
46
+
47
+ <fcd-export xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/fcd_file.xsd">
48
+ <timestep time="0.00"/>
49
+ <timestep time="1.00"/>
50
+ <timestep time="2.00"/>
51
+ <timestep time="3.00"/>
52
+ <timestep time="4.00"/>
53
+ <timestep time="5.00"/>
54
+ <timestep time="6.00"/>
55
+ <timestep time="7.00"/>
56
+ <timestep time="8.00"/>
57
+ <timestep time="9.00"/>
58
+ <timestep time="10.00"/>
59
+ <timestep time="11.00"/>
60
+ <timestep time="12.00"/>
61
+ <timestep time="13.00"/>
62
+ <timestep time="14.00"/>
63
+ <timestep time="15.00"/>
64
+ <timestep time="16.00"/>
65
+ <timestep time="17.00"/>
66
+ <timestep time="18.00"/>
67
+ <timestep time="19.00"/>
68
+ <timestep time="20.00"/>
69
+ <timestep time="21.00"/>
70
+ <timestep time="22.00"/>
71
+ <timestep time="23.00"/>
72
+ <timestep time="24.00"/>
73
+ <timestep time="25.00"/>
74
+ <timestep time="26.00"/>
75
+ <timestep time="27.00"/>
76
+ <timestep time="28.00"/>
77
+ <timestep time="29.00"/>
78
+ <timestep time="30.00"/>
79
+ <timestep time="31.00"/>
80
+ <timestep time="32.00"/>
81
+ <timestep time="33.00"/>
82
+ <timestep time="34.00"/>
83
+ <timestep time="35.00"/>
84
+ <timestep time="36.00"/>
85
+ <timestep time="37.00"/>
86
+ <timestep time="38.00"/>
87
+ <timestep time="39.00"/>
88
+ <timestep time="40.00"/>
89
+ <timestep time="41.00"/>
90
+ <timestep time="42.00"/>
91
+ <timestep time="43.00"/>
92
+ <timestep time="44.00"/>
93
+ <timestep time="45.00"/>
94
+ <timestep time="46.00"/>
95
+ <timestep time="47.00"/>
96
+ <timestep time="48.00"/>
97
+ <timestep time="49.00"/>
98
+ <timestep time="50.00"/>
99
+ <timestep time="51.00"/>
100
+ <timestep time="52.00"/>
101
+ <timestep time="53.00"/>
102
+ <timestep time="54.00"/>
103
+ <timestep time="55.00"/>
104
+ <timestep time="56.00"/>
105
+ <timestep time="57.00"/>
106
+ <timestep time="58.00"/>
107
+ <timestep time="59.00"/>
108
+ <timestep time="60.00"/>
109
+ <timestep time="61.00"/>
110
+ <timestep time="62.00"/>
111
+ <timestep time="63.00"/>
112
+ <timestep time="64.00"/>
113
+ <timestep time="65.00"/>
114
+ <timestep time="66.00"/>
115
+ <timestep time="67.00"/>
116
+ <timestep time="68.00"/>
117
+ <timestep time="69.00"/>
118
+ <timestep time="70.00"/>
119
+ <timestep time="71.00"/>
120
+ <timestep time="72.00"/>
121
+ <timestep time="73.00"/>
122
+ <timestep time="74.00"/>
123
+ <timestep time="75.00"/>
124
+ <timestep time="76.00"/>
125
+ <timestep time="77.00"/>
126
+ <timestep time="78.00"/>
127
+ <timestep time="79.00"/>
128
+ <timestep time="80.00"/>
129
+ <timestep time="81.00"/>
130
+ <timestep time="82.00"/>
131
+ <timestep time="83.00"/>
132
+ <timestep time="84.00"/>
133
+ <timestep time="85.00"/>
134
+ <timestep time="86.00"/>
135
+ <timestep time="87.00"/>
136
+ <timestep time="88.00"/>
137
+ <timestep time="89.00"/>
138
+ <timestep time="90.00"/>
139
+ <timestep time="91.00"/>
140
+ <timestep time="92.00"/>
141
+ <timestep time="93.00"/>
142
+ <timestep time="94.00"/>
143
+ <timestep time="95.00"/>
144
+ <timestep time="96.00"/>
145
+ <timestep time="97.00"/>
146
+ <timestep time="98.00"/>
147
+ <timestep time="99.00"/>
148
+ <timestep time="100.00"/>
149
+ <timestep time="101.00"/>
150
+ <timestep time="102.00"/>
151
+ <timestep time="103.00"/>
152
+ <timestep time="104.00"/>
153
+ <timestep time="105.00"/>
154
+ <timestep time="106.00"/>
155
+ <timestep time="107.00"/>
156
+ <timestep time="108.00"/>
157
+ <timestep time="109.00"/>
158
+ <timestep time="110.00"/>
159
+ <timestep time="111.00"/>
160
+ <timestep time="112.00"/>
161
+ <timestep time="113.00"/>
162
+ <timestep time="114.00"/>
163
+ <timestep time="115.00"/>
164
+ <timestep time="116.00"/>
165
+ <timestep time="117.00"/>
166
+ <timestep time="118.00"/>
167
+ <timestep time="119.00"/>
168
+ <timestep time="120.00"/>
169
+ <timestep time="121.00"/>
170
+ <timestep time="122.00"/>
171
+ <timestep time="123.00"/>
172
+ <timestep time="124.00"/>
173
+ <timestep time="125.00"/>
174
+ <timestep time="126.00"/>
175
+ <timestep time="127.00"/>
176
+ <timestep time="128.00"/>
177
+ <timestep time="129.00"/>
178
+ <timestep time="130.00"/>
179
+ <timestep time="131.00"/>
180
+ <timestep time="132.00"/>
181
+ <timestep time="133.00"/>
182
+ <timestep time="134.00"/>
183
+ <timestep time="135.00"/>
184
+ <timestep time="136.00"/>
185
+ <timestep time="137.00"/>
186
+ <timestep time="138.00"/>
187
+ <timestep time="139.00"/>
188
+ <timestep time="140.00"/>
189
+ <timestep time="141.00"/>
190
+ <timestep time="142.00"/>
191
+ <timestep time="143.00"/>
192
+ <timestep time="144.00"/>
193
+ <timestep time="145.00"/>
194
+ <timestep time="146.00"/>
195
+ <timestep time="147.00"/>
196
+ <timestep time="148.00"/>
197
+ <timestep time="149.00"/>
198
+ <timestep time="150.00"/>
199
+ <timestep time="151.00"/>
200
+ <timestep time="152.00"/>
201
+ <timestep time="153.00"/>
202
+ <timestep time="154.00"/>
203
+ <timestep time="155.00"/>
204
+ <timestep time="156.00"/>
205
+ <timestep time="157.00"/>
206
+ <timestep time="158.00"/>
207
+ <timestep time="159.00"/>
208
+ <timestep time="160.00"/>
209
+ <timestep time="161.00"/>
210
+ <timestep time="162.00"/>
211
+ <timestep time="163.00"/>
212
+ <timestep time="164.00"/>
213
+ <timestep time="165.00"/>
214
+ <timestep time="166.00"/>
215
+ <timestep time="167.00">
216
+ <vehicle id="0" x="463.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="331.40" lane="2/1to1/1_0" slope="0.00"/>
217
+ </timestep>
218
+ <timestep time="168.00">
219
+ <vehicle id="0" x="453.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="341.40" lane="2/1to1/1_0" slope="0.00"/>
220
+ </timestep>
221
+ <timestep time="169.00">
222
+ <vehicle id="0" x="443.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="351.40" lane="2/1to1/1_0" slope="0.00"/>
223
+ </timestep>
224
+ <timestep time="170.00">
225
+ <vehicle id="0" x="433.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="361.40" lane="2/1to1/1_0" slope="0.00"/>
226
+ </timestep>
227
+ <timestep time="171.00">
228
+ <vehicle id="0" x="423.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="371.40" lane="2/1to1/1_0" slope="0.00"/>
229
+ </timestep>
230
+ <timestep time="172.00">
231
+ <vehicle id="0" x="413.85" y="401.65" angle="270.00" type="t1" speed="10.00" pos="381.40" lane="2/1to1/1_0" slope="0.00"/>
232
+ <vehicle id="1" x="460.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="334.80" lane="2/1to1/1_0" slope="0.00"/>
233
+ </timestep>
234
+ <timestep time="173.00">
235
+ <vehicle id="0" x="407.55" y="401.65" angle="270.00" type="t1" speed="6.30" pos="387.70" lane="2/1to1/1_0" slope="0.00"/>
236
+ <vehicle id="1" x="451.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="343.80" lane="2/1to1/1_0" slope="0.00"/>
237
+ </timestep>
238
+ <timestep time="174.00">
239
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="1.80" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
240
+ <vehicle id="1" x="442.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="352.80" lane="2/1to1/1_0" slope="0.00"/>
241
+ </timestep>
242
+ <timestep time="175.00">
243
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
244
+ <vehicle id="1" x="433.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="361.80" lane="2/1to1/1_0" slope="0.00"/>
245
+ </timestep>
246
+ <timestep time="176.00">
247
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
248
+ <vehicle id="1" x="424.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="370.80" lane="2/1to1/1_0" slope="0.00"/>
249
+ </timestep>
250
+ <timestep time="177.00">
251
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
252
+ <vehicle id="1" x="415.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="379.80" lane="2/1to1/1_0" slope="0.00"/>
253
+ </timestep>
254
+ <timestep time="178.00">
255
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
256
+ <vehicle id="1" x="410.85" y="401.65" angle="270.00" type="t2" speed="4.60" pos="384.40" lane="2/1to1/1_0" slope="0.00"/>
257
+ </timestep>
258
+ <timestep time="179.00">
259
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
260
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.10" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
261
+ </timestep>
262
+ <timestep time="180.00">
263
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
264
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
265
+ </timestep>
266
+ <timestep time="181.00">
267
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
268
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
269
+ </timestep>
270
+ <timestep time="182.00">
271
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
272
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
273
+ </timestep>
274
+ <timestep time="183.00">
275
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
276
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
277
+ </timestep>
278
+ <timestep time="184.00">
279
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
280
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
281
+ </timestep>
282
+ <timestep time="185.00">
283
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
284
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
285
+ </timestep>
286
+ <timestep time="186.00">
287
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
288
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
289
+ </timestep>
290
+ <timestep time="187.00">
291
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
292
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
293
+ </timestep>
294
+ <timestep time="188.00">
295
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
296
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
297
+ </timestep>
298
+ <timestep time="189.00">
299
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
300
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
301
+ </timestep>
302
+ <timestep time="190.00">
303
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
304
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
305
+ </timestep>
306
+ <timestep time="191.00">
307
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
308
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
309
+ </timestep>
310
+ <timestep time="192.00">
311
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
312
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
313
+ </timestep>
314
+ <timestep time="193.00">
315
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
316
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
317
+ </timestep>
318
+ <timestep time="194.00">
319
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
320
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
321
+ </timestep>
322
+ <timestep time="195.00">
323
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
324
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
325
+ </timestep>
326
+ <timestep time="196.00">
327
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
328
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
329
+ </timestep>
330
+ <timestep time="197.00">
331
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
332
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
333
+ </timestep>
334
+ <timestep time="198.00">
335
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
336
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
337
+ </timestep>
338
+ <timestep time="199.00">
339
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
340
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
341
+ </timestep>
342
+ <timestep time="200.00">
343
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
344
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
345
+ </timestep>
346
+ <timestep time="201.00">
347
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
348
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
349
+ </timestep>
350
+ <timestep time="202.00">
351
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
352
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
353
+ </timestep>
354
+ <timestep time="203.00">
355
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
356
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
357
+ </timestep>
358
+ <timestep time="204.00">
359
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
360
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
361
+ </timestep>
362
+ <timestep time="205.00">
363
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
364
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
365
+ </timestep>
366
+ <timestep time="206.00">
367
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
368
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
369
+ </timestep>
370
+ <timestep time="207.00">
371
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
372
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
373
+ </timestep>
374
+ <timestep time="208.00">
375
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
376
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
377
+ </timestep>
378
+ <timestep time="209.00">
379
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
380
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
381
+ </timestep>
382
+ <timestep time="210.00">
383
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
384
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
385
+ </timestep>
386
+ <timestep time="211.00">
387
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
388
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
389
+ </timestep>
390
+ <timestep time="212.00">
391
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
392
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
393
+ </timestep>
394
+ <timestep time="213.00">
395
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
396
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
397
+ </timestep>
398
+ <timestep time="214.00">
399
+ <vehicle id="0" x="405.75" y="401.65" angle="270.00" type="t1" speed="0.00" pos="389.50" lane="2/1to1/1_0" slope="0.00"/>
400
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
401
+ </timestep>
402
+ <timestep time="215.00">
403
+ <vehicle id="0" x="404.95" y="401.65" angle="270.00" type="t1" speed="0.80" pos="390.30" lane="2/1to1/1_0" slope="0.00"/>
404
+ <vehicle id="1" x="410.75" y="401.65" angle="270.00" type="t2" speed="0.00" pos="384.50" lane="2/1to1/1_0" slope="0.00"/>
405
+ </timestep>
406
+ <timestep time="216.00">
407
+ <vehicle id="0" x="393.85" y="401.65" angle="270.00" type="t1" speed="1.60" pos="1.40" lane="1/1to0/1_0" slope="0.00"/>
408
+ <vehicle id="1" x="409.95" y="401.65" angle="270.00" type="t2" speed="0.80" pos="385.30" lane="2/1to1/1_0" slope="0.00"/>
409
+ </timestep>
410
+ <timestep time="217.00">
411
+ <vehicle id="0" x="391.45" y="401.65" angle="270.00" type="t1" speed="2.40" pos="3.80" lane="1/1to0/1_0" slope="0.00"/>
412
+ <vehicle id="1" x="408.35" y="401.65" angle="270.00" type="t2" speed="1.60" pos="386.90" lane="2/1to1/1_0" slope="0.00"/>
413
+ </timestep>
414
+ <timestep time="218.00">
415
+ <vehicle id="0" x="388.25" y="401.65" angle="270.00" type="t1" speed="3.20" pos="7.00" lane="1/1to0/1_0" slope="0.00"/>
416
+ <vehicle id="1" x="405.95" y="401.65" angle="270.00" type="t2" speed="2.40" pos="389.30" lane="2/1to1/1_0" slope="0.00"/>
417
+ </timestep>
418
+ <timestep time="219.00">
419
+ <vehicle id="0" x="384.25" y="401.65" angle="270.00" type="t1" speed="4.00" pos="11.00" lane="1/1to0/1_0" slope="0.00"/>
420
+ <vehicle id="1" x="393.25" y="401.65" angle="270.00" type="t2" speed="3.20" pos="2.00" lane="1/1to0/1_0" slope="0.00"/>
421
+ </timestep>
422
+ <timestep time="220.00">
423
+ <vehicle id="0" x="379.45" y="401.65" angle="270.00" type="t1" speed="4.80" pos="15.80" lane="1/1to0/1_0" slope="0.00"/>
424
+ <vehicle id="1" x="389.25" y="401.65" angle="270.00" type="t2" speed="4.00" pos="6.00" lane="1/1to0/1_0" slope="0.00"/>
425
+ </timestep>
426
+ <timestep time="221.00">
427
+ <vehicle id="0" x="373.85" y="401.65" angle="270.00" type="t1" speed="5.60" pos="21.40" lane="1/1to0/1_0" slope="0.00"/>
428
+ <vehicle id="1" x="384.45" y="401.65" angle="270.00" type="t2" speed="4.80" pos="10.80" lane="1/1to0/1_0" slope="0.00"/>
429
+ </timestep>
430
+ <timestep time="222.00">
431
+ <vehicle id="0" x="367.45" y="401.65" angle="270.00" type="t1" speed="6.40" pos="27.80" lane="1/1to0/1_0" slope="0.00"/>
432
+ <vehicle id="1" x="378.85" y="401.65" angle="270.00" type="t2" speed="5.60" pos="16.40" lane="1/1to0/1_0" slope="0.00"/>
433
+ </timestep>
434
+ <timestep time="223.00">
435
+ <vehicle id="0" x="360.25" y="401.65" angle="270.00" type="t1" speed="7.20" pos="35.00" lane="1/1to0/1_0" slope="0.00"/>
436
+ <vehicle id="1" x="372.45" y="401.65" angle="270.00" type="t2" speed="6.40" pos="22.80" lane="1/1to0/1_0" slope="0.00"/>
437
+ </timestep>
438
+ <timestep time="224.00">
439
+ <vehicle id="0" x="352.25" y="401.65" angle="270.00" type="t1" speed="8.00" pos="43.00" lane="1/1to0/1_0" slope="0.00"/>
440
+ <vehicle id="1" x="365.25" y="401.65" angle="270.00" type="t2" speed="7.20" pos="30.00" lane="1/1to0/1_0" slope="0.00"/>
441
+ </timestep>
442
+ <timestep time="225.00">
443
+ <vehicle id="0" x="343.45" y="401.65" angle="270.00" type="t1" speed="8.80" pos="51.80" lane="1/1to0/1_0" slope="0.00"/>
444
+ <vehicle id="1" x="357.25" y="401.65" angle="270.00" type="t2" speed="8.00" pos="38.00" lane="1/1to0/1_0" slope="0.00"/>
445
+ </timestep>
446
+ <timestep time="226.00">
447
+ <vehicle id="0" x="333.85" y="401.65" angle="270.00" type="t1" speed="9.60" pos="61.40" lane="1/1to0/1_0" slope="0.00"/>
448
+ <vehicle id="1" x="348.45" y="401.65" angle="270.00" type="t2" speed="8.80" pos="46.80" lane="1/1to0/1_0" slope="0.00"/>
449
+ </timestep>
450
+ <timestep time="227.00">
451
+ <vehicle id="1" x="339.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="55.80" lane="1/1to0/1_0" slope="0.00"/>
452
+ </timestep>
453
+ <timestep time="228.00">
454
+ <vehicle id="1" x="330.45" y="401.65" angle="270.00" type="t2" speed="9.00" pos="64.80" lane="1/1to0/1_0" slope="0.00"/>
455
+ </timestep>
456
+ <timestep time="229.00"/>
457
+ <timestep time="230.00"/>
458
+ <timestep time="231.00"/>
459
+ <timestep time="232.00"/>
460
+ <timestep time="233.00"/>
461
+ <timestep time="234.00"/>
462
+ <timestep time="235.00"/>
463
+ <timestep time="236.00"/>
464
+ <timestep time="237.00"/>
465
+ <timestep time="238.00"/>
466
+ <timestep time="239.00"/>
467
+ <timestep time="240.00"/>
468
+ <timestep time="241.00"/>
469
+ <timestep time="242.00"/>
470
+ <timestep time="243.00"/>
471
+ <timestep time="244.00"/>
472
+ <timestep time="245.00"/>
473
+ <timestep time="246.00"/>
474
+ <timestep time="247.00"/>
475
+ <timestep time="248.00"/>
476
+ <timestep time="249.00"/>
477
+ <timestep time="250.00"/>
478
+ <timestep time="251.00"/>
479
+ <timestep time="252.00"/>
480
+ <timestep time="253.00"/>
481
+ <timestep time="254.00"/>
482
+ <timestep time="255.00"/>
483
+ <timestep time="256.00"/>
484
+ <timestep time="257.00"/>
485
+ <timestep time="258.00"/>
486
+ <timestep time="259.00"/>
487
+ <timestep time="260.00"/>
488
+ <timestep time="261.00"/>
489
+ <timestep time="262.00"/>
490
+ <timestep time="263.00"/>
491
+ <timestep time="264.00"/>
492
+ <timestep time="265.00"/>
493
+ </fcd-export>
examples/sumo/zones.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [[400,400,445,403],[365,400,400,403]]
examples/tiled/README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tiled map zone notifications
2
+
3
+ Index a named object layer once, then pass the previous and current world-pixel positions of each player, NPC, or vehicle to `move`. The example requires an orthogonal Tiled JSON export (`.tmj`) with static, unrotated rectangular trigger zones. It uses the tracked object's point anchor, such as its feet.
4
+
5
+ ```sh
6
+ node examples/tiled/demo.mjs
7
+ node --test examples/tiled/zones.test.mjs
8
+ ```
9
+
10
+ The demo starts on Platform (Tiled ID 10). At x=48 the player leaves Platform and enters Concourse (ID 20). Callbacks for one move may arrive in either order.
11
+
12
+ ```js
13
+ import { buildTiledZones } from './zones.mjs';
14
+
15
+ const { index, objects } = buildTiledZones(map, ['Station', 'Zones']);
16
+ index.at(player.x, player.y, id => showInitialZone(objects[id]));
17
+ index.move(player.x, player.y, next.x, next.y, (id, entered) => {
18
+ notifyPlayer(objects[id].id, entered);
19
+ });
20
+ ```
21
+
22
+ Select a layer with an array of names, from the outermost group to the object layer. Names must identify a single layer at each level. The adapter adds each group and layer's pixel offsets. Object and layer visibility affect rendering only. This permits an invisible trigger layer. The adapter rejects parallax, nonzero layer tile offsets, template instances and other shapes in the selected layer. Rebuild the index after map edits. [Tiled JSON object and layer format](https://doc.mapeditor.org/en/stable/reference/json-map-format/).
23
+
24
+ This adapter opts into EdgeChime’s half-open bounds. Left and top edges belong to a rectangle. Right and bottom edges belong to the neighboring rectangle if it starts there. A jump across an entire zone with both endpoints outside emits no event.
25
+
26
+ For comparison, WorkAdventure’s own area API distinguishes initial subscriptions from movement. Its implementation at the revision below includes both rectangle limits, shifts the player’s y-coordinate by 16, dispatches leaves before entries and provides all current areas alongside the changes. A WorkAdventure integration would need to preserve these behaviors. [Area API](https://docs.workadventu.re/developer/map-scripting/references/api-mapeditor/) · [Area dispatch](https://github.com/workadventure/workadventure/blob/621f2bf29b36e1aa3aacb2e4a64299356f2cf412/libs/map-editor/src/GameMap/GameMapAreas.ts) · [Rectangle predicate](https://github.com/workadventure/workadventure/blob/621f2bf29b36e1aa3aacb2e4a64299356f2cf412/libs/math-utils/src/MathUtils.ts).
examples/tiled/demo.mjs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { readFileSync } from 'node:fs';
2
+ import { buildTiledZones } from './zones.mjs';
3
+
4
+ const map = JSON.parse(readFileSync(new URL('./station.tmj', import.meta.url), 'utf8'));
5
+ const { index, objects } = buildTiledZones(map, ['Station', 'Zones']);
6
+ index.at(40, 8, id => console.log('initial', objects[id].id, objects[id].name));
7
+ index.move(40, 8, 48, 8, (id, entered) => console.log(entered ? 'enter' : 'leave', objects[id].id, objects[id].name));
examples/tiled/station.tmj ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "map", "version": "1.10", "orientation": "orthogonal",
3
+ "tilewidth": 16, "tileheight": 16, "width": 8, "height": 4,
4
+ "nextlayerid": 3, "nextobjectid": 21, "tilesets": [],
5
+ "layers": [{
6
+ "id": 1, "type": "group", "name": "Station", "offsetx": 10, "offsety": 4,
7
+ "layers": [{
8
+ "id": 2, "type": "objectgroup", "name": "Zones", "offsetx": 6, "offsety": -4,
9
+ "objects": [
10
+ {"id": 10, "name": "Platform", "x": 0, "y": 0, "width": 32, "height": 16},
11
+ {"id": 20, "name": "Concourse", "x": 32, "y": 0, "width": 32, "height": 16}
12
+ ]
13
+ }]
14
+ }]
15
+ }
examples/tiled/zones.mjs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { EdgeChime } from '../../index.js';
2
+
3
+ /** Index static rectangles from one named object layer in an orthogonal Tiled map. */
4
+ export function buildTiledZones(map, path) {
5
+ if (map.orientation !== 'orthogonal') throw Error('Expected an orthogonal map');
6
+ if (!Array.isArray(path) || !path.length || path.some(name => typeof name !== 'string' || !name.length)) {
7
+ throw Error('Specify a nonempty path of layer names');
8
+ }
9
+ let offsetX = 0, offsetY = 0;
10
+ let layers = map.layers, layer;
11
+ for (let i = 0; i < path.length; i++) {
12
+ const matches = layers.filter(candidate => candidate.name === path[i]);
13
+ if (matches.length !== 1) throw Error('Missing or ambiguous layer: ' + path.slice(0, i + 1).join(' / '));
14
+ layer = matches[0];
15
+ const expected = i === path.length - 1 ? 'objectgroup' : 'group';
16
+ if (layer.type !== expected) throw Error('Expected layer of type ' + expected + ': ' + layer.name);
17
+ if ((layer.x ?? 0) !== 0 || (layer.y ?? 0) !== 0) throw Error('Unsupported nonzero layer x/y: ' + layer.name);
18
+ if ((layer.parallaxx ?? 1) !== 1 || (layer.parallaxy ?? 1) !== 1) throw Error('Parallax layer: ' + layer.name);
19
+ const dx = layer.offsetx ?? 0, dy = layer.offsety ?? 0;
20
+ if (!Number.isFinite(dx) || !Number.isFinite(dy)) throw Error('Invalid layer offset: ' + layer.name);
21
+ offsetX += dx;
22
+ offsetY += dy;
23
+ layers = layer.layers;
24
+ }
25
+ if (!Array.isArray(layer.objects)) throw Error('Expected an objects array on ' + layer.name);
26
+ const objects = layer.objects.slice(); // Keep the ID mapping stable if the map's array is reordered.
27
+ const ids = new Set();
28
+ const boxes = objects.map(object => {
29
+ if (!Number.isSafeInteger(object.id) || object.id <= 0 || ids.has(object.id)) throw Error('Invalid or duplicate Tiled object ID: ' + object.id);
30
+ ids.add(object.id);
31
+ if ((object.rotation ?? 0) !== 0 || object.ellipse || object.capsule || object.point ||
32
+ ['gid', 'text', 'polygon', 'polyline', 'template'].some(key => key in object)) {
33
+ throw Error('Expected an unrotated rectangle for Tiled object ' + object.id);
34
+ }
35
+ if (![object.x, object.y, object.width, object.height].every(Number.isFinite) ||
36
+ object.width <= 0 || object.height <= 0) throw Error('Invalid rectangle for Tiled object ' + object.id);
37
+ const x = offsetX + object.x, y = offsetY + object.y;
38
+ return [x, y, x + object.width, y + object.height];
39
+ });
40
+ return { index: new EdgeChime(boxes), objects };
41
+ }
examples/tiled/zones.test.mjs ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import { readFileSync } from 'node:fs';
3
+ import test from 'node:test';
4
+ import { buildTiledZones } from './zones.mjs';
5
+
6
+ const map = JSON.parse(readFileSync(new URL('./station.tmj', import.meta.url), 'utf8'));
7
+ const path = ['Station', 'Zones'];
8
+ test('uses nested pixel offsets and original object IDs at a shared edge', () => {
9
+ const { index, objects } = buildTiledZones(map, path);
10
+ const initial = [], events = [];
11
+ index.at(16, 0, id => initial.push(objects[id].id));
12
+ index.move(47, 15, 48, 15, (id, enter) => events.push([objects[id].id, enter]));
13
+ assert.deepEqual(initial, [10]);
14
+ assert.deepEqual(events.sort((a, b) => a[0] - b[0]), [[10, false], [20, true]]);
15
+ assert.equal(index.at(80, 16, () => {}), 0);
16
+ });
17
+ test('rejects unsupported geometries, orientation and transforms', () => {
18
+ for (const shape of [{ gid: 2 }, { rotation: 90 }, { point: true }, { ellipse: true },
19
+ { capsule: true }, { polyline: [] }, { polygon: [] }, { text: {} }, { template: 'other.tx' }]) {
20
+ const edited = structuredClone(map);
21
+ Object.assign(edited.layers[0].layers[0].objects[0], shape);
22
+ assert.throws(() => buildTiledZones(edited, path), /unrotated rectangle/);
23
+ }
24
+ assert.throws(() => buildTiledZones({ ...map, orientation: 'isometric' }, path), /orthogonal/);
25
+ for (const transform of [{ x: 2 }, { parallaxx: 0.5 }, { offsety: '12' }]) {
26
+ const edited = structuredClone(map);
27
+ Object.assign(edited.layers[0], transform);
28
+ assert.throws(() => buildTiledZones(edited, path));
29
+ }
30
+ });
31
+ test('rejects a missing or ambiguous selection and ignores unrelated object layers', () => {
32
+ assert.throws(() => buildTiledZones(map, ['Zones']), /Missing/);
33
+ assert.throws(() => buildTiledZones(map, ['Station']), /objectgroup/);
34
+ assert.throws(() => buildTiledZones({ ...map, layers: [...map.layers, ...map.layers] }, path), /ambiguous/);
35
+ const extra = { name: 'Graphics', type: 'objectgroup', objects: [{ gid: 2 }] };
36
+ assert.equal(buildTiledZones({ ...map, layers: [extra, ...map.layers] }, path).objects.length, 2);
37
+ });
index.d.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Box = readonly [minX: number, minY: number, maxX: number, maxY: number];
2
+
3
+ /** Immutable index over half-open boxes. IDs follow the input order. */
4
+ export class EdgeChime {
5
+ constructor(boxes: Iterable<Box>);
6
+ /** Calls emit for each box containing the point and returns the call count. */
7
+ at(x: number, y: number, emit: (id: number) => void): number;
8
+ /** Calls emit once per changed membership. The callback order is unspecified. */
9
+ move(
10
+ x0: number, y0: number, x1: number, y1: number,
11
+ emit: (id: number, entered: boolean) => void,
12
+ ): number;
13
+ }
index.html CHANGED
@@ -3,6 +3,8 @@
3
  <head>
4
  <meta charset="utf-8">
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
 
 
6
  <meta name="theme-color" content="#f7f6ef">
7
  <title>EdgeChime · Live region membership</title>
8
  <style>
@@ -14,7 +16,7 @@
14
  </head>
15
  <body>
16
  <main>
17
- <header><div class="brand"><span class="mark" aria-hidden="true"></span>EdgeChime</div><a class="source" href="https://edgechime.tancurl3.chatgpt.site/source.zip">Download source ↓</a></header>
18
  <section class="intro"><h1>Which regions changed?</h1><p>Move one agent through overlapping subscriptions. EdgeChime reports each region the agent enters or leaves between two positions.</p></section>
19
  <div class="instrument">
20
  <div class="controls">
@@ -34,6 +36,7 @@
34
  <div class="legend"><span><i class="key" aria-hidden="true"></i>Subscription</span><span><i class="key active" aria-hidden="true"></i>Current membership</span><span><i class="key agent" aria-hidden="true"></i>Agent position</span></div>
35
  </div>
36
  <p class="explain"><code>at()</code> finds the starting memberships. Each subsequent <code>move()</code> emits entered and exited region IDs. Regions containing both endpoints stay in the retained count.</p>
 
37
  <span class="sr" id="announce" role="status" aria-live="polite"></span>
38
  <noscript>Enable JavaScript to run the live region index.</noscript>
39
  </main>
 
3
  <head>
4
  <meta charset="utf-8">
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="description" content="A dependency-free spatial index for exact enter and exit events. Try moving an agent through overlapping rectangular geofences and replay the benchmarks.">
7
+ <link rel="alternate" type="text/markdown" href="https://edgechime.tancurl3.chatgpt.site/README.md" title="EdgeChime API and benchmark guide">
8
  <meta name="theme-color" content="#f7f6ef">
9
  <title>EdgeChime · Live region membership</title>
10
  <style>
 
16
  </head>
17
  <body>
18
  <main>
19
+ <header><div class="brand"><span class="mark" aria-hidden="true"></span>EdgeChime</div><a class="source" href="https://edgechime.tancurl3.chatgpt.site/source.zip">Download source</a></header>
20
  <section class="intro"><h1>Which regions changed?</h1><p>Move one agent through overlapping subscriptions. EdgeChime reports each region the agent enters or leaves between two positions.</p></section>
21
  <div class="instrument">
22
  <div class="controls">
 
36
  <div class="legend"><span><i class="key" aria-hidden="true"></i>Subscription</span><span><i class="key active" aria-hidden="true"></i>Current membership</span><span><i class="key agent" aria-hidden="true"></i>Agent position</span></div>
37
  </div>
38
  <p class="explain"><code>at()</code> finds the starting memberships. Each subsequent <code>move()</code> emits entered and exited region IDs. Regions containing both endpoints stay in the retained count.</p>
39
+ <p class="explain"><a href="https://edgechime.tancurl3.chatgpt.site/README.md">API and installation</a> · <a href="https://edgechime.tancurl3.chatgpt.site/bench/results.json">Benchmark measurements (JSON)</a></p>
40
  <span class="sr" id="announce" role="status" aria-live="polite"></span>
41
  <noscript>Enable JavaScript to run the live region index.</noscript>
42
  </main>
index.js CHANGED
@@ -7,12 +7,31 @@ function buildAxis(rects, count, axis) {
7
  codes.sort((a, b) => rects[offset(a)] - rects[offset(b)]);
8
  const values = new Float64Array(codes.length);
9
  for (let i = 0; i < codes.length; i++) values[i] = rects[offset(codes[i])];
10
- return { codes, values };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
 
13
  // Return the first coordinate strictly greater than the search point.
14
- function upperBound(values, x, lo = 0) {
15
- let hi = values.length;
16
  while (lo < hi) {
17
  const mid = lo + ((hi - lo) >>> 1);
18
  if (values[mid] <= x) lo = mid + 1;
@@ -21,6 +40,15 @@ function upperBound(values, x, lo = 0) {
21
  return lo;
22
  }
23
 
 
 
 
 
 
 
 
 
 
24
  function crossingEnd(values, hi, start) {
25
  // Most small movements touch zero or a handful of edges.
26
  const stop = Math.min(values.length, start + 8);
@@ -30,6 +58,54 @@ function crossingEnd(values, hi, start) {
30
  return upperBound(values, hi, pos);
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  function checkPoint(x, y) {
34
  if (!Number.isFinite(x) || !Number.isFinite(y)) {
35
  throw new RangeError("Point coordinates must be finite numbers");
@@ -40,6 +116,82 @@ function checkEmitter(emit) {
40
  if (typeof emit !== "function") throw new TypeError("emit must be a function");
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  function scanMove(r, x0, y0, x1, y1, emit) {
44
  let count = 0;
45
  for (let i = 0; i < r.length; i += 4) {
@@ -56,6 +208,9 @@ function scanMove(r, x0, y0, x1, y1, emit) {
56
  /** Static index over finite, nonempty, half-open 2D boxes. */
57
  export class EdgeChime {
58
  #rects;
 
 
 
59
  #x;
60
  #y;
61
 
@@ -82,6 +237,11 @@ export class EdgeChime {
82
  this.#rects = r;
83
  this.#x = buildAxis(r, input.length, 0);
84
  this.#y = buildAxis(r, input.length, 1);
 
 
 
 
 
85
  }
86
 
87
  /** Visit IDs containing (x,y). Returns the number visited. */
@@ -89,6 +249,8 @@ export class EdgeChime {
89
  checkPoint(x, y);
90
  checkEmitter(emit);
91
  const r = this.#rects;
 
 
92
  let count = 0;
93
  for (let i = 0; i < r.length; i += 4) {
94
  if (r[i] <= x && x < r[i + 2] && r[i + 1] <= y && y < r[i + 3]) {
@@ -114,19 +276,28 @@ export class EdgeChime {
114
  const hiX = right ? x1 : x0;
115
  const loY = up ? y0 : y1;
116
  const hiY = up ? y1 : y0;
117
- const x = this.#x;
118
- const y = this.#y;
 
 
 
 
 
 
119
  let xStart = 0, xEnd = 0, yStart = 0, yEnd = 0;
120
  if (loX !== hiX) {
121
- xStart = upperBound(x.values, loX);
122
  xEnd = crossingEnd(x.values, hiX, xStart);
123
  }
124
  if (loY !== hiY) {
125
- yStart = upperBound(y.values, loY);
126
  yEnd = crossingEnd(y.values, hiY, yStart);
127
  }
128
- // With many crossed edges, a sequential pass is cheaper than random box reads.
 
129
  if (xEnd - xStart + yEnd - yStart > r.length / 16) {
 
 
130
  return scanMove(r, x0, y0, x1, y1, emit);
131
  }
132
 
 
7
  codes.sort((a, b) => rects[offset(a)] - rects[offset(b)]);
8
  const values = new Float64Array(codes.length);
9
  for (let i = 0; i < codes.length; i++) values[i] = rects[offset(codes[i])];
10
+ return searchable(codes, values);
11
+ }
12
+
13
+ function searchable(codes, values) {
14
+ // A small directory narrows binary search to one coordinate bucket. Building
15
+ // and querying use the same bucket expression, including floating-point ties.
16
+ const low = values[0];
17
+ const high = values[values.length - 1];
18
+ const bins = Math.min(65536, Math.ceil(codes.length / 4));
19
+ const scale = bins / (high - low);
20
+ let directory = null;
21
+ if (codes.length >= 512 && scale > 0 && Number.isFinite(scale)) {
22
+ directory = new Uint32Array(bins + 1);
23
+ let prev = -1;
24
+ for (let i = 0; i < values.length; i++) {
25
+ const bin = Math.min(bins - 1, Math.floor((values[i] - low) * scale));
26
+ while (prev < bin) directory[++prev] = i;
27
+ }
28
+ while (prev < bins) directory[++prev] = values.length;
29
+ }
30
+ return { codes, values, low, high, scale, directory };
31
  }
32
 
33
  // Return the first coordinate strictly greater than the search point.
34
+ function upperBound(values, x, lo = 0, hi = values.length) {
 
35
  while (lo < hi) {
36
  const mid = lo + ((hi - lo) >>> 1);
37
  if (values[mid] <= x) lo = mid + 1;
 
40
  return lo;
41
  }
42
 
43
+ function firstCrossing(axis, lo) {
44
+ if (lo < axis.low) return 0;
45
+ if (lo >= axis.high) return axis.values.length;
46
+ const dir = axis.directory;
47
+ if (!dir) return upperBound(axis.values, lo);
48
+ const bin = Math.min(dir.length - 2, Math.floor((lo - axis.low) * axis.scale));
49
+ return upperBound(axis.values, lo, dir[bin], dir[bin + 1]);
50
+ }
51
+
52
  function crossingEnd(values, hi, start) {
53
  // Most small movements touch zero or a handful of edges.
54
  const stop = Math.min(values.length, start + 8);
 
58
  return upperBound(values, hi, pos);
59
  }
60
 
61
+ const STRIPES = 16;
62
+
63
+ function stripeId(stripes, p) {
64
+ if (p <= stripes.low) return 0;
65
+ if (p >= stripes.high) return STRIPES - 1;
66
+ return Math.min(STRIPES - 1, Math.floor((p - stripes.low) * stripes.scale));
67
+ }
68
+
69
+ // Copy edges into the orthogonal strips their box intersects. In a narrow-box
70
+ // workload this avoids visiting distant fences with the same X or Y boundary.
71
+ // Abandon the optional index if it would exceed 2.5 copies per original edge.
72
+ function stripeAxis(axis, orth, r, off) {
73
+ const scale = STRIPES / (orth.high - orth.low);
74
+ if (!(scale > 0) || !Number.isFinite(scale)) return null;
75
+ const stripes = { low: orth.low, high: orth.high, scale, axes: [] };
76
+ const n = axis.codes.length / 2;
77
+ const lo = new Uint8Array(n), hi = new Uint8Array(n);
78
+ const lengths = new Float64Array(STRIPES + 1);
79
+ let total = 0;
80
+ for (let id = 0; id < n; id++) {
81
+ const i = id * 4 + off;
82
+ const a = lo[id] = stripeId(stripes, r[i]);
83
+ const b = hi[id] = stripeId(stripes, r[i + 2]);
84
+ total += b - a + 1;
85
+ if (total > 2.5 * n) return null;
86
+ lengths[a] += 2;
87
+ lengths[b + 1] -= 2;
88
+ }
89
+ const cs = [], vs = [];
90
+ const ptr = new Uint32Array(STRIPES);
91
+ let length = 0;
92
+ for (let j = 0; j < STRIPES; j++) {
93
+ length += lengths[j];
94
+ cs[j] = new Uint32Array(length);
95
+ vs[j] = new Float64Array(length);
96
+ }
97
+ for (let k = 0; k < axis.codes.length; k++) {
98
+ const code = axis.codes[k], id = code >>> 1;
99
+ for (let j = lo[id]; j <= hi[id]; j++) {
100
+ const pos = ptr[j]++;
101
+ cs[j][pos] = code;
102
+ vs[j][pos] = axis.values[k];
103
+ }
104
+ }
105
+ for (let j = 0; j < STRIPES; j++) stripes.axes[j] = searchable(cs[j], vs[j]);
106
+ return stripes;
107
+ }
108
+
109
  function checkPoint(x, y) {
110
  if (!Number.isFinite(x) || !Number.isFinite(y)) {
111
  throw new RangeError("Point coordinates must be finite numbers");
 
116
  if (typeof emit !== "function") throw new TypeError("emit must be a function");
117
  }
118
 
119
+ // Pack leaves into square-ish tiles and consecutive groups of sixteen. The
120
+ // outer box of a group rejects queries without reading the individual boxes.
121
+ const FANOUT = 16;
122
+
123
+ function packRects(rects, x, y) {
124
+ const n = rects.length / 4;
125
+ const order = new Uint32Array(n);
126
+ // Reuse the two edge orders. Assign columns by increasing minX, then fill
127
+ // each column in minY order. This grouping needs no additional sort.
128
+ const slice = Math.ceil(Math.sqrt(n / FANOUT)) * FANOUT;
129
+ const column = new Uint32Array(n);
130
+ const cursor = new Uint32Array(Math.ceil(n / slice));
131
+ let rank = 0;
132
+ for (const code of x.codes) {
133
+ if ((code & 1) === 0) column[code >>> 1] = Math.floor(rank++ / slice);
134
+ }
135
+ for (let i = 0; i < cursor.length; i++) cursor[i] = i * slice;
136
+ for (const code of y.codes) {
137
+ if ((code & 1) === 0) {
138
+ const id = code >>> 1;
139
+ order[cursor[column[id]]++] = id;
140
+ }
141
+ }
142
+
143
+ const levels = [];
144
+ let current = rects;
145
+ while (current.length > 4) {
146
+ const groups = Math.ceil(current.length / (4 * FANOUT));
147
+ const next = new Float64Array(groups * 4);
148
+ for (let g = 0; g < groups; g++) {
149
+ const end = Math.min((g + 1) * FANOUT, current.length / 4);
150
+ let left = Infinity, bottom = Infinity, right = -Infinity, top = -Infinity;
151
+ for (let k = g * FANOUT; k < end; k++) {
152
+ const i = (current === rects ? order[k] : k) * 4;
153
+ left = Math.min(left, current[i]);
154
+ bottom = Math.min(bottom, current[i + 1]);
155
+ right = Math.max(right, current[i + 2]);
156
+ top = Math.max(top, current[i + 3]);
157
+ }
158
+ next[g * 4] = left;
159
+ next[g * 4 + 1] = bottom;
160
+ next[g * 4 + 2] = right;
161
+ next[g * 4 + 3] = top;
162
+ }
163
+ levels.push(next);
164
+ current = next;
165
+ }
166
+ return { levels, order };
167
+ }
168
+
169
+ // Traverse the union of both endpoint queries once. Each box has one leaf,
170
+ // so reports need neither a scratch membership set nor callback deduplication.
171
+ function visitPacked(tree, rects, level, node, x0, y0, x1, y1, emit, pointQuery) {
172
+ let count = 0;
173
+ const data = level === 0 ? rects : tree.levels[level - 1];
174
+ const limit = Math.min((node + 1) * FANOUT, data.length / 4);
175
+ for (let k = node * FANOUT; k < limit; k++) {
176
+ const id = level === 0 ? tree.order[k] : k;
177
+ const i = id * 4;
178
+ const before = !pointQuery && data[i] <= x0 && x0 < data[i + 2] &&
179
+ data[i + 1] <= y0 && y0 < data[i + 3];
180
+ const after = data[i] <= x1 && x1 < data[i + 2] &&
181
+ data[i + 1] <= y1 && y1 < data[i + 3];
182
+ if (level === 0) {
183
+ if (before !== after) {
184
+ if (pointQuery) emit(id);
185
+ else emit(id, after);
186
+ count++;
187
+ }
188
+ } else if (before || after) {
189
+ count += visitPacked(tree, rects, level - 1, k, x0, y0, x1, y1, emit, pointQuery);
190
+ }
191
+ }
192
+ return count;
193
+ }
194
+
195
  function scanMove(r, x0, y0, x1, y1, emit) {
196
  let count = 0;
197
  for (let i = 0; i < r.length; i += 4) {
 
208
  /** Static index over finite, nonempty, half-open 2D boxes. */
209
  export class EdgeChime {
210
  #rects;
211
+ #tree;
212
+ #xs;
213
+ #ys;
214
  #x;
215
  #y;
216
 
 
237
  this.#rects = r;
238
  this.#x = buildAxis(r, input.length, 0);
239
  this.#y = buildAxis(r, input.length, 1);
240
+ if (input.length >= 256) {
241
+ this.#xs = stripeAxis(this.#x, this.#y, r, 1);
242
+ this.#ys = stripeAxis(this.#y, this.#x, r, 0);
243
+ }
244
+ this.#tree = input.length >= 256 ? packRects(r, this.#x, this.#y) : null;
245
  }
246
 
247
  /** Visit IDs containing (x,y). Returns the number visited. */
 
249
  checkPoint(x, y);
250
  checkEmitter(emit);
251
  const r = this.#rects;
252
+ const tree = this.#tree;
253
+ if (tree) return visitPacked(tree, r, tree.levels.length - 1, 0, x, y, x, y, emit, true);
254
  let count = 0;
255
  for (let i = 0; i < r.length; i += 4) {
256
  if (r[i] <= x && x < r[i + 2] && r[i + 1] <= y && y < r[i + 3]) {
 
276
  const hiX = right ? x1 : x0;
277
  const loY = up ? y0 : y1;
278
  const hiY = up ? y1 : y0;
279
+ // X crossings may depend on either endpoint's Y, so use a strip only when
280
+ // both endpoints share it. The Y pass always requires X membership at x0.
281
+ let x = this.#x, y = this.#y;
282
+ if (this.#xs) {
283
+ const old = stripeId(this.#xs, y0);
284
+ if (old === stripeId(this.#xs, y1)) x = this.#xs.axes[old];
285
+ }
286
+ if (this.#ys) y = this.#ys.axes[stripeId(this.#ys, x0)];
287
  let xStart = 0, xEnd = 0, yStart = 0, yEnd = 0;
288
  if (loX !== hiX) {
289
+ xStart = firstCrossing(x, loX);
290
  xEnd = crossingEnd(x.values, hiX, xStart);
291
  }
292
  if (loY !== hiY) {
293
+ yStart = firstCrossing(y, loY);
294
  yEnd = crossingEnd(y.values, hiY, yStart);
295
  }
296
+ // Once edge processing grows expensive, query both endpoints together in
297
+ // the packed spatial hierarchy. Small indexes use a sequential pass.
298
  if (xEnd - xStart + yEnd - yStart > r.length / 16) {
299
+ const tree = this.#tree;
300
+ if (tree) return visitPacked(tree, r, tree.levels.length - 1, 0, x0, y0, x1, y1, emit, false);
301
  return scanMove(r, x0, y0, x1, y1, emit);
302
  }
303
 
package.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@pgg-engineering/edgechime",
3
+ "version": "0.1.0",
4
+ "description": "Exact enter and exit events for moving points over static rectangular subscriptions.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": { "types": "./index.d.ts", "import": "./index.js", "default": "./index.js" }
8
+ },
9
+ "types": "./index.d.ts",
10
+ "bin": { "edgechime": "./bin/edgechime.js" },
11
+ "files": ["index.js", "index.d.ts", "bin", "README.md", "LICENSE"],
12
+ "scripts": { "test": "node --test", "bench": "node bench/run.js" },
13
+ "engines": { "node": ">=18" },
14
+ "keywords": ["geofence", "spatial-index", "area-of-interest", "subscriptions", "multi-agent", "telemetry", "enter-exit"],
15
+ "license": "MIT"
16
+ }
source.zip ADDED
Binary file (99.2 kB). View file
 
test/cli.test.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const cli = fileURLToPath(new URL('../bin/edgechime.js', import.meta.url));
10
+ function run(lines) {
11
+ const dir = mkdtempSync(join(tmpdir(), 'edgechime-'));
12
+ try {
13
+ const path = join(dir, 'zones.json');
14
+ writeFileSync(path, '[[0,0,2,2],[1,1,4,4]]');
15
+ return spawnSync(process.execPath, [cli, path], { input: lines, encoding: 'utf8', timeout: 5000 });
16
+ } finally {
17
+ rmSync(dir, { recursive: true, force: true });
18
+ }
19
+ }
20
+
21
+ test('independent agents, quiet samples, empty lines, forget and reuse', () => {
22
+ const events = [
23
+ { agent:'a', x:0, y:0 }, { agent:'b', x:3, y:3 },
24
+ { agent:'b', x:2, y:2 }, { agent:'a', x:1, y:1 },
25
+ { agent:'b', forget:true }, { agent:'b', forget:true }, { agent:'b', x:0, y:0 }
26
+ ];
27
+ const result = run(events.map(JSON.stringify).join('\n\n'));
28
+ assert.equal(result.status, 0, result.stderr);
29
+ assert.deepEqual(result.stdout.trim().split('\n').map(s => JSON.parse(s)), [
30
+ {agent:'a', entered:[0], exited:[]}, {agent:'b', entered:[1], exited:[]},
31
+ {agent:'a', entered:[1], exited:[]}, {agent:'b', entered:[], exited:[1]},
32
+ {agent:'b', entered:[0], exited:[]}
33
+ ]);
34
+ });
35
+
36
+ test('invalid input includes the failing line and a nonzero exit', () => {
37
+ const result = run('\n{"agent":"a","y":1}\n');
38
+ assert.equal(result.status, 1);
39
+ assert.match(result.stderr, /input line 2: expected finite x and y/);
40
+ });
test/index.test.mjs ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { EdgeChime } from '../index.js';
4
+
5
+ // Direct per-box oracle, independent of the index and traversal order.
6
+ const contains = ([xMin, yMin, xMax, yMax], x, y) =>
7
+ xMin <= x && x < xMax && yMin <= y && y < yMax;
8
+
9
+ function inspectPoint(index, boxes, x, y) {
10
+ const ids = [];
11
+ const count = index.at(x, y, id => ids.push(id));
12
+ const expected = boxes.flatMap((box, id) => contains(box, x, y) ? [id] : []);
13
+ assert.equal(count, expected.length);
14
+ assert.deepEqual(ids.sort((a, b) => a - b), expected);
15
+ }
16
+
17
+ function inspectMove(index, boxes, x0, y0, x1, y1) {
18
+ const events = [];
19
+ const count = index.move(x0, y0, x1, y1, (id, entered) => events.push([id, entered]));
20
+ const expected = [];
21
+ boxes.forEach((box, id) => {
22
+ const wasInside = contains(box, x0, y0);
23
+ const isInside = contains(box, x1, y1);
24
+ if (wasInside !== isInside) expected.push([id, isInside]);
25
+ });
26
+ assert.equal(count, expected.length);
27
+ assert.deepEqual(events.sort((a, b) => a[0] - b[0]), expected);
28
+ }
29
+
30
+ test('empty index, stationary points, and jumps over both boundaries', () => {
31
+ for (const boxes of [[], [[0, 0, 1, 1]]]) {
32
+ const index = new EdgeChime(boxes);
33
+ inspectPoint(index, boxes, 0, 0);
34
+ inspectMove(index, boxes, 0, 0, 0, 0);
35
+ inspectMove(index, boxes, -100, 0.5, 100, 0.5);
36
+ inspectMove(index, boxes, 0.5, 100, 0.5, -100);
37
+ inspectMove(index, boxes, -1, -1, 4, 4);
38
+ }
39
+ });
40
+
41
+ test('corners, shared edges, duplicate subscriptions, and half-open membership', () => {
42
+ const boxes = [
43
+ [0, 0, 2, 2], [0, 0, 2, 2], [2, 0, 4, 2],
44
+ [0, 2, 2, 4], [2, 2, 4, 4], [-1, -1, 3, 3],
45
+ ];
46
+ const index = new EdgeChime(boxes);
47
+ const points = [[-1, -1], [-0, 0], [0, 1], [1, 0], [1, 1],
48
+ [2, 0], [2, 1], [0, 2], [1, 2], [2, 2], [3, 3], [4, 4]];
49
+ for (const [x0, y0] of points) {
50
+ inspectPoint(index, boxes, x0, y0);
51
+ for (const [x1, y1] of points) inspectMove(index, boxes, x0, y0, x1, y1);
52
+ }
53
+ });
54
+
55
+ test('finite floating-point bounds retain their original precision', () => {
56
+ const epsilon = Number.EPSILON;
57
+ const huge = Number.MAX_VALUE;
58
+ const tiny = Number.MIN_VALUE;
59
+ const boxes = [
60
+ [1, -1, 1 + epsilon, 1], [1 + epsilon, -1, 1 + 2 * epsilon, 1],
61
+ [-huge, -huge, huge, huge], [-tiny, -tiny, tiny, tiny],
62
+ ];
63
+ const index = new EdgeChime(boxes);
64
+ const points = [[1, 0], [1 + epsilon, 0], [1 + 2 * epsilon, 0],
65
+ [-huge, -huge], [huge, huge], [-tiny, -tiny], [-0, 0], [tiny, 0]];
66
+ for (const from of points) {
67
+ inspectPoint(index, boxes, ...from);
68
+ for (const to of points) inspectMove(index, boxes, ...from, ...to);
69
+ }
70
+ });
71
+
72
+ test('rejects invalid boxes and non-finite query coordinates', () => {
73
+ for (const box of [[1, 0, 1, 1], [0, 1, 1, 1], [2, 0, 1, 1],
74
+ [0, 2, 1, 1], [0, 0, Infinity, 1], [-Infinity, 0, 1, 1],
75
+ [0, NaN, 1, 1], [0, 0, 1], ['0', 0, 1, 1]]) {
76
+ assert.throws(() => new EdgeChime([box]));
77
+ }
78
+ const index = new EdgeChime([[0, 0, 1, 1]]);
79
+ for (const invalid of [NaN, Infinity, -Infinity]) {
80
+ for (const [method, length] of [['at', 2], ['move', 4]]) {
81
+ for (let i = 0; i < length; i++) {
82
+ const coords = Array(length).fill(0);
83
+ coords[i] = invalid;
84
+ assert.throws(() => index[method](...coords, () => {}));
85
+ }
86
+ }
87
+ }
88
+ });
89
+
90
+ test('the constructed index is independent of later input edits', () => {
91
+ const input = [[0, 0, 2, 2], [3, 3, 8, 8]];
92
+ const original = input.map(box => [...box]);
93
+ const index = new EdgeChime(input);
94
+ input[0][2] = 0;
95
+ input.reverse();
96
+ input.length = 0;
97
+ inspectPoint(index, original, 1, 1);
98
+ inspectMove(index, original, 1, 1, 4, 4);
99
+ });
100
+
101
+ test('callback queries on the same index cannot interfere with outer traversal', () => {
102
+ const boxes = Array.from({length: 180}, (_, i) => [i % 13, i % 5, 16 + i % 17, 9 + i % 11]);
103
+ const index = new EdgeChime(boxes);
104
+ const outer = [];
105
+ const count = index.move(-1, -1, 13, 7, (id, entered) => {
106
+ outer.push([id, entered]);
107
+ if (outer.length === 1 || outer.length === 70) {
108
+ inspectMove(index, boxes, 13, 7, 30, 15);
109
+ inspectPoint(index, boxes, 15, 10);
110
+ }
111
+ });
112
+ assert.equal(count, boxes.length);
113
+ assert.deepEqual(outer.sort((a, b) => a[0] - b[0]), boxes.map((_, id) => [id, true]));
114
+ });
115
+
116
+ test('random updates agree exactly with scanning every rectangle', () => {
117
+ let state = 0x64ac82f1;
118
+ function draw(limit) {
119
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
120
+ return Math.floor((state / 0x100000000) * limit);
121
+ }
122
+ const coord = () => draw(97) - 48;
123
+ for (const n of [1, 7, 31, 64, 129, 513]) {
124
+ const boxes = Array.from({length: n}, () => {
125
+ const x = coord(), y = coord();
126
+ return [x, y, x + draw(40) + 1, y + draw(40) + 1];
127
+ });
128
+ const index = new EdgeChime(boxes);
129
+ for (let i = 0; i < 200; i++) {
130
+ const [l, b, r, t] = boxes[draw(n)];
131
+ const x = i % 3 === 0 ? l : coord();
132
+ const y = i % 3 === 0 ? b : coord();
133
+ const u = i % 4 === 0 ? r : i % 4 === 1 ? x : coord();
134
+ const v = i % 4 === 0 ? t : i % 4 === 2 ? y : coord();
135
+ inspectPoint(index, boxes, x, y);
136
+ inspectMove(index, boxes, x, y, u, v);
137
+ inspectMove(index, boxes, u, v, x, y);
138
+ }
139
+ }
140
+ });