mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
Show drone airspace, OSM places, sea marks and ski pistes on Navara, and keep them across engine switches
This commit is contained in:
1 parent
43b4e9348b
commit
843c4a111d
25 files changed
+838
-295
No files matched your search
@@ -1,85 +1,13 @@
|
||||
import * as geo from '../../../geo/index.js';
|
||||
import { createNavaraPolygonDisplay } from '../../shared/render/navaraPolygons.js';
|
||||
import { containmentAccent } from '../cards.js';
|
||||
|
||||
import { containsGroundPoint } from '../../shared/render/groundRing.js';
|
||||
import { createZonesNavaraRenderer } from '../../shared/render/navaraZones.js';
|
||||
|
||||
export function createPerimetersNavaraRenderer(engine, { view }) {
|
||||
let polygons = [];
|
||||
const display = createNavaraPolygonDisplay(engine, view, (color, show) => ({
|
||||
polygon: {
|
||||
color,
|
||||
show,
|
||||
clampToGround: true,
|
||||
transparent: true,
|
||||
opacity: 0.25,
|
||||
return createZonesNavaraRenderer(
|
||||
engine,
|
||||
{ view },
|
||||
{
|
||||
idPrefix: 'fire-perimeter',
|
||||
colorOf: (row) => containmentAccent(row.containedPct),
|
||||
},
|
||||
polyline: {
|
||||
color,
|
||||
show,
|
||||
clampToGround: true,
|
||||
width: 2,
|
||||
transparent: true,
|
||||
opacity: 0.9,
|
||||
},
|
||||
}));
|
||||
return {
|
||||
setVisible: display.setVisible,
|
||||
replace(rows) {
|
||||
const groups = new Map(),
|
||||
next = [];
|
||||
for (const row of rows) {
|
||||
const color = containmentAccent(row.containedPct);
|
||||
if (!groups.has(color)) groups.set(color, []);
|
||||
for (const [index, rings] of row.polygons.entries()) {
|
||||
const id = `fire-perimeter:${row.stableId}:${index}`;
|
||||
const properties = { incident: row.stableId };
|
||||
const group = groups.get(color);
|
||||
group.push(
|
||||
{
|
||||
type: 'Feature',
|
||||
id,
|
||||
properties,
|
||||
geometry: { type: 'Polygon', coordinates: rings },
|
||||
},
|
||||
{
|
||||
type: 'Feature',
|
||||
id: id + '-outline',
|
||||
properties,
|
||||
geometry: { type: 'LineString', coordinates: rings[0] },
|
||||
},
|
||||
);
|
||||
next.push({ id, rings });
|
||||
}
|
||||
}
|
||||
display.replace(groups);
|
||||
polygons = next;
|
||||
},
|
||||
onClick(callback) {
|
||||
// Perimeters never claim a sibling pick. The input port shares the
|
||||
// native click result with other consumers of the same gesture.
|
||||
return engine.input.on('click', callback, { pick: true });
|
||||
},
|
||||
pick(event) {
|
||||
if (event.picked) return event.picked;
|
||||
const point = engine.picker.pickGlobe(event.position);
|
||||
if (!point) return null;
|
||||
const pos = geo.cartographic.fromCartesian(point);
|
||||
const lon = geo.math.toDegrees(pos.longitude),
|
||||
lat = geo.math.toDegrees(pos.latitude);
|
||||
for (let i = polygons.length - 1; i >= 0; i--) {
|
||||
const { id, rings } = polygons[i];
|
||||
if (
|
||||
containsGroundPoint(rings[0], lon, lat) &&
|
||||
!rings.slice(1).some((ring) => containsGroundPoint(ring, lon, lat))
|
||||
)
|
||||
return { id };
|
||||
}
|
||||
return null;
|
||||
},
|
||||
destroy() {
|
||||
polygons = [];
|
||||
display.destroy();
|
||||
},
|
||||
};
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user