-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from dfpc-coe/sensor
Sensor Parsing
- Loading branch information
Showing
6 changed files
with
406 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import CoT from './lib/cot.js'; | ||
export * as Feature from './lib/types/feature.js' | ||
export * as Types from './lib/types/types.js' | ||
export * as CoTTypes from './lib/types/cot-types.js' | ||
export * from './lib/chat.js' | ||
export * from './lib/fileshare.js' | ||
export * from './lib/force-delete.js' | ||
export * from './lib/data-package.js' | ||
export * from './lib/xml/basemap.js' | ||
export * from './lib/xml/iconset.js' | ||
export * as Feature from './lib/types/feature.js'; | ||
export * as Types from './lib/types/types.js'; | ||
export * as CoTTypes from './lib/types/cot-types.js'; | ||
export * from './lib/chat.js'; | ||
export * from './lib/sensor.js'; | ||
export * from './lib/fileshare.js'; | ||
export * from './lib/force-delete.js'; | ||
export * from './lib/data-package.js'; | ||
export * from './lib/xml/basemap.js'; | ||
export * from './lib/xml/iconset.js'; | ||
|
||
export default CoT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { Static } from '@sinclair/typebox'; | ||
import { Position, Polygon } from './types/feature.js'; | ||
import { SensorAttributes } from './types/types.js'; | ||
import { sector } from '@turf/sector'; | ||
|
||
export default class Sensor { | ||
center: Static<typeof Position>; | ||
sensor: Static<typeof SensorAttributes>; | ||
|
||
constructor( | ||
center: Static<typeof Position>, | ||
sensor: Static<typeof SensorAttributes> | ||
) { | ||
this.center = center; | ||
this.sensor = sensor; | ||
} | ||
|
||
to_geojson(): Static<typeof Polygon> | null { | ||
if (!this.sensor.range) return null; | ||
if (!this.sensor.azimuth) return null; | ||
if (!this.sensor.fov) return null; | ||
|
||
return sector( | ||
this.center, | ||
this.sensor.range / 1000, | ||
this.sensor.azimuth, | ||
this.sensor.azimuth + this.sensor.fov, | ||
).geometry; | ||
} | ||
} |
Oops, something went wrong.