2020 get_not_supported_array ,
2121)
2222from src .energyml .utils .data .mesh import *
23+ from src .energyml .utils .data .mesh import _create_shape , _write_geojson_shape
2324from src .energyml .utils .epc import gen_energyml_object_path
24- from src .energyml .utils .introspection import is_abstract , get_obj_uuid , get_class_fields
25+ from src .energyml .utils .introspection import (
26+ is_abstract ,
27+ get_obj_uuid ,
28+ get_class_fields ,
29+ )
2530from src .energyml .utils .manager import get_sub_classes
2631from src .energyml .utils .serialization import (
2732 read_energyml_xml_file ,
2833 read_energyml_xml_str ,
2934 read_energyml_xml_bytes ,
35+ read_energyml_xml_tree ,
3036)
3137from src .energyml .utils .validation import validate_epc
32- from src .energyml .utils .xml import RGX_CONTENT_TYPE
38+ from src .energyml .utils .xml import RGX_CONTENT_TYPE , get_tree
39+
40+
41+ logger = logging .getLogger (__name__ )
3342
3443
3544def test_array ():
@@ -331,6 +340,40 @@ def test_export_multiple():
331340 )
332341
333342
343+ def test_export_multiple_geojson ():
344+ uuid_list = [
345+ # "a3f31b20-c93a-4682-8f6c-71be087202a4", # grid2d
346+ # "e6d5e3b4-ca6b-4182-89fa-96f7efee42ca", # grid2d
347+ # "a3f31b20-c93a-4682-8f6c-71be087202a4", # TrSet
348+ # "8659a66c-8727-420a-badf-578819698239", # TrSet
349+ # "4e23ee3e-54a7-427a-83f9-1473de6c56a4", # polyline
350+ "38bf3283-9514-43ab-81e3-17080dc5826f" , # polyline
351+ ]
352+ export_multiple_data (
353+ epc_path = "D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/EQN_ORIGIN_PLUS_TRIANG_SET/"
354+ "Volve_Horizons_and_Faults_Depth_originEQN_Plus.epc" ,
355+ uuid_list = uuid_list ,
356+ output_folder_path = "../example/result/export-energyml-utils" ,
357+ # output_folder_path="D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/EQN_ORIGIN_PLUS_TRIANG_SET/export-energyml-utils",
358+ file_format = MeshFileFormat .GEOJSON ,
359+ logger = logger ,
360+ )
361+
362+
363+ def test_export_multiple_geojson_volve ():
364+ uuid_list = [
365+ "d87b8581-7c98-4d73-8e62-6a5fe6501f6b" , # grid
366+ ]
367+ export_multiple_data (
368+ epc_path = "D:/Geosiris/OSDU/manifestTranslation/#Data/VOLVE_STRUCT_simple.epc" ,
369+ uuid_list = uuid_list ,
370+ output_folder_path = "../example/result/export-energyml-utils" ,
371+ # output_folder_path="D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/EQN_ORIGIN_PLUS_TRIANG_SET/export-energyml-utils",
372+ file_format = MeshFileFormat .GEOJSON ,
373+ logger = logger ,
374+ )
375+
376+
334377def test_export_multiple_testing_package ():
335378 uuid_list = [
336379 "030a82f6-10a7-4ecf-af03-54749e098624" , # grid2d
@@ -458,8 +501,157 @@ def read_unreferenced_h5_file():
458501 )
459502
460503
504+ def test_etree ():
505+ path = "../rc/obj_EpcExternalPartReference_61fa2fdf-46ab-4c02-ab72-7895cce58e37.xml"
506+
507+ with open (path , "rb" ) as f :
508+ xml_content = f .read ()
509+ print (read_energyml_xml_tree (get_tree (xml_content )))
510+
511+
512+ def test_simple_geojson ():
513+
514+ # data = [
515+ # [0, 0, 0],
516+ # [1, 1, 1],
517+ # [2, 2, 2],
518+ # [3, 3, 3],
519+ # [4, 4, 4],
520+ # [5, 5, 5],
521+ # [6, 6, 6],
522+ # [7, 7, 7],
523+ # ]
524+
525+ data = [
526+ [1.9014022183555446 , 58.44504279085361 , 6473036.072509766 ],
527+ [1.9013737107179551 , 58.44504703767692 , 6472932.990478516 ],
528+ [1.9003568945435436 , 58.44551437459448 , 6472946.729736328 ],
529+ [1.9003568945435436 , 58.44551437459448 , 6473144.458251953 ],
530+ [1.8988426423505782 , 58.446273843095085 , 6472907.2568359375 ],
531+ # [0, 0, 0],
532+ [1.8693970878231008 , 58.458691432495556 , 6473685.377441406 ],
533+ # [666, 666, 66600000000],
534+ [1.8680866057645866 , 58.45740440847041 , 6473473.168212891 ],
535+ [1.8667123866065054 , 58.45605393200282 , 6473242.957763672 ],
536+ ]
537+
538+ indices_a = [0 , 1 , 2 ]
539+ indices_b = [3 , 4 , 5 , 6 , 7 ]
540+
541+ indices_all = [indices_a , indices_b ]
542+
543+ for t in GeoJsonGeometryType :
544+ print (
545+ f"> NI { t } \n " ,
546+ _create_shape (
547+ geo_type = t ,
548+ point_list = data ,
549+ indices = indices_b ,
550+ point_offset = 0 ,
551+ logger = logger ,
552+ ),
553+ )
554+
555+ print (
556+ f"> I { t } \n " ,
557+ _create_shape (
558+ geo_type = t ,
559+ point_list = data ,
560+ indices = indices_b ,
561+ point_offset = 0 ,
562+ logger = logger ,
563+ ),
564+ )
565+ print (
566+ f"> II { t } \n " ,
567+ _create_shape (
568+ geo_type = t ,
569+ point_list = data ,
570+ indices = indices_all ,
571+ point_offset = 0 ,
572+ logger = logger ,
573+ ),
574+ )
575+
576+ print (f"\n +++++++++++++++++++++++++\n " )
577+
578+
579+ def test_simple_geojson_io ():
580+
581+ data = [
582+ [0 , 0 , 0 ],
583+ [1 , 1 , 1 ],
584+ [2 , 2 , 2 ],
585+ [3 , 3 , 3 ],
586+ [4 , 4 , 4 ],
587+ [5 , 5 , 5 ],
588+ [6 , 6 , 6 ],
589+ [7 , 7 , 7 ],
590+ ]
591+
592+ indices_a = [0 , 1 , 2 ]
593+ indices_b = [3 , 4 , 5 , 6 , 7 ]
594+
595+ indices_all = [indices_a , indices_b ]
596+
597+ for t in GeoJsonGeometryType :
598+ io_a = BytesIO ()
599+ _write_geojson_shape (
600+ out = io_a ,
601+ geo_type = t ,
602+ point_list = data ,
603+ indices = indices_b ,
604+ point_offset = 0 ,
605+ logger = logger ,
606+ )
607+ print (f"> NI { t } \n " , io_a .getvalue ())
608+
609+ io_b = BytesIO ()
610+ _write_geojson_shape (
611+ out = io_b ,
612+ geo_type = t ,
613+ point_list = data ,
614+ indices = indices_b ,
615+ point_offset = 0 ,
616+ logger = logger ,
617+ )
618+ print (f"> I { t } \n " , io_b .getvalue ())
619+
620+ io_c = BytesIO ()
621+ _write_geojson_shape (
622+ out = io_c ,
623+ geo_type = t ,
624+ point_list = data ,
625+ indices = indices_all ,
626+ point_offset = 0 ,
627+ logger = logger ,
628+ )
629+ print (f"> II { t } \n " , io_c .getvalue ())
630+
631+ print (
632+ f"> REF { t } \n " ,
633+ _create_shape (
634+ geo_type = t ,
635+ point_list = data ,
636+ indices = indices_all ,
637+ point_offset = 0 ,
638+ logger = logger ,
639+ )[0 ],
640+ )
641+
642+ print (f"\n +++++++++++++++++++++++++\n " )
643+
644+
461645if __name__ == "__main__" :
462- print (get_class_fields (WellboreMarkerFrameRepresentation ))
646+
647+ logging .basicConfig (
648+ format = "%(asctime)s %(levelname)-8s %(message)s" ,
649+ filename = "main_data.log" ,
650+ level = logging .DEBUG ,
651+ datefmt = "%Y-%m-%d %H:%M:%S" ,
652+ )
653+
654+ # print(get_class_fields(WellboreMarkerFrameRepresentation))
463655 # test_array()
464656 # test_h5_path()
465657 # read_h5_datasets()
@@ -482,3 +674,10 @@ def read_unreferenced_h5_file():
482674 #
483675 # test_read_external_part_with_xsi()
484676 # read_unreferenced_h5_file()
677+
678+ # test_export_multiple_geojson()
679+ # test_export_multiple_geojson_volve()
680+ # test_simple_geojson()
681+ test_simple_geojson_io ()
682+
683+ # test_etree()
0 commit comments