-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new models for GIS system Issue #379
- Loading branch information
1 parent
bcb19b2
commit a4f6f13
Showing
2 changed files
with
199 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,198 @@ | ||
module GisModels | ||
|
||
open Aardvark.Base | ||
|
||
open Chiron | ||
open PRo3D.Base | ||
|
||
type SpiceName = SpiceName of string | ||
with | ||
member x.Value = | ||
let (SpiceName v) = x in v | ||
static member FromJson(_ : SpiceName) = | ||
json { | ||
let! v = Json.read "SpiceName" | ||
return (SpiceName v) | ||
} | ||
static member ToJson (x : SpiceName) = | ||
json { | ||
do! Json.write "SpiceName" x.Value | ||
} | ||
|
||
module SpiceName = | ||
let value (SpiceName spiceName) = | ||
spiceName | ||
|
||
/// Reference Frames "A reference frame (or simply “frame”) is specified by an | ||
/// ordered set of three mutually orthogonal, possibly time dependent, unit-length direction vectors" | ||
/// https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/Tutorials/pdf/individual_docs/17_frames_and_coordinate_systems.pdf | ||
/// https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/frames.html | ||
type ReferenceFrame = | ||
{ | ||
version : int | ||
label : string | ||
description : option<string> | ||
spiceName : SpiceName | ||
body : option<SpiceName> | ||
} | ||
with | ||
static member current = 0 | ||
static member private readV0 = | ||
json { | ||
let! label = Json.read "label" | ||
let! description = Json.tryRead "description" | ||
let! spiceName = Json.read "spiceName" | ||
let! body = Json.tryRead "body" | ||
|
||
return { | ||
version = ReferenceFrame.current | ||
label = label | ||
description = description | ||
spiceName = spiceName | ||
body = body | ||
} | ||
} | ||
static member FromJson(_ : ReferenceFrame) = | ||
json { | ||
let! v = Json.read "version" | ||
match v with | ||
| 0 -> return! ReferenceFrame.readV0 | ||
| _ -> return! v |> sprintf "don't know version %A of ReferenceFrame" |> Json.error | ||
} | ||
static member ToJson (x : ReferenceFrame) = | ||
json { | ||
do! Json.write "version" ReferenceFrame.current | ||
do! Json.write "label" x.label | ||
do! Json.write "description" x.description | ||
do! Json.write "spiceName" x.spiceName | ||
} | ||
|
||
/// “Body” means a natural body: sun, planet, satellite, comet, asteroid. | ||
/// https://cosmoguide.org/catalog-file-defining-a-natural-body/ | ||
type Body = { | ||
version : int | ||
label : string | ||
spiceName : SpiceName | ||
color : C4f | ||
radius : float | ||
geometryPath : option<string> | ||
textureName : option<string> | ||
} with | ||
static member current = 0 | ||
static member private readV0 = | ||
json { | ||
let! label = Json.read "label" | ||
let! spiceName = Json.read "spiceName" | ||
let! color = Json.read "color" | ||
let! radius = Json.read "radius" | ||
let! geometryPath = Json.tryRead "geometryPath" | ||
let! textureName = Json.tryRead "textureName" | ||
|
||
return { | ||
version = Body.current | ||
label = label | ||
spiceName = spiceName | ||
color = C4f.Parse color | ||
radius = radius | ||
geometryPath = geometryPath | ||
textureName = textureName | ||
} | ||
} | ||
static member FromJson(_ : Body) = | ||
json { | ||
let! v = Json.read "version" | ||
match v with | ||
| 0 -> return! Body.readV0 | ||
| _ -> return! v |> sprintf "don't know version %A of ReferenceFrame" |> Json.error | ||
} | ||
static member ToJson (x : Body) = | ||
json { | ||
do! Json.write "version" Body.current | ||
do! Json.write "label" x.label | ||
do! Json.write "spiceName" x.spiceName | ||
do! Json.write "color" (string x.color) | ||
do! Json.write "radius" x.radius | ||
do! Json.write "geometryPath" x.geometryPath | ||
do! Json.write "textureName" x.textureName | ||
} | ||
|
||
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | ||
module Body = | ||
let mars = | ||
{ | ||
version = Body.current | ||
label = "Mars" | ||
spiceName = SpiceName "Mars" | ||
color = C4f.Red | ||
geometryPath = None | ||
radius = 3376200.0 //polar radius in meter | ||
textureName = None | ||
} | ||
|
||
let earth = | ||
{ | ||
version = Body.current | ||
label = "Earth" | ||
spiceName = SpiceName "Earth" | ||
color = C4f.Blue | ||
geometryPath = None | ||
radius = 6356800.0 // polar radius in meter | ||
textureName = None | ||
} | ||
|
||
let moon = | ||
{ | ||
version = Body.current | ||
label = "Moon" | ||
spiceName = SpiceName "Moon" | ||
color = C4f.Silver | ||
geometryPath = None | ||
radius = 1736000.0 //polar radius in meter | ||
textureName = None | ||
} | ||
|
||
let didymos = | ||
{ | ||
version = Body.current | ||
label = "Didymos" | ||
spiceName = SpiceName "Didymos" | ||
color = C4f.Grey | ||
geometryPath = None | ||
radius = 382.5 //mean radius +/- 2.5m | ||
textureName = None | ||
} | ||
|
||
let dimorphos = | ||
{ | ||
version = Body.current | ||
label = "Dimorphos" | ||
spiceName = SpiceName "Dimorphos" | ||
color = C4f.Grey | ||
geometryPath = None | ||
radius = 75.5 //mean radius +/- 2.5m | ||
textureName = None | ||
} | ||
|
||
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | ||
module ReferenceFrame = | ||
///Wikipedia: Defined with the Earth's Mean Equator and Mean Equinox (MEME) at 12:00 Terrestrial Time on 1 January 2000. | ||
/// https://en.wikipedia.org/wiki/Earth-centered_inertial | ||
let j2000 = | ||
{ | ||
version = ReferenceFrame.current | ||
label = "J2000" | ||
description = Some "Defined with Earth's Mean Equator and Mean Equinox (MEME) at 12:00 Terrestrial Time on 1 January 2000" | ||
spiceName = SpiceName "J2000" | ||
body = None | ||
} | ||
let iauMars = | ||
{ | ||
version = ReferenceFrame.current | ||
label = "IAU_MARS" | ||
description = Some "Mars body-fixed frame" | ||
spiceName = SpiceName "IAU_MARS" | ||
body = Some (SpiceName "Mars") | ||
} | ||
|
||
type Spacecraft = | ||
| Hera |
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