fix: open dataset with readonly mode

This commit is contained in:
2024-11-08 10:48:59 +01:00
parent ed7685faa5
commit d9ba3633a7
5 changed files with 21 additions and 5 deletions

View File

@@ -8,6 +8,13 @@
"fantomas"
],
"rollForward": false
},
"dotnet-trace": {
"version": "9.0.553101",
"commands": [
"dotnet-trace"
],
"rollForward": false
}
}
}

3
.gitignore vendored
View File

@@ -9,3 +9,6 @@ obj/
.direnv/*
*.sln.DotSettings.user
.pre-commit-config.yaml
*.def
*.sif
*.nettrace

View File

@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.300",
"version": "8.0.*",
"rollForward": "latestPatch"
}
}
}

View File

@@ -1,4 +1,4 @@
open System
open System
open System.IO
open Argu
open Oceanbox.FvcomKit
@@ -105,11 +105,13 @@ let main argv =
let path = args.GetResult(Input_Grid)
Log.Information $"Using input file: %s{path}"
let ds = DataSetUri.Create path |> DataSet.Open
let ds = DataSet.Open(path, openMode = ResourceOpenMode.ReadOnly)
Log.Verbose "Opened dataset"
let grd = ds |> Fvcom.getGrid
let neighborIndex = grd.ToGrid() |> Grid.makeNeighborIndex
let grid = grd.ToGrid()
let neighborIndex = grid |> Grid.makeNeighborIndex
let extendedGrid = Grid.ExtendedGrid(grid)
Log.Verbose "Created in-memory structures, separating coastline..."
let coastEdges, innerNodes = separateCoastline grid
Log.Verbose

View File

@@ -1,6 +1,7 @@
module Gridding.Polygon
open Oceanbox.FvcomKit
open Serilog
/// <summary>
/// Separate coastline nodes from inner nodes.
@@ -11,6 +12,7 @@ let separateCoastline (grid: Grid.Grid) =
let getEdges (a, b, c) = [ (a, b); (b, c); (c, a) ]
let allEdges =
Log.Debug "Finding all edges"
(Map.empty, grid.Elem)
||> Array.fold (fun allEdges elem ->
// Get all edges of the elem and sort the coordinates
@@ -30,6 +32,7 @@ let separateCoastline (grid: Grid.Grid) =
// Coastal edges will only have one reference
let coastalEdges =
Log.Debug "Finding coastal edges"
(Array.empty, allEdges)
||> Map.fold (fun acc edge count ->
match count with
@@ -39,6 +42,7 @@ let separateCoastline (grid: Grid.Grid) =
// Find all nodes that are not part of a coastal edge
let innerNodes =
Log.Debug "Finding all nodes that are not part of a coastal edge"
[| 0 .. grid.Nodes.Length - 1 |]
|> Array.filter (fun node ->
coastalEdges