Files
MapLibreParticleLab/packages/maplibre-particle-rn

@navsea/maplibre-particle-rn

13.4.1-particle.1 是 NavSea 维护的 MapLibre Particle React Native 入口。Consumer 只直接安装本包;本包将 @maplibre/maplibre-react-native@11.3.6 声明为 peer dependency,并由 WeatherRuntime 提供 HostField / Timeline 的低频控制。

Android 使用 cc.navsea.maplibre:android-sdk-particle-opengl:13.4.1-particle.1。Expo Consumer 在 app config 加入 @navsea/maplibre-particle-rn/app.plugin;plugin 会加入 https://pbf.jpcn.ccwu.cc/maven 并替换 MLRN 的 OpenGL Native SDK 请求,避免官方与 Particle AAR 同时进入 APK。

WeatherColor 和 RasterParticle 是 Core-only style layer,不是 React 组件。使用 createParticleWeatherStyle() 或等价 Style JSON 声明。binary submit 始终为 metadataJson + local file:// payload,通过 WeatherRuntime.submitWindField() 进入既有 Native/Core 链路。

WeatherV2 HTTP 数据链

包内 weatherV2 子模块负责:

WeatherV2 HTTP
  → weather_manifest.json
  → wind time_index.json
  → pt full-frame WVECBIN1
  → JS/TS canonical converter
  → maplibre-particle-field/v1
  → local binary file URI
  → WeatherRuntime.submitWindField()
  → WeatherColorLayer + RasterParticleLayer

Native 不理解 provider、HTTP、dataset、Route 或 ETA;Core 仍然独占 T0/T1/MIX、Runtime Field Window 和 GPU 插值。

最小调用

import { File, Paths } from "expo-file-system";
import {
  WeatherV2HttpClient,
  loadWeatherV2WindIntoRuntime,
} from "@navsea/maplibre-particle-rn";

const client = new WeatherV2HttpClient({
  baseUrl: "https://weather.jpcn.ccwu.cc",
});

const fileStore = {
  async writeTempFile(fileName: string, bytes: Uint8Array) {
    const file = new File(Paths.cache, fileName);
    file.write(bytes);
    return file.uri;
  },
};

fileStore 是 Host 适配点,不属于 WeatherV2 协议。NavSea 可以换成自己的缓存目录、文件系统和生命周期策略,不需要修改 HTTP client 或 canonical converter。

await loadWeatherV2WindIntoRuntime({
  reactTag,
  client,
  fileStore,
  datasetId: "ecmwf-hres",
  referenceTime: "2026080600",
  targetTimes: ["2026080700", "2026080706", "2026080712", "2026080718"],
  weatherColorVisible: true,
  particleVisible: true,
  playbackState: "PAUSE",
});

await WeatherRuntime.setPlaybackState(reactTag, "PLAY");

WeatherV2HttpClient.getWindContext() 会从 manifest 选择 wind dataset 并读取 time index。NavSea 正式代码通常应先取得 context,再根据当前时间、路线/ETA 或业务策略选择 targetTimes;上面的固定四帧只用于当前 Test Host 回归。

转换器读取服务端 WVECBIN1 的 U plane、V plane、speed plane 和 valid mask;正式 canonical payload 只保留 interleaved U/V,invalid sample 写为 -9999。方向和单位固定为 U=eastward、V=northward、m/s、north-west origin、rows north-to-south。

下载/转换/提交按帧串行执行,避免同时在 JS 内存保留多份约 5 MiB 的 WVECBIN1 与约 3 MiB 的 canonical payload。没有 number[]、JSON 数值数组、base64 或 per-frame JNI Field 上传。

本包不包含 Test Host、WeatherV2 fixture、AAR、APK、cache 或凭证。发布前仍需通过 tarball Consumer APK 与实体机 smoke;Release Tag 由 Release Freeze 阶段单独创建。