Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Includes:

- 📦 Extent class for working with bounding boxes
- 🀄️ Tiler class for splitting the world into rectangular tiles
- 🕹️ Transform class for managing translation, scale, rotation
- 📺 Viewport class for managing view state and converting between Lon/Lat (λ,φ) and Cartesian (x,y) coordinates
- 🕹️ Transform class for managing translation, zoom, rotation
- 📺 Viewport class for managing view state and converting between Lon/Lat [λ,φ] and Cartesian [x,y] coordinates


### util
Expand Down
4 changes: 1 addition & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/classes/_rapid_sdk_math.Viewport.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Viewport | rapid-sdk</title><meta name="description" content="Documentation for rapid-sdk"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">rapid-sdk</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">rapid-sdk</a></li><li><a href="../modules/_rapid_sdk_math.html">@rapid-sdk/math</a></li><li><a href="_rapid_sdk_math.Viewport.html">Viewport</a></li></ul><h1>Class Viewport</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p><code>Viewport</code> is a class for managing the state of the viewer
and converting between Lon/Lat (λ,φ) and Cartesian (x,y) coordinates</p>
and converting between Lon/Lat [λ,φ] and Cartesian [x,y] coordinates</p>
<p>Original geographic coordinate data is in WGS84 (Lon,Lat)
and &quot;projected&quot; into screen space (x,y) using the Web Mercator projection
and &quot;projected&quot; into screen space [x,y] using the Web Mercator projection
see: <a href="https://en.wikipedia.org/wiki/Web_Mercator_projection">https://en.wikipedia.org/wiki/Web_Mercator_projection</a></p>
<p>The parameters of this projection are stored in <code>_transform</code></p>
<ul>
Expand Down Expand Up @@ -57,15 +57,15 @@ <h4 class="tsd-anchor-link"><a id="Example" class="tsd-anchor"></a>Example<a hre
<div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Example-4" class="tsd-anchor"></a>Example<a href="#Example-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">v</span><span class="hl-1"> = </span><span class="hl-4">new</span><span class="hl-1"> </span><span class="hl-6">Viewport</span><span class="hl-1">();</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-2">dimensions</span><span class="hl-1"> = [</span><span class="hl-8">800</span><span class="hl-1">, </span><span class="hl-8">600</span><span class="hl-1">]</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-2">transform</span><span class="hl-1"> = { </span><span class="hl-2">x:</span><span class="hl-1"> </span><span class="hl-8">400</span><span class="hl-1">, </span><span class="hl-2">y:</span><span class="hl-1"> </span><span class="hl-8">300</span><span class="hl-1"> };</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">centerLoc</span><span class="hl-1">(); </span><span class="hl-7">// returns [0, 0] (&quot;Null Island&quot;)</span>
</code><button type="button">Copy</button></pre>

</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rapideditor/rapid-sdk/blob/66c0299ce69484864b04c101c02f0abe3bf32869/packages/math/src/Viewport.ts#L185">Viewport.ts:185</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="project" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>project</span><a href="#project" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="project.project-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">project</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">loc</span>, <span class="tsd-kind-parameter">includeRotation</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a><a href="#project.project-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Projects a coordinate from Lon/Lat (λ,φ) to Cartesian (x,y)</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">loc</span>: <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></span><div class="tsd-comment tsd-typography"><p>Lon/Lat (λ,φ)</p>
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">includeRotation</span>: <span class="tsd-signature-type">boolean</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></h4><p>Cartesian (x,y)</p>
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rapideditor/rapid-sdk/blob/66c0299ce69484864b04c101c02f0abe3bf32869/packages/math/src/Viewport.ts#L185">Viewport.ts:185</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="project" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>project</span><a href="#project" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="project.project-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">project</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">loc</span>, <span class="tsd-kind-parameter">includeRotation</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a><a href="#project.project-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Projects a coordinate from Lon/Lat [λ,φ] to Cartesian [x,y]</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">loc</span>: <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></span><div class="tsd-comment tsd-typography"><p>Lon/Lat [λ,φ]</p>
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">includeRotation</span>: <span class="tsd-signature-type">boolean</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></h4><p>Cartesian [x,y]</p>
<div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Example-5" class="tsd-anchor"></a>Example<a href="#Example-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">v</span><span class="hl-1"> = </span><span class="hl-4">new</span><span class="hl-1"> </span><span class="hl-6">Viewport</span><span class="hl-1">();</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">project</span><span class="hl-1">([</span><span class="hl-8">0</span><span class="hl-1">, </span><span class="hl-8">0</span><span class="hl-1">]); </span><span class="hl-7">// returns [0, 0]</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">project</span><span class="hl-1">([</span><span class="hl-8">180</span><span class="hl-1">, -</span><span class="hl-8">85.0511287798</span><span class="hl-1">]); </span><span class="hl-7">// returns [256, 256]</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">project</span><span class="hl-1">([-</span><span class="hl-8">180</span><span class="hl-1">, </span><span class="hl-8">85.0511287798</span><span class="hl-1">]); </span><span class="hl-7">// returns [-256, -256]</span>
</code><button type="button">Copy</button></pre>

</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rapideditor/rapid-sdk/blob/66c0299ce69484864b04c101c02f0abe3bf32869/packages/math/src/Viewport.ts#L84">Viewport.ts:84</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="unproject" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>unproject</span><a href="#unproject" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="unproject.unproject-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">unproject</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">point</span>, <span class="tsd-kind-parameter">includeRotation</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a><a href="#unproject.unproject-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Unprojects a coordinate from given Cartesian (x,y) to Lon/Lat (λ,φ)</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">point</span>: <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></span><div class="tsd-comment tsd-typography"><p>Cartesian (x,y)</p>
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">includeRotation</span>: <span class="tsd-signature-type">boolean</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></h4><p>Lon/Lat (λ,φ)</p>
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rapideditor/rapid-sdk/blob/66c0299ce69484864b04c101c02f0abe3bf32869/packages/math/src/Viewport.ts#L84">Viewport.ts:84</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="unproject" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>unproject</span><a href="#unproject" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="unproject.unproject-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">unproject</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">point</span>, <span class="tsd-kind-parameter">includeRotation</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a><a href="#unproject.unproject-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Unprojects a coordinate from given Cartesian [x,y] to Lon/Lat [λ,φ]</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">point</span>: <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></span><div class="tsd-comment tsd-typography"><p>Cartesian [x,y]</p>
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">includeRotation</span>: <span class="tsd-signature-type">boolean</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../types/_rapid_sdk_math.Vec2.html" class="tsd-signature-type tsd-kind-type-alias">Vec2</a></h4><p>Lon/Lat [λ,φ]</p>
<div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Example-6" class="tsd-anchor"></a>Example<a href="#Example-6" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">v</span><span class="hl-1"> = </span><span class="hl-4">new</span><span class="hl-1"> </span><span class="hl-6">Viewport</span><span class="hl-1">();</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">unproject</span><span class="hl-1">([</span><span class="hl-8">0</span><span class="hl-1">, </span><span class="hl-8">0</span><span class="hl-1">]); </span><span class="hl-7">// returns [0, 0]</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">unproject</span><span class="hl-1">([</span><span class="hl-8">256</span><span class="hl-1">, </span><span class="hl-8">256</span><span class="hl-1">]); </span><span class="hl-7">// returns [180, -85.0511287798]</span><br/><span class="hl-2">v</span><span class="hl-1">.</span><span class="hl-6">unproject</span><span class="hl-1">([-</span><span class="hl-8">256</span><span class="hl-1">, -</span><span class="hl-8">256</span><span class="hl-1">]); </span><span class="hl-7">// returns [-180, 85.0511287798]</span>
</code><button type="button">Copy</button></pre>

Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<p>🕹️ Transform class for managing translation, scale, rotation</p>
</li>
<li>
<p>📺 Viewport class for managing view state and converting between Lon/Lat (λ,φ) and Cartesian (x,y) coordinates</p>
<p>📺 Viewport class for managing view state and converting between Lon/Lat [λ,φ] and Cartesian [x,y] coordinates</p>
</li>
</ul>
<a id="md:util" class="tsd-anchor"></a><h3 class="tsd-anchor-link">util<a href="#md:util" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>🧳 <a href="/packages/util">@rapid-sdk/util</a></p>
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/_rapid_sdk_math.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<p>🕹️ Transform class for managing translation, scale, rotation</p>
</li>
<li>
<p>📺 Viewport class for managing view state and converting between Lon/Lat (λ,φ) and Cartesian (x,y) coordinates</p>
<p>📺 Viewport class for managing view state and converting between Lon/Lat [λ,φ] and Cartesian [x,y] coordinates</p>
</li>
</ul>
<a id="md:contributing" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Contributing<a href="#md:contributing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>This project is just getting started! 🌱</p>
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"packages/math",
"packages/util"
],
"dependencies": {
"@types/geojson": "^7946.0.16"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/bun": "^1.3.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/math/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { Extent } from '@rapid-sdk/math'; // ESM import named

- 📦 Extent class for working with bounding boxes
- 🀄️ Tiler class for splitting the world into rectangular tiles
- 🕹️ Transform class for managing translation, scale, rotation
- 📺 Viewport class for managing view state and converting between Lon/Lat (λ,φ) and Cartesian (x,y) coordinates
- 🕹️ Transform class for managing translation, zoom, rotation
- 📺 Viewport class for managing view state and converting between Lon/Lat [λ,φ] and Cartesian [x,y] coordinates


## Contributing
Expand Down
1 change: 1 addition & 0 deletions packages/math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"test": "bun test --dots --coverage ./test"
},
"dependencies": {
"@types/geojson": "^7946.0.16",
"@types/d3-polygon": "^3.0.2",
"d3-polygon": "^3.0.1"
},
Expand Down
Loading