Skip to content

Commit 3f0a762

Browse files
fix Sample.PositionsWithBounds/InMemoryMerge
1 parent 47ccb8a commit 3f0a762

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/Aardvark.Geometry.Quadtree/Query.fs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,12 @@ module Sample =
698698
for i = 0 to r.Positions.Length - 1 do
699699
let p = r.Positions.[i]
700700
let c = r.Cells.[i]
701-
let (found, (n0, c0)) = result.TryGetValue(p)
702-
if found then
701+
702+
703+
//let (found, (n0, c0)) = result.TryGetValue(p) // this somehow throws a nullreferenceexception when key does not exist
704+
//if found then // (probably the compiler generates some code which accesses the out param tuple which is not initialized ...)
705+
if (result.ContainsKey(p)) then
706+
let (n0, c0) = result[p]
703707
if c.Exponent < c0.Exponent then result.[p] <- (r.Node, c)
704708
else
705709
result.[p] <- (r.Node, c)

src/Scratch/Program.fs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,12 +1430,48 @@ let test_20240208 () =
14301430
check 0 1 -1 10.0f
14311431
check 1 1 -1 10.0f
14321432

1433+
let cp_20240219_quadtreetest () =
1434+
1435+
let path = Path.GetFullPath(@"W:\Datasets\Vgm\Quadtree\20240219_quadtree.sample.error\quad\20240219_samplePoint")
1436+
1437+
printfn "path = %s" path
1438+
1439+
let options = SerializationOptions.NewInMemoryStore(verbose = false)
1440+
1441+
let idFile = Guid(File.ReadAllText(@"W:\Datasets\Vgm\Quadtree\20240219_quadtree.sample.error\quad\20240219_samplePoint\builder.20240219143640.638439502006524432.key.txt"))
1442+
let builderReloadedFile = Builder.Import(path, idFile)
1443+
match builderReloadedFile with
1444+
| None -> printfn "reloaded from file = None"
1445+
| Some x ->
1446+
printfn "reloaded from file, %d patches" (x.GetPatches() |> Seq.length)
1447+
1448+
let sw = Stopwatch.StartNew()
1449+
let buildConfig = { BuildConfig.Default with Verbose = false; SplitLimitPowerOfTwo = 8 }
1450+
let maybeQuadtree = x.Build2 buildConfig
1451+
sw.Stop()
1452+
printfn "[TIMING] build: %A" sw.Elapsed
1453+
1454+
match maybeQuadtree with
1455+
| None -> failwith ""
1456+
| Some qtree ->
1457+
1458+
let pos = V2d(66077.6476628291, 270082.243676802)
1459+
match Sample.Position Query.Config.Default pos qtree with
1460+
| None -> failwith "foo"
1461+
| Some x -> printfn "sample is: %A" x
1462+
1463+
()
1464+
1465+
()
1466+
14331467
[<EntryPoint>]
14341468
let main argv =
14351469

1470+
cp_20240219_quadtreetest ()
1471+
14361472
//test_20240208 ()
14371473

1438-
cp_20240202_quadtreetest ()
1474+
//cp_20240202_quadtreetest ()
14391475

14401476
//buildSerializationTest_20240202 ()
14411477

0 commit comments

Comments
 (0)