Skip to content

Commit

Permalink
Insert current geometry in DB version
Browse files Browse the repository at this point in the history
  • Loading branch information
schroedtert committed Mar 15, 2024
1 parent 2b80ae9 commit 263069a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python_modules/jupedsim/jupedsim/sqlite_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def begin_writing(self, simulation: Simulation) -> None:
" hash INTEGER NOT NULL, "
" wkt TEXT NOT NULL)"
)
cur.execute("CREATE UNIQUE INDEX geometry_hash on geometry( hash)")
cur.execute(
"INSERT INTO geometry VALUES(?, ?)",
(hash(geo), geo),
Expand Down Expand Up @@ -154,9 +155,16 @@ def write_iteration_state(self, simulation: Simulation) -> None:
("ymax", str(max(ymax, float(old_ymax)))),
],
)

geo_wkt = simulation.get_geometry().as_wkt()
geo_hash = hash(geo_wkt)
cur.execute(
"INSERT OR IGNORE INTO geometry(hash, wkt) VALUES(?,?)",
(geo_hash, geo_wkt),
)
cur.execute(
"INSERT INTO frame_data VALUES(?, ?)",
(frame, hash(simulation.get_geometry().as_wkt())),
(frame, geo_hash),
)
cur.execute("COMMIT")
except sqlite3.Error as e:
Expand Down

0 comments on commit 263069a

Please sign in to comment.