@@ -177,7 +177,7 @@ def _(mo):
177177@app .cell
178178def _ (io , requests ):
179179 # Read ZIP from disk after downloading manually
180- # zip = Path(r"C:\Users\joost\ReposWindows\bedrock-ge\examples\hk_kaitak_ags3\public\ kaitak_ags3.zip")
180+ # zip = Path.home() / "Downloads" / " kaitak_ags3.zip"
181181
182182 # Request ZIP from GitHub
183183 raw_githubusercontent_url = "https://raw.githubusercontent.com/bedrock-engineer/bedrock-ge/main/examples/hk_kaitak_ags3/kaitak_ags3.zip"
@@ -226,13 +226,30 @@ def _(mo):
226226
227227
228228@app .cell
229- def _ (CRS , zip , zipfile ):
229+ def _ ():
230+ import json
231+ import hashlib
232+ import base64
233+
230234 from bedrock_ge .gi .ags3 import ags3_to_brgi_db_mapping
231235 from bedrock_ge .gi .ags_parser import ags_to_brgi_db_mapping
232- from bedrock_ge .gi .mapping_models import BedrockGIMapping
233- from bedrock_ge .gi .mapper import map_to_brgi_db
234236 from bedrock_ge .gi .db_operations import merge_databases
237+ from bedrock_ge .gi .mapper import map_to_brgi_db
238+ from bedrock_ge .gi .mapping_models import BedrockGIMapping
239+ from bedrock_ge .gi .schemas import (
240+ BedrockGIDatabase ,
241+ InSituTestSchema ,
242+ LabTestSchema ,
243+ LocationSchema ,
244+ ProjectSchema ,
245+ SampleSchema ,
246+ )
247+
248+ return ags_to_brgi_db_mapping , map_to_brgi_db , merge_databases
249+
235250
251+ @app .cell
252+ def _ (CRS , ags_to_brgi_db_mapping , map_to_brgi_db , zip , zipfile ):
236253 projected_crs = CRS ("EPSG:2326" )
237254 vertrical_crs = CRS ("EPSG:5738" )
238255 brgi_dbs = []
@@ -269,96 +286,12 @@ def _(CRS, zip, zipfile):
269286 # brgi_db_obj = map_to_brgi_db(ags3_mapping_obj)
270287
271288 # brgi_db_obj
272- return ags3_mapping , brgi_dbs , merge_databases
273-
274-
275- @app .cell
276- def _ (project_data_jsons ):
277- hash (project_data_jsons )
278- return
279-
280-
281- @app .cell
282- def _ (ags3_mapping , pd ):
283- import base64
284- import hashlib
285- import json
286-
287- brgi_db_mapping = ags3_mapping
288- project_data_jsons = json .dumps (brgi_db_mapping .Project .data , sort_keys = True )
289- project_data_hash = hashlib .blake2b (
290- project_data_jsons .encode ("utf-8" ), digest_size = 9
291- ).digest ()
292- url_safe_hash = base64 .b64encode (project_data_hash ).decode ()
293- project_uid = brgi_db_mapping .Project .project_id + "-" + url_safe_hash
294- location_df = pd .DataFrame (
295- {
296- "location_uid" : brgi_db_mapping .Location .data [
297- brgi_db_mapping .Location .location_id_column
298- ]
299- + f"_{ project_uid } " ,
300- "location_source_id" : brgi_db_mapping .Location .data [
301- brgi_db_mapping .Location .location_id_column
302- ],
303- "project_uid" : project_uid ,
304- "easting" : brgi_db_mapping .Location .data [
305- brgi_db_mapping .Location .easting_column
306- ],
307- "northing" : brgi_db_mapping .Location .data [
308- brgi_db_mapping .Location .northing_column
309- ],
310- "ground_level_elevation" : brgi_db_mapping .Location .data [
311- brgi_db_mapping .Location .ground_level_elevation_column
312- ],
313- "depth_to_base" : brgi_db_mapping .Location .data [
314- brgi_db_mapping .Location .depth_to_base_column
315- ],
316- }
317- )
318- return base64 , hashlib , project_data_jsons , project_uid , url_safe_hash
319-
320-
321- @app .cell
322- def _ (url_safe_hash ):
323- b64_hash = url_safe_hash
324- print (b64_hash )
325- return
326-
327-
328- @app .cell
329- def _ (base64 ):
330- b = b'\xff \x00 \xfa '
331- encoded = base64 .b64encode (b ).decode ()
332- print (encoded )
333- return
334-
335-
336- @app .cell
337- def _ (base64 , hashlib , project_data_jsons , project_uid ):
338- print (project_uid )
339- bytes_hash = hashlib .blake2b (
340- project_data_jsons .encode ("utf-8" ), digest_size = 8
341- ).digest ()
342- safe_hash = base64 .b85encode (bytes_hash ).decode ()
343- safe_hash
344- return
345-
346-
347- @app .cell
348- def _ (ags3_mapping ):
349- ags3_mapping .Project
350- return
351-
352-
353- @app .cell
354- def _ (brgi_dbs ):
355- brgi_dbs [7 ].Project
356- return
289+ return (brgi_dbs ,)
357290
358291
359292@app .cell
360293def _ (brgi_dbs , merge_databases ):
361- brgi_db_obj = merge_databases (brgi_dbs )
294+ merged_brgi_db = merge_databases (brgi_dbs )
362295 return
363296
364297
0 commit comments