Compare commits
111
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7d980390d | ||
|
|
05bc8856f6 | ||
|
|
562a53e853 | ||
|
|
419744e64b | ||
|
|
b008537694 | ||
|
|
11919731d2 | ||
|
|
2a285312b0 | ||
|
|
027672d885 | ||
|
|
e016342dea | ||
|
|
a56e2b6340 | ||
|
|
b1fa384476 | ||
|
|
efa886ad3e | ||
|
|
3d25b2642a | ||
|
|
ca7125f3ac | ||
|
|
c247e3dde0 | ||
|
|
a25d7ce09b | ||
|
|
1bbd97b382 | ||
|
|
5999ef7d8d | ||
|
|
a764eefcd8 | ||
|
|
f2bd3fecfe | ||
|
|
ee5702f21e | ||
|
|
c4e9dd3951 | ||
|
|
2e928d2d64 | ||
|
|
8ec9465274 | ||
|
|
de40d79662 | ||
|
|
853c173c37 | ||
|
|
fcef4d46fa | ||
|
|
3e8a54a541 | ||
|
|
5c97ceaa64 | ||
|
|
9312c40862 | ||
|
|
52a08dfd7b | ||
|
|
fe1c80e798 | ||
|
|
bce7da4006 | ||
|
|
534ccc03af | ||
|
|
0736b7a051 | ||
|
|
c706d83009 | ||
|
|
6b3f351d38 | ||
|
|
62c333e99a | ||
|
|
e46096dd87 | ||
|
|
48c4045f84 | ||
|
|
c656c86baa | ||
|
|
975c4b1d38 | ||
|
|
38fc546b12 | ||
|
|
66f9d705d7 | ||
|
|
652aa3f94f | ||
|
|
e6995e3a17 | ||
|
|
ba8d031d19 | ||
|
|
4d33d434c0 | ||
|
|
350f70c34f | ||
|
|
0c54d6ca1d | ||
|
|
9a92640469 | ||
|
|
44c05efd95 | ||
|
|
b19ec0af6e | ||
|
|
0a3d7c96ea | ||
|
|
665ad5317c | ||
|
|
5ca9be2070 | ||
|
|
e6dc172871 | ||
|
|
74d61f3e8c | ||
|
|
875e12cb22 | ||
|
|
c773eacceb | ||
|
|
91123ecc1b | ||
|
|
51b7fe01d5 | ||
|
|
f98615e198 | ||
|
|
0d795bf5e8 | ||
|
|
76b7fea27b | ||
|
|
2e93b45927 | ||
|
|
8b7b4204b4 | ||
|
|
5d62ce138a | ||
|
|
706fde7610 | ||
|
|
7db1980e0f | ||
|
|
60a584d03f | ||
|
|
9f9e0fb81a | ||
|
|
665893ef80 | ||
|
|
f5ea9d6432 | ||
|
|
f4c420a665 | ||
|
|
6c6f44cc7e | ||
|
|
c4f32ece18 | ||
|
|
6cfef39e1b | ||
|
|
bccdc6aa26 | ||
|
|
fcdea75bdc | ||
|
|
9748d02820 | ||
|
|
39c7324872 | ||
|
|
53f4a02d07 | ||
|
|
3f6c9bf7c7 | ||
|
|
3df54a8c47 | ||
|
|
1d90209d51 | ||
|
|
f64d5a61ba | ||
|
|
c995716d02 | ||
|
|
899d23e2e5 | ||
|
|
59b0c638c7 | ||
|
|
9e8ea82480 | ||
|
|
3c516ff021 | ||
|
|
e77626d84d | ||
|
|
5f85a1d9e8 | ||
|
|
4845b72cc8 | ||
|
|
3522c7646f | ||
|
|
97188a9c64 | ||
|
|
90b9c029df | ||
|
|
c2722856d8 | ||
|
|
1505b0902b | ||
|
|
83752b96c9 | ||
|
|
9db38cb0de | ||
|
|
522e976739 | ||
|
|
19b521c5ca | ||
|
|
e8e2311422 | ||
|
|
41e2413af4 | ||
|
|
a3e19cecef | ||
|
|
62daafc4a0 | ||
|
|
3f17dd21f8 | ||
|
|
400ac5aa13 | ||
|
|
83d329e407 |
No files matched your search
@@ -1,95 +0,0 @@
|
||||
---
|
||||
trigger: model_decision
|
||||
description: This is an explanation of the purpose of the project
|
||||
---
|
||||
|
||||
WorldWideView is best described as a modular, real‑time geospatial intelligence engine built on top of a CesiumJS 3D globe, designed to ingest live data streams, transform them through a plugin system, and render them as high‑performance visual layers. The repository you have open shows a Next.js application with a generalized plugin architecture and a Cesium viewer at its core .
|
||||
|
||||
🌍 What WorldWideView fundamentally is
|
||||
WorldWideView is a real‑time situational awareness platform. It takes raw, fast‑moving geospatial signals—like aircraft positions, maritime AIS, satellite orbits, or any other sensor feed—and turns them into interactive, cinematic layers on a 3D globe. The system is built to be:
|
||||
|
||||
Modular, so each data source is a plugin.
|
||||
|
||||
High‑performance, using Cesium primitives instead of entities.
|
||||
|
||||
Extensible, allowing new data types without rewriting the core.
|
||||
|
||||
Real‑time, updating the globe smoothly as new data arrives.
|
||||
|
||||
Visual, using icons, arrows, and 3D models to represent moving objects.
|
||||
|
||||
It’s essentially your own open, customizable version of tools like SkyGlass, ADSBexchange 3D, or WorldView (Bilawal Sidhu’s demo), but engineered for long‑term scalability.
|
||||
|
||||
🧩 Core components of the system
|
||||
Plugin system (your recent commits)
|
||||
Your latest commit message—“generalize plugin system, remove aviation special treatment” —shows that the architecture now treats every data source as a plugin. This means:
|
||||
|
||||
Each plugin defines how it fetches, parses, and visualizes data.
|
||||
|
||||
The core engine doesn’t care whether the plugin is aviation, maritime, satellites, or something else.
|
||||
|
||||
You can add new intelligence layers without touching the core.
|
||||
|
||||
This is a major architectural milestone.
|
||||
|
||||
Cesium rendering engine
|
||||
The project initializes a Cesium globe inside a Next.js app. Cesium handles:
|
||||
|
||||
Globe rendering
|
||||
|
||||
Camera control
|
||||
|
||||
Terrain and imagery layers
|
||||
|
||||
Worker‑based geometry processing
|
||||
|
||||
High‑performance primitives for thousands of objects
|
||||
|
||||
Your open tabs (Cesium picking performance, CZML, map type switching) show you’re actively tuning this layer.
|
||||
|
||||
Real‑time data ingestion
|
||||
The system is designed to ingest live feeds such as:
|
||||
|
||||
ADS‑B aircraft positions
|
||||
|
||||
AIS maritime positions
|
||||
|
||||
Satellite TLE propagation
|
||||
|
||||
Custom sensor networks
|
||||
|
||||
Each plugin transforms raw data into Cesium‑ready primitives.
|
||||
|
||||
Visual representation
|
||||
Your recent work on low‑poly aircraft icons and arrow models shows the platform is moving toward:
|
||||
|
||||
Lightweight, directional markers
|
||||
|
||||
Orientation‑aware icons
|
||||
|
||||
Smooth fly‑to tracking
|
||||
|
||||
Cinematic camera behavior
|
||||
|
||||
This is what gives the platform its “WorldView‑like” feel.
|
||||
|
||||
🚀 What makes WorldWideView unique
|
||||
1. It’s modular from the ground up
|
||||
Most geospatial dashboards hard‑code aviation or maritime logic. You’ve removed that. Any data source can become a plugin.
|
||||
|
||||
2. It’s built for performance
|
||||
You’re migrating from Cesium Entities to Primitives, optimizing picking, and reducing GPU stalls—this is what allows thousands of objects to render smoothly.
|
||||
|
||||
3. It’s designed for real‑time intelligence
|
||||
Not just visualization—actual situational awareness. The architecture supports:
|
||||
|
||||
live updates
|
||||
|
||||
event‑driven pipelines
|
||||
|
||||
time‑dynamic objects
|
||||
|
||||
replay capability (future feature)
|
||||
|
||||
4. It’s open and extensible
|
||||
Unlike proprietary tools, your system can be extended by anyone who writes a plugin.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
description: cesium
|
||||
---
|
||||
|
||||
https://cesium.com/
|
||||
https://cesium.com/platform/cesiumjs/
|
||||
https://cesium.com/platform/cesiumjs/ion-sdk/
|
||||
https://sandcastle.cesium.com/?id=czml
|
||||
https://cesium.com/learn/cesiumjs-learn/
|
||||
https://cesium.com/learn/cesiumjs-learn/cesiumjs-camera/
|
||||
https://cesium.com/learn/cesiumjs-learn/cesiumjs-geometry-appearances/
|
||||
https://cesium.com/learn/cesiumjs-learn/cesiumjs-flight-tracker/
|
||||
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
.next
|
||||
.git
|
||||
*.md
|
||||
artifacts
|
||||
.env*
|
||||
!.env.example
|
||||
@@ -0,0 +1,4 @@
|
||||
DATABASE_URL=file:./data/wwv.db
|
||||
|
||||
# Edition: "local" | "cloud" | "demo"
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
+33
-4
@@ -1,15 +1,44 @@
|
||||
# Environment Variables Example
|
||||
# ============================================================
|
||||
# .env — committed to git (non-secret defaults)
|
||||
# ============================================================
|
||||
# This file is tracked by git. Only put non-secret values here.
|
||||
# Prisma reads DATABASE_URL from this file.
|
||||
|
||||
# Cesium Ion Access Token (Required for terrain and default imagery)
|
||||
# Get your token at https://ion.cesium.com/
|
||||
# Database (SQLite for local — zero config; PostgreSQL for cloud)
|
||||
DATABASE_URL=file:./data/wwv.db
|
||||
|
||||
# ============================================================
|
||||
# .env.local — NOT committed (secrets & API keys)
|
||||
# ============================================================
|
||||
# Copy everything below into a new file called .env.local
|
||||
# .env.local is gitignored and overrides .env values.
|
||||
|
||||
# Cesium Ion Access Token (optional — get one free at https://ion.cesium.com/)
|
||||
NEXT_PUBLIC_CESIUM_ION_TOKEN=
|
||||
|
||||
# Bing Maps API Key (Optional, for high-res imagery)
|
||||
# Get your key at https://www.bingmapsportal.com/
|
||||
NEXT_PUBLIC_BING_MAPS_KEY=
|
||||
|
||||
# Supabase Configuration (Required for persistence and historical data)
|
||||
# Supabase Configuration (Optional — cloud-only features)
|
||||
# Found in your Supabase Project Settings > API
|
||||
NEXT_PUBLIC_SUPABASE_URL=
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
||||
SUPABASE_SERVICE_ROLE_KEY=
|
||||
|
||||
# OpenSky Network — multi-account credential rotation
|
||||
# Comma-separated clientId:clientSecret pairs.
|
||||
# Example: OPENSKY_CREDENTIALS=acct1-id:acct1-secret,acct2-id:acct2-secret
|
||||
OPENSKY_CREDENTIALS=
|
||||
|
||||
# Marketplace Bridge Token — shared secret for marketplace → WWV install requests
|
||||
# Generate any random string, then set the same value in the marketplace instance config.
|
||||
WWV_BRIDGE_TOKEN=
|
||||
|
||||
# Edition: "local" | "cloud" | "demo"
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
|
||||
# Demo Admin Secret (demo edition only)
|
||||
# Allows operator plugin management on the demo instance via x-wwv-admin-secret header.
|
||||
# Generate any random string. Only set this on the demo deployment.
|
||||
# WWV_DEMO_ADMIN_SECRET=
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Report something that isn't working correctly
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Describe the Bug
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '...'
|
||||
3. See error
|
||||
|
||||
## Expected Behaviour
|
||||
|
||||
What you expected to happen.
|
||||
|
||||
## Actual Behaviour
|
||||
|
||||
What actually happened. Include screenshots or console errors if applicable.
|
||||
|
||||
## Environment
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| OS | e.g. Windows 11 |
|
||||
| Browser | e.g. Chrome 122 |
|
||||
| Node.js | e.g. 20.x |
|
||||
| Plugin(s) affected | e.g. ADS-B, AIS |
|
||||
|
||||
## Additional Context
|
||||
|
||||
Any other context about the problem — relevant config, data source URLs, Cesium Ion token issues, etc.
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature or improvement
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
A brief, one-line description of the feature.
|
||||
|
||||
## Motivation
|
||||
|
||||
Why is this needed? What problem does it solve or what use case does it enable?
|
||||
|
||||
## Proposed Solution
|
||||
|
||||
Describe your suggested approach. If this is a new **plugin**, describe:
|
||||
- The data source (URL, format, update frequency)
|
||||
- What it would render on the globe (icons, paths, primitives)
|
||||
- Any external APIs or credentials required
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
Any other approaches you thought about and why you ruled them out.
|
||||
|
||||
## Additional Context
|
||||
|
||||
Screenshots, mockups, links to similar tools, or relevant documentation.
|
||||
@@ -0,0 +1,44 @@
|
||||
## Summary
|
||||
|
||||
<!-- A short description of what this PR does and why. -->
|
||||
|
||||
## Type of Change
|
||||
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature
|
||||
- [ ] New plugin
|
||||
- [ ] Refactor / code quality
|
||||
- [ ] Documentation
|
||||
- [ ] Performance improvement
|
||||
|
||||
## Related Issue
|
||||
|
||||
Closes #<!-- issue number -->
|
||||
|
||||
## Changes Made
|
||||
|
||||
<!-- List the key changes. Be specific about files and modules affected. -->
|
||||
|
||||
-
|
||||
-
|
||||
|
||||
## Testing
|
||||
|
||||
- [ ] I ran `npm test` and all tests pass
|
||||
- [ ] I manually tested this in the browser against a live data source
|
||||
- [ ] I added or updated tests for my changes
|
||||
|
||||
## Plugin Checklist (if applicable)
|
||||
|
||||
- [ ] Plugin is registered with `PluginRegistry`
|
||||
- [ ] Plugin does not import or depend on core rendering logic directly
|
||||
- [ ] Plugin cleans up Cesium primitives on unmount/disable
|
||||
- [ ] No hardcoded credentials or API keys committed
|
||||
|
||||
## Screenshots / Recordings
|
||||
|
||||
<!-- If this changes the UI or globe rendering, include a screenshot or screen recording. -->
|
||||
|
||||
## Notes for Reviewer
|
||||
|
||||
<!-- Any context that would help the reviewer understand the approach or trade-offs. -->
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Publish Plugin to NPM
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "wwv-plugin-*-v*" # e.g. wwv-plugin-aviation-v1.0.1
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write # Required for OIDC trusted publishing (no NPM_TOKEN needed)
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Detect package name from tag
|
||||
id: pkg
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
# Strips the -vX.Y.Z suffix: "wwv-plugin-aviation-v1.0.1" → "wwv-plugin-aviation"
|
||||
PKG=$(echo "$TAG" | sed 's/-v[0-9].*//')
|
||||
echo "package=$PKG" >> $GITHUB_OUTPUT
|
||||
echo "Publishing: $PKG"
|
||||
|
||||
- name: Build package
|
||||
run: npm run build -w packages/${{ steps.pkg.outputs.package }}
|
||||
|
||||
- name: Publish to NPM (OIDC)
|
||||
run: npm publish packages/${{ steps.pkg.outputs.package }} --access public --provenance
|
||||
+16
@@ -17,12 +17,24 @@
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# agents
|
||||
/.agents/
|
||||
|
||||
# performance
|
||||
/performance/
|
||||
|
||||
# artifacts
|
||||
/artifacts/
|
||||
|
||||
# scripts
|
||||
/scripts/
|
||||
|
||||
# local database
|
||||
/data/
|
||||
|
||||
# generated prisma client
|
||||
/src/generated/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
@@ -38,6 +50,7 @@ yarn-error.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
!.env
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
@@ -45,3 +58,6 @@ yarn-error.log*
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# Plugin build artifacts
|
||||
packages/*/dist/
|
||||
@@ -0,0 +1,55 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and maintainers of **WorldWideView** pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
---
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behaviour that contributes to a positive environment:
|
||||
|
||||
- Using welcoming and inclusive language
|
||||
- Being respectful of differing viewpoints and experiences
|
||||
- Gracefully accepting constructive criticism
|
||||
- Focusing on what is best for the community
|
||||
- Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behaviour:
|
||||
|
||||
- The use of sexualised language or imagery, and sexual attention or advances of any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information without explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
---
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Maintainers are responsible for clarifying and enforcing our standards of acceptable behaviour and will take appropriate and fair corrective action in response to any behaviour that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct.
|
||||
|
||||
---
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all project spaces — GitHub issues, pull requests, discussions, and any other official channels.
|
||||
|
||||
---
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by opening a GitHub issue marked **[CoC]** or by contacting the maintainer directly via GitHub.
|
||||
|
||||
All complaints will be reviewed and investigated promptly and fairly. The maintainer is obligated to respect the privacy and security of the reporter.
|
||||
|
||||
---
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
# Contributing to WorldWideView
|
||||
|
||||
Thank you for your interest in contributing to **WorldWideView** — a modular, real-time geospatial intelligence engine!
|
||||
|
||||
This project is licensed under the [Elastic License 2.0](./LICENSE). By submitting a contribution, you agree that your code will be made available under those same terms.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Getting Started](#getting-started)
|
||||
- [Development Setup](#development-setup)
|
||||
- [Project Structure](#project-structure)
|
||||
- [How to Contribute](#how-to-contribute)
|
||||
- [Plugin Contributions](#plugin-contributions)
|
||||
- [Code Standards](#code-standards)
|
||||
- [Commit & Branch Conventions](#commit--branch-conventions)
|
||||
- [Pull Request Process](#pull-request-process)
|
||||
- [Running Tests](#running-tests)
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. **Fork** the repository on GitHub.
|
||||
2. **Clone** your fork locally:
|
||||
```bash
|
||||
git clone https://github.com/<your-username>/worldwideview.git
|
||||
cd worldwideview
|
||||
```
|
||||
3. **Install dependencies**:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
4. **Copy the environment file** and fill in your API keys:
|
||||
```bash
|
||||
cp .env.example .env.local
|
||||
```
|
||||
5. **Start the dev server**:
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Visit `http://localhost:3000` to confirm everything is running.
|
||||
|
||||
---
|
||||
|
||||
## Development Setup
|
||||
|
||||
| Requirement | Version |
|
||||
|-------------|---------|
|
||||
| Node.js | 18+ |
|
||||
| npm | 9+ |
|
||||
|
||||
See [`docs/SETUP.md`](docs/SETUP.md) for detailed environment setup, including Cesium Ion token configuration.
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
core/ # Core engine: state, data bus, plugin registry
|
||||
plugins/ # Data source plugins (ADS-B, AIS, satellites, etc.)
|
||||
components/ # React UI components
|
||||
hooks/ # Custom React hooks
|
||||
docs/ # Architecture and user guides
|
||||
```
|
||||
|
||||
See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for a deep dive into the rendering pipeline and plugin lifecycle.
|
||||
|
||||
---
|
||||
|
||||
## How to Contribute
|
||||
|
||||
Ways you can help:
|
||||
|
||||
- 🐛 **Bug fixes** — Check the [issue tracker](https://github.com/silvertakana/worldwideview/issues)
|
||||
- 🧩 **New plugins** — Add a new data source layer (see below)
|
||||
- 📖 **Documentation** — Improve guides or add examples
|
||||
- ⚡ **Performance** — Cesium primitive optimizations, GPU stall reduction
|
||||
- 🧪 **Tests** — Expand Vitest coverage
|
||||
|
||||
For large features, **open an issue first** to discuss the design before writing code.
|
||||
|
||||
---
|
||||
|
||||
## Plugin Contributions
|
||||
|
||||
The core extension point of WorldWideView is its **plugin system**. Each plugin is a self-contained data layer that:
|
||||
|
||||
1. Fetches or subscribes to a data source
|
||||
2. Transforms raw data into Cesium-ready primitives
|
||||
3. Registers itself with the `PluginRegistry`
|
||||
|
||||
See [`docs/PLUGIN_GUIDE.md`](docs/PLUGIN_GUIDE.md) for a full walkthrough. New plugins are very welcome — if you have access to a live geospatial data feed, a plugin is the best way to contribute.
|
||||
|
||||
---
|
||||
|
||||
## Code Standards
|
||||
|
||||
This project follows these principles:
|
||||
|
||||
- **Single Responsibility Principle** — each file/module does one thing
|
||||
- **DRY & SOLID** — avoid duplication, favour composition
|
||||
- **Clean Architecture** — UI, logic, and data are separate concerns
|
||||
- **Defensive Programming** — validate inputs, handle edge cases explicitly
|
||||
- **File size** — keep files under 150 lines; split into modules if needed
|
||||
|
||||
Use TypeScript strictly. Avoid `any` unless absolutely unavoidable.
|
||||
|
||||
---
|
||||
|
||||
## Commit & Branch Conventions
|
||||
|
||||
**Branch naming:**
|
||||
```
|
||||
feat/short-description
|
||||
fix/short-description
|
||||
docs/short-description
|
||||
refactor/short-description
|
||||
```
|
||||
|
||||
**Commit messages** follow [Conventional Commits](https://www.conventionalcommits.org/):
|
||||
```
|
||||
feat: add maritime AIS plugin
|
||||
fix: resolve camera snap on globe reset
|
||||
docs: update plugin guide with lifecycle diagram
|
||||
refactor: extract billboard factory from CesiumMap
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. Ensure your branch is up to date with `main`.
|
||||
2. Run tests and confirm they pass: `npm test`
|
||||
3. Fill out the [PR template](.github/PULL_REQUEST_TEMPLATE.md) completely.
|
||||
4. Request a review — PRs need at least one approval before merging.
|
||||
5. Squash commits on merge if the history is noisy.
|
||||
|
||||
---
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
npm test # Run all tests via Vitest
|
||||
npm run test:ui # Open Vitest UI (interactive)
|
||||
```
|
||||
|
||||
Tests live alongside source files in `__tests__/` directories or as `.test.ts` files.
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
# Stage 1: Install dependencies
|
||||
FROM node:22-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Stage 2: Build the application
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
RUN node scripts/copy-cesium.mjs
|
||||
|
||||
# Stage 3: Production runner
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
|
||||
# Copy standalone server output
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
|
||||
# Copy static assets that standalone mode does NOT include
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,250 +0,0 @@
|
||||
# World Wide View — Implementation Plan
|
||||
|
||||
A next-generation, open-source geospatial intelligence platform combining **Worldview's cinematic CesiumJS 3D globe** with **Worldmonitor's data-rich ingestion engine**, built around a **modular plugin ecosystem**, and designed for both **community self-hosting** and **commercial SaaS deployment**.
|
||||
|
||||
## User Review Required
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **CesiumJS + Google 3D Tiles (Recommended)**: For a "low cost, fast, and efficient" setup that looks like Bilawal's "Worldview" videos, I recommend **CesiumJS with Google Maps Photorealistic 3D Tiles**.
|
||||
> - **Cost**: Google Provides a **$200/month free credit**, which covers ~33,000 sessions (each session is 3 hours of 3D globe usage). This is essentially **$0 for small-to-medium volume**.
|
||||
> - **Efficiency**: CesiumJS is built natively for 3D Tiles and time-dynamic data (CZML), making it the "fastest" path to build the cinematic features you want.
|
||||
> - **Alternatives**: MapLibre GL JS is "lighter" for standard maps but lacks the high-end 3D terrain/building polish. Deck.gl is better suited for the dashboard overlays (which we can still integrate into Cesium).
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Scope for this bootstrap**: This plan covers **Phase 1 — Foundation/MVP** only. This gets you a working 3D globe app with the plugin architecture, 3 live data layers, a timeline, cinematic camera, and a sidebar intelligence panel. Subsequent phases will be planned after Phase 1 ships.
|
||||
|
||||
> [!WARNING]
|
||||
> **API keys required**:
|
||||
> - **Google Maps Tile API Key** (Required for Photorealistic 3D Tiles — Includes $200/mo credit).
|
||||
> - **OpenSky Network** account (free at [opensky-network.org](https://opensky-network.org)).
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### Project Scaffolding
|
||||
|
||||
Summary: Initialize a Next.js (App Router) + TypeScript project with a modular architecture, designed from day one as a plugin ecosystem.
|
||||
|
||||
#### [NEW] [package.json](file:///c:/dev/World%20Wide%20View/package.json)
|
||||
Root `package.json` with Next.js, React 18, TypeScript, CesiumJS, and Resium. Will include a custom `copy-cesium` script to move static assets to `/public/cesium` for Next.js compatibility.
|
||||
|
||||
#### [NEW] [next.config.mjs](file:///c:/dev/World%20Wide%20View/next.config.mjs)
|
||||
Next.js config with path aliases, environment variable handling, and specific Webpack exclusions for CesiumJS Node.js dependencies.
|
||||
|
||||
#### [NEW] [tsconfig.json](file:///c:/dev/World%20Wide%20View/tsconfig.json)
|
||||
TypeScript config with strict mode, path aliases for `@/core`, `@/plugins`, `@/components`.
|
||||
|
||||
#### [NEW] [.env.example](file:///c:/dev/World%20Wide%20View/.env.example)
|
||||
Template with all required/optional environment variables documented.
|
||||
|
||||
---
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
c:\dev\World Wide View\
|
||||
├── public/ # Static assets (including /cesium)
|
||||
├── src/
|
||||
│ ├── app/ # Next.js App Router
|
||||
│ │ ├── page.tsx # Main entry (Client component)
|
||||
│ │ ├── layout.tsx # Root layout
|
||||
│ │ ├── globals.css # Global styles
|
||||
│ │ └── api/ # Next.js Route Handlers (Backend)
|
||||
│ │ ├── aviation/route.ts# OpenSky proxy
|
||||
│ │ ├── maritime/route.ts# AIS proxy
|
||||
│ │ └── wildfire/route.ts# NASA FIRMS proxy
|
||||
│ ├── core/ # Core platform code
|
||||
│ │ ├── globe/ # CesiumJS globe wrapper (Dynamic Import)
|
||||
│ │ │ ├── GlobeView.tsx # Main 3D globe component
|
||||
│ │ │ ├── CameraController.ts # Cinematic camera system
|
||||
│ │ │ ├── LayerRenderer.ts # Renders plugin data on globe
|
||||
│ │ │ └── TimelineSync.ts # Syncs Cesium clock with UI
|
||||
│ │ ├── plugins/ # Plugin system
|
||||
│ │ │ ├── PluginManager.ts # Plugin lifecycle manager
|
||||
│ │ │ ├── PluginTypes.ts # Plugin interface definitions
|
||||
│ │ │ └── PluginRegistry.ts# Registration & discovery
|
||||
│ │ ├── data/ # Data management
|
||||
│ │ │ ├── DataBus.ts # Event bus for data flow
|
||||
│ │ │ ├── CacheLayer.ts # In-memory + IndexedDB caching
|
||||
│ │ │ └── PollingManager.ts# Manages refresh intervals
|
||||
│ │ └── state/ # Global state management
|
||||
│ │ └── store.ts # Zustand store
|
||||
│ ├── plugins/ # Built-in data source plugins
|
||||
│ │ ├── aviation/ # OpenSky / ADS-B
|
||||
│ │ ├── maritime/ # AIS vessel tracking
|
||||
│ │ └── wildfire/ # NASA FIRMS
|
||||
│ ├── components/ # UI components
|
||||
│ │ ├── layout/ # AppShell, Header, Sidebar
|
||||
│ │ ├── panels/ # LayerPanel, IntelPanel, Detail
|
||||
│ │ ├── timeline/ # Timeline scrubber
|
||||
│ │ └── common/ # Loading, Toast, etc.
|
||||
│ └── utils/ # Helpers
|
||||
├── .env.example
|
||||
├── package.json
|
||||
├── tsconfig.json
|
||||
└── next.config.mjs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Core Globe Component
|
||||
|
||||
#### [NEW] [GlobeView.tsx](file:///c:/dev/World%20Wide%20View/src/core/globe/GlobeView.tsx)
|
||||
- CesiumJS `Viewer` inside React using Resium
|
||||
- WGS84 ellipsoid, terrain, imagery layers
|
||||
- Request render mode for performance
|
||||
- Integrates with `TimelineSync` for time-based filtering
|
||||
|
||||
#### [NEW] [CameraController.ts](file:///c:/dev/World%20Wide%20View/src/core/globe/CameraController.ts)
|
||||
- Cinematic fly-to animations with easing (Worldview-style smooth transitions)
|
||||
- 8 regional presets (Global, Americas, Europe, MENA, Asia, Africa, Oceania, LatAm)
|
||||
- Orbit mode for idle/attract state
|
||||
- URL state sync (lat, lon, zoom, heading, pitch)
|
||||
|
||||
#### [NEW] [LayerRenderer.ts](file:///c:/dev/World%20Wide%20View/src/core/globe/LayerRenderer.ts)
|
||||
- Renders plugin data as Cesium entities (points, billboards, polylines, polygons)
|
||||
- Smart clustering via `EntityCluster`
|
||||
- Progressive disclosure (detail at higher zoom)
|
||||
- Color/size coding based on data attributes
|
||||
|
||||
#### [NEW] [TimelineSync.ts](file:///c:/dev/World%20Wide%20View/src/core/globe/TimelineSync.ts)
|
||||
- Bidirectional sync between Cesium clock and UI timeline
|
||||
- Time window filtering (1h, 6h, 24h, 48h, 7d)
|
||||
- Playback controls, speed multiplier
|
||||
- Notifies plugins of current time window
|
||||
|
||||
---
|
||||
|
||||
### Plugin System
|
||||
|
||||
The heart of the modular architecture. Every data source implements a standard interface.
|
||||
|
||||
#### [NEW] [PluginTypes.ts](file:///c:/dev/World%20Wide%20View/src/core/plugins/PluginTypes.ts)
|
||||
```typescript
|
||||
export interface WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
category: 'aviation' | 'maritime' | 'conflict' | 'natural-disaster' |
|
||||
'infrastructure' | 'cyber' | 'economic' | 'custom';
|
||||
version: string;
|
||||
|
||||
initialize(context: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
|
||||
// Optional UI hooks
|
||||
getSidebarComponent?(): React.ComponentType;
|
||||
getDetailComponent?(): React.ComponentType<{ entity: GeoEntity }>;
|
||||
}
|
||||
```
|
||||
|
||||
#### [NEW] [PluginManager.ts](file:///c:/dev/World%20Wide%20View/src/core/plugins/PluginManager.ts)
|
||||
- Plugin lifecycle (register, initialize, enable, disable, destroy)
|
||||
- Routes data from plugins → `LayerRenderer`
|
||||
- Manages polling per plugin
|
||||
- Emits events via `DataBus`
|
||||
|
||||
#### [NEW] [PluginRegistry.ts](file:///c:/dev/World%20Wide%20View/src/core/plugins/PluginRegistry.ts)
|
||||
- Static registry of built-in plugins + dynamic registration API
|
||||
|
||||
---
|
||||
|
||||
### Built-in Plugins (3 for MVP)
|
||||
|
||||
#### [NEW] Aviation — [src/plugins/aviation/](file:///c:/dev/World%20Wide%20View/src/plugins/aviation/)
|
||||
- **Source**: OpenSky Network REST API
|
||||
- **Rendering**: Aircraft billboards with heading rotation, altitude coloring
|
||||
- **Polling**: 10s | **Backend proxy**: `/api/aviation`
|
||||
|
||||
#### [NEW] Maritime — [src/plugins/maritime/](file:///c:/dev/World%20Wide%20View/src/plugins/maritime/)
|
||||
- **Source**: Public AIS feeds
|
||||
- **Rendering**: Ship icons, color-coded by vessel type
|
||||
- **Polling**: 60s | **Backend proxy**: `/api/maritime`
|
||||
|
||||
#### [NEW] Wildfire — [src/plugins/wildfire/](file:///c:/dev/World%20Wide%20View/src/plugins/wildfire/)
|
||||
- **Source**: NASA FIRMS (VIIRS thermal hotspots)
|
||||
- **Rendering**: Heat-colored point clusters (FRP intensity)
|
||||
- **Polling**: 5min | **Backend proxy**: `/api/wildfire`
|
||||
|
||||
---
|
||||
|
||||
### UI Components
|
||||
|
||||
Dark, cinematic, premium interface — glassmorphism panels floating over the globe.
|
||||
|
||||
#### [NEW] [AppShell.tsx](file:///c:/dev/World%20Wide%20View/src/components/layout/AppShell.tsx)
|
||||
Full-viewport layout with globe as background, floating glassmorphism header, collapsible sidebars, bottom timeline.
|
||||
|
||||
#### [NEW] [Header.tsx](file:///c:/dev/World%20Wide%20View/src/components/layout/Header.tsx)
|
||||
Branding, Cmd+K search, region presets, time window selector, settings.
|
||||
|
||||
#### [NEW] [LayerPanel.tsx](file:///c:/dev/World%20Wide%20View/src/components/panels/LayerPanel.tsx)
|
||||
Toggleable plugin layers grouped by category with entity counts.
|
||||
|
||||
#### [NEW] [Timeline.tsx](file:///c:/dev/World%20Wide%20View/src/components/timeline/Timeline.tsx)
|
||||
Horizontal time scrubber, playback controls, event density sparkline.
|
||||
|
||||
#### [NEW] [index.css](file:///c:/dev/World%20Wide%20View/src/styles/index.css)
|
||||
Dark-mode-first design system: deep navy/charcoal palette, glassmorphism, Inter + JetBrains Mono typography, smooth micro-animations.
|
||||
|
||||
---
|
||||
|
||||
### Backend API (Next.js Route Handlers)
|
||||
|
||||
#### [NEW] [src/app/api/](file:///c:/dev/World%20Wide%20View/src/app/api/)
|
||||
Next.js Route Handlers utilizing Web Standard Request/Response APIs. Handles rate limiting, server-side data fetching (proxying), and caching (via Next.js `fetch` cache or in-memory). This replaces the need for a separate Express server.
|
||||
|
||||
#### [NEW] Route files
|
||||
- `src/app/api/aviation/route.ts` — OpenSky proxy
|
||||
- `src/app/api/maritime/route.ts` — AIS proxy
|
||||
- `src/app/api/wildfire/route.ts` — NASA FIRMS proxy
|
||||
|
||||
---
|
||||
|
||||
### State Management
|
||||
|
||||
#### [NEW] [store.ts](file:///c:/dev/World%20Wide%20View/src/core/state/store.ts)
|
||||
Zustand store with slices: `globe`, `layers`, `timeline`, `ui`, `data`.
|
||||
|
||||
---
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Automated Tests
|
||||
|
||||
**Build verification:**
|
||||
```bash
|
||||
cd "c:\dev\World Wide View"
|
||||
npm run build
|
||||
```
|
||||
|
||||
**Type checking:**
|
||||
```bash
|
||||
cd "c:\dev\World Wide View"
|
||||
npx tsc --noEmit
|
||||
```
|
||||
|
||||
### Browser Verification
|
||||
1. Open `http://localhost:5173` → CesiumJS globe renders with terrain, header/sidebar/timeline visible
|
||||
2. Enable aviation layer → aircraft icons appear, clicking shows detail
|
||||
3. Enable wildfire layer → fire hotspots render as colored points
|
||||
4. Scrub timeline → data filters by time window
|
||||
5. Click region presets → smooth cinematic fly-to animations
|
||||
|
||||
### Manual Verification
|
||||
1. Run `npm run dev` — starts the Next.js integrated development server
|
||||
2. Verify 3D globe renders with terrain and satellite imagery (ensuring SSR is properly disabled for the globe component)
|
||||
3. Toggle layers via layer panel
|
||||
4. Drag timeline to filter events
|
||||
5. Test camera preset fly-tos
|
||||
6. Resize browser — panels collapse gracefully
|
||||
|
||||
> [!TIP]
|
||||
> First run requires `VITE_CESIUM_TOKEN` in `.env` (free from [cesium.com/ion](https://cesium.com/ion)). App shows a warning if missing but still renders a basic globe.
|
||||
@@ -14,7 +14,7 @@ As a real-time situational awareness platform, it turns raw geospatial signals
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
git clone https://github.com/your-repo/worldwideview.git
|
||||
git clone https://github.com/silvertakana/worldwideview.git
|
||||
cd worldwideview
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# WorldWideView — Phase 1 MVP Task Breakdown
|
||||
|
||||
## Planning
|
||||
- [/] Explore existing codebase and understand project state
|
||||
- [/] Write implementation plan for Phase 1 MVP
|
||||
- [ ] Get user approval on implementation plan
|
||||
|
||||
## Phase 1: Project Scaffolding
|
||||
- [ ] Initialize Next.js + TypeScript project with App Router
|
||||
- [ ] Configure CesiumJS integration (Webpack, static assets, SSR bypass)
|
||||
- [ ] Set up design system (CSS custom properties, glassmorphism, typography)
|
||||
- [ ] Configure Zustand state management
|
||||
- [ ] Set up path aliases and project structure
|
||||
|
||||
## Phase 2: Core Globe Component
|
||||
- [ ] Implement `GlobeView.tsx` — CesiumJS viewer with Google 3D Tiles
|
||||
- [ ] Implement `CameraController.ts` — cinematic fly-to, orbit mode, presets
|
||||
- [ ] Implement `LayerRenderer.ts` — entity rendering, clustering, progressive disclosure
|
||||
- [ ] Implement `TimelineSync.ts` — clock sync, time-window filtering, playback
|
||||
|
||||
## Phase 3: Plugin System
|
||||
- [ ] Define `PluginTypes.ts` — `WorldPlugin` interface, `GeoEntity`, `LayerConfig`
|
||||
- [ ] Implement `PluginManager.ts` — lifecycle, polling, data routing
|
||||
- [ ] Implement `PluginRegistry.ts` — static + dynamic registration
|
||||
- [ ] Implement `DataBus.ts` — event bus for cross-plugin communication
|
||||
- [ ] Implement `CacheLayer.ts` — in-memory + IndexedDB caching
|
||||
- [ ] Implement `PollingManager.ts` — per-plugin refresh
|
||||
|
||||
## Phase 4: Built-in Plugins (MVP)
|
||||
- [ ] Aviation plugin (OpenSky Network)
|
||||
- [ ] Maritime plugin (AIS feeds)
|
||||
- [ ] Wildfire plugin (NASA FIRMS)
|
||||
- [ ] Backend API proxy routes for each plugin
|
||||
|
||||
## Phase 5: UI Components
|
||||
- [ ] `AppShell.tsx` — full-viewport layout with floating panels
|
||||
- [ ] `Header.tsx` — branding, search, region presets, time selector
|
||||
- [ ] `LayerPanel.tsx` — toggleable layer list grouped by category
|
||||
- [ ] `Timeline.tsx` — horizontal scrubber with playback controls
|
||||
- [ ] `IntelPanel.tsx` — entity detail and intelligence sidebar
|
||||
- [ ] Global CSS design system (dark mode, glassmorphism, animations)
|
||||
|
||||
## Phase 6: Verification
|
||||
- [ ] Build verification (`npm run build` + type-check)
|
||||
- [ ] Browser verification — globe renders, layers toggle, camera presets work
|
||||
- [ ] Manual verification — time scrubbing, responsive layout, API proxies
|
||||
@@ -0,0 +1,378 @@
|
||||
# Creating a WorldWideView Plugin
|
||||
|
||||
This guide walks you through building, publishing, and listing your own WorldWideView plugin from scratch.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
WorldWideView plugins display geospatial data on a 3D Cesium globe. Every plugin must implement the `WorldPlugin` interface from the **Plugin SDK** (`@worldwideview/wwv-plugin-sdk`).
|
||||
|
||||
There are **three plugin formats**:
|
||||
|
||||
| Format | Use Case | Example |
|
||||
|---|---|---|
|
||||
| **`static`** | GeoJSON file loaded at startup — no API calls at runtime | Military Bases, Nuclear Facilities, Embassies |
|
||||
| **`bundle`** | Full TypeScript class with custom logic, live API data, UI components | Aviation, Maritime, Wildfire |
|
||||
| **`declarative`** | JSON-only manifest that points to an external API — no code needed | *(Future)* |
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Node.js ≥ 18
|
||||
- npm account (for publishing)
|
||||
- The WorldWideView monorepo cloned locally
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Create Your Plugin Package
|
||||
|
||||
All plugins live under `packages/` in the monorepo.
|
||||
|
||||
```bash
|
||||
mkdir packages/wwv-plugin-my-data
|
||||
cd packages/wwv-plugin-my-data
|
||||
```
|
||||
|
||||
Create `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-my-data",
|
||||
"version": "1.0.0",
|
||||
"description": "WorldWideView plugin — my custom data layer",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": ["src"],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"geojson",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-my-data"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The SDK is declared as a **peer dependency**, not a direct dependency. The host application provides it at runtime.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Write Your Plugin Code
|
||||
|
||||
Create `src/index.ts`. Here are examples for the two most common formats:
|
||||
|
||||
### Option A — Static GeoJSON Plugin (simplest)
|
||||
|
||||
For static plugins, the npm package is just metadata. The actual loading is handled by the `StaticDataPlugin` loader at runtime, driven by a manifest + GeoJSON file.
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* @worldwideview/wwv-plugin-my-data
|
||||
*
|
||||
* Static GeoJSON plugin — my custom dataset.
|
||||
*
|
||||
* This package exists for npm registry metadata. The actual plugin logic
|
||||
* is handled by WorldWideView's StaticDataPlugin loader at runtime using
|
||||
* the manifest + GeoJSON data file served from the host application.
|
||||
*/
|
||||
export const PLUGIN_ID = "my-data" as const;
|
||||
```
|
||||
|
||||
For static plugins you also need:
|
||||
1. A **GeoJSON file** placed at `public/data/my_data.geojson` in the main app
|
||||
2. A **manifest entry** in the marketplace (see Step 4)
|
||||
|
||||
### Option B — Bundle Plugin (full control)
|
||||
|
||||
For bundle plugins, you write a class that implements the `WorldPlugin` interface:
|
||||
|
||||
```typescript
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class MyDataPlugin implements WorldPlugin {
|
||||
// ─── Required Metadata ──────────────────────────────
|
||||
id = "my-data";
|
||||
name = "My Data Layer";
|
||||
description = "Displays custom points on the globe.";
|
||||
icon = "MapPin"; // Lucide icon name (string)
|
||||
category = "custom" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
// ─── Lifecycle ──────────────────────────────────────
|
||||
async initialize(ctx: PluginContext): Promise<void> {
|
||||
// Called once when the plugin is loaded.
|
||||
// Use ctx.apiBaseUrl, ctx.timeRange, ctx.onDataUpdate, etc.
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
// Called when the plugin is unloaded. Clean up timers, sockets, etc.
|
||||
}
|
||||
|
||||
// ─── Data ───────────────────────────────────────────
|
||||
async fetch(timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Fetch your data from an API and return GeoEntity objects.
|
||||
const res = await fetch("https://api.example.com/points");
|
||||
const data = await res.json();
|
||||
|
||||
return data.map((item: any) => ({
|
||||
id: String(item.id),
|
||||
pluginId: this.id,
|
||||
latitude: item.lat,
|
||||
longitude: item.lon,
|
||||
altitude: 0,
|
||||
timestamp: new Date(),
|
||||
label: item.name,
|
||||
properties: { type: item.type },
|
||||
}));
|
||||
}
|
||||
|
||||
getPollingInterval(): number {
|
||||
return 60_000; // Re-fetch every 60 seconds
|
||||
}
|
||||
|
||||
// ─── Rendering ──────────────────────────────────────
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#3b82f6",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 40,
|
||||
maxEntities: 5000,
|
||||
};
|
||||
}
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
return {
|
||||
type: "point",
|
||||
color: "#3b82f6",
|
||||
size: 8,
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Publish to npm
|
||||
|
||||
```bash
|
||||
cd packages/wwv-plugin-my-data
|
||||
npm publish --access public
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The marketplace pulls metadata (version, description, keywords) directly from the npm registry at runtime. You do not need to duplicate this metadata in the marketplace.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Register in the Marketplace
|
||||
|
||||
### 4a. Add to `knownPlugins.ts`
|
||||
|
||||
Open `worldwideview-marketplace/src/data/knownPlugins.ts` and add your plugin:
|
||||
|
||||
```typescript
|
||||
{
|
||||
id: "my-data",
|
||||
npmPackage: "@worldwideview/wwv-plugin-my-data",
|
||||
icon: "MapPin", // Lucide icon name
|
||||
category: "Custom", // Must match a value in CATEGORIES
|
||||
format: "static", // "static" | "bundle"
|
||||
trust: "verified", // "built-in" | "verified" | "unverified"
|
||||
capabilities: ["data:own"],
|
||||
longDescription:
|
||||
"Description shown on the plugin detail page in the marketplace.",
|
||||
changelog:
|
||||
"v1.0.0 — Initial release.",
|
||||
},
|
||||
```
|
||||
|
||||
### 4b. Add a manifest (static plugins only)
|
||||
|
||||
For **static** format plugins, open `worldwideview-marketplace/src/data/pluginManifests.ts` and add:
|
||||
|
||||
```typescript
|
||||
"my-data": {
|
||||
id: "my-data",
|
||||
name: "My Data Layer",
|
||||
version: "1.0.0",
|
||||
description: "My custom data layer",
|
||||
type: "data-layer",
|
||||
format: "static",
|
||||
trust: "verified",
|
||||
capabilities: ["data:own"],
|
||||
category: "Custom",
|
||||
icon: "MapPin",
|
||||
dataFile: "/data/my_data.geojson", // Path to GeoJSON in public/
|
||||
rendering: {
|
||||
entityType: "point",
|
||||
color: "#3b82f6",
|
||||
labelField: "name",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
maxEntities: 5000,
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
Bundle plugins do **not** need a manifest entry here — their code is loaded via dynamic import.
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — Test Locally
|
||||
|
||||
1. Start the WorldWideView app: `npm run dev` (in the `worldwideview` directory)
|
||||
2. Start the marketplace: `npm run dev` (in the `worldwideview-marketplace` directory)
|
||||
3. Open the marketplace at `http://localhost:3001/browse`
|
||||
4. Find your plugin and click **Install**
|
||||
5. Verify the data appears on the globe at `http://localhost:3000`
|
||||
|
||||
---
|
||||
|
||||
## SDK Interface Reference
|
||||
|
||||
The `WorldPlugin` interface requires these properties and methods:
|
||||
|
||||
### Required Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|---|---|---|
|
||||
| `id` | `string` | Unique plugin identifier (e.g., `"my-data"`) |
|
||||
| `name` | `string` | Display name shown in the sidebar |
|
||||
| `description` | `string` | Short description |
|
||||
| `icon` | `string \| ComponentType` | Lucide icon name or React component |
|
||||
| `category` | `PluginCategory` | One of: `aviation`, `maritime`, `conflict`, `natural-disaster`, `infrastructure`, `cyber`, `economic`, `custom` |
|
||||
| `version` | `string` | Semver version string |
|
||||
|
||||
### Required Methods
|
||||
|
||||
| Method | Returns | Description |
|
||||
|---|---|---|
|
||||
| `initialize(ctx)` | `Promise<void>` | Set up the plugin. Receives `PluginContext` with API URLs, time range, callbacks |
|
||||
| `destroy()` | `void` | Clean up resources (timers, sockets, etc.) |
|
||||
| `fetch(timeRange)` | `Promise<GeoEntity[]>` | Return the data to display on the globe |
|
||||
| `getPollingInterval()` | `number` | Milliseconds between `fetch()` calls |
|
||||
| `getLayerConfig()` | `LayerConfig` | Layer appearance (color, clustering, limits) |
|
||||
| `renderEntity(entity)` | `CesiumEntityOptions` | How each entity renders on the globe |
|
||||
|
||||
### Optional Methods
|
||||
|
||||
| Method | Returns | Description |
|
||||
|---|---|---|
|
||||
| `getSelectionBehavior(entity)` | `SelectionBehavior \| null` | Trail / fly-to on click |
|
||||
| `getServerConfig()` | `ServerPluginConfig` | Server-side API routing |
|
||||
| `getFilterDefinitions()` | `FilterDefinition[]` | Declarative filter UI |
|
||||
| `getSidebarComponent()` | `ComponentType` | Custom sidebar panel |
|
||||
| `getDetailComponent()` | `ComponentType<{ entity }>` | Custom detail panel |
|
||||
| `getSettingsComponent()` | `ComponentType<{ pluginId }>` | Custom settings panel |
|
||||
|
||||
### Key Types
|
||||
|
||||
```typescript
|
||||
interface GeoEntity {
|
||||
id: string;
|
||||
pluginId: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
altitude?: number;
|
||||
heading?: number;
|
||||
speed?: number;
|
||||
timestamp: Date;
|
||||
label?: string;
|
||||
properties: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface LayerConfig {
|
||||
color: string;
|
||||
iconUrl?: string;
|
||||
clusterEnabled: boolean;
|
||||
clusterDistance: number;
|
||||
minZoomLevel?: number;
|
||||
maxEntities?: number;
|
||||
}
|
||||
|
||||
interface CesiumEntityOptions {
|
||||
type: "billboard" | "point" | "polyline" | "polygon" | "label" | "model";
|
||||
color?: string;
|
||||
size?: number;
|
||||
iconUrl?: string;
|
||||
rotation?: number;
|
||||
modelUrl?: string;
|
||||
modelScale?: number;
|
||||
// ... more options
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Real Examples
|
||||
|
||||
### Borders Plugin (bundle format)
|
||||
|
||||
A minimal bundle plugin that implements the `WorldPlugin` interface directly:
|
||||
|
||||
- **Source**: `packages/wwv-plugin-borders/src/index.ts`
|
||||
- **npm**: `@worldwideview/wwv-plugin-borders`
|
||||
|
||||
### Military Bases Plugin (static format)
|
||||
|
||||
A static GeoJSON plugin where the npm package is just metadata:
|
||||
|
||||
- **Source**: `packages/wwv-plugin-military-bases/src/index.ts`
|
||||
- **GeoJSON**: `public/data/military_bases.geojson`
|
||||
- **npm**: `@worldwideview/wwv-plugin-military-bases`
|
||||
- **Manifest**: Defined in `worldwideview-marketplace/src/data/pluginManifests.ts`
|
||||
|
||||
---
|
||||
|
||||
## How It All Connects
|
||||
|
||||
```
|
||||
Developer writes plugin
|
||||
│
|
||||
▼
|
||||
Publish to npm ──────────────────────────────────► npm registry
|
||||
│ │
|
||||
▼ │
|
||||
Add to knownPlugins.ts ──► Marketplace ◄────────────┘
|
||||
(+ pluginManifests.ts shows plugin (fetches version,
|
||||
for static plugins) in browse grid description, etc.)
|
||||
│
|
||||
▼
|
||||
User clicks "Install"
|
||||
│
|
||||
▼
|
||||
Marketplace sends manifest
|
||||
to WorldWideView instance
|
||||
│
|
||||
▼
|
||||
InstalledPluginsLoader saves
|
||||
manifest to database (Prisma)
|
||||
│
|
||||
▼
|
||||
loadPluginFromManifest() routes
|
||||
by format: static → StaticDataPlugin
|
||||
bundle → dynamic import
|
||||
│
|
||||
▼
|
||||
Plugin renders on the 3D globe
|
||||
```
|
||||
+336749
File diff suppressed because it is too large.
Load diff
+35
-34
@@ -1,46 +1,47 @@
|
||||
import type { NextConfig } from "next";
|
||||
import path from "path";
|
||||
import webpack from "webpack";
|
||||
import CopyPlugin from "copy-webpack-plugin";
|
||||
|
||||
const cesiumSource = path.resolve(__dirname, "node_modules/cesium/Build/Cesium");
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/(.*)",
|
||||
headers: [
|
||||
{
|
||||
key: "Content-Security-Policy",
|
||||
value: [
|
||||
"default-src 'self'",
|
||||
// CesiumJS requires unsafe-eval (worker compilation) and unsafe-inline (styles)
|
||||
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob:",
|
||||
"style-src 'self' 'unsafe-inline' fonts.googleapis.com",
|
||||
"font-src 'self' fonts.gstatic.com",
|
||||
"img-src 'self' data: blob: *.tile.openstreetmap.org *.arcgisonline.com *.virtualearth.net *.bing.com *.googleapis.com",
|
||||
"connect-src 'self' *.supabase.co *.worldwideview.dev *.cesium.com *.arcgisonline.com *.virtualearth.net *.googleapis.com *.vercel-scripts.com",
|
||||
"worker-src 'self' blob:",
|
||||
"frame-ancestors 'none'",
|
||||
].join("; "),
|
||||
},
|
||||
{ key: "X-Frame-Options", value: "DENY" },
|
||||
{ key: "X-Content-Type-Options", value: "nosniff" },
|
||||
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
||||
{ key: "X-DNS-Prefetch-Control", value: "on" },
|
||||
{
|
||||
key: "Permissions-Policy",
|
||||
value: "camera=(), microphone=(), geolocation=(self)",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
outputFileTracingExcludes: {
|
||||
"*": ["./public/cesium/**"],
|
||||
},
|
||||
env: {
|
||||
CESIUM_BASE_URL: "/cesium",
|
||||
},
|
||||
webpack: (config, { isServer }) => {
|
||||
if (!isServer) {
|
||||
// Copy Cesium static assets to public/cesium (Production only)
|
||||
if (process.env.NODE_ENV === "production" || !isServer) {
|
||||
// We only add it here if it's production or if we're not using predev
|
||||
// To be safe, let's just make it only run if NOT in dev
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
config.plugins?.push(
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.join(cesiumSource, "Workers"),
|
||||
to: path.resolve(__dirname, "public/cesium/Workers"),
|
||||
},
|
||||
{
|
||||
from: path.join(cesiumSource, "ThirdParty"),
|
||||
to: path.resolve(__dirname, "public/cesium/ThirdParty"),
|
||||
},
|
||||
{
|
||||
from: path.join(cesiumSource, "Assets"),
|
||||
to: path.resolve(__dirname, "public/cesium/Assets"),
|
||||
},
|
||||
{
|
||||
from: path.join(cesiumSource, "Widgets"),
|
||||
to: path.resolve(__dirname, "public/cesium/Widgets"),
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Define CESIUM_BASE_URL for Cesium's worker resolution
|
||||
config.plugins?.push(
|
||||
new webpack.DefinePlugin({
|
||||
|
||||
Generated
+3664
-22
File diff suppressed because it is too large.
Load diff
+27
-4
@@ -2,21 +2,38 @@
|
||||
"name": "worldwideview",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"workspaces": ["packages/*"],
|
||||
"scripts": {
|
||||
"clean": "node -e \"const fs=require('fs');fs.rmSync('.next',{recursive:true,force:true})\"",
|
||||
"dev": "next dev --webpack",
|
||||
"predev": "node scripts/copy-cesium.mjs",
|
||||
"predev": "npx prisma migrate deploy && node scripts/copy-cesium.mjs",
|
||||
"copy-cesium": "node scripts/copy-cesium.mjs",
|
||||
"build": "next build --webpack",
|
||||
"start": "next start"
|
||||
"start": "next start",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"@worldwideview/wwv-plugin-aviation": "*",
|
||||
"@worldwideview/wwv-plugin-maritime": "*",
|
||||
"@worldwideview/wwv-plugin-wildfire": "*",
|
||||
"@worldwideview/wwv-plugin-borders": "*",
|
||||
"@worldwideview/wwv-plugin-camera": "*",
|
||||
"@worldwideview/wwv-plugin-military-aviation": "*",
|
||||
"@auth/prisma-adapter": "^2.11.1",
|
||||
"@prisma/adapter-better-sqlite3": "^7.5.0",
|
||||
"@prisma/client": "^7.5.0",
|
||||
"@supabase/supabase-js": "^2.98.0",
|
||||
"@vercel/analytics": "^1.6.1",
|
||||
"bcryptjs": "^3.0.3",
|
||||
"cesium": "^1.139.0",
|
||||
"cheerio": "^1.2.0",
|
||||
"hls.js": "^1.6.15",
|
||||
"insecam-api": "^0.0.3",
|
||||
"jsdom": "^28.1.0",
|
||||
"lucide-react": "^0.576.0",
|
||||
"next": "16.1.6",
|
||||
"next-auth": "^5.0.0-beta.30",
|
||||
"prisma": "^7.5.0",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3",
|
||||
"react-player": "^3.4.0",
|
||||
@@ -26,11 +43,17 @@
|
||||
"zustand": "^5.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@types/bcryptjs": "^3.0.0",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@vitejs/plugin-react": "^5.1.4",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
"typescript": "^5"
|
||||
"jsdom": "^28.1.0",
|
||||
"typescript": "^5",
|
||||
"vitest": "^4.0.18"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
# @worldwideview/wwv-plugin-aviation
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time commercial aircraft tracking** via the [OpenSky Network](https://opensky-network.org/) API.
|
||||
|
||||
## Features
|
||||
|
||||
- 🛩️ Live aircraft positions updated every 15 seconds
|
||||
- 🎨 Altitude-based color coding (green → cyan → blue → purple → pink)
|
||||
- ✈️ 3D airplane model rendering with heading-oriented rotation
|
||||
- 🔍 Filters: country of origin, altitude range, on-ground status, callsign
|
||||
- 📡 Flight trail rendering on entity selection
|
||||
- ⏪ History playback mode support
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-aviation
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { AviationPlugin } from "@worldwideview/wwv-plugin-aviation";
|
||||
|
||||
const plugin = new AviationPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking aircraft on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Live data is fetched from the [OpenSky Network REST API](https://openskynetwork.github.io/opensky-api/). Requires server-side API route at `/api/aviation`.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with live tracking, altitude coloring, and 3D model rendering.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions, SelectionBehavior, ServerPluginConfig, FilterDefinition } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class AviationPlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "aviation";
|
||||
version: string;
|
||||
private context;
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null;
|
||||
getServerConfig(): ServerPluginConfig;
|
||||
getFilterDefinitions(): FilterDefinition[];
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAqBvC,qBAAa,cAAe,YAAW,WAAW;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAc;IAClB,WAAW,SAAqD;IAChE,IAAI,4IAAS;IACb,QAAQ,EAAG,UAAU,CAAU;IAC/B,OAAO,SAAW;IAClB,OAAO,CAAC,OAAO,CAA8B;IAEvC,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACnD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA0DxD,kBAAkB,IAAI,MAAM;IAC5B,cAAc,IAAI,WAAW;IAE7B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB;IAWpD,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,GAAG,IAAI;IAKjE,eAAe,IAAI,kBAAkB;IAIrC,oBAAoB,IAAI,gBAAgB,EAAE;CAQ7C"}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AviationPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
function altitudeToColor(altitude) {
|
||||
if (altitude === null || altitude <= 0)
|
||||
return "#4ade80";
|
||||
if (altitude < 3000)
|
||||
return "#22d3ee";
|
||||
if (altitude < 8000)
|
||||
return "#3b82f6";
|
||||
if (altitude < 12000)
|
||||
return "#a78bfa";
|
||||
return "#f472b6";
|
||||
}
|
||||
var AviationPlugin = /** @class */ (function () {
|
||||
function AviationPlugin() {
|
||||
this.id = "aviation";
|
||||
this.name = "Aviation";
|
||||
this.description = "Real-time aircraft tracking via OpenSky Network";
|
||||
this.icon = lucide_react_1.Plane;
|
||||
this.category = "aviation";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
}
|
||||
AviationPlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
AviationPlugin.prototype.destroy = function () { this.context = null; };
|
||||
AviationPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var time, res_1, historyData, res, data, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 6, , 7]);
|
||||
if (!this.context.isPlaybackMode()) return [3 /*break*/, 3];
|
||||
time = this.context.getCurrentTime().getTime();
|
||||
return [4 /*yield*/, fetch("/api/aviation/history?time=".concat(time))];
|
||||
case 1:
|
||||
res_1 = _a.sent();
|
||||
if (!res_1.ok)
|
||||
throw new Error("History API returned ".concat(res_1.status));
|
||||
return [4 /*yield*/, res_1.json()];
|
||||
case 2:
|
||||
historyData = _a.sent();
|
||||
if (!historyData.records || !Array.isArray(historyData.records))
|
||||
return [2 /*return*/, []];
|
||||
return [2 /*return*/, historyData.records.map(function (s) { return ({
|
||||
id: "aviation-history-".concat(s.icao24),
|
||||
pluginId: "aviation",
|
||||
latitude: s.latitude,
|
||||
longitude: s.longitude,
|
||||
altitude: (s.altitude || 0) * 10,
|
||||
heading: s.heading || undefined,
|
||||
speed: s.speed || undefined,
|
||||
timestamp: new Date(s.timestamp),
|
||||
label: s.callsign || s.icao24,
|
||||
properties: { icao24: s.icao24, callsign: s.callsign, altitude_m: s.altitude, velocity_ms: s.speed, heading: s.heading, on_ground: s.altitude === null || s.altitude <= 0 },
|
||||
}); })];
|
||||
case 3: return [4 /*yield*/, fetch("/api/aviation")];
|
||||
case 4:
|
||||
res = _a.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("Aviation API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 5:
|
||||
data = _a.sent();
|
||||
if (data.error && !data.states)
|
||||
return [2 /*return*/, []];
|
||||
if (!data.states || !Array.isArray(data.states))
|
||||
return [2 /*return*/, []];
|
||||
return [2 /*return*/, data.states
|
||||
.filter(function (s) { return s[6] !== null && s[5] !== null; })
|
||||
.map(function (s) {
|
||||
var _a;
|
||||
var st = {
|
||||
icao24: s[0], callsign: ((_a = s[1]) === null || _a === void 0 ? void 0 : _a.trim()) || null,
|
||||
origin_country: s[2], time_position: s[3],
|
||||
last_contact: s[4], longitude: s[5],
|
||||
latitude: s[6], baro_altitude: s[7],
|
||||
on_ground: s[8], velocity: s[9],
|
||||
true_track: s[10], vertical_rate: s[11],
|
||||
sensors: s[12], geo_altitude: s[13],
|
||||
squawk: s[14], spi: s[15], position_source: s[16],
|
||||
};
|
||||
return {
|
||||
id: "aviation-".concat(st.icao24), pluginId: "aviation",
|
||||
latitude: st.latitude, longitude: st.longitude,
|
||||
altitude: (st.baro_altitude || 0) * 10,
|
||||
heading: st.true_track || undefined, speed: st.velocity || undefined,
|
||||
timestamp: new Date((st.time_position || st.last_contact) * 1000),
|
||||
label: st.callsign || st.icao24,
|
||||
properties: { icao24: st.icao24, callsign: st.callsign, origin_country: st.origin_country, altitude_m: st.baro_altitude, velocity_ms: st.velocity, heading: st.true_track, vertical_rate: st.vertical_rate, on_ground: st.on_ground, squawk: st.squawk },
|
||||
};
|
||||
})];
|
||||
case 6:
|
||||
err_1 = _a.sent();
|
||||
console.error("[AviationPlugin] Fetch error:", err_1);
|
||||
return [2 /*return*/, []];
|
||||
case 7: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
AviationPlugin.prototype.getPollingInterval = function () { return 15000; };
|
||||
AviationPlugin.prototype.getLayerConfig = function () { return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 40, maxEntities: 5000 }; };
|
||||
AviationPlugin.prototype.renderEntity = function (entity) {
|
||||
var alt = entity.properties.altitude_m;
|
||||
var isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: altitudeToColor(alt), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
};
|
||||
AviationPlugin.prototype.getSelectionBehavior = function (entity) {
|
||||
if (entity.properties.on_ground)
|
||||
return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#00fff7", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
};
|
||||
AviationPlugin.prototype.getServerConfig = function () {
|
||||
return { apiBasePath: "/api/aviation", pollingIntervalMs: 5000, requiresAuth: true, historyEnabled: true, availabilityEnabled: true };
|
||||
};
|
||||
AviationPlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{ id: "origin_country", label: "Country", type: "select", propertyKey: "origin_country", options: [{ value: "United States", label: "United States" }, { value: "China", label: "China" }, { value: "United Kingdom", label: "United Kingdom" }, { value: "Germany", label: "Germany" }, { value: "France", label: "France" }, { value: "Japan", label: "Japan" }, { value: "Australia", label: "Australia" }, { value: "Canada", label: "Canada" }, { value: "India", label: "India" }, { value: "Brazil", label: "Brazil" }, { value: "Russia", label: "Russia" }, { value: "Turkey", label: "Turkey" }, { value: "South Korea", label: "South Korea" }, { value: "Indonesia", label: "Indonesia" }, { value: "Mexico", label: "Mexico" }] },
|
||||
{ id: "altitude", label: "Altitude (m)", type: "range", propertyKey: "altitude_m", range: { min: 0, max: 15000, step: 500 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
];
|
||||
};
|
||||
return AviationPlugin;
|
||||
}());
|
||||
exports.AviationPlugin = AviationPlugin;
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-aviation",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for real-time commercial aircraft tracking via the OpenSky Network API. Renders 3D aircraft models with altitude-based coloring, flight trails, and country/altitude/callsign filters",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-aviation",
|
||||
"aviation",
|
||||
"aircraft-tracking",
|
||||
"opensky",
|
||||
"flight-tracker",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-aviation"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { Plane } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
SelectionBehavior,
|
||||
ServerPluginConfig,
|
||||
FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
interface OpenSkyState {
|
||||
icao24: string; callsign: string | null; origin_country: string;
|
||||
time_position: number | null; last_contact: number;
|
||||
longitude: number | null; latitude: number | null;
|
||||
baro_altitude: number | null; on_ground: boolean;
|
||||
velocity: number | null; true_track: number | null;
|
||||
vertical_rate: number | null; sensors: number[] | null;
|
||||
geo_altitude: number | null; squawk: string | null;
|
||||
spi: boolean; position_source: number;
|
||||
}
|
||||
|
||||
function altitudeToColor(altitude: number | null): string {
|
||||
if (altitude === null || altitude <= 0) return "#4ade80";
|
||||
if (altitude < 3000) return "#22d3ee";
|
||||
if (altitude < 8000) return "#3b82f6";
|
||||
if (altitude < 12000) return "#a78bfa";
|
||||
return "#f472b6";
|
||||
}
|
||||
|
||||
export class AviationPlugin implements WorldPlugin {
|
||||
id = "aviation";
|
||||
name = "Aviation";
|
||||
description = "Real-time aircraft tracking via OpenSky Network";
|
||||
icon = Plane;
|
||||
category = "aviation" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
// Use PluginContext instead of direct useStore access
|
||||
if (this.context!.isPlaybackMode()) {
|
||||
const time = this.context!.getCurrentTime().getTime();
|
||||
const res = await fetch(`/api/aviation/history?time=${time}`);
|
||||
if (!res.ok) throw new Error(`History API returned ${res.status}`);
|
||||
const historyData = await res.json();
|
||||
if (!historyData.records || !Array.isArray(historyData.records)) return [];
|
||||
return historyData.records.map((s: Record<string, unknown>): GeoEntity => ({
|
||||
id: `aviation-history-${s.icao24}`,
|
||||
pluginId: "aviation",
|
||||
latitude: s.latitude as number,
|
||||
longitude: s.longitude as number,
|
||||
altitude: ((s.altitude as number) || 0) * 10,
|
||||
heading: (s.heading as number) || undefined,
|
||||
speed: (s.speed as number) || undefined,
|
||||
timestamp: new Date(s.timestamp as string),
|
||||
label: (s.callsign as string) || (s.icao24 as string),
|
||||
properties: { icao24: s.icao24, callsign: s.callsign, altitude_m: s.altitude, velocity_ms: s.speed, heading: s.heading, on_ground: (s.altitude as number) === null || (s.altitude as number) <= 0 },
|
||||
}));
|
||||
}
|
||||
|
||||
const res = await fetch("/api/aviation");
|
||||
if (!res.ok) throw new Error(`Aviation API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (data.error && !data.states) return [];
|
||||
if (!data.states || !Array.isArray(data.states)) return [];
|
||||
|
||||
return data.states
|
||||
.filter((s: unknown[]) => s[6] !== null && s[5] !== null)
|
||||
.map((s: unknown[]): GeoEntity => {
|
||||
const st: OpenSkyState = {
|
||||
icao24: s[0] as string, callsign: (s[1] as string)?.trim() || null,
|
||||
origin_country: s[2] as string, time_position: s[3] as number | null,
|
||||
last_contact: s[4] as number, longitude: s[5] as number | null,
|
||||
latitude: s[6] as number | null, baro_altitude: s[7] as number | null,
|
||||
on_ground: s[8] as boolean, velocity: s[9] as number | null,
|
||||
true_track: s[10] as number | null, vertical_rate: s[11] as number | null,
|
||||
sensors: s[12] as number[] | null, geo_altitude: s[13] as number | null,
|
||||
squawk: s[14] as string | null, spi: s[15] as boolean, position_source: s[16] as number,
|
||||
};
|
||||
return {
|
||||
id: `aviation-${st.icao24}`, pluginId: "aviation",
|
||||
latitude: st.latitude!, longitude: st.longitude!,
|
||||
altitude: (st.baro_altitude || 0) * 10,
|
||||
heading: st.true_track || undefined, speed: st.velocity || undefined,
|
||||
timestamp: new Date((st.time_position || st.last_contact) * 1000),
|
||||
label: st.callsign || st.icao24,
|
||||
properties: { icao24: st.icao24, callsign: st.callsign, origin_country: st.origin_country, altitude_m: st.baro_altitude, velocity_ms: st.velocity, heading: st.true_track, vertical_rate: st.vertical_rate, on_ground: st.on_ground, squawk: st.squawk },
|
||||
};
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[AviationPlugin] Fetch error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 15000; }
|
||||
getLayerConfig(): LayerConfig { return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 40, maxEntities: 5000 }; }
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const alt = entity.properties.altitude_m as number | null;
|
||||
const isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: altitudeToColor(alt), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null {
|
||||
if (entity.properties.on_ground) return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#00fff7", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
}
|
||||
|
||||
getServerConfig(): ServerPluginConfig {
|
||||
return { apiBasePath: "/api/aviation", pollingIntervalMs: 5000, requiresAuth: true, historyEnabled: true, availabilityEnabled: true };
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "origin_country", label: "Country", type: "select", propertyKey: "origin_country", options: [{ value: "United States", label: "United States" }, { value: "China", label: "China" }, { value: "United Kingdom", label: "United Kingdom" }, { value: "Germany", label: "Germany" }, { value: "France", label: "France" }, { value: "Japan", label: "Japan" }, { value: "Australia", label: "Australia" }, { value: "Canada", label: "Canada" }, { value: "India", label: "India" }, { value: "Brazil", label: "Brazil" }, { value: "Russia", label: "Russia" }, { value: "Turkey", label: "Turkey" }, { value: "South Korea", label: "South Korea" }, { value: "Indonesia", label: "Indonesia" }, { value: "Mexico", label: "Mexico" }] },
|
||||
{ id: "altitude", label: "Altitude (m)", type: "range", propertyKey: "altitude_m", range: { min: 0, max: 15000, step: 500 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# @worldwideview/wwv-plugin-borders
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin that displays **political borders and country labels** as a globe overlay.
|
||||
|
||||
## Features
|
||||
|
||||
- 🗺️ Country border outlines rendered on the 3D globe
|
||||
- 🏷️ Country name labels
|
||||
- ⚡ Zero-polling — static layer with no data fetching overhead
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-borders
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { BordersPlugin } from "@worldwideview/wwv-plugin-borders";
|
||||
|
||||
const plugin = new BordersPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to display borders on the globe. Border rendering is managed by the host application's `BordersManager`.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with GeoJSON-based political boundaries.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class BordersPlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "custom";
|
||||
version: string;
|
||||
initialize(_ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(_entity: GeoEntity): CesiumEntityOptions;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,aAAc,YAAW,WAAW;IAC7C,EAAE,SAAa;IACf,IAAI,SAAsB;IAC1B,WAAW,SAA+D;IAC1E,IAAI,4IAAO;IACX,QAAQ,EAAG,QAAQ,CAAU;IAC7B,OAAO,SAAW;IAEZ,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACpD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKxD,kBAAkB,IAAI,MAAM;IAE5B,cAAc,IAAI,WAAW;IAI7B,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,mBAAmB;CAGxD"}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BordersPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var BordersPlugin = /** @class */ (function () {
|
||||
function BordersPlugin() {
|
||||
this.id = "borders";
|
||||
this.name = "Borders & Labels";
|
||||
this.description = "Displays political borders and country labels on the map.";
|
||||
this.icon = lucide_react_1.Map;
|
||||
this.category = "custom";
|
||||
this.version = "1.0.0";
|
||||
}
|
||||
BordersPlugin.prototype.initialize = function (_ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
BordersPlugin.prototype.destroy = function () { };
|
||||
BordersPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
// Rendering is managed by BordersManager in GlobeView
|
||||
return [2 /*return*/, []];
|
||||
});
|
||||
});
|
||||
};
|
||||
BordersPlugin.prototype.getPollingInterval = function () { return 9999999; };
|
||||
BordersPlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#00ffff", clusterEnabled: false, clusterDistance: 0, maxEntities: 0 };
|
||||
};
|
||||
BordersPlugin.prototype.renderEntity = function (_entity) {
|
||||
return { type: "point" };
|
||||
};
|
||||
return BordersPlugin;
|
||||
}());
|
||||
exports.BordersPlugin = BordersPlugin;
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-borders",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin that displays political borders and country labels as a globe overlay",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-borders",
|
||||
"borders",
|
||||
"countries",
|
||||
"geopolitical",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-borders"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
} from "@/core/plugins/PluginTypes";
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class BordersPlugin implements WorldPlugin {
|
||||
id = "borders";
|
||||
@@ -16,32 +16,21 @@ export class BordersPlugin implements WorldPlugin {
|
||||
category = "custom" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { }
|
||||
|
||||
async initialize(_ctx: PluginContext): Promise<void> { }
|
||||
destroy(): void { }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Return an empty array since the actual rendering is managed by BordersManager in GlobeView
|
||||
// Rendering is managed by BordersManager in GlobeView
|
||||
return [];
|
||||
}
|
||||
|
||||
getPollingInterval(): number {
|
||||
return 9999999; // Essentially never poll
|
||||
}
|
||||
getPollingInterval(): number { return 9999999; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#00ffff", // Cyan
|
||||
clusterEnabled: false,
|
||||
clusterDistance: 0,
|
||||
maxEntities: 0,
|
||||
};
|
||||
return { color: "#00ffff", clusterEnabled: false, clusterDistance: 0, maxEntities: 0 };
|
||||
}
|
||||
|
||||
renderEntity(_entity: GeoEntity): CesiumEntityOptions {
|
||||
// Unused for Borders
|
||||
return {
|
||||
type: "point",
|
||||
};
|
||||
return { type: "point" };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
# @worldwideview/wwv-plugin-camera
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for displaying **public live cameras and traffic cameras** on the 3D globe.
|
||||
|
||||
## Features
|
||||
|
||||
- 📷 Multiple data sources: default camera database, traffic cameras, custom URL, file upload
|
||||
- 🌍 GeoJSON support for custom camera datasets
|
||||
- 🎥 Live camera detail view with stream embedding
|
||||
- ⚙️ Built-in settings component for source selection
|
||||
- 🔍 Filters: country, city, popular cameras
|
||||
- 📍 Clustered point rendering with labels
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-camera
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `react` ≥ 18
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { CameraPlugin } from "@worldwideview/wwv-plugin-camera";
|
||||
|
||||
const plugin = new CameraPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine. The plugin includes a settings component for switching between camera data sources and a detail component for viewing individual camera streams.
|
||||
|
||||
## Data Sources
|
||||
|
||||
| Source | Description |
|
||||
|---|---|
|
||||
| `default` | Built-in public camera GeoJSON database |
|
||||
| `traffic` | Traffic cameras via `/api/camera/traffic` endpoint |
|
||||
| `url` | Custom JSON URL providing camera data |
|
||||
| `file` | User-uploaded JSON file with camera data |
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with curated public camera feeds.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -0,0 +1,8 @@
|
||||
import React from "react";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
interface CameraDetailProps {
|
||||
entity: GeoEntity;
|
||||
}
|
||||
export declare const CameraDetail: React.FC<CameraDetailProps>;
|
||||
export {};
|
||||
//# sourceMappingURL=CameraDetail.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CameraDetail.d.ts","sourceRoot":"","sources":["../src/CameraDetail.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,UAAU,iBAAiB;IAAG,MAAM,EAAE,SAAS,CAAC;CAAE;AAElD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmCpD,CAAC"}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraDetail = void 0;
|
||||
var react_1 = require("react");
|
||||
var CameraStream_1 = require("@/components/video/CameraStream");
|
||||
var CameraDetail = function (_a) {
|
||||
var entity = _a.entity;
|
||||
var properties = entity.properties;
|
||||
var stream = properties.stream;
|
||||
var previewUrl = properties.preview_url;
|
||||
var city = properties.city;
|
||||
var region = properties.region;
|
||||
var country = properties.country;
|
||||
var isIframe = !!properties.is_iframe;
|
||||
var categories = properties.categories || [];
|
||||
return (<div className="flex flex-col gap-4">
|
||||
<CameraStream_1.CameraStream id={entity.id} streamUrl={stream} previewUrl={previewUrl} isIframe={isIframe} label={city || country}/>
|
||||
<div className="intel-panel__props">
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-xs)", borderBottom: "1px solid var(--border-subtle)", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Location</span>
|
||||
<span className="intel-panel__prop-value" style={{ textAlign: "left", width: "100%", whiteSpace: "normal", lineHeight: "1.4", fontSize: "12px", color: "var(--text-primary)" }}>
|
||||
{[city, region, country].filter(Boolean).join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
{categories.length > 0 && (<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-sm)", borderBottom: "none", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Categories</span>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>
|
||||
{categories.map(function (cat) { return (<span key={cat} style={{ borderRadius: "12px", backgroundColor: "var(--bg-tertiary)", padding: "2px 8px", fontSize: "10px", fontWeight: 500, color: "var(--text-secondary)", border: "1px solid var(--border-subtle)" }}>
|
||||
{cat}
|
||||
</span>); })}
|
||||
</div>
|
||||
</div>)}
|
||||
</div>
|
||||
</div>);
|
||||
};
|
||||
exports.CameraDetail = CameraDetail;
|
||||
@@ -0,0 +1,5 @@
|
||||
import React from "react";
|
||||
export declare const CameraSettings: React.FC<{
|
||||
pluginId: string;
|
||||
}>;
|
||||
//# sourceMappingURL=CameraSettings.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CameraSettings.d.ts","sourceRoot":"","sources":["../src/CameraSettings.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAQ3C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CA+FzD,CAAC"}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
"use client";
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraSettings = void 0;
|
||||
var react_1 = require("react");
|
||||
var store_1 = require("@/core/state/store");
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var PluginManager_1 = require("@/core/plugins/PluginManager");
|
||||
var cameraSettingsStyles_1 = require("./cameraSettingsStyles");
|
||||
var CameraSettings = function (_a) {
|
||||
var pluginId = _a.pluginId;
|
||||
var settingsRaw = (0, store_1.useStore)(function (s) { return s.dataConfig.pluginSettings[pluginId]; });
|
||||
var settings = __assign({ sourceType: "default" }, (settingsRaw || {}));
|
||||
var updatePluginSettings = (0, store_1.useStore)(function (s) { return s.updatePluginSettings; });
|
||||
var setHighlightLayerId = (0, store_1.useStore)(function (s) { return s.setHighlightLayerId; });
|
||||
var _b = react_1.default.useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
||||
var handleSourceTypeChange = function (type) {
|
||||
updatePluginSettings(pluginId, { sourceType: type });
|
||||
setHighlightLayerId(null);
|
||||
};
|
||||
var triggerFetch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var managed;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
managed = PluginManager_1.pluginManager.getPlugin(pluginId);
|
||||
if (!(managed && managed.enabled)) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, PluginManager_1.pluginManager.fetchForPlugin(pluginId, managed.context.timeRange)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
_a.label = 2;
|
||||
case 2: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleLoadData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
setIsLoading(true);
|
||||
updatePluginSettings(pluginId, { action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
setIsLoading(false);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleResetAll = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
updatePluginSettings(pluginId, { action: "reset", actionId: Date.now(), loaded: false, customUrl: "", customData: null });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleFileUpload = function (e) {
|
||||
var _a;
|
||||
var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
||||
if (!file)
|
||||
return;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var json, _a;
|
||||
var _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 2, , 3]);
|
||||
json = JSON.parse((_b = event.target) === null || _b === void 0 ? void 0 : _b.result);
|
||||
updatePluginSettings(pluginId, { customData: json, action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
_a = _c.sent();
|
||||
alert("Invalid JSON file format.");
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
reader.readAsText(file);
|
||||
};
|
||||
return (<div style={{ display: "flex", flexDirection: "column", gap: "var(--space-md)" }}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-muted)", marginBottom: "var(--space-xs)" }}>Data Source Configuration</div>
|
||||
<div style={{ display: "flex", gap: "var(--space-xs)" }}>
|
||||
{[["default", lucide_react_1.Database, "Default"], ["traffic", lucide_react_1.TrafficCone, "Traffic Cams"], ["url", lucide_react_1.Link, "URL"], ["file", lucide_react_1.Upload, "File"]].map(function (_a) {
|
||||
var type = _a[0], Icon = _a[1], label = _a[2];
|
||||
return (<button key={type} onClick={function () { return handleSourceTypeChange(type); }} style={(0, cameraSettingsStyles_1.sourceTabStyle)(settings.sourceType === type)}>
|
||||
<Icon size={14}/><span style={{ fontSize: 10 }}>{label}</span>
|
||||
</button>);
|
||||
})}
|
||||
</div>
|
||||
{settings.sourceType === "default" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>Built-in camera dataset</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>)}
|
||||
{settings.sourceType === "traffic" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>DOT traffic cameras (GDOT + more)</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>)}
|
||||
{settings.sourceType === "url" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<label style={cameraSettingsStyles_1.labelStyle}>URL</label>
|
||||
<div style={{ display: "flex", gap: "var(--space-sm)", marginTop: "4px" }}>
|
||||
<input type="text" placeholder="http://..." value={settings.customUrl || ""} onChange={function (e) { return updatePluginSettings(pluginId, { customUrl: e.target.value }); }} style={__assign(__assign({}, cameraSettingsStyles_1.inputStyle), { flex: 1 })}/>
|
||||
<button onClick={handleLoadData} disabled={!settings.customUrl || isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(!settings.customUrl || isLoading)}>{isLoading ? "Loading..." : "Load"}</button>
|
||||
</div>
|
||||
</div>)}
|
||||
{settings.sourceType === "file" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<label style={cameraSettingsStyles_1.labelStyle}>JSON File</label>
|
||||
<input type="file" accept=".json" onChange={handleFileUpload} style={__assign(__assign({}, cameraSettingsStyles_1.inputStyle), { width: "100%", marginTop: "4px", padding: "4px", fontSize: "10px" })}/>
|
||||
{settings.customData && Array.isArray(settings.customData) && (<div style={{ fontSize: 10, color: "var(--accent-green)", marginTop: "4px" }}>✓ Data loaded ({settings.customData.length} cameras)</div>)}
|
||||
</div>)}
|
||||
<button onClick={handleResetAll} style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: "6px", background: "transparent", border: "1px solid var(--border-subtle)", borderRadius: "var(--radius-sm)", padding: "6px var(--space-md)", fontSize: 11, color: "var(--text-muted)", cursor: "pointer", transition: "all 0.2s ease" }}>
|
||||
<lucide_react_1.RotateCcw size={12}/> Reset All Sources
|
||||
</button>
|
||||
</div>);
|
||||
};
|
||||
exports.CameraSettings = CameraSettings;
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Manages Cesium Entity polylines for camera frustum outlines.
|
||||
*
|
||||
* Draws 4 side-edge lines from the camera apex to the 4 far
|
||||
* corners of the view pyramid. No far-plane rectangle is drawn
|
||||
* (it would clip the earth surface).
|
||||
*
|
||||
* Architecture: corners come from frustumGeometry.ts so a future
|
||||
* ground-projection step can replace the far-plane corners with
|
||||
* terrain-intersection points without changing this renderer.
|
||||
*/
|
||||
import type { Viewer as CesiumViewer } from "cesium";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class FrustumRenderer {
|
||||
/** Map from entity id → array of 4 Cesium.Entity polylines */
|
||||
private entityMap;
|
||||
/**
|
||||
* Sync frustum outlines with the current set of camera entities.
|
||||
* Only draws for entities whose `properties` include heading.
|
||||
*/
|
||||
update(viewer: CesiumViewer, entities: GeoEntity[]): void;
|
||||
/** Remove all frustum entities from the viewer. */
|
||||
clear(viewer: CesiumViewer): void;
|
||||
private resolveHeading;
|
||||
private buildEdges;
|
||||
private createNew;
|
||||
private updateExisting;
|
||||
private removeStale;
|
||||
private addEdgeLine;
|
||||
}
|
||||
//# sourceMappingURL=FrustumRenderer.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FrustumRenderer.d.ts","sourceRoot":"","sources":["../src/FrustumRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAW/D,qBAAa,eAAe;IACxB,8DAA8D;IAC9D,OAAO,CAAC,SAAS,CAA+B;IAEhD;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI;IAuBzD,mDAAmD;IACnD,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAejC,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,WAAW;CAiBtB"}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Manages Cesium Entity polylines for camera frustum outlines.
|
||||
*
|
||||
* Draws 4 side-edge lines from the camera apex to the 4 far
|
||||
* corners of the view pyramid. No far-plane rectangle is drawn
|
||||
* (it would clip the earth surface).
|
||||
*
|
||||
* Architecture: corners come from frustumGeometry.ts so a future
|
||||
* ground-projection step can replace the far-plane corners with
|
||||
* terrain-intersection points without changing this renderer.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FrustumRenderer = void 0;
|
||||
var cesium_1 = require("cesium");
|
||||
var frustumGeometry_1 = require("./frustumGeometry");
|
||||
var FRUSTUM_COLOR = cesium_1.Color.fromCssColorString("#00ccff").withAlpha(0.6);
|
||||
var EDGE_WIDTH = 2;
|
||||
var FrustumRenderer = /** @class */ (function () {
|
||||
function FrustumRenderer() {
|
||||
/** Map from entity id → array of 4 Cesium.Entity polylines */
|
||||
this.entityMap = new Map();
|
||||
}
|
||||
/**
|
||||
* Sync frustum outlines with the current set of camera entities.
|
||||
* Only draws for entities whose `properties` include heading.
|
||||
*/
|
||||
FrustumRenderer.prototype.update = function (viewer, entities) {
|
||||
if (!viewer || viewer.isDestroyed())
|
||||
return;
|
||||
var activeIds = new Set();
|
||||
for (var _i = 0, entities_1 = entities; _i < entities_1.length; _i++) {
|
||||
var geo = entities_1[_i];
|
||||
if (geo.pluginId !== "camera")
|
||||
continue;
|
||||
var heading = this.resolveHeading(geo);
|
||||
if (heading === undefined)
|
||||
continue;
|
||||
activeIds.add(geo.id);
|
||||
var edges = this.buildEdges(geo, heading);
|
||||
if (this.entityMap.has(geo.id)) {
|
||||
this.updateExisting(viewer, geo.id, edges);
|
||||
}
|
||||
else {
|
||||
this.createNew(viewer, geo.id, edges);
|
||||
}
|
||||
}
|
||||
this.removeStale(viewer, activeIds);
|
||||
};
|
||||
/** Remove all frustum entities from the viewer. */
|
||||
FrustumRenderer.prototype.clear = function (viewer) {
|
||||
if (!viewer || viewer.isDestroyed()) {
|
||||
this.entityMap.clear();
|
||||
return;
|
||||
}
|
||||
for (var _i = 0, _a = this.entityMap; _i < _a.length; _i++) {
|
||||
var _b = _a[_i], lines = _b[1];
|
||||
for (var _c = 0, lines_1 = lines; _c < lines_1.length; _c++) {
|
||||
var line = lines_1[_c];
|
||||
viewer.entities.remove(line);
|
||||
}
|
||||
}
|
||||
this.entityMap.clear();
|
||||
};
|
||||
// ─── Private helpers ─────────────────────────────────────
|
||||
FrustumRenderer.prototype.resolveHeading = function (geo) {
|
||||
var p = geo.properties;
|
||||
if (typeof p.heading === "number")
|
||||
return p.heading;
|
||||
if (typeof p.azimuth === "number")
|
||||
return p.azimuth;
|
||||
if (typeof p.heading === "string") {
|
||||
return parseFloat(p.heading) || undefined;
|
||||
}
|
||||
return geo.heading;
|
||||
};
|
||||
FrustumRenderer.prototype.buildEdges = function (geo, heading) {
|
||||
var p = geo.properties;
|
||||
return (0, frustumGeometry_1.computeFrustumEdges)({
|
||||
lat: geo.latitude,
|
||||
lon: geo.longitude,
|
||||
alt: toNum(p.altitude, toNum(p.alt, frustumGeometry_1.FRUSTUM_DEFAULTS.alt)),
|
||||
headingDeg: heading,
|
||||
pitchDeg: toNum(p.pitch, frustumGeometry_1.FRUSTUM_DEFAULTS.pitchDeg),
|
||||
hFovDeg: toNum(p.fov, toNum(p.hFov, frustumGeometry_1.FRUSTUM_DEFAULTS.hFovDeg)),
|
||||
vFovDeg: toNum(p.vFov, frustumGeometry_1.FRUSTUM_DEFAULTS.vFovDeg),
|
||||
rangeMtrs: toNum(p.range, frustumGeometry_1.FRUSTUM_DEFAULTS.rangeMtrs),
|
||||
});
|
||||
};
|
||||
FrustumRenderer.prototype.createNew = function (viewer, id, edges) {
|
||||
var _this = this;
|
||||
var corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
var lines = corners.map(function (corner) {
|
||||
return _this.addEdgeLine(viewer, id, edges.apex, corner);
|
||||
});
|
||||
this.entityMap.set(id, lines);
|
||||
};
|
||||
FrustumRenderer.prototype.updateExisting = function (viewer, id, edges) {
|
||||
var corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
var existing = this.entityMap.get(id);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
existing[i].polyline.positions = toPositions(edges.apex, corners[i]);
|
||||
}
|
||||
};
|
||||
FrustumRenderer.prototype.removeStale = function (viewer, activeIds) {
|
||||
for (var _i = 0, _a = this.entityMap; _i < _a.length; _i++) {
|
||||
var _b = _a[_i], id = _b[0], lines = _b[1];
|
||||
if (!activeIds.has(id)) {
|
||||
for (var _c = 0, lines_2 = lines; _c < lines_2.length; _c++) {
|
||||
var line = lines_2[_c];
|
||||
viewer.entities.remove(line);
|
||||
}
|
||||
this.entityMap.delete(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
FrustumRenderer.prototype.addEdgeLine = function (viewer, parentId, from, to) {
|
||||
return viewer.entities.add({
|
||||
id: "frustum-".concat(parentId, "-").concat(Math.random().toString(36).slice(2, 8)),
|
||||
polyline: {
|
||||
positions: toPositions(from, to),
|
||||
width: EDGE_WIDTH,
|
||||
material: new cesium_1.PolylineGlowMaterialProperty({
|
||||
glowPower: 0.15,
|
||||
color: FRUSTUM_COLOR,
|
||||
}),
|
||||
clampToGround: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
return FrustumRenderer;
|
||||
}());
|
||||
exports.FrustumRenderer = FrustumRenderer;
|
||||
// ─── Utilities ───────────────────────────────────────────────
|
||||
function toPositions(a, b) {
|
||||
return [
|
||||
cesium_1.Cartesian3.fromDegrees(a.lon, a.lat, a.alt),
|
||||
cesium_1.Cartesian3.fromDegrees(b.lon, b.lat, b.alt),
|
||||
];
|
||||
}
|
||||
function toNum(val, fallback) {
|
||||
if (typeof val === "number" && !Number.isNaN(val))
|
||||
return val;
|
||||
if (typeof val === "string") {
|
||||
var n = parseFloat(val);
|
||||
if (!Number.isNaN(n))
|
||||
return n;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare function mapRawCamera(cam: Record<string, unknown>, index: number, prefix: string): GeoEntity;
|
||||
export declare function mapGeoJsonFeature(feature: unknown, index: number, prefix: string): GeoEntity;
|
||||
//# sourceMappingURL=cameraMapper.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cameraMapper.d.ts","sourceRoot":"","sources":["../src/cameraMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAWnG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAc5F"}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mapRawCamera = mapRawCamera;
|
||||
exports.mapGeoJsonFeature = mapGeoJsonFeature;
|
||||
var DEFAULT_CAMERA_ALT = 8;
|
||||
function mapRawCamera(cam, index, prefix) {
|
||||
var _a, _b;
|
||||
return {
|
||||
id: "camera-".concat(prefix, "-").concat(index),
|
||||
pluginId: "camera",
|
||||
latitude: cam.latitude,
|
||||
longitude: cam.longitude,
|
||||
altitude: (_b = (_a = cam.altitude) !== null && _a !== void 0 ? _a : cam.elevation) !== null && _b !== void 0 ? _b : DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: cam.city || cam.country || "Unknown Camera",
|
||||
properties: __assign({}, cam),
|
||||
};
|
||||
}
|
||||
function mapGeoJsonFeature(feature, index, prefix) {
|
||||
var _a, _b, _c;
|
||||
var f = feature;
|
||||
var _d = (_b = (_a = f.geometry) === null || _a === void 0 ? void 0 : _a.coordinates) !== null && _b !== void 0 ? _b : [0, 0], lon = _d[0], lat = _d[1];
|
||||
var props = (_c = f.properties) !== null && _c !== void 0 ? _c : {};
|
||||
return {
|
||||
id: "camera-".concat(prefix, "-").concat(index),
|
||||
pluginId: "camera",
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
altitude: DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: props.city || props.country || "Unknown Camera",
|
||||
properties: __assign({}, props),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type React from "react";
|
||||
export declare const inputGroupStyle: React.CSSProperties;
|
||||
export declare const labelStyle: React.CSSProperties;
|
||||
export declare const inputStyle: React.CSSProperties;
|
||||
export declare const loadButtonStyle: (disabled: boolean) => React.CSSProperties;
|
||||
export declare const sourceTabStyle: (active: boolean) => React.CSSProperties;
|
||||
//# sourceMappingURL=cameraSettingsStyles.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cameraSettingsStyles.d.ts","sourceRoot":"","sources":["../src/cameraSettingsStyles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAwE,CAAC;AAC7G,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,aAAkI,CAAC;AAClK,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,aAAyO,CAAC;AACzQ,eAAO,MAAM,eAAe,GAAI,UAAU,OAAO,KAAG,KAAK,CAAC,aAA0S,CAAC;AACrW,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,KAAG,KAAK,CAAC,aAAya,CAAC"}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sourceTabStyle = exports.loadButtonStyle = exports.inputStyle = exports.labelStyle = exports.inputGroupStyle = void 0;
|
||||
exports.inputGroupStyle = { display: "flex", flexDirection: "column", gap: "4px" };
|
||||
exports.labelStyle = { fontSize: 10, fontWeight: 600, color: "var(--text-muted)", textTransform: "uppercase", letterSpacing: "0.05em" };
|
||||
exports.inputStyle = { background: "var(--bg-tertiary)", border: "1px solid var(--border-subtle)", color: "var(--text-primary)", padding: "var(--space-xs) var(--space-sm)", borderRadius: "var(--radius-sm)", fontSize: 12, outline: "none" };
|
||||
var loadButtonStyle = function (disabled) { return ({ background: "var(--accent-cyan)", color: "var(--bg-primary)", border: "none", borderRadius: "var(--radius-sm)", padding: "0 var(--space-md)", fontSize: 12, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, transition: "all 0.2s ease" }); };
|
||||
exports.loadButtonStyle = loadButtonStyle;
|
||||
var sourceTabStyle = function (active) { return ({ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: "4px", padding: "8px", borderRadius: "var(--radius-md)", background: active ? "var(--accent-cyan-subtle)" : "var(--bg-tertiary)", border: active ? "1px solid var(--accent-cyan)" : "1px solid var(--border-subtle)", cursor: "pointer", color: active ? "var(--accent-cyan)" : "var(--text-secondary)", transition: "all 0.2s ease" }); };
|
||||
exports.sourceTabStyle = sourceTabStyle;
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Pure math for computing 3D camera frustum edges.
|
||||
* No Cesium dependency — fully unit-testable.
|
||||
*
|
||||
* The frustum is a pyramid with:
|
||||
* - apex at the camera position
|
||||
* - 4 corner rays extending outward at `range` meters
|
||||
* - orientation defined by heading, pitch, and FOV
|
||||
*
|
||||
* Architecture note: returns raw corner positions so that
|
||||
* a future ground-projection step can raycast these rays
|
||||
* onto the terrain surface.
|
||||
*/
|
||||
export interface Point3D {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
}
|
||||
/** The 4 far-plane corners + the apex, ready for rendering. */
|
||||
export interface FrustumEdges {
|
||||
apex: Point3D;
|
||||
topLeft: Point3D;
|
||||
topRight: Point3D;
|
||||
bottomLeft: Point3D;
|
||||
bottomRight: Point3D;
|
||||
}
|
||||
export interface FrustumParams {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
headingDeg: number;
|
||||
pitchDeg: number;
|
||||
hFovDeg: number;
|
||||
vFovDeg: number;
|
||||
rangeMtrs: number;
|
||||
}
|
||||
export declare const FRUSTUM_DEFAULTS: {
|
||||
readonly alt: 8;
|
||||
readonly headingDeg: 0;
|
||||
readonly pitchDeg: -10;
|
||||
readonly hFovDeg: 50;
|
||||
readonly vFovDeg: 35;
|
||||
readonly rangeMtrs: 200;
|
||||
};
|
||||
/**
|
||||
* Compute the 4 frustum corner points at `range` distance
|
||||
* from the camera, given orientation and FOV.
|
||||
*
|
||||
* Returns edges that can be drawn as 4 polylines from apex
|
||||
* to each corner, or passed to a ground-projection step.
|
||||
*/
|
||||
export declare function computeFrustumEdges(params: FrustumParams): FrustumEdges;
|
||||
/**
|
||||
* Convert a cardinal direction string to degrees.
|
||||
* Returns `undefined` if not recognised.
|
||||
*/
|
||||
export declare function cardinalToHeading(dir: string): number | undefined;
|
||||
//# sourceMappingURL=frustumGeometry.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"frustumGeometry.d.ts","sourceRoot":"","sources":["../src/frustumGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,MAAM,WAAW,OAAO;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAID,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAIX;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAwBvE;AAeD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE"}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Pure math for computing 3D camera frustum edges.
|
||||
* No Cesium dependency — fully unit-testable.
|
||||
*
|
||||
* The frustum is a pyramid with:
|
||||
* - apex at the camera position
|
||||
* - 4 corner rays extending outward at `range` meters
|
||||
* - orientation defined by heading, pitch, and FOV
|
||||
*
|
||||
* Architecture note: returns raw corner positions so that
|
||||
* a future ground-projection step can raycast these rays
|
||||
* onto the terrain surface.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FRUSTUM_DEFAULTS = void 0;
|
||||
exports.computeFrustumEdges = computeFrustumEdges;
|
||||
exports.cardinalToHeading = cardinalToHeading;
|
||||
var DEG2RAD = Math.PI / 180;
|
||||
var EARTH_RADIUS = 6371000; // metres
|
||||
// ─── Defaults ────────────────────────────────────────────────
|
||||
exports.FRUSTUM_DEFAULTS = {
|
||||
alt: 8,
|
||||
headingDeg: 0,
|
||||
pitchDeg: -10,
|
||||
hFovDeg: 50,
|
||||
vFovDeg: 35,
|
||||
rangeMtrs: 200,
|
||||
};
|
||||
// ─── Core computation ────────────────────────────────────────
|
||||
/**
|
||||
* Compute the 4 frustum corner points at `range` distance
|
||||
* from the camera, given orientation and FOV.
|
||||
*
|
||||
* Returns edges that can be drawn as 4 polylines from apex
|
||||
* to each corner, or passed to a ground-projection step.
|
||||
*/
|
||||
function computeFrustumEdges(params) {
|
||||
var lat = params.lat, lon = params.lon, alt = params.alt, headingDeg = params.headingDeg, pitchDeg = params.pitchDeg, hFovDeg = params.hFovDeg, vFovDeg = params.vFovDeg, rangeMtrs = params.rangeMtrs;
|
||||
var apex = { lat: lat, lon: lon, alt: alt };
|
||||
var halfH = (hFovDeg / 2) * DEG2RAD;
|
||||
var halfV = (vFovDeg / 2) * DEG2RAD;
|
||||
var heading = headingDeg * DEG2RAD;
|
||||
var pitch = pitchDeg * DEG2RAD;
|
||||
// For each corner we compute horizontal bearing offset ± halfH
|
||||
// and vertical pitch offset ± halfV, then project to a destination.
|
||||
var corners = [
|
||||
[-halfH, halfV], // topLeft
|
||||
[halfH, halfV], // topRight
|
||||
[-halfH, -halfV], // bottomLeft
|
||||
[halfH, -halfV], // bottomRight
|
||||
];
|
||||
var _a = corners.map(function (_a) {
|
||||
var hOff = _a[0], vOff = _a[1];
|
||||
return projectCorner(lat, lon, alt, heading, pitch, hOff, vOff, rangeMtrs);
|
||||
}), topLeft = _a[0], topRight = _a[1], bottomLeft = _a[2], bottomRight = _a[3];
|
||||
return { apex: apex, topLeft: topLeft, topRight: topRight, bottomLeft: bottomLeft, bottomRight: bottomRight };
|
||||
}
|
||||
// ─── Cardinal direction helper ───────────────────────────────
|
||||
var CARDINAL_MAP = {
|
||||
n: 0, north: 0, nb: 0, northbound: 0,
|
||||
ne: 45, northeast: 45, neb: 45,
|
||||
e: 90, east: 90, eb: 90, eastbound: 90,
|
||||
se: 135, southeast: 135, seb: 135,
|
||||
s: 180, south: 180, sb: 180, southbound: 180,
|
||||
sw: 225, southwest: 225, swb: 225,
|
||||
w: 270, west: 270, wb: 270, westbound: 270,
|
||||
nw: 315, northwest: 315, nwb: 315,
|
||||
};
|
||||
/**
|
||||
* Convert a cardinal direction string to degrees.
|
||||
* Returns `undefined` if not recognised.
|
||||
*/
|
||||
function cardinalToHeading(dir) {
|
||||
return CARDINAL_MAP[dir.trim().toLowerCase()];
|
||||
}
|
||||
// ─── Internal math ───────────────────────────────────────────
|
||||
/**
|
||||
* Project a single frustum corner from the camera position.
|
||||
*
|
||||
* 1. Compute the bearing = heading + horizontal offset
|
||||
* 2. Compute the ground distance = range * cos(pitch + vOff)
|
||||
* 3. Compute the altitude delta = range * sin(pitch + vOff)
|
||||
* 4. Use haversine destination formula for the ground position
|
||||
*/
|
||||
function projectCorner(latDeg, lonDeg, altM, headingRad, pitchRad, hOffRad, vOffRad, range) {
|
||||
var bearing = headingRad + hOffRad;
|
||||
var elevation = pitchRad + vOffRad;
|
||||
var groundDist = range * Math.cos(elevation);
|
||||
var altDelta = range * Math.sin(elevation);
|
||||
var dest = destinationPoint(latDeg, lonDeg, Math.abs(groundDist), bearing);
|
||||
return {
|
||||
lat: dest.lat,
|
||||
lon: dest.lon,
|
||||
alt: Math.max(0, altM + altDelta),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Haversine destination point given start coords (deg),
|
||||
* distance (m), and bearing (rad).
|
||||
*/
|
||||
function destinationPoint(latDeg, lonDeg, distMetres, bearingRad) {
|
||||
var lat1 = latDeg * DEG2RAD;
|
||||
var lon1 = lonDeg * DEG2RAD;
|
||||
var angularDist = distMetres / EARTH_RADIUS;
|
||||
var sinLat1 = Math.sin(lat1);
|
||||
var cosLat1 = Math.cos(lat1);
|
||||
var sinD = Math.sin(angularDist);
|
||||
var cosD = Math.cos(angularDist);
|
||||
var lat2 = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(bearingRad));
|
||||
var lon2 = lon1 + Math.atan2(Math.sin(bearingRad) * sinD * cosLat1, cosD - sinLat1 * Math.sin(lat2));
|
||||
return { lat: lat2 / DEG2RAD, lon: lon2 / DEG2RAD };
|
||||
}
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var CameraDetail_1 = require("./CameraDetail");
|
||||
var CameraSettings_1 = require("./CameraSettings");
|
||||
var cameraMapper_1 = require("./cameraMapper");
|
||||
var analytics_1 = require("@/lib/analytics");
|
||||
var CameraPlugin = /** @class */ (function () {
|
||||
function CameraPlugin() {
|
||||
this.id = "camera";
|
||||
this.name = "Cameras";
|
||||
this.description = "Public live cameras from across the globe";
|
||||
this.icon = lucide_react_1.Camera;
|
||||
this.category = "infrastructure";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = null;
|
||||
}
|
||||
CameraPlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
CameraPlugin.prototype.destroy = function () { this.context = null; };
|
||||
CameraPlugin.prototype.requiresConfiguration = function (settingsRaw) {
|
||||
var _a;
|
||||
var s = settingsRaw;
|
||||
var sourceType = (_a = s === null || s === void 0 ? void 0 : s.sourceType) !== null && _a !== void 0 ? _a : "default";
|
||||
if (sourceType === "default" || sourceType === "traffic")
|
||||
return false;
|
||||
if (sourceType === "url" && !(s === null || s === void 0 ? void 0 : s.customUrl))
|
||||
return true;
|
||||
if (sourceType === "file" && !(s === null || s === void 0 ? void 0 : s.customData))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
CameraPlugin.prototype.getAllEntities = function () { return Object.values(this.sourceBuckets).flat(); };
|
||||
CameraPlugin.prototype.pushUpdate = function () { var _a; (_a = this.context) === null || _a === void 0 ? void 0 : _a.onDataUpdate(this.getAllEntities()); };
|
||||
CameraPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rawSettings, settings, isAutoDefault, error_1;
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
rawSettings = this.context.getPluginSettings(this.id);
|
||||
settings = __assign({ sourceType: "default", action: undefined, actionId: undefined, loaded: undefined, customUrl: undefined, customData: undefined }, (rawSettings || {}));
|
||||
if (settings.action === "reset") {
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = settings.actionId;
|
||||
return [2 /*return*/, []];
|
||||
}
|
||||
isAutoDefault = (settings.sourceType === "default" || settings.sourceType === "traffic")
|
||||
&& !this.lastActionId && !this.sourceBuckets["default"];
|
||||
if (!isAutoDefault && (settings.action !== "load" || settings.actionId === this.lastActionId)) {
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
}
|
||||
this.lastActionId = (_a = settings.actionId) !== null && _a !== void 0 ? _a : -1;
|
||||
_c.label = 1;
|
||||
case 1:
|
||||
_c.trys.push([1, 9, , 10]);
|
||||
if (!(settings.sourceType === "default")) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, this.loadDefaultSource()];
|
||||
case 2:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 3:
|
||||
if (!(settings.sourceType === "traffic")) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, this.loadTrafficCameras()];
|
||||
case 4:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 5:
|
||||
if (!(settings.sourceType === "url")) return [3 /*break*/, 7];
|
||||
return [4 /*yield*/, this.loadUrlSource(settings)];
|
||||
case 6:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
if (settings.sourceType === "file") {
|
||||
this.loadFileSource(settings);
|
||||
}
|
||||
_c.label = 8;
|
||||
case 8:
|
||||
(0, analytics_1.trackEvent)("camera-source-load", { sourceType: settings.sourceType });
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
case 9:
|
||||
error_1 = _c.sent();
|
||||
console.error("[CameraPlugin] Fetch error:", error_1);
|
||||
(_b = this.context) === null || _b === void 0 ? void 0 : _b.onError(error_1 instanceof Error ? error_1 : new Error(String(error_1)));
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
case 10: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadDefaultSource = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, geojson;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, fetch("/public-cameras.json")];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
geojson = _a.sent();
|
||||
if (geojson && Array.isArray(geojson.features)) {
|
||||
this.sourceBuckets["default"] = geojson.features.map(function (f, i) { return (0, cameraMapper_1.mapGeoJsonFeature)(f, i, "default"); });
|
||||
}
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
this.pushUpdate();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadTrafficCameras = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, data, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 4]);
|
||||
return [4 /*yield*/, fetch("/api/camera/traffic")];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _a.sent();
|
||||
if (data.cameras && Array.isArray(data.cameras)) {
|
||||
this.sourceBuckets["default"] = data.cameras.map(function (f, i) { return (0, cameraMapper_1.mapGeoJsonFeature)(f, i, "traffic"); });
|
||||
}
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
console.warn("[CameraPlugin] Traffic cameras API failed:", err_1);
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
this.pushUpdate();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadUrlSource = function (settings) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, res, data;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!settings.customUrl)
|
||||
return [2 /*return*/];
|
||||
url = settings.customUrl;
|
||||
if (!/^https?:\/\//i.test(url))
|
||||
url = "http://".concat(url);
|
||||
return [4 /*yield*/, fetch(url)];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _a.sent();
|
||||
if (Array.isArray(data)) {
|
||||
this.sourceBuckets["url"] = data.map(function (c, i) { return (0, cameraMapper_1.mapRawCamera)(c, i, "url"); });
|
||||
}
|
||||
_a.label = 3;
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadFileSource = function (settings) {
|
||||
if (!settings.customData || !Array.isArray(settings.customData))
|
||||
return;
|
||||
this.sourceBuckets["file"] = settings.customData.map(function (c, i) { return (0, cameraMapper_1.mapRawCamera)(c, i, "file"); });
|
||||
};
|
||||
CameraPlugin.prototype.getPollingInterval = function () { return 3600000; };
|
||||
CameraPlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#60a5fa", clusterEnabled: true, clusterDistance: 50, maxEntities: 10000 };
|
||||
};
|
||||
CameraPlugin.prototype.renderEntity = function (entity) {
|
||||
return {
|
||||
type: "point", color: "#60a5fa", size: 6,
|
||||
outlineColor: "#ffffff", outlineWidth: 1.5,
|
||||
labelText: entity.label, labelFont: "11px Inter, system-ui, sans-serif",
|
||||
};
|
||||
};
|
||||
CameraPlugin.prototype.getDetailComponent = function () { return CameraDetail_1.CameraDetail; };
|
||||
CameraPlugin.prototype.getSettingsComponent = function () { return CameraSettings_1.CameraSettings; };
|
||||
CameraPlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{ id: "country", label: "Country", type: "text", propertyKey: "country" },
|
||||
{ id: "city", label: "City", type: "text", propertyKey: "city" },
|
||||
{ id: "is_popular", label: "Popular Only", type: "boolean", propertyKey: "is_popular" },
|
||||
];
|
||||
};
|
||||
return CameraPlugin;
|
||||
}());
|
||||
exports.CameraPlugin = CameraPlugin;
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-camera",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for displaying public live cameras and traffic cameras on the globe. Supports custom data sources via URL, file upload, and GeoJSON",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-camera",
|
||||
"camera",
|
||||
"live-camera",
|
||||
"traffic-camera",
|
||||
"cctv",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-camera"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"react": ">=18",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
+5
-33
@@ -2,12 +2,10 @@
|
||||
|
||||
import React from "react";
|
||||
import { ExternalLink, MapPin, Tag } from "lucide-react";
|
||||
import type { GeoEntity } from "@/core/plugins/PluginTypes";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
import { CameraStream } from "@/components/video/CameraStream";
|
||||
|
||||
interface CameraDetailProps {
|
||||
entity: GeoEntity;
|
||||
}
|
||||
interface CameraDetailProps { entity: GeoEntity; }
|
||||
|
||||
export const CameraDetail: React.FC<CameraDetailProps> = ({ entity }) => {
|
||||
const { properties } = entity;
|
||||
@@ -21,46 +19,20 @@ export const CameraDetail: React.FC<CameraDetailProps> = ({ entity }) => {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<CameraStream
|
||||
id={entity.id}
|
||||
streamUrl={stream}
|
||||
previewUrl={previewUrl}
|
||||
isIframe={isIframe}
|
||||
label={city || country}
|
||||
/>
|
||||
|
||||
<CameraStream id={entity.id} streamUrl={stream} previewUrl={previewUrl} isIframe={isIframe} label={city || country} />
|
||||
<div className="intel-panel__props">
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-xs)", borderBottom: "1px solid var(--border-subtle)", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Location</span>
|
||||
<span className="intel-panel__prop-value" style={{
|
||||
textAlign: "left",
|
||||
width: "100%",
|
||||
whiteSpace: "normal",
|
||||
lineHeight: "1.4",
|
||||
fontSize: "12px",
|
||||
color: "var(--text-primary)"
|
||||
}}>
|
||||
<span className="intel-panel__prop-value" style={{ textAlign: "left", width: "100%", whiteSpace: "normal", lineHeight: "1.4", fontSize: "12px", color: "var(--text-primary)" }}>
|
||||
{[city, region, country].filter(Boolean).join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{categories.length > 0 && (
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-sm)", borderBottom: "none", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Categories</span>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>
|
||||
{categories.map((cat) => (
|
||||
<span
|
||||
key={cat}
|
||||
style={{
|
||||
borderRadius: "12px",
|
||||
backgroundColor: "var(--bg-tertiary)",
|
||||
padding: "2px 8px",
|
||||
fontSize: "10px",
|
||||
fontWeight: 500,
|
||||
color: "var(--text-secondary)",
|
||||
border: "1px solid var(--border-subtle)"
|
||||
}}
|
||||
>
|
||||
<span key={cat} style={{ borderRadius: "12px", backgroundColor: "var(--bg-tertiary)", padding: "2px 8px", fontSize: "10px", fontWeight: 500, color: "var(--text-secondary)", border: "1px solid var(--border-subtle)" }}>
|
||||
{cat}
|
||||
</span>
|
||||
))}
|
||||
@@ -0,0 +1,106 @@
|
||||
"use client";
|
||||
|
||||
import React, { ChangeEvent } from "react";
|
||||
import { useStore } from "@/core/state/store";
|
||||
import { Upload, Link as LinkIcon, Database, RotateCcw, TrafficCone } from "lucide-react";
|
||||
import { pluginManager } from "@/core/plugins/PluginManager";
|
||||
import { inputGroupStyle, labelStyle, inputStyle, loadButtonStyle, sourceTabStyle } from "./cameraSettingsStyles";
|
||||
|
||||
type SourceType = "default" | "traffic" | "url" | "file";
|
||||
|
||||
export const CameraSettings: React.FC<{ pluginId: string }> = ({ pluginId }) => {
|
||||
const settingsRaw = useStore((s) => s.dataConfig.pluginSettings[pluginId]);
|
||||
const settings = { sourceType: "default" as SourceType, ...(settingsRaw || {}) };
|
||||
const updatePluginSettings = useStore((s) => s.updatePluginSettings);
|
||||
const setHighlightLayerId = useStore((s) => s.setHighlightLayerId);
|
||||
const [isLoading, setIsLoading] = React.useState(false);
|
||||
|
||||
const handleSourceTypeChange = (type: SourceType) => {
|
||||
updatePluginSettings(pluginId, { sourceType: type });
|
||||
setHighlightLayerId(null);
|
||||
};
|
||||
|
||||
const triggerFetch = async () => {
|
||||
const managed = pluginManager.getPlugin(pluginId);
|
||||
if (managed && managed.enabled) {
|
||||
await pluginManager.fetchForPlugin(pluginId, managed.context.timeRange);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoadData = async () => {
|
||||
setIsLoading(true);
|
||||
updatePluginSettings(pluginId, { action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
const handleResetAll = async () => {
|
||||
updatePluginSettings(pluginId, { action: "reset", actionId: Date.now(), loaded: false, customUrl: "", customData: null });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
};
|
||||
|
||||
const handleFileUpload = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (event) => {
|
||||
try {
|
||||
const json = JSON.parse(event.target?.result as string);
|
||||
updatePluginSettings(pluginId, { customData: json, action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
} catch { alert("Invalid JSON file format."); }
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "var(--space-md)" }}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-muted)", marginBottom: "var(--space-xs)" }}>Data Source Configuration</div>
|
||||
<div style={{ display: "flex", gap: "var(--space-xs)" }}>
|
||||
{([["default", Database, "Default"], ["traffic", TrafficCone, "Traffic Cams"], ["url", LinkIcon, "URL"], ["file", Upload, "File"]] as const).map(
|
||||
([type, Icon, label]) => (
|
||||
<button key={type} onClick={() => handleSourceTypeChange(type)} style={sourceTabStyle(settings.sourceType === type)}>
|
||||
<Icon size={14} /><span style={{ fontSize: 10 }}>{label}</span>
|
||||
</button>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
{settings.sourceType === "default" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>Built-in camera dataset</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={loadButtonStyle(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "traffic" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>DOT traffic cameras (GDOT + more)</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={loadButtonStyle(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "url" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<label style={labelStyle}>URL</label>
|
||||
<div style={{ display: "flex", gap: "var(--space-sm)", marginTop: "4px" }}>
|
||||
<input type="text" placeholder="http://..." value={(settings.customUrl as string) || ""} onChange={(e) => updatePluginSettings(pluginId, { customUrl: e.target.value })} style={{ ...inputStyle, flex: 1 }} />
|
||||
<button onClick={handleLoadData} disabled={!settings.customUrl || isLoading} style={loadButtonStyle(!settings.customUrl || isLoading)}>{isLoading ? "Loading..." : "Load"}</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "file" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<label style={labelStyle}>JSON File</label>
|
||||
<input type="file" accept=".json" onChange={handleFileUpload} style={{ ...inputStyle, width: "100%", marginTop: "4px", padding: "4px", fontSize: "10px" }} />
|
||||
{settings.customData && Array.isArray(settings.customData) && (
|
||||
<div style={{ fontSize: 10, color: "var(--accent-green)", marginTop: "4px" }}>✓ Data loaded ({(settings.customData as unknown[]).length} cameras)</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<button onClick={handleResetAll} style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: "6px", background: "transparent", border: "1px solid var(--border-subtle)", borderRadius: "var(--radius-sm)", padding: "6px var(--space-md)", fontSize: 11, color: "var(--text-muted)", cursor: "pointer", transition: "all 0.2s ease" }}>
|
||||
<RotateCcw size={12} /> Reset All Sources
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Manages Cesium Entity polylines for camera frustum outlines.
|
||||
*
|
||||
* Draws 4 side-edge lines from the camera apex to the 4 far
|
||||
* corners of the view pyramid. No far-plane rectangle is drawn
|
||||
* (it would clip the earth surface).
|
||||
*
|
||||
* Architecture: corners come from frustumGeometry.ts so a future
|
||||
* ground-projection step can replace the far-plane corners with
|
||||
* terrain-intersection points without changing this renderer.
|
||||
*/
|
||||
|
||||
import {
|
||||
Cartesian3,
|
||||
Color,
|
||||
Entity,
|
||||
PolylineGlowMaterialProperty,
|
||||
} from "cesium";
|
||||
import type { Viewer as CesiumViewer } from "cesium";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
import {
|
||||
computeFrustumEdges,
|
||||
FRUSTUM_DEFAULTS,
|
||||
type FrustumEdges,
|
||||
type Point3D,
|
||||
} from "./frustumGeometry";
|
||||
|
||||
const FRUSTUM_COLOR = Color.fromCssColorString("#00ccff").withAlpha(0.6);
|
||||
const EDGE_WIDTH = 2;
|
||||
|
||||
export class FrustumRenderer {
|
||||
/** Map from entity id → array of 4 Cesium.Entity polylines */
|
||||
private entityMap = new Map<string, Entity[]>();
|
||||
|
||||
/**
|
||||
* Sync frustum outlines with the current set of camera entities.
|
||||
* Only draws for entities whose `properties` include heading.
|
||||
*/
|
||||
update(viewer: CesiumViewer, entities: GeoEntity[]): void {
|
||||
if (!viewer || viewer.isDestroyed()) return;
|
||||
const activeIds = new Set<string>();
|
||||
|
||||
for (const geo of entities) {
|
||||
if (geo.pluginId !== "camera") continue;
|
||||
|
||||
const heading = this.resolveHeading(geo);
|
||||
if (heading === undefined) continue;
|
||||
|
||||
activeIds.add(geo.id);
|
||||
const edges = this.buildEdges(geo, heading);
|
||||
|
||||
if (this.entityMap.has(geo.id)) {
|
||||
this.updateExisting(viewer, geo.id, edges);
|
||||
} else {
|
||||
this.createNew(viewer, geo.id, edges);
|
||||
}
|
||||
}
|
||||
|
||||
this.removeStale(viewer, activeIds);
|
||||
}
|
||||
|
||||
/** Remove all frustum entities from the viewer. */
|
||||
clear(viewer: CesiumViewer): void {
|
||||
if (!viewer || viewer.isDestroyed()) {
|
||||
this.entityMap.clear();
|
||||
return;
|
||||
}
|
||||
for (const [, lines] of this.entityMap) {
|
||||
for (const line of lines) {
|
||||
viewer.entities.remove(line);
|
||||
}
|
||||
}
|
||||
this.entityMap.clear();
|
||||
}
|
||||
|
||||
// ─── Private helpers ─────────────────────────────────────
|
||||
|
||||
private resolveHeading(geo: GeoEntity): number | undefined {
|
||||
const p = geo.properties;
|
||||
if (typeof p.heading === "number") return p.heading;
|
||||
if (typeof p.azimuth === "number") return p.azimuth;
|
||||
if (typeof p.heading === "string") {
|
||||
return parseFloat(p.heading) || undefined;
|
||||
}
|
||||
return geo.heading;
|
||||
}
|
||||
|
||||
private buildEdges(geo: GeoEntity, heading: number): FrustumEdges {
|
||||
const p = geo.properties;
|
||||
return computeFrustumEdges({
|
||||
lat: geo.latitude,
|
||||
lon: geo.longitude,
|
||||
alt: toNum(p.altitude, toNum(p.alt, FRUSTUM_DEFAULTS.alt)),
|
||||
headingDeg: heading,
|
||||
pitchDeg: toNum(p.pitch, FRUSTUM_DEFAULTS.pitchDeg),
|
||||
hFovDeg: toNum(p.fov, toNum(p.hFov, FRUSTUM_DEFAULTS.hFovDeg)),
|
||||
vFovDeg: toNum(p.vFov, FRUSTUM_DEFAULTS.vFovDeg),
|
||||
rangeMtrs: toNum(p.range, FRUSTUM_DEFAULTS.rangeMtrs),
|
||||
});
|
||||
}
|
||||
|
||||
private createNew(viewer: CesiumViewer, id: string, edges: FrustumEdges): void {
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
const lines = corners.map((corner) =>
|
||||
this.addEdgeLine(viewer, id, edges.apex, corner),
|
||||
);
|
||||
this.entityMap.set(id, lines);
|
||||
}
|
||||
|
||||
private updateExisting(viewer: CesiumViewer, id: string, edges: FrustumEdges): void {
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
const existing = this.entityMap.get(id)!;
|
||||
for (let i = 0; i < 4; i++) {
|
||||
existing[i].polyline!.positions = toPositions(edges.apex, corners[i]) as any;
|
||||
}
|
||||
}
|
||||
|
||||
private removeStale(viewer: CesiumViewer, activeIds: Set<string>): void {
|
||||
for (const [id, lines] of this.entityMap) {
|
||||
if (!activeIds.has(id)) {
|
||||
for (const line of lines) viewer.entities.remove(line);
|
||||
this.entityMap.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private addEdgeLine(
|
||||
viewer: CesiumViewer, parentId: string,
|
||||
from: Point3D, to: Point3D,
|
||||
): Entity {
|
||||
return viewer.entities.add({
|
||||
id: `frustum-${parentId}-${Math.random().toString(36).slice(2, 8)}`,
|
||||
polyline: {
|
||||
positions: toPositions(from, to),
|
||||
width: EDGE_WIDTH,
|
||||
material: new PolylineGlowMaterialProperty({
|
||||
glowPower: 0.15,
|
||||
color: FRUSTUM_COLOR,
|
||||
}),
|
||||
clampToGround: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Utilities ───────────────────────────────────────────────
|
||||
|
||||
function toPositions(a: Point3D, b: Point3D): Cartesian3[] {
|
||||
return [
|
||||
Cartesian3.fromDegrees(a.lon, a.lat, a.alt),
|
||||
Cartesian3.fromDegrees(b.lon, b.lat, b.alt),
|
||||
];
|
||||
}
|
||||
|
||||
function toNum(val: unknown, fallback: number): number {
|
||||
if (typeof val === "number" && !Number.isNaN(val)) return val;
|
||||
if (typeof val === "string") {
|
||||
const n = parseFloat(val);
|
||||
if (!Number.isNaN(n)) return n;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
const DEFAULT_CAMERA_ALT = 8;
|
||||
|
||||
export function mapRawCamera(cam: Record<string, unknown>, index: number, prefix: string): GeoEntity {
|
||||
return {
|
||||
id: `camera-${prefix}-${index}`,
|
||||
pluginId: "camera",
|
||||
latitude: cam.latitude as number,
|
||||
longitude: cam.longitude as number,
|
||||
altitude: (cam.altitude as number) ?? (cam.elevation as number) ?? DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: (cam.city as string) || (cam.country as string) || "Unknown Camera",
|
||||
properties: { ...cam },
|
||||
};
|
||||
}
|
||||
|
||||
export function mapGeoJsonFeature(feature: unknown, index: number, prefix: string): GeoEntity {
|
||||
const f = feature as { geometry?: { coordinates?: number[] }; properties?: Record<string, unknown> };
|
||||
const [lon, lat] = f.geometry?.coordinates ?? [0, 0];
|
||||
const props = f.properties ?? {};
|
||||
return {
|
||||
id: `camera-${prefix}-${index}`,
|
||||
pluginId: "camera",
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
altitude: DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: (props.city as string) || (props.country as string) || "Unknown Camera",
|
||||
properties: { ...props },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type React from "react";
|
||||
|
||||
export const inputGroupStyle: React.CSSProperties = { display: "flex", flexDirection: "column", gap: "4px" };
|
||||
export const labelStyle: React.CSSProperties = { fontSize: 10, fontWeight: 600, color: "var(--text-muted)", textTransform: "uppercase", letterSpacing: "0.05em" };
|
||||
export const inputStyle: React.CSSProperties = { background: "var(--bg-tertiary)", border: "1px solid var(--border-subtle)", color: "var(--text-primary)", padding: "var(--space-xs) var(--space-sm)", borderRadius: "var(--radius-sm)", fontSize: 12, outline: "none" };
|
||||
export const loadButtonStyle = (disabled: boolean): React.CSSProperties => ({ background: "var(--accent-cyan)", color: "var(--bg-primary)", border: "none", borderRadius: "var(--radius-sm)", padding: "0 var(--space-md)", fontSize: 12, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, transition: "all 0.2s ease" });
|
||||
export const sourceTabStyle = (active: boolean): React.CSSProperties => ({ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: "4px", padding: "8px", borderRadius: "var(--radius-md)", background: active ? "var(--accent-cyan-subtle)" : "var(--bg-tertiary)", border: active ? "1px solid var(--accent-cyan)" : "1px solid var(--border-subtle)", cursor: "pointer", color: active ? "var(--accent-cyan)" : "var(--text-secondary)", transition: "all 0.2s ease" });
|
||||
@@ -0,0 +1,128 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
computeFrustumEdges,
|
||||
cardinalToHeading,
|
||||
FRUSTUM_DEFAULTS,
|
||||
type FrustumParams,
|
||||
} from "./frustumGeometry";
|
||||
|
||||
// ─── computeFrustumEdges ─────────────────────────────────────
|
||||
|
||||
describe("computeFrustumEdges", () => {
|
||||
const baseParams: FrustumParams = {
|
||||
lat: 40.0,
|
||||
lon: -83.0,
|
||||
alt: 8,
|
||||
headingDeg: 0,
|
||||
pitchDeg: 0,
|
||||
hFovDeg: 50,
|
||||
vFovDeg: 35,
|
||||
rangeMtrs: 200,
|
||||
};
|
||||
|
||||
it("returns apex at the camera position", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
expect(edges.apex.lat).toBe(40.0);
|
||||
expect(edges.apex.lon).toBe(-83.0);
|
||||
expect(edges.apex.alt).toBe(8);
|
||||
});
|
||||
|
||||
it("produces 4 distinct corner points", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
|
||||
// All corners should differ from each other
|
||||
for (let i = 0; i < corners.length; i++) {
|
||||
for (let j = i + 1; j < corners.length; j++) {
|
||||
const same = corners[i].lat === corners[j].lat
|
||||
&& corners[i].lon === corners[j].lon
|
||||
&& corners[i].alt === corners[j].alt;
|
||||
expect(same).toBe(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("corners are roughly at the expected range from apex", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
|
||||
for (const c of corners) {
|
||||
const dLat = (c.lat - edges.apex.lat) * 111_320;
|
||||
const dLon = (c.lon - edges.apex.lon) * 111_320 * Math.cos(edges.apex.lat * Math.PI / 180);
|
||||
const dAlt = c.alt - edges.apex.alt;
|
||||
const dist = Math.sqrt(dLat * dLat + dLon * dLon + dAlt * dAlt);
|
||||
// Should be close to 200m (within 10% tolerance for spherical approx)
|
||||
expect(dist).toBeGreaterThan(150);
|
||||
expect(dist).toBeLessThan(250);
|
||||
}
|
||||
});
|
||||
|
||||
it("heading north means corners are north of the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 0, pitchDeg: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeGreaterThan(edges.apex.lat);
|
||||
}
|
||||
});
|
||||
|
||||
it("heading south means corners are south of the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 180, pitchDeg: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeLessThan(edges.apex.lat);
|
||||
}
|
||||
});
|
||||
|
||||
it("left corners are to the left of right corners (heading north)", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 0, pitchDeg: 0 });
|
||||
// Heading north: left = west (smaller lon), right = east (larger lon)
|
||||
expect(edges.topLeft.lon).toBeLessThan(edges.topRight.lon);
|
||||
expect(edges.bottomLeft.lon).toBeLessThan(edges.bottomRight.lon);
|
||||
});
|
||||
|
||||
it("zero range produces corners at the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, rangeMtrs: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeCloseTo(edges.apex.lat, 6);
|
||||
expect(c.lon).toBeCloseTo(edges.apex.lon, 6);
|
||||
}
|
||||
});
|
||||
|
||||
it("corner altitudes clamp to 0 when pitch is steep enough", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, pitchDeg: -80, alt: 5 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.alt).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── cardinalToHeading ───────────────────────────────────────
|
||||
|
||||
describe("cardinalToHeading", () => {
|
||||
it("parses cardinal directions", () => {
|
||||
expect(cardinalToHeading("N")).toBe(0);
|
||||
expect(cardinalToHeading("E")).toBe(90);
|
||||
expect(cardinalToHeading("S")).toBe(180);
|
||||
expect(cardinalToHeading("W")).toBe(270);
|
||||
});
|
||||
|
||||
it("parses abbreviations", () => {
|
||||
expect(cardinalToHeading("NB")).toBe(0);
|
||||
expect(cardinalToHeading("EB")).toBe(90);
|
||||
expect(cardinalToHeading("SB")).toBe(180);
|
||||
expect(cardinalToHeading("WB")).toBe(270);
|
||||
});
|
||||
|
||||
it("parses full names case-insensitively", () => {
|
||||
expect(cardinalToHeading("Northbound")).toBe(0);
|
||||
expect(cardinalToHeading("SOUTHEAST")).toBe(135);
|
||||
expect(cardinalToHeading(" west ")).toBe(270);
|
||||
});
|
||||
|
||||
it("returns undefined for unknown strings", () => {
|
||||
expect(cardinalToHeading("foo")).toBeUndefined();
|
||||
expect(cardinalToHeading("")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* Pure math for computing 3D camera frustum edges.
|
||||
* No Cesium dependency — fully unit-testable.
|
||||
*
|
||||
* The frustum is a pyramid with:
|
||||
* - apex at the camera position
|
||||
* - 4 corner rays extending outward at `range` meters
|
||||
* - orientation defined by heading, pitch, and FOV
|
||||
*
|
||||
* Architecture note: returns raw corner positions so that
|
||||
* a future ground-projection step can raycast these rays
|
||||
* onto the terrain surface.
|
||||
*/
|
||||
|
||||
const DEG2RAD = Math.PI / 180;
|
||||
const EARTH_RADIUS = 6_371_000; // metres
|
||||
|
||||
// ─── Public types ────────────────────────────────────────────
|
||||
|
||||
export interface Point3D {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
}
|
||||
|
||||
/** The 4 far-plane corners + the apex, ready for rendering. */
|
||||
export interface FrustumEdges {
|
||||
apex: Point3D;
|
||||
topLeft: Point3D;
|
||||
topRight: Point3D;
|
||||
bottomLeft: Point3D;
|
||||
bottomRight: Point3D;
|
||||
}
|
||||
|
||||
export interface FrustumParams {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number; // metres above ground
|
||||
headingDeg: number; // 0 = north, 90 = east
|
||||
pitchDeg: number; // 0 = horizontal, negative = looking down
|
||||
hFovDeg: number; // horizontal field of view
|
||||
vFovDeg: number; // vertical field of view (or derived from aspect)
|
||||
rangeMtrs: number; // max visible distance
|
||||
}
|
||||
|
||||
// ─── Defaults ────────────────────────────────────────────────
|
||||
|
||||
export const FRUSTUM_DEFAULTS = {
|
||||
alt: 8,
|
||||
headingDeg: 0,
|
||||
pitchDeg: -10,
|
||||
hFovDeg: 50,
|
||||
vFovDeg: 35,
|
||||
rangeMtrs: 200,
|
||||
} as const;
|
||||
|
||||
// ─── Core computation ────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Compute the 4 frustum corner points at `range` distance
|
||||
* from the camera, given orientation and FOV.
|
||||
*
|
||||
* Returns edges that can be drawn as 4 polylines from apex
|
||||
* to each corner, or passed to a ground-projection step.
|
||||
*/
|
||||
export function computeFrustumEdges(params: FrustumParams): FrustumEdges {
|
||||
const { lat, lon, alt, headingDeg, pitchDeg, hFovDeg, vFovDeg, rangeMtrs } = params;
|
||||
|
||||
const apex: Point3D = { lat, lon, alt };
|
||||
|
||||
const halfH = (hFovDeg / 2) * DEG2RAD;
|
||||
const halfV = (vFovDeg / 2) * DEG2RAD;
|
||||
const heading = headingDeg * DEG2RAD;
|
||||
const pitch = pitchDeg * DEG2RAD;
|
||||
|
||||
// For each corner we compute horizontal bearing offset ± halfH
|
||||
// and vertical pitch offset ± halfV, then project to a destination.
|
||||
const corners: [number, number][] = [
|
||||
[-halfH, halfV], // topLeft
|
||||
[halfH, halfV], // topRight
|
||||
[-halfH, -halfV], // bottomLeft
|
||||
[halfH, -halfV], // bottomRight
|
||||
];
|
||||
|
||||
const [topLeft, topRight, bottomLeft, bottomRight] = corners.map(
|
||||
([hOff, vOff]) => projectCorner(lat, lon, alt, heading, pitch, hOff, vOff, rangeMtrs),
|
||||
);
|
||||
|
||||
return { apex, topLeft, topRight, bottomLeft, bottomRight };
|
||||
}
|
||||
|
||||
// ─── Cardinal direction helper ───────────────────────────────
|
||||
|
||||
const CARDINAL_MAP: Record<string, number> = {
|
||||
n: 0, north: 0, nb: 0, northbound: 0,
|
||||
ne: 45, northeast: 45, neb: 45,
|
||||
e: 90, east: 90, eb: 90, eastbound: 90,
|
||||
se: 135, southeast: 135, seb: 135,
|
||||
s: 180, south: 180, sb: 180, southbound: 180,
|
||||
sw: 225, southwest: 225, swb: 225,
|
||||
w: 270, west: 270, wb: 270, westbound: 270,
|
||||
nw: 315, northwest: 315, nwb: 315,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a cardinal direction string to degrees.
|
||||
* Returns `undefined` if not recognised.
|
||||
*/
|
||||
export function cardinalToHeading(dir: string): number | undefined {
|
||||
return CARDINAL_MAP[dir.trim().toLowerCase()];
|
||||
}
|
||||
|
||||
// ─── Internal math ───────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Project a single frustum corner from the camera position.
|
||||
*
|
||||
* 1. Compute the bearing = heading + horizontal offset
|
||||
* 2. Compute the ground distance = range * cos(pitch + vOff)
|
||||
* 3. Compute the altitude delta = range * sin(pitch + vOff)
|
||||
* 4. Use haversine destination formula for the ground position
|
||||
*/
|
||||
function projectCorner(
|
||||
latDeg: number, lonDeg: number, altM: number,
|
||||
headingRad: number, pitchRad: number,
|
||||
hOffRad: number, vOffRad: number,
|
||||
range: number,
|
||||
): Point3D {
|
||||
const bearing = headingRad + hOffRad;
|
||||
const elevation = pitchRad + vOffRad;
|
||||
|
||||
const groundDist = range * Math.cos(elevation);
|
||||
const altDelta = range * Math.sin(elevation);
|
||||
|
||||
const dest = destinationPoint(latDeg, lonDeg, Math.abs(groundDist), bearing);
|
||||
|
||||
return {
|
||||
lat: dest.lat,
|
||||
lon: dest.lon,
|
||||
alt: Math.max(0, altM + altDelta),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Haversine destination point given start coords (deg),
|
||||
* distance (m), and bearing (rad).
|
||||
*/
|
||||
function destinationPoint(
|
||||
latDeg: number, lonDeg: number,
|
||||
distMetres: number, bearingRad: number,
|
||||
): { lat: number; lon: number } {
|
||||
const lat1 = latDeg * DEG2RAD;
|
||||
const lon1 = lonDeg * DEG2RAD;
|
||||
const angularDist = distMetres / EARTH_RADIUS;
|
||||
|
||||
const sinLat1 = Math.sin(lat1);
|
||||
const cosLat1 = Math.cos(lat1);
|
||||
const sinD = Math.sin(angularDist);
|
||||
const cosD = Math.cos(angularDist);
|
||||
|
||||
const lat2 = Math.asin(
|
||||
sinLat1 * cosD + cosLat1 * sinD * Math.cos(bearingRad),
|
||||
);
|
||||
const lon2 = lon1 + Math.atan2(
|
||||
Math.sin(bearingRad) * sinD * cosLat1,
|
||||
cosD - sinLat1 * Math.sin(lat2),
|
||||
);
|
||||
|
||||
return { lat: lat2 / DEG2RAD, lon: lon2 / DEG2RAD };
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
import { Camera } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions, FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
import { CameraDetail } from "./CameraDetail";
|
||||
import { CameraSettings as CameraSettingsComponent } from "./CameraSettings";
|
||||
import { mapRawCamera, mapGeoJsonFeature } from "./cameraMapper";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
|
||||
type CameraSettings = {
|
||||
sourceType: "default" | "traffic" | "url" | "file";
|
||||
action?: string;
|
||||
actionId?: number;
|
||||
loaded?: boolean;
|
||||
customUrl?: string;
|
||||
customData?: unknown[] | null;
|
||||
};
|
||||
|
||||
export class CameraPlugin implements WorldPlugin {
|
||||
id = "camera";
|
||||
name = "Cameras";
|
||||
description = "Public live cameras from across the globe";
|
||||
icon = Camera;
|
||||
category = "infrastructure" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
private sourceBuckets: Record<string, GeoEntity[]> = {};
|
||||
private lastActionId: number | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
requiresConfiguration(settingsRaw: unknown): boolean {
|
||||
const s = settingsRaw as { sourceType?: string; customUrl?: string; customData?: unknown } | null;
|
||||
const sourceType = s?.sourceType ?? "default";
|
||||
if (sourceType === "default" || sourceType === "traffic") return false;
|
||||
if (sourceType === "url" && !s?.customUrl) return true;
|
||||
if (sourceType === "file" && !s?.customData) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private getAllEntities(): GeoEntity[] { return Object.values(this.sourceBuckets).flat(); }
|
||||
private pushUpdate(): void { this.context?.onDataUpdate(this.getAllEntities()); }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Use context instead of direct useStore access
|
||||
const rawSettings = this.context!.getPluginSettings<Record<string, unknown>>(this.id);
|
||||
const settings = {
|
||||
sourceType: "default" as "default" | "traffic" | "url" | "file",
|
||||
action: undefined as string | undefined,
|
||||
actionId: undefined as number | undefined,
|
||||
loaded: undefined as boolean | undefined,
|
||||
customUrl: undefined as string | undefined,
|
||||
customData: undefined as unknown[] | null | undefined,
|
||||
...((rawSettings as Record<string, unknown>) || {}),
|
||||
};
|
||||
|
||||
if (settings.action === "reset") {
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = settings.actionId as number;
|
||||
return [];
|
||||
}
|
||||
|
||||
const isAutoDefault = (settings.sourceType === "default" || settings.sourceType === "traffic")
|
||||
&& !this.lastActionId && !this.sourceBuckets["default"];
|
||||
if (!isAutoDefault && (settings.action !== "load" || settings.actionId === this.lastActionId)) {
|
||||
return this.getAllEntities();
|
||||
}
|
||||
this.lastActionId = (settings.actionId as number) ?? -1;
|
||||
|
||||
try {
|
||||
if (settings.sourceType === "default") {
|
||||
await this.loadDefaultSource();
|
||||
} else if (settings.sourceType === "traffic") {
|
||||
await this.loadTrafficCameras();
|
||||
} else if (settings.sourceType === "url") {
|
||||
await this.loadUrlSource(settings);
|
||||
} else if (settings.sourceType === "file") {
|
||||
this.loadFileSource(settings);
|
||||
}
|
||||
trackEvent("camera-source-load", { sourceType: settings.sourceType });
|
||||
return this.getAllEntities();
|
||||
} catch (error) {
|
||||
console.error("[CameraPlugin] Fetch error:", error);
|
||||
this.context?.onError(error instanceof Error ? error : new Error(String(error)));
|
||||
return this.getAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
private async loadDefaultSource(): Promise<void> {
|
||||
const res = await fetch("/public-cameras.json");
|
||||
if (res.ok) {
|
||||
const geojson = await res.json();
|
||||
if (geojson && Array.isArray(geojson.features)) {
|
||||
this.sourceBuckets["default"] = geojson.features.map(
|
||||
(f: unknown, i: number) => mapGeoJsonFeature(f, i, "default"),
|
||||
);
|
||||
}
|
||||
}
|
||||
this.pushUpdate();
|
||||
}
|
||||
|
||||
private async loadTrafficCameras(): Promise<void> {
|
||||
try {
|
||||
const res = await fetch("/api/camera/traffic");
|
||||
if (!res.ok) throw new Error(`API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (data.cameras && Array.isArray(data.cameras)) {
|
||||
this.sourceBuckets["default"] = data.cameras.map(
|
||||
(f: unknown, i: number) => mapGeoJsonFeature(f, i, "traffic"),
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[CameraPlugin] Traffic cameras API failed:", err);
|
||||
}
|
||||
this.pushUpdate();
|
||||
}
|
||||
|
||||
private async loadUrlSource(settings: Record<string, unknown>): Promise<void> {
|
||||
if (!settings.customUrl) return;
|
||||
let url = settings.customUrl as string;
|
||||
if (!/^https?:\/\//i.test(url)) url = `http://${url}`;
|
||||
const res = await fetch(url);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) {
|
||||
this.sourceBuckets["url"] = data.map((c, i) => mapRawCamera(c, i, "url"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadFileSource(settings: Record<string, unknown>): void {
|
||||
if (!settings.customData || !Array.isArray(settings.customData)) return;
|
||||
this.sourceBuckets["file"] = settings.customData.map((c: unknown, i: number) => mapRawCamera(c as Record<string, unknown>, i, "file"));
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 3600000; }
|
||||
getLayerConfig(): LayerConfig {
|
||||
return { color: "#60a5fa", clusterEnabled: true, clusterDistance: 50, maxEntities: 10000 };
|
||||
}
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
return {
|
||||
type: "point", color: "#60a5fa", size: 6,
|
||||
outlineColor: "#ffffff", outlineWidth: 1.5,
|
||||
labelText: entity.label, labelFont: "11px Inter, system-ui, sans-serif",
|
||||
};
|
||||
}
|
||||
|
||||
getDetailComponent() { return CameraDetail; }
|
||||
getSettingsComponent() { return CameraSettingsComponent; }
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "country", label: "Country", type: "text", propertyKey: "country" },
|
||||
{ id: "city", label: "City", type: "text", propertyKey: "city" },
|
||||
{ id: "is_popular", label: "Popular Only", type: "boolean", propertyKey: "is_popular" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# @worldwideview/wwv-plugin-embassies
|
||||
|
||||
WorldWideView plugin — **Embassies & Consulates**.
|
||||
|
||||
## Data Source
|
||||
|
||||
- **Source:** OpenStreetMap via [Overpass Turbo](https://overpass-turbo.eu/)
|
||||
- **Tag:** `amenity=embassy`
|
||||
- **Format:** Static GeoJSON (17,266 features)
|
||||
- **License:** [ODbL](https://opendatacommons.org/licenses/odbl/) (OpenStreetMap)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-embassies
|
||||
```
|
||||
|
||||
## Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release with global diplomatic mission data from OSM.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-embassies",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin — Global embassies, consulates, and diplomatic missions from OpenStreetMap",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-embassies",
|
||||
"embassies"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-embassies"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Landmark } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class EmbassiesConsulatesPlugin implements WorldPlugin {
|
||||
id = "embassies";
|
||||
name = "Embassies & Consulates";
|
||||
description = "Global embassies, consulates, and diplomatic missions from OpenStreetMap";
|
||||
icon = Landmark;
|
||||
category = "custom" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(_ctx: PluginContext): Promise<void> { }
|
||||
destroy(): void { }
|
||||
async fetch(_tr: TimeRange): Promise<GeoEntity[]> { return []; }
|
||||
getPollingInterval(): number { return 0; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#a855f7",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
maxEntities: 1000,
|
||||
};
|
||||
}
|
||||
|
||||
renderEntity(_e: GeoEntity): CesiumEntityOptions {
|
||||
return { type: "point", color: "#a855f7", size: 8 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
# @worldwideview/wwv-plugin-maritime
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time vessel tracking** via AIS (Automatic Identification System) feeds.
|
||||
|
||||
## Features
|
||||
|
||||
- 🚢 Live vessel positions with heading and speed indicators
|
||||
- 🎨 Color-coded by vessel type (cargo, tanker, passenger, fishing, military, sailing, tug)
|
||||
- 🔍 Filters: vessel type, speed range
|
||||
- 📍 Clustered point rendering with vessel name labels
|
||||
- 🔄 Demo mode with realistic sample vessels when API is unavailable
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-maritime
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { MaritimePlugin } from "@worldwideview/wwv-plugin-maritime";
|
||||
|
||||
const plugin = new MaritimePlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking vessels on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Vessel data is fetched from the `/api/maritime` endpoint. Falls back to demo data with 15 sample vessels when the API is unavailable.
|
||||
|
||||
## Vessel Colors
|
||||
|
||||
| Type | Color |
|
||||
|---|---|
|
||||
| Cargo | 🟡 `#f59e0b` |
|
||||
| Tanker | 🔴 `#ef4444` |
|
||||
| Passenger | 🔵 `#3b82f6` |
|
||||
| Fishing | 🔵 `#22d3ee` |
|
||||
| Military | 🟣 `#a78bfa` |
|
||||
| Sailing | 🟢 `#4ade80` |
|
||||
| Tug | 🟠 `#f97316` |
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with AIS-based vessel tracking and ship-type filtering.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions, FilterDefinition } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class MaritimePlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "maritime";
|
||||
version: string;
|
||||
private context;
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
getFilterDefinitions(): FilterDefinition[];
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAqDvC,qBAAa,cAAe,YAAW,WAAW;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAc;IAClB,WAAW,SAAmC;IAC9C,IAAI,4IAAQ;IACZ,QAAQ,EAAG,UAAU,CAAU;IAC/B,OAAO,SAAW;IAClB,OAAO,CAAC,OAAO,CAA8B;IAEvC,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACnD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAYxD,kBAAkB,IAAI,MAAM;IAE5B,cAAc,IAAI,WAAW;IAI7B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB;IASpD,oBAAoB,IAAI,gBAAgB,EAAE;CAc7C"}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MaritimePlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var VESSEL_COLORS = {
|
||||
cargo: "#f59e0b",
|
||||
tanker: "#ef4444",
|
||||
passenger: "#3b82f6",
|
||||
fishing: "#22d3ee",
|
||||
military: "#a78bfa",
|
||||
sailing: "#4ade80",
|
||||
tug: "#f97316",
|
||||
other: "#94a3b8",
|
||||
};
|
||||
function getVesselColor(type) {
|
||||
var lower = type.toLowerCase();
|
||||
for (var _i = 0, _a = Object.entries(VESSEL_COLORS); _i < _a.length; _i++) {
|
||||
var _b = _a[_i], key = _b[0], color = _b[1];
|
||||
if (lower.includes(key))
|
||||
return color;
|
||||
}
|
||||
return VESSEL_COLORS.other;
|
||||
}
|
||||
function generateDemoVessels() {
|
||||
var vessels = [
|
||||
{ name: "EVER GIVEN", mmsi: "353136000", type: "cargo", lat: 30.0, lon: 32.5, speed: 12.5, heading: 340 },
|
||||
{ name: "MAERSK SEALAND", mmsi: "220417000", type: "cargo", lat: 51.9, lon: 1.2, speed: 15.0, heading: 210 },
|
||||
{ name: "PACIFIC RUBY", mmsi: "538004561", type: "tanker", lat: 1.2, lon: 103.7, speed: 8.3, heading: 125 },
|
||||
{ name: "QUEEN MARY 2", mmsi: "310627000", type: "passenger", lat: 40.6, lon: -74.0, speed: 22.0, heading: 90 },
|
||||
{ name: "OCEAN EXPLORER", mmsi: "245390000", type: "fishing", lat: -33.8, lon: 18.4, speed: 4.2, heading: 180 },
|
||||
{ name: "ARCTIC SUNRISE", mmsi: "246585000", type: "other", lat: 69.0, lon: 18.0, speed: 6.0, heading: 45 },
|
||||
{ name: "BLUE MARLIN", mmsi: "244870698", type: "cargo", lat: 22.3, lon: 113.9, speed: 10.5, heading: 270 },
|
||||
{ name: "STENA BULK", mmsi: "265548750", type: "tanker", lat: 57.7, lon: 11.9, speed: 12.0, heading: 300 },
|
||||
{ name: "SPIRIT OF BRITAIN", mmsi: "235082198", type: "passenger", lat: 50.9, lon: 1.4, speed: 20.0, heading: 160 },
|
||||
{ name: "DEEP BLUE", mmsi: "538006050", type: "fishing", lat: -4.0, lon: 39.6, speed: 3.5, heading: 95 },
|
||||
{ name: "CRIMSON ACE", mmsi: "477558200", type: "tanker", lat: 26.2, lon: 56.3, speed: 14.0, heading: 200 },
|
||||
{ name: "SAGA HORIZON", mmsi: "311000596", type: "passenger", lat: 35.3, lon: 139.6, speed: 18.0, heading: 0 },
|
||||
{ name: "ATLANTIC GUARDIAN", mmsi: "219354000", type: "tug", lat: 56.1, lon: -3.2, speed: 7.5, heading: 245 },
|
||||
{ name: "JADE STAR", mmsi: "636092783", type: "cargo", lat: -12.0, lon: -77.0, speed: 11.0, heading: 320 },
|
||||
{ name: "NORTHERN SPIRIT", mmsi: "257038700", type: "fishing", lat: 62.4, lon: 6.1, speed: 5.0, heading: 170 },
|
||||
];
|
||||
return vessels.map(function (v) { return ({
|
||||
id: "maritime-".concat(v.mmsi),
|
||||
pluginId: "maritime",
|
||||
latitude: v.lat + (Math.random() - 0.5) * 0.1,
|
||||
longitude: v.lon + (Math.random() - 0.5) * 0.1,
|
||||
heading: v.heading,
|
||||
speed: v.speed,
|
||||
timestamp: new Date(),
|
||||
label: v.name,
|
||||
properties: { mmsi: v.mmsi, vesselName: v.name, vesselType: v.type, speed_knots: v.speed, heading: v.heading },
|
||||
}); });
|
||||
}
|
||||
var MaritimePlugin = /** @class */ (function () {
|
||||
function MaritimePlugin() {
|
||||
this.id = "maritime";
|
||||
this.name = "Maritime";
|
||||
this.description = "Vessel tracking via AIS feeds";
|
||||
this.icon = lucide_react_1.Ship;
|
||||
this.category = "maritime";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
}
|
||||
MaritimePlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
MaritimePlugin.prototype.destroy = function () { this.context = null; };
|
||||
MaritimePlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, data, vessels, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 3, , 4]);
|
||||
return [4 /*yield*/, fetch("/api/maritime")];
|
||||
case 1:
|
||||
res = _b.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("Maritime API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _b.sent();
|
||||
vessels = data.vessels || generateDemoVessels();
|
||||
return [2 /*return*/, vessels.map(function (v) { return (__assign(__assign({}, v), { timestamp: new Date(v.timestamp) })); })];
|
||||
case 3:
|
||||
_a = _b.sent();
|
||||
return [2 /*return*/, generateDemoVessels()];
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
MaritimePlugin.prototype.getPollingInterval = function () { return 60000; };
|
||||
MaritimePlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#f59e0b", clusterEnabled: true, clusterDistance: 50 };
|
||||
};
|
||||
MaritimePlugin.prototype.renderEntity = function (entity) {
|
||||
var vesselType = entity.properties.vesselType || "other";
|
||||
return {
|
||||
type: "point", color: getVesselColor(vesselType), size: 7,
|
||||
rotation: entity.heading, outlineColor: "#000000", outlineWidth: 1,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
};
|
||||
MaritimePlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{
|
||||
id: "vessel_type", label: "Vessel Type", type: "select", propertyKey: "vesselType",
|
||||
options: [
|
||||
{ value: "cargo", label: "Cargo" }, { value: "tanker", label: "Tanker" },
|
||||
{ value: "passenger", label: "Passenger" }, { value: "fishing", label: "Fishing" },
|
||||
{ value: "military", label: "Military" }, { value: "sailing", label: "Sailing" },
|
||||
{ value: "tug", label: "Tug" }, { value: "other", label: "Other" },
|
||||
],
|
||||
},
|
||||
{ id: "speed", label: "Speed (knots)", type: "range", propertyKey: "speed_knots", range: { min: 0, max: 30, step: 1 } },
|
||||
];
|
||||
};
|
||||
return MaritimePlugin;
|
||||
}());
|
||||
exports.MaritimePlugin = MaritimePlugin;
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-maritime",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for real-time vessel tracking via AIS feeds. Color-coded by vessel type with speed and heading indicators",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-maritime",
|
||||
"maritime",
|
||||
"vessel-tracking",
|
||||
"ais",
|
||||
"ships",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-maritime"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,17 @@ import type {
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
FilterDefinition,
|
||||
} from "@/core/plugins/PluginTypes";
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
const VESSEL_COLORS: Record<string, string> = {
|
||||
cargo: "#f59e0b", // amber
|
||||
tanker: "#ef4444", // red
|
||||
passenger: "#3b82f6", // blue
|
||||
fishing: "#22d3ee", // cyan
|
||||
military: "#a78bfa", // purple
|
||||
sailing: "#4ade80", // green
|
||||
tug: "#f97316", // orange
|
||||
other: "#94a3b8", // slate
|
||||
cargo: "#f59e0b",
|
||||
tanker: "#ef4444",
|
||||
passenger: "#3b82f6",
|
||||
fishing: "#22d3ee",
|
||||
military: "#a78bfa",
|
||||
sailing: "#4ade80",
|
||||
tug: "#f97316",
|
||||
other: "#94a3b8",
|
||||
};
|
||||
|
||||
function getVesselColor(type: string): string {
|
||||
@@ -28,7 +28,6 @@ function getVesselColor(type: string): string {
|
||||
return VESSEL_COLORS.other;
|
||||
}
|
||||
|
||||
// Demo AIS data (used when no real AIS feed is configured)
|
||||
function generateDemoVessels(): GeoEntity[] {
|
||||
const vessels = [
|
||||
{ name: "EVER GIVEN", mmsi: "353136000", type: "cargo", lat: 30.0, lon: 32.5, speed: 12.5, heading: 340 },
|
||||
@@ -48,7 +47,6 @@ function generateDemoVessels(): GeoEntity[] {
|
||||
{ name: "NORTHERN SPIRIT", mmsi: "257038700", type: "fishing", lat: 62.4, lon: 6.1, speed: 5.0, heading: 170 },
|
||||
];
|
||||
|
||||
// Add slight random jitter to make it feel alive
|
||||
return vessels.map((v) => ({
|
||||
id: `maritime-${v.mmsi}`,
|
||||
pluginId: "maritime",
|
||||
@@ -58,13 +56,7 @@ function generateDemoVessels(): GeoEntity[] {
|
||||
speed: v.speed,
|
||||
timestamp: new Date(),
|
||||
label: v.name,
|
||||
properties: {
|
||||
mmsi: v.mmsi,
|
||||
vesselName: v.name,
|
||||
vesselType: v.type,
|
||||
speed_knots: v.speed,
|
||||
heading: v.heading,
|
||||
},
|
||||
properties: { mmsi: v.mmsi, vesselName: v.name, vesselType: v.type, speed_knots: v.speed, heading: v.heading },
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -75,16 +67,10 @@ export class MaritimePlugin implements WorldPlugin {
|
||||
icon = Ship;
|
||||
category = "maritime" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> {
|
||||
this.context = ctx;
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.context = null;
|
||||
}
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
@@ -92,69 +78,39 @@ export class MaritimePlugin implements WorldPlugin {
|
||||
if (!res.ok) throw new Error(`Maritime API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
const vessels = data.vessels || generateDemoVessels();
|
||||
|
||||
// Ensure timestamps are Date objects (JSON turns them into strings)
|
||||
return vessels.map((v: any) => ({
|
||||
...v,
|
||||
timestamp: new Date(v.timestamp)
|
||||
}));
|
||||
return vessels.map((v: GeoEntity) => ({ ...v, timestamp: new Date(v.timestamp) }));
|
||||
} catch {
|
||||
// Fall back to demo data
|
||||
return generateDemoVessels();
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number {
|
||||
return 60000; // 60 seconds
|
||||
}
|
||||
getPollingInterval(): number { return 60000; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#f59e0b",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
};
|
||||
return { color: "#f59e0b", clusterEnabled: true, clusterDistance: 50 };
|
||||
}
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const vesselType = (entity.properties.vesselType as string) || "other";
|
||||
return {
|
||||
type: "point",
|
||||
color: getVesselColor(vesselType),
|
||||
size: 7,
|
||||
rotation: entity.heading,
|
||||
outlineColor: "#000000",
|
||||
outlineWidth: 1,
|
||||
labelText: entity.label || undefined,
|
||||
labelFont: "11px JetBrains Mono, monospace",
|
||||
type: "point", color: getVesselColor(vesselType), size: 7,
|
||||
rotation: entity.heading, outlineColor: "#000000", outlineWidth: 1,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{
|
||||
id: "vessel_type",
|
||||
label: "Vessel Type",
|
||||
type: "select",
|
||||
propertyKey: "vesselType",
|
||||
id: "vessel_type", label: "Vessel Type", type: "select", propertyKey: "vesselType",
|
||||
options: [
|
||||
{ value: "cargo", label: "Cargo" },
|
||||
{ value: "tanker", label: "Tanker" },
|
||||
{ value: "passenger", label: "Passenger" },
|
||||
{ value: "fishing", label: "Fishing" },
|
||||
{ value: "military", label: "Military" },
|
||||
{ value: "sailing", label: "Sailing" },
|
||||
{ value: "tug", label: "Tug" },
|
||||
{ value: "other", label: "Other" },
|
||||
{ value: "cargo", label: "Cargo" }, { value: "tanker", label: "Tanker" },
|
||||
{ value: "passenger", label: "Passenger" }, { value: "fishing", label: "Fishing" },
|
||||
{ value: "military", label: "Military" }, { value: "sailing", label: "Sailing" },
|
||||
{ value: "tug", label: "Tug" }, { value: "other", label: "Other" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "speed",
|
||||
label: "Speed (knots)",
|
||||
type: "range",
|
||||
propertyKey: "speed_knots",
|
||||
range: { min: 0, max: 30, step: 1 },
|
||||
},
|
||||
{ id: "speed", label: "Speed (knots)", type: "range", propertyKey: "speed_knots", range: { min: 0, max: 30, step: 1 } },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# @worldwideview/wwv-plugin-military
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time military aircraft tracking** via [adsb.fi](https://adsb.fi/).
|
||||
|
||||
## Features
|
||||
|
||||
- 🛡️ Live military aircraft positions updated every 60 seconds
|
||||
- 🎨 Altitude-based coloring (green → orange → red → pink → yellow)
|
||||
- ✈️ 3D airplane model rendering with heading-oriented rotation
|
||||
- 📡 Flight trail rendering on entity selection
|
||||
- 🔍 Filters: aircraft type, callsign, registration, altitude range, on-ground status
|
||||
- 📋 Rich entity properties (hex, squawk, category, emergency status)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-military
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { MilitaryPlugin } from "@worldwideview/wwv-plugin-military";
|
||||
|
||||
const plugin = new MilitaryPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking military aircraft on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Military aircraft data is fetched from [adsb.fi](https://adsb.fi/) via the `/api/military` endpoint. No authentication required.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release. Renamed from wwv-plugin-military for clarity.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-military-aviation",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin for real-time military aircraft tracking via adsb.fi. Features altitude-based coloring, flight trail rendering, and aircraft type filters",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-military-aviation",
|
||||
"military",
|
||||
"military-aviation",
|
||||
"adsb",
|
||||
"aircraft-tracking",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-military-aviation"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { Shield } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions, SelectionBehavior,
|
||||
ServerPluginConfig, FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
interface AdsbFiAircraft {
|
||||
hex: string; flight?: string; r?: string; t?: string;
|
||||
lat?: number; lon?: number; alt_baro?: number | "ground";
|
||||
alt_geom?: number; gs?: number; track?: number; squawk?: string;
|
||||
dbFlags?: number; category?: string; emergency?: string;
|
||||
seen?: number; seen_pos?: number;
|
||||
}
|
||||
|
||||
function militaryAltitudeToColor(altFeet: number | null): string {
|
||||
if (altFeet === null || altFeet <= 0) return "#39ff14";
|
||||
if (altFeet < 10000) return "#ff6f00";
|
||||
if (altFeet < 25000) return "#ff1744";
|
||||
if (altFeet < 40000) return "#ff4081";
|
||||
return "#ffea00";
|
||||
}
|
||||
|
||||
function feetToMeters(feet: number): number { return feet * 0.3048; }
|
||||
|
||||
export class MilitaryPlugin implements WorldPlugin {
|
||||
id = "military-aviation";
|
||||
name = "Military Aviation";
|
||||
description = "Real-time military aircraft tracking via adsb.fi";
|
||||
icon = Shield;
|
||||
category = "aviation" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
const res = await fetch("/api/military");
|
||||
if (!res.ok) throw new Error(`Military API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (!data.ac || !Array.isArray(data.ac)) return [];
|
||||
|
||||
return data.ac
|
||||
.filter((ac: AdsbFiAircraft) => ac.lat != null && ac.lon != null)
|
||||
.map((ac: AdsbFiAircraft): GeoEntity => {
|
||||
const altFeet = typeof ac.alt_baro === "number" ? ac.alt_baro : null;
|
||||
const altMeters = altFeet !== null ? feetToMeters(altFeet) : null;
|
||||
const isOnGround = ac.alt_baro === "ground";
|
||||
return {
|
||||
id: `military-aviation-${ac.hex}`, pluginId: "military-aviation",
|
||||
latitude: ac.lat!, longitude: ac.lon!,
|
||||
altitude: altMeters !== null ? altMeters * 10 : 0,
|
||||
heading: ac.track ?? undefined, speed: ac.gs ?? undefined,
|
||||
timestamp: new Date(),
|
||||
label: ac.flight?.trim() || ac.r || ac.hex,
|
||||
properties: { hex: ac.hex, callsign: ac.flight?.trim() || null, registration: ac.r || null, aircraft_type: ac.t || null, altitude_ft: altFeet, altitude_m: altMeters, ground_speed_kts: ac.gs ?? null, heading: ac.track ?? null, squawk: ac.squawk || null, on_ground: isOnGround, category: ac.category || null, emergency: ac.emergency || null },
|
||||
};
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[MilitaryPlugin] Fetch error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 60000; }
|
||||
getLayerConfig(): LayerConfig { return { color: "#ff6f00", clusterEnabled: true, clusterDistance: 40, maxEntities: 3000 }; }
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const altFeet = entity.properties.altitude_ft as number | null;
|
||||
const isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/military-plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: militaryAltitudeToColor(altFeet), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null {
|
||||
if (entity.properties.on_ground) return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#ffea00", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
}
|
||||
|
||||
getServerConfig(): ServerPluginConfig {
|
||||
return { apiBasePath: "/api/military", pollingIntervalMs: 60000, requiresAuth: false };
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "aircraft_type", label: "Aircraft Type", type: "text", propertyKey: "aircraft_type" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
{ id: "registration", label: "Registration", type: "text", propertyKey: "registration" },
|
||||
{ id: "altitude", label: "Altitude (ft)", type: "range", propertyKey: "altitude_ft", range: { min: 0, max: 60000, step: 1000 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# @worldwideview/wwv-plugin-military-bases
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin that displays **worldwide military bases, airfields, and barracks** on the 3D globe.
|
||||
|
||||
## Features
|
||||
|
||||
- 🏛️ Military installations sourced from OpenStreetMap
|
||||
- 📍 Point markers with clustering for dense regions
|
||||
- ⚡ Static GeoJSON layer — no external API calls at runtime
|
||||
|
||||
## Installation
|
||||
|
||||
Install via the WorldWideView Marketplace, or manually:
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-military-bases
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## How It Works
|
||||
|
||||
This is a **static format** plugin. The GeoJSON data file is served by the host application at `/data/military_bases.geojson`. The plugin manifest tells WorldWideView's `StaticDataPlugin` loader how to render the data (point markers, clustering, colour).
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release with OSM military installation data.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-military-bases",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin for worldwide military bases, airfields, and barracks from OpenStreetMap",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-military-bases",
|
||||
"military",
|
||||
"bases",
|
||||
"airfields",
|
||||
"geojson",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-military-bases"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @worldwideview/wwv-plugin-military-bases
|
||||
*
|
||||
* Static GeoJSON plugin — worldwide military bases, airfields, and barracks
|
||||
* sourced from OpenStreetMap.
|
||||
*
|
||||
* This package exists for npm registry metadata. The actual plugin logic
|
||||
* is handled by WorldWideView's StaticDataPlugin loader at runtime using
|
||||
* the manifest + GeoJSON data file served from the host application.
|
||||
*/
|
||||
export const PLUGIN_ID = "military-bases" as const;
|
||||
@@ -0,0 +1,37 @@
|
||||
# @worldwideview/wwv-plugin-nuclear
|
||||
|
||||
WorldWideView plugin that displays **global nuclear power plants, reactors, and decommissioned facilities** on the 3D globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
- **Source:** OpenStreetMap via [Overpass Turbo](https://overpass-turbo.eu/)
|
||||
- **Tag:** `generator:source=nuclear`
|
||||
- **Format:** Static GeoJSON (~758 facilities worldwide)
|
||||
- **License:** [ODbL](https://opendatacommons.org/licenses/odbl/) (OpenStreetMap)
|
||||
|
||||
## Features
|
||||
|
||||
- Nuclear power plants, research reactors, and decommissioned sites
|
||||
- Status classification: operational, decommissioned, abandoned, under construction
|
||||
- Operator and output metadata where available
|
||||
- Point clustering at global zoom levels
|
||||
|
||||
## Installation
|
||||
|
||||
Install via the [WorldWideView Marketplace](https://github.com/silvertakana/worldwideview-marketplace) or manually:
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-nuclear
|
||||
```
|
||||
|
||||
## Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release with global nuclear facility data from OSM.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-nuclear",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin displaying global nuclear power plants, reactors, and decommissioned facilities from OpenStreetMap",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-nuclear",
|
||||
"nuclear",
|
||||
"nuclear-power",
|
||||
"power-plants",
|
||||
"energy",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-nuclear"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Atom } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class NuclearPlugin implements WorldPlugin {
|
||||
id = "nuclear";
|
||||
name = "Nuclear Facilities";
|
||||
description = "Global nuclear power plants and reactors from OSM.";
|
||||
icon = Atom;
|
||||
category = "infrastructure" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(_ctx: PluginContext): Promise<void> { }
|
||||
destroy(): void { }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Rendering managed by StaticDataPlugin loader
|
||||
return [];
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 0; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#22d3ee",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
maxEntities: 1000,
|
||||
};
|
||||
}
|
||||
|
||||
renderEntity(_entity: GeoEntity): CesiumEntityOptions {
|
||||
return { type: "point", color: "#22d3ee", size: 8 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
# @worldwideview/wwv-plugin-sdk
|
||||
|
||||
Plugin SDK for building [WorldWideView](https://github.com/silvertakana/worldwideview) globe plugins. Provides TypeScript types, interfaces, and utilities that all plugins depend on.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-sdk
|
||||
```
|
||||
|
||||
## Core Interfaces
|
||||
|
||||
| Interface | Purpose |
|
||||
|---|---|
|
||||
| `WorldPlugin` | Main plugin contract — lifecycle, data fetching, rendering |
|
||||
| `GeoEntity` | A positioned object on the globe (lat/lon/alt + properties) |
|
||||
| `PluginContext` | Host app context injected into every plugin at init |
|
||||
| `LayerConfig` | Visual layer settings (color, clustering, limits) |
|
||||
| `CesiumEntityOptions` | Per-entity Cesium rendering options (point, model, etc.) |
|
||||
| `SelectionBehavior` | Optional trail / fly-to behavior on entity selection |
|
||||
| `FilterDefinition` | Declarative filter UI (text, select, range, boolean) |
|
||||
| `ServerPluginConfig` | Server-side API routing and polling config |
|
||||
|
||||
## Quick Example
|
||||
|
||||
```ts
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions } from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class MyPlugin implements WorldPlugin {
|
||||
id = "my-plugin";
|
||||
name = "My Plugin";
|
||||
description = "A custom WorldWideView plugin";
|
||||
icon = "🌍";
|
||||
category = "custom";
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(ctx: PluginContext) { /* setup */ }
|
||||
destroy() { /* cleanup */ }
|
||||
|
||||
async fetch(timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Return geo-positioned entities
|
||||
return [];
|
||||
}
|
||||
|
||||
getPollingInterval() { return 30000; }
|
||||
getLayerConfig(): LayerConfig {
|
||||
return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 40 };
|
||||
}
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
return { type: "point", color: "#3b82f6", size: 6 };
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with core interfaces and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with core types and interfaces.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
import type { ComponentType } from "react";
|
||||
export type { PluginManifest, PluginFormat, PluginType, TrustTier, PluginCapability, DataSourceConfig, FieldMapping, RenderingConfig } from "./manifest";
|
||||
export type PluginCategory = "aviation" | "maritime" | "conflict" | "natural-disaster" | "infrastructure" | "cyber" | "economic" | "custom";
|
||||
export interface TimeRange {
|
||||
start: Date;
|
||||
end: Date;
|
||||
}
|
||||
export type TimeWindow = "1h" | "6h" | "24h" | "48h" | "7d";
|
||||
export interface GeoEntity {
|
||||
id: string;
|
||||
pluginId: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
altitude?: number;
|
||||
heading?: number;
|
||||
speed?: number;
|
||||
timestamp: Date;
|
||||
label?: string;
|
||||
properties: Record<string, unknown>;
|
||||
}
|
||||
export interface LayerConfig {
|
||||
color: string;
|
||||
iconUrl?: string;
|
||||
clusterEnabled: boolean;
|
||||
clusterDistance: number;
|
||||
minZoomLevel?: number;
|
||||
maxEntities?: number;
|
||||
}
|
||||
export interface CesiumEntityOptions {
|
||||
type: "billboard" | "point" | "polyline" | "polygon" | "label" | "model";
|
||||
color?: string;
|
||||
size?: number;
|
||||
iconUrl?: string;
|
||||
rotation?: number;
|
||||
outlineColor?: string;
|
||||
outlineWidth?: number;
|
||||
labelText?: string;
|
||||
labelFont?: string;
|
||||
distanceDisplayCondition?: {
|
||||
near: number;
|
||||
far: number;
|
||||
};
|
||||
modelUrl?: string;
|
||||
modelScale?: number;
|
||||
modelMinPixelSize?: number;
|
||||
modelHeadingOffset?: number;
|
||||
}
|
||||
export interface SelectionBehavior {
|
||||
showTrail?: boolean;
|
||||
trailDurationSec?: number;
|
||||
trailStepSec?: number;
|
||||
trailColor?: string;
|
||||
flyToOffsetMultiplier?: number;
|
||||
flyToBaseDistance?: number;
|
||||
}
|
||||
export interface ServerPluginConfig {
|
||||
apiBasePath: string;
|
||||
pollingIntervalMs: number;
|
||||
requiresAuth?: boolean;
|
||||
historyEnabled?: boolean;
|
||||
availabilityEnabled?: boolean;
|
||||
}
|
||||
export interface PluginContext {
|
||||
apiBaseUrl: string;
|
||||
timeRange: TimeRange;
|
||||
onDataUpdate: (entities: GeoEntity[]) => void;
|
||||
onError: (error: Error) => void;
|
||||
/** Get plugin-specific settings from the app config store */
|
||||
getPluginSettings: <T = unknown>(pluginId: string) => T | undefined;
|
||||
/** Returns true if the app is in timeline playback mode */
|
||||
isPlaybackMode: () => boolean;
|
||||
/** Returns the current timeline time (relevant in playback mode) */
|
||||
getCurrentTime: () => Date;
|
||||
}
|
||||
export interface FilterSelectOption {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
export interface FilterRangeConfig {
|
||||
min: number;
|
||||
max: number;
|
||||
step: number;
|
||||
}
|
||||
export interface FilterDefinition {
|
||||
id: string;
|
||||
label: string;
|
||||
type: "text" | "select" | "range" | "boolean";
|
||||
propertyKey: string;
|
||||
options?: FilterSelectOption[];
|
||||
range?: FilterRangeConfig;
|
||||
}
|
||||
export type FilterValue = {
|
||||
type: "text";
|
||||
value: string;
|
||||
} | {
|
||||
type: "select";
|
||||
values: string[];
|
||||
} | {
|
||||
type: "range";
|
||||
min: number;
|
||||
max: number;
|
||||
} | {
|
||||
type: "boolean";
|
||||
value: boolean;
|
||||
};
|
||||
export interface WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string | ComponentType<{
|
||||
size?: number;
|
||||
color?: string;
|
||||
}>;
|
||||
category: PluginCategory;
|
||||
version: string;
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
getSelectionBehavior?(entity: GeoEntity): SelectionBehavior | null;
|
||||
getServerConfig?(): ServerPluginConfig;
|
||||
getFilterDefinitions?(): FilterDefinition[];
|
||||
getSidebarComponent?(): ComponentType;
|
||||
getDetailComponent?(): ComponentType<{
|
||||
entity: GeoEntity;
|
||||
}>;
|
||||
getSettingsComponent?(): ComponentType<{
|
||||
pluginId: string;
|
||||
}>;
|
||||
requiresConfiguration?(settings: unknown): boolean;
|
||||
}
|
||||
export type DataBusEvents = {
|
||||
pluginRegistered: {
|
||||
pluginId: string;
|
||||
defaultInterval: number;
|
||||
};
|
||||
dataUpdated: {
|
||||
pluginId: string;
|
||||
entities: GeoEntity[];
|
||||
};
|
||||
entitySelected: {
|
||||
entity: GeoEntity | null;
|
||||
};
|
||||
layerToggled: {
|
||||
pluginId: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
timeRangeChanged: {
|
||||
timeRange: TimeRange;
|
||||
};
|
||||
cameraPreset: {
|
||||
presetId: string;
|
||||
};
|
||||
cameraFaceTowards: {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
};
|
||||
cameraGoTo: {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
distance?: number;
|
||||
maxPitch?: number;
|
||||
heading?: number;
|
||||
};
|
||||
globeReady: Record<string, never>;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGzJ,MAAM,MAAM,cAAc,GACpB,UAAU,GACV,UAAU,GACV,UAAU,GACV,kBAAkB,GAClB,gBAAgB,GAChB,OAAO,GACP,UAAU,GACV,QAAQ,CAAC;AAGf,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACb;AAED,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAG5D,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAGD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAGD,MAAM,WAAW,iBAAiB;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAGD,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAKD,MAAM,WAAW,aAAa;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,6DAA6D;IAC7D,iBAAiB,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC;IACpE,2DAA2D;IAC3D,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,oEAAoE;IACpE,cAAc,EAAE,MAAM,IAAI,CAAC;CAC9B;AAGD,MAAM,WAAW,kBAAkB;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;CAAE;AACrE,MAAM,WAAW,iBAAiB;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;CAAE;AAC9E,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,MAAM,WAAW,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAG1C,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAGhB,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAI,IAAI,CAAC;IAGhB,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAClD,kBAAkB,IAAI,MAAM,CAAC;IAG7B,cAAc,IAAI,WAAW,CAAC;IAC9B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAAC;IAGrD,oBAAoB,CAAC,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,GAAG,IAAI,CAAC;IACnE,eAAe,CAAC,IAAI,kBAAkB,CAAC;IACvC,oBAAoB,CAAC,IAAI,gBAAgB,EAAE,CAAC;IAC5C,mBAAmB,CAAC,IAAI,aAAa,CAAC;IACtC,kBAAkB,CAAC,IAAI,aAAa,CAAC;QAAE,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IAC5D,oBAAoB,CAAC,IAAI,aAAa,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,qBAAqB,CAAC,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;CACtD;AAGD,MAAM,MAAM,aAAa,GAAG;IACxB,gBAAgB,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,WAAW,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC;IACzD,cAAc,EAAE;QAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7C,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,gBAAgB,EAAE;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,CAAC;IAC3C,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,iBAAiB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,UAAU,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACrC,CAAC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// ─── WorldWideView Plugin SDK ─────────────────────────────────
|
||||
// The public API for building WorldWideView plugins.
|
||||
// Import from "@worldwideview/wwv-plugin-sdk" in your plugin.
|
||||
export {};
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
import type { PluginCategory } from "./index";
|
||||
export type PluginFormat = "declarative" | "static" | "bundle";
|
||||
export type PluginType = "data-layer" | "extension";
|
||||
export type TrustTier = "built-in" | "verified" | "unverified";
|
||||
export type PluginCapability = "data:own" | `data:read:${string}` | "ui:detail-panel" | "ui:sidebar" | "ui:toolbar" | "ui:settings" | "globe:overlay" | "globe:camera" | "storage:read" | "storage:write" | "network:fetch";
|
||||
export interface DataSourceConfig {
|
||||
url: string;
|
||||
method: "GET" | "POST";
|
||||
pollInterval: number;
|
||||
format: "geojson" | "json" | "csv";
|
||||
auth?: {
|
||||
type: "header" | "query";
|
||||
key: string;
|
||||
envVar: string;
|
||||
} | null;
|
||||
headers?: Record<string, string>;
|
||||
body?: Record<string, unknown>;
|
||||
arrayPath?: string;
|
||||
}
|
||||
export interface FieldMapping {
|
||||
id: string;
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
altitude?: string;
|
||||
heading?: string;
|
||||
speed?: string;
|
||||
label?: string;
|
||||
timestamp?: string;
|
||||
properties?: Record<string, string>;
|
||||
}
|
||||
export interface RenderingConfig {
|
||||
entityType: "billboard" | "point" | "polyline" | "polygon" | "label" | "model";
|
||||
color?: string;
|
||||
icon?: string;
|
||||
sizeField?: string;
|
||||
labelField?: string;
|
||||
clusterEnabled?: boolean;
|
||||
clusterDistance?: number;
|
||||
modelUrl?: string;
|
||||
minZoomLevel?: number;
|
||||
maxEntities?: number;
|
||||
}
|
||||
export interface PluginManifest {
|
||||
id: string;
|
||||
name: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
type: PluginType;
|
||||
format: PluginFormat;
|
||||
trust: TrustTier;
|
||||
capabilities: PluginCapability[];
|
||||
category: PluginCategory | string;
|
||||
icon?: string;
|
||||
compatibility?: {
|
||||
worldwideview: string;
|
||||
};
|
||||
requires?: {
|
||||
envVars?: string[];
|
||||
};
|
||||
dataSource?: DataSourceConfig;
|
||||
fieldMapping?: FieldMapping;
|
||||
dataFile?: string;
|
||||
rendering?: RenderingConfig;
|
||||
entry?: string;
|
||||
assets?: string[];
|
||||
extends?: string[];
|
||||
}
|
||||
//# sourceMappingURL=manifest.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,CAAC;AACpD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GACtB,UAAU,GACV,aAAa,MAAM,EAAE,GACrB,iBAAiB,GACjB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,eAAe,GACf,cAAc,GACd,cAAc,GACd,eAAe,GACf,eAAe,CAAC;AAEtB,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,eAAe;IAC5B,UAAU,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAClC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// ─── Plugin Manifest Types ───────────────────────────────────
|
||||
// Schema for plugin.json manifest files.
|
||||
// Three formats: declarative (JSON-only), static (GeoJSON), bundle (JS code).
|
||||
export {};
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-sdk",
|
||||
"version": "1.0.4",
|
||||
"description": "Plugin SDK — types, interfaces, and utilities for building WorldWideView globe plugins",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.build.json",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"wwv-plugin-sdk",
|
||||
"globe",
|
||||
"cesium",
|
||||
"plugin-sdk",
|
||||
"geospatial"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-sdk"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"react": ">=18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/react": "^19"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// ─── WorldWideView Plugin SDK ─────────────────────────────────
|
||||
// The public API for building WorldWideView plugins.
|
||||
// Import from "@worldwideview/wwv-plugin-sdk" in your plugin.
|
||||
|
||||
import type { ComponentType } from "react";
|
||||
|
||||
// ─── Re-export manifest types ─────────────────────────────────
|
||||
export type { PluginManifest, PluginFormat, PluginType, TrustTier, PluginCapability, DataSourceConfig, FieldMapping, RenderingConfig } from "./manifest";
|
||||
|
||||
// ─── Categories ──────────────────────────────────────────────
|
||||
export type PluginCategory =
|
||||
| "aviation"
|
||||
| "maritime"
|
||||
| "conflict"
|
||||
| "natural-disaster"
|
||||
| "infrastructure"
|
||||
| "cyber"
|
||||
| "economic"
|
||||
| "custom";
|
||||
|
||||
// ─── Time ────────────────────────────────────────────────────
|
||||
export interface TimeRange {
|
||||
start: Date;
|
||||
end: Date;
|
||||
}
|
||||
|
||||
export type TimeWindow = "1h" | "6h" | "24h" | "48h" | "7d";
|
||||
|
||||
// ─── Geo Entities ────────────────────────────────────────────
|
||||
export interface GeoEntity {
|
||||
id: string;
|
||||
pluginId: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
altitude?: number;
|
||||
heading?: number;
|
||||
speed?: number;
|
||||
timestamp: Date;
|
||||
label?: string;
|
||||
properties: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// ─── Layer Config ────────────────────────────────────────────
|
||||
export interface LayerConfig {
|
||||
color: string;
|
||||
iconUrl?: string;
|
||||
clusterEnabled: boolean;
|
||||
clusterDistance: number;
|
||||
minZoomLevel?: number;
|
||||
maxEntities?: number;
|
||||
}
|
||||
|
||||
// ─── Cesium Entity Options ───────────────────────────────────
|
||||
export interface CesiumEntityOptions {
|
||||
type: "billboard" | "point" | "polyline" | "polygon" | "label" | "model";
|
||||
color?: string;
|
||||
size?: number;
|
||||
iconUrl?: string;
|
||||
rotation?: number;
|
||||
outlineColor?: string;
|
||||
outlineWidth?: number;
|
||||
labelText?: string;
|
||||
labelFont?: string;
|
||||
distanceDisplayCondition?: { near: number; far: number };
|
||||
modelUrl?: string;
|
||||
modelScale?: number;
|
||||
modelMinPixelSize?: number;
|
||||
modelHeadingOffset?: number;
|
||||
}
|
||||
|
||||
// ─── Selection Behavior ──────────────────────────────────────
|
||||
export interface SelectionBehavior {
|
||||
showTrail?: boolean;
|
||||
trailDurationSec?: number;
|
||||
trailStepSec?: number;
|
||||
trailColor?: string;
|
||||
flyToOffsetMultiplier?: number;
|
||||
flyToBaseDistance?: number;
|
||||
}
|
||||
|
||||
// ─── Server Plugin Config ────────────────────────────────────
|
||||
export interface ServerPluginConfig {
|
||||
apiBasePath: string;
|
||||
pollingIntervalMs: number;
|
||||
requiresAuth?: boolean;
|
||||
historyEnabled?: boolean;
|
||||
availabilityEnabled?: boolean;
|
||||
}
|
||||
|
||||
// ─── Plugin Context ──────────────────────────────────────────
|
||||
// Provided by the host app when initializing each plugin.
|
||||
// All plugins (built-in and 3rd party) receive the same context.
|
||||
export interface PluginContext {
|
||||
apiBaseUrl: string;
|
||||
timeRange: TimeRange;
|
||||
onDataUpdate: (entities: GeoEntity[]) => void;
|
||||
onError: (error: Error) => void;
|
||||
/** Get plugin-specific settings from the app config store */
|
||||
getPluginSettings: <T = unknown>(pluginId: string) => T | undefined;
|
||||
/** Returns true if the app is in timeline playback mode */
|
||||
isPlaybackMode: () => boolean;
|
||||
/** Returns the current timeline time (relevant in playback mode) */
|
||||
getCurrentTime: () => Date;
|
||||
}
|
||||
|
||||
// ─── Filter Definitions ──────────────────────────────────────
|
||||
export interface FilterSelectOption { value: string; label: string; }
|
||||
export interface FilterRangeConfig { min: number; max: number; step: number; }
|
||||
export interface FilterDefinition {
|
||||
id: string;
|
||||
label: string;
|
||||
type: "text" | "select" | "range" | "boolean";
|
||||
propertyKey: string;
|
||||
options?: FilterSelectOption[];
|
||||
range?: FilterRangeConfig;
|
||||
}
|
||||
|
||||
export type FilterValue =
|
||||
| { type: "text"; value: string }
|
||||
| { type: "select"; values: string[] }
|
||||
| { type: "range"; min: number; max: number }
|
||||
| { type: "boolean"; value: boolean };
|
||||
|
||||
// ─── World Plugin Interface ──────────────────────────────────
|
||||
export interface WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string | ComponentType<{ size?: number; color?: string }>;
|
||||
category: PluginCategory;
|
||||
version: string;
|
||||
|
||||
// Lifecycle
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
|
||||
// Data
|
||||
fetch(timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
|
||||
// Rendering
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
|
||||
// Optional
|
||||
getSelectionBehavior?(entity: GeoEntity): SelectionBehavior | null;
|
||||
getServerConfig?(): ServerPluginConfig;
|
||||
getFilterDefinitions?(): FilterDefinition[];
|
||||
getSidebarComponent?(): ComponentType;
|
||||
getDetailComponent?(): ComponentType<{ entity: GeoEntity }>;
|
||||
getSettingsComponent?(): ComponentType<{ pluginId: string }>;
|
||||
requiresConfiguration?(settings: unknown): boolean;
|
||||
}
|
||||
|
||||
// ─── Data Bus Event Types ────────────────────────────────────
|
||||
export type DataBusEvents = {
|
||||
pluginRegistered: { pluginId: string; defaultInterval: number };
|
||||
dataUpdated: { pluginId: string; entities: GeoEntity[] };
|
||||
entitySelected: { entity: GeoEntity | null };
|
||||
layerToggled: { pluginId: string; enabled: boolean };
|
||||
timeRangeChanged: { timeRange: TimeRange };
|
||||
cameraPreset: { presetId: string };
|
||||
cameraFaceTowards: { lat: number; lon: number; alt: number };
|
||||
cameraGoTo: { lat: number; lon: number; alt: number; distance?: number; maxPitch?: number; heading?: number };
|
||||
globeReady: Record<string, never>;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
// ─── Plugin Manifest Types ───────────────────────────────────
|
||||
// Schema for plugin.json manifest files.
|
||||
// Three formats: declarative (JSON-only), static (GeoJSON), bundle (JS code).
|
||||
|
||||
import type { PluginCategory } from "./index";
|
||||
|
||||
export type PluginFormat = "declarative" | "static" | "bundle";
|
||||
export type PluginType = "data-layer" | "extension";
|
||||
export type TrustTier = "built-in" | "verified" | "unverified";
|
||||
|
||||
export type PluginCapability =
|
||||
| "data:own"
|
||||
| `data:read:${string}`
|
||||
| "ui:detail-panel"
|
||||
| "ui:sidebar"
|
||||
| "ui:toolbar"
|
||||
| "ui:settings"
|
||||
| "globe:overlay"
|
||||
| "globe:camera"
|
||||
| "storage:read"
|
||||
| "storage:write"
|
||||
| "network:fetch";
|
||||
|
||||
export interface DataSourceConfig {
|
||||
url: string;
|
||||
method: "GET" | "POST";
|
||||
pollInterval: number;
|
||||
format: "geojson" | "json" | "csv";
|
||||
auth?: { type: "header" | "query"; key: string; envVar: string } | null;
|
||||
headers?: Record<string, string>;
|
||||
body?: Record<string, unknown>;
|
||||
arrayPath?: string;
|
||||
}
|
||||
|
||||
export interface FieldMapping {
|
||||
id: string;
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
altitude?: string;
|
||||
heading?: string;
|
||||
speed?: string;
|
||||
label?: string;
|
||||
timestamp?: string;
|
||||
properties?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface RenderingConfig {
|
||||
entityType: "billboard" | "point" | "polyline" | "polygon" | "label" | "model";
|
||||
color?: string;
|
||||
icon?: string;
|
||||
sizeField?: string;
|
||||
labelField?: string;
|
||||
clusterEnabled?: boolean;
|
||||
clusterDistance?: number;
|
||||
modelUrl?: string;
|
||||
minZoomLevel?: number;
|
||||
maxEntities?: number;
|
||||
}
|
||||
|
||||
export interface PluginManifest {
|
||||
id: string;
|
||||
name: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
type: PluginType;
|
||||
format: PluginFormat;
|
||||
trust: TrustTier;
|
||||
capabilities: PluginCapability[];
|
||||
category: PluginCategory | string;
|
||||
icon?: string;
|
||||
compatibility?: { worldwideview: string };
|
||||
requires?: { envVars?: string[] };
|
||||
dataSource?: DataSourceConfig;
|
||||
fieldMapping?: FieldMapping;
|
||||
dataFile?: string;
|
||||
rendering?: RenderingConfig;
|
||||
entry?: string;
|
||||
assets?: string[];
|
||||
extends?: string[];
|
||||
}
|
||||
Loaded 100 of 310 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user