Skip to content

Commit dbaf720

Browse files
committed
feat: add example
1 parent 1443c70 commit dbaf720

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

blog/2025/2025-01-21-introducing-bytey/index.mdx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,33 @@ We did start with a bit of research if any library existed for this, but nothing
3030

3131
You can see how `38.5` became `_p~iF` and `-120.2` became `~ps|U`. The first coordinate doesn't have much of a cost savings, but as the coordinate pairs continue and each pair has the offset from the previous you can tell how the data savings begin to take place.
3232

33-
We wrote a quick PHPUnit test to confirm our implementation of the algorithm, and it matched Google's documentation.
33+
Imagine if we went to draw a box around our office we might get the coordinate pairs of:
34+
35+
* `28.03630, -82.49009`
36+
* `28.03654, -82.49009`
37+
* `28.03655, -82.49099`
38+
* `28.03629, -82.49100`
39+
* `28.03630, -82.49009`
40+
41+
This helps establish the point that most coordinates are just small iterations of the previous coordinate -- not shifting much in terms of the positioning. If we were to render those with a 19 zoom we'd get this image.
42+
43+
<div class="text--center">
44+
![](./static-map-google.png)
45+
</div>
46+
47+
This would form a URL that compounded the coordinate pairs to draw the lines.
48+
49+
```
50+
&markers=28.03630,-82.49009,28.03654,-82.49009,28.03655,-82.49099,28.03629,-82.49100,28.03630,-82.49009
51+
```
52+
53+
If we apply the algorithm we see a much smaller URL decreasing 94 characters to 22.
54+
55+
```
56+
&markers={ybjD`jnvNo@?ArDr@@AuD
57+
```
58+
59+
This was a savings of ~75% less characters and was promising for a real integration. We wrote a quick PHPUnit test to confirm our implementation of the algorithm, and it matched Google's documentation.
3460

3561
```php
3662
#[DataProvider('googleDataProvider')]
@@ -65,7 +91,7 @@ public static function googleDataProvider(): array {
6591
}
6692
```
6793

68-
So we took our affected entity that was generating a 19.5k character URL and ran it through the algorithm. The new URL was 3.3k characters, which suggested an 83% reduction in character length. A few more real life tests, and we had a fix out the door and a new package built.
94+
So we took our affected entity that was generating a 19.5k character length URL and ran it through the algorithm. The new URL was 3.3k characters, which suggested an 83% reduction in length in a more real life example. A few more real life tests, and we had a fix out the door and a new package built.
6995

7096
Thus, [Bytey](https://github.com/sourcetoad/Bytey) was born.
7197

13 KB
Loading

0 commit comments

Comments
 (0)