Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
//#![allow(unused_variables)]

extern crate ecrt_sys;
extern crate dggal_sys;

use std::ffi::CString;
use std::ffi::CStr;
use std::ffi::c_void;
use std::slice;
use std::mem;

// *** This code should be moved to / generated inside the DGGAL rust bindings
pub const nullZone : dggal_sys::DGGRSZone = 0xFFFFFFFFFFFFFFFFu64;
pub const nullInst : ecrt_sys::Instance = 0 as ecrt_sys::Instance;
pub const nullVTbl : *mut *mut c_void = 0 as *mut *mut c_void;
pub const nullPtr : *mut c_void = 0 as *mut c_void;

pub type GeoPoint = dggal_sys::GeoPoint;
pub type GeoExtent = dggal_sys::GeoExtent;
pub type DGGRSZone = dggal_sys::DGGRSZone;

pub struct DGGRS {
   imp: dggal_sys::DGGRS,
   mDGGAL: ecrt_sys::Module
}

pub struct Application {
   app: ecrt_sys::Application
}
impl Drop for Application {
   fn drop(&mut self) {
      unsafe {
         ecrt_sys::__eCNameSpace__eC__types__eInstance_DecRef(self.app);
      }
   }
}

impl Application {
   pub fn new(_args: &Vec<String>) -> Application
   {
      unsafe {
         let app = ecrt_sys::ecrt_init(nullInst, true as u32, false as u32, 0,
               0 /*ptr::null_mut::<* mut * mut i8>()*/ as * mut * mut i8); // TODO: argc, args);
         Application { app: app }
      }
   }
}

pub struct DGGAL {
   mDGGAL: ecrt_sys::Module
}

impl DGGAL {
   pub fn new(app: &Application) -> DGGAL
   {
      unsafe {
         DGGAL { mDGGAL: dggal_sys::dggal_init(app.app) }
      }
   }

   pub fn newDGGRS(&self, name: &str) -> Option<DGGRS>
   {
      let dggrsName = CString::new(name).unwrap();
      unsafe {
         let c = ecrt_sys::__eCNameSpace__eC__types__eSystem_FindClass(self.mDGGAL, dggrsName.as_ptr());

         if c != nullVTbl as * mut ecrt_sys::Class {
            Some(DGGRS { imp: ecrt_sys::__eCNameSpace__eC__types__eInstance_New(c) as dggal_sys::DGGRS, mDGGAL: self as *const _ as *mut _ })
         }
         else {
            None
         }
      }
   }

}

impl DGGRS {
   // TODO: Could we use rust function-generating macros?

   pub fn getZoneFromTextID(&self, zoneID: &str) -> dggal_sys::DGGRSZone
   {
      let mut zone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneFromTextID_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zoneID: * const i8) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            let csZoneID = CString::new(zoneID).unwrap();
            zone = method(self.imp, csZoneID.as_ptr());
         }
      }
      zone
   }

   pub fn getZoneLevel(&self, zone: dggal_sys::DGGRSZone) -> i32
   {
      let mut level = -1;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneLevel_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> i32 = std::mem::transmute(cMethod);
            level = method(self.imp, zone);
         }
      }
      level
   }

   pub fn countZoneEdges(&self, zone: dggal_sys::DGGRSZone) -> i32
   {
      let mut level = -1;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_countZoneEdges_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> i32 = std::mem::transmute(cMethod);
            level = method(self.imp, zone);
         }
      }
      level
   }

   pub fn getRefinementRatio(&self) -> i32
   {
      let mut depth = -1;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getRefinementRatio_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            depth = method(self.imp,);
         }
      }
      depth
   }

   pub fn getMaxDGGRSZoneLevel(&self) -> i32
   {
      let mut depth = -1;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getMaxDGGRSZoneLevel_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            depth = method(self.imp,);
         }
      }
      depth
   }

   pub fn getZoneWGS84Centroid(&self, zone: dggal_sys::DGGRSZone) -> dggal_sys::GeoPoint
   {
      let mut centroid = dggal_sys::GeoPoint { lat: 0.0, lon: 0.0 };
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneWGS84Centroid_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, centroid: *mut dggal_sys::GeoPoint) = std::mem::transmute(cMethod);
            method(self.imp, zone, std::ptr::from_mut(&mut centroid));
         }
      }
      centroid
   }

   pub fn getZoneWGS84Vertices(&self, zone: dggal_sys::DGGRSZone) -> Vec<dggal_sys::GeoPoint>
   {
      let vertices: Vec<dggal_sys::GeoPoint>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut v: [dggal_sys::GeoPoint; 6] = [dggal_sys::GeoPoint { lat: 0.0, lon: 0.0 }; 6]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneWGS84Vertices_vTblID as usize));
         let mut n: i32 = 0;
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, vertices: *mut dggal_sys::GeoPoint) -> i32 = std::mem::transmute(cMethod);
            n = method(self.imp, zone, std::ptr::from_mut(&mut v[0]));
         }
         vertices = slice::from_raw_parts(&v[0], n as usize).to_vec();
      }
      vertices
   }

   pub fn getZoneArea(&self, zone: dggal_sys::DGGRSZone) -> f64
   {
      let mut area = 0.0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneArea_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> f64 = std::mem::transmute(cMethod);
            area = method(self.imp, zone);
         }
      }
      area
   }

   pub fn countSubZones(&self, zone: dggal_sys::DGGRSZone, depth: i32) -> u64
   {
      let mut count = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_countSubZones_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, depth: i32) -> u64 = std::mem::transmute(cMethod);
            count = method(self.imp, zone, depth);
         }
      }
      count
   }

   pub fn getZoneTextID(&self, zone: dggal_sys::DGGRSZone) -> String
   {
      let id: String;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut zoneID = [0i8; 256]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneTextID_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, zoneID: *mut i8) = std::mem::transmute(cMethod);
            method(self.imp, zone, std::ptr::from_mut(&mut zoneID[0]));
         }
         id = CStr::from_ptr(zoneID.as_ptr()).to_str().unwrap().to_string();
      }
      id
   }

   pub fn getZoneParents(&self, zone: dggal_sys::DGGRSZone) -> Vec<dggal_sys::DGGRSZone>
   {
      let mut n: i32 = 0;
      let parents: Vec<dggal_sys::DGGRSZone>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut p = [nullZone; 3]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneParents_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, parents: *mut dggal_sys::DGGRSZone) -> i32 = std::mem::transmute(cMethod);
            n = method(self.imp, zone, std::ptr::from_mut(&mut p[0]));
         }
         parents = slice::from_raw_parts(&p[0], n as usize).to_vec();
      }
      parents
   }

   pub fn getZoneChildren(&self, zone: dggal_sys::DGGRSZone) -> Vec<dggal_sys::DGGRSZone>
   {
      let mut n: i32 = 0;
      let children: Vec<dggal_sys::DGGRSZone>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut ch = [nullZone; 9]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneChildren_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, children: *mut dggal_sys::DGGRSZone) -> i32 = std::mem::transmute(cMethod);
            n = method(self.imp, zone, std::ptr::from_mut(&mut ch[0]));
         }
         children = slice::from_raw_parts(&ch[0], n as usize).to_vec();
      }
      children
   }

   pub fn getZoneNeighbors(&self, zone: dggal_sys::DGGRSZone, nbTypes: &mut [i32; 6]) -> Vec<dggal_sys::DGGRSZone>
   {
      let mut n: i32 = 0;
      let neighbors: Vec<dggal_sys::DGGRSZone>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut nb = [nullZone; 6]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneNeighbors_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, neighbors: *mut dggal_sys::DGGRSZone, nbTypes: *mut i32) -> i32 = std::mem::transmute(cMethod);
            n = method(self.imp, zone, std::ptr::from_mut(&mut nb[0]), std::ptr::from_mut(&mut nbTypes[0]));
         }
         neighbors = slice::from_raw_parts(&nb[0], n as usize).to_vec();
      }
      neighbors
   }

   pub fn getZoneCentroidParent(&self, zone: dggal_sys::DGGRSZone) -> dggal_sys::DGGRSZone
   {
      let mut centroidParent: dggal_sys::DGGRSZone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneCentroidParent_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            centroidParent = method(self.imp, zone);
         }
      }
      centroidParent
   }

   pub fn getZoneCentroidChild(&self, zone: dggal_sys::DGGRSZone) -> dggal_sys::DGGRSZone
   {
      let mut centroidChild: dggal_sys::DGGRSZone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneCentroidChild_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            centroidChild = method(self.imp, zone);
         }
      }
      centroidChild
   }

   pub fn isZoneCentroidChild(&self, zone: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_isZoneCentroidChild_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone) -> u32 = std::mem::transmute(cMethod);
            result = method(self.imp, zone) != 0;
         }
      }
      result
   }

   pub fn getZoneWGS84Extent(&self, zone: dggal_sys::DGGRSZone) -> dggal_sys::GeoExtent
   {
      let mut extent: dggal_sys::GeoExtent = dggal_sys::GeoExtent {    // REVIEW: Any way to avoid this initialization?
         ll: dggal_sys::GeoPoint { lat: 0.0, lon: 0.0 },
         ur: dggal_sys::GeoPoint { lat: 0.0, lon: 0.0 } };
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneWGS84Extent_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, extent: *mut dggal_sys::GeoExtent) = std::mem::transmute(cMethod);
            method(self.imp, zone, std::ptr::from_mut(&mut extent));
         }
      }
      extent
   }

   pub fn listZones(&self, level: i32, bbox: &dggal_sys::GeoExtent) -> Vec<dggal_sys::DGGRSZone>
   {
      let zones: Vec<dggal_sys::DGGRSZone>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_listZones_vTblID as usize));
         let mut n: usize = 0;
         let mut a: *const dggal_sys::DGGRSZone = nullPtr as *const dggal_sys::DGGRSZone;

         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, level: i32, bbox: *const dggal_sys::GeoExtent) -> dggal_sys::template_Array_DGGRSZone = std::mem::transmute(cMethod);
            let az: dggal_sys::template_Array_DGGRSZone = method(self.imp, level, bbox);
            if az != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((az as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array;
            }
         }
         zones = slice::from_raw_parts(a, n).to_vec();
      }
      zones
   }

   pub fn getZoneRefinedWGS84Vertices(&self, zone: dggal_sys::DGGRSZone, refinement: i32) -> Vec<dggal_sys::GeoPoint>
   {
      let vertices: Vec<dggal_sys::GeoPoint>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut n: usize = 0;
         let mut a: *const dggal_sys::GeoPoint = nullPtr as *const dggal_sys::GeoPoint;

         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneRefinedWGS84Vertices_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, refinement: i32) -> dggal_sys::template_Array_GeoPoint = std::mem::transmute(cMethod);
            let ap: dggal_sys::template_Array_GeoPoint = method(self.imp, zone, refinement);
            if ap != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((ap as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array as *const dggal_sys::GeoPoint;
            }
         }
         vertices = slice::from_raw_parts(a, n).to_vec();
      }
      vertices
   }

   pub fn getSubZones(&self, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> Vec<dggal_sys::DGGRSZone>
   {
      let zones: Vec<dggal_sys::DGGRSZone>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getSubZones_vTblID as usize));
         let mut n: usize = 0;
         let mut a: *const dggal_sys::DGGRSZone = nullPtr as *const dggal_sys::DGGRSZone;

         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> dggal_sys::template_Array_DGGRSZone = std::mem::transmute(cMethod);
            let az: dggal_sys::template_Array_DGGRSZone = method(self.imp, parent, relativeDepth);
            if az != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((az as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array;
            }
         }
         zones = slice::from_raw_parts(a, n).to_vec();
      }
      zones
   }

   pub fn getZoneFromWGS84Centroid(&self, level: i32, centroid: &dggal_sys::GeoPoint) -> dggal_sys::DGGRSZone
   {
      let mut zone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneFromWGS84Centroid_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, level: i32, centroid: * const dggal_sys::GeoPoint) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            zone = method(self.imp, level, centroid);
         }
      }
      zone
   }

   pub fn getZoneFromCRSCentroid(&self, level: i32, crs: dggal_sys::CRS, centroid: &ecrt_sys::Pointd) -> dggal_sys::DGGRSZone
   {
      let mut zone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneFromCRSCentroid_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, level: i32, crs: dggal_sys::CRS, centroid: * const ecrt_sys::Pointd) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            zone = method(self.imp, level, crs, centroid);
         }
      }
      zone
   }

   pub fn countZones(&self, level: i32) -> u64
   {
      let mut count = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_countZones_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, level: i32) -> u64 = std::mem::transmute(cMethod);
            count = method(self.imp, level);
         }
      }
      count
   }

   pub fn getFirstSubZone(&self, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> dggal_sys::DGGRSZone
   {
      let mut zone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getFirstSubZone_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            zone = method(self.imp, parent, relativeDepth);
         }
      }
      zone
   }

   pub fn getIndexMaxDepth(&self) -> i32
   {
      let mut maxDepth = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getIndexMaxDepth_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            maxDepth = method(self.imp);
         }
      }
      maxDepth
   }

   pub fn getMaxChildren(&self) -> i32
   {
      let mut maxChildren = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getMaxChildren_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            maxChildren = method(self.imp);
         }
      }
      maxChildren
   }

   pub fn getMaxNeighbors(&self) -> i32
   {
      let mut maxNeighbors = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getMaxNeighbors_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            maxNeighbors = method(self.imp);
         }
      }
      maxNeighbors
   }

   pub fn getMaxParents(&self) -> i32
   {
      let mut maxParents = 0;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getMaxParents_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS) -> i32 = std::mem::transmute(cMethod);
            maxParents = method(self.imp);
         }
      }
      maxParents
   }

   pub fn getSubZoneAtIndex(&self, parent: dggal_sys::DGGRSZone, index: i64) -> dggal_sys::DGGRSZone
   {
      let mut zone = nullZone;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getSubZoneAtIndex_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, index: i64) -> dggal_sys::DGGRSZone = std::mem::transmute(cMethod);
            zone = method(self.imp, parent, index);
         }
      }
      zone
   }

   pub fn getSubZoneIndex(&self, parent: dggal_sys::DGGRSZone, subZone: dggal_sys::DGGRSZone) -> i64
   {
      let mut index = -1;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getSubZoneIndex_vTblID as usize));
         if cMethod != 0usize {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, subZone: dggal_sys::DGGRSZone) -> i64 = std::mem::transmute(cMethod);
            index = method(self.imp, parent, subZone);
         }
      }
      index
   }

   pub fn getSubZoneCRSCentroids(&self, parent: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, relativeDepth: i32) -> Vec<ecrt_sys::Pointd>
   {
      let centroids: Vec<ecrt_sys::Pointd>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut n: usize = 0;
         let mut a: *const ecrt_sys::Pointd = nullPtr as *const ecrt_sys::Pointd;

         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getSubZoneCRSCentroids_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, relativeDepth: i32) -> dggal_sys::template_Array_Pointd = std::mem::transmute(cMethod);
            let ap: dggal_sys::template_Array_Pointd = method(self.imp, parent, crs, relativeDepth);
            if ap != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((ap as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array as *const ecrt_sys::Pointd;
            }
         }
         centroids = slice::from_raw_parts(a, n).to_vec();
      }
      centroids
   }

   pub fn getSubZoneWGS84Centroids(&self, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> Vec<dggal_sys::GeoPoint>
   {
      let centroids: Vec<dggal_sys::GeoPoint>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut n: usize = 0;
         let mut a: *const dggal_sys::GeoPoint = nullPtr as *const dggal_sys::GeoPoint;

         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getSubZoneWGS84Centroids_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, parent: dggal_sys::DGGRSZone, relativeDepth: i32) -> dggal_sys::template_Array_GeoPoint = std::mem::transmute(cMethod);
            let ap: dggal_sys::template_Array_GeoPoint = method(self.imp, parent, relativeDepth);
            if ap != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((ap as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array as *const dggal_sys::GeoPoint;
            }
         }
         centroids = slice::from_raw_parts(a, n).to_vec();
      }
      centroids
   }

   pub fn getZoneCRSVertices(&self, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS) -> Vec<ecrt_sys::Pointd>
   {
      let vertices: Vec<ecrt_sys::Pointd>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut v: [ecrt_sys::Pointd; 6] = [ecrt_sys::Pointd { x: 0.0, y: 0.0 }; 6]; // REVIEW: Any way to avoid this initialization?
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneCRSVertices_vTblID as usize));
         let mut n: i32 = 0;
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, vertices: *mut ecrt_sys::Pointd) -> i32 = std::mem::transmute(cMethod);
            n = method(self.imp, zone, crs, std::ptr::from_mut(&mut v[0]));
         }
         vertices = slice::from_raw_parts(&v[0], n as usize).to_vec();
      }
      vertices
   }

   pub fn getZoneRefinedCRSVertices(&self, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, refinement: i32) -> Vec<ecrt_sys::Pointd>
   {
      let vertices: Vec<ecrt_sys::Pointd>;
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let mut n: usize = 0;
         let mut a: *const ecrt_sys::Pointd = nullPtr as *const ecrt_sys::Pointd;

         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneRefinedCRSVertices_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, refinement: i32) -> dggal_sys::template_Array_GeoPoint = std::mem::transmute(cMethod);
            let ap: dggal_sys::template_Array_GeoPoint = method(self.imp, zone, crs, refinement);
            if ap != nullInst {
               let am: *const ecrt_sys::class_members_Array = ((ap as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               n = (*am).count as usize;
               a = (*am).array as *const ecrt_sys::Pointd;
            }
         }
         vertices = slice::from_raw_parts(a, n).to_vec();
      }
      vertices
   }

   pub fn getZoneCRSCentroid(&self, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS) -> ecrt_sys::Pointd
   {
      let mut centroid = ecrt_sys::Pointd { x: 0.0, y: 0.0 };
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneCRSCentroid_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, centroid: *mut ecrt_sys::Pointd) = std::mem::transmute(cMethod);
            method(self.imp, zone, crs, std::ptr::from_mut(&mut centroid));
         }
      }
      centroid
   }

   pub fn getZoneCRSExtent(&self, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS) -> dggal_sys::CRSExtent
   {
      let mut extent: dggal_sys::CRSExtent = dggal_sys::CRSExtent {    // REVIEW: Any way to avoid this initialization?
         tl: ecrt_sys::Pointd { x: 0.0, y: 0.0 },
         br: ecrt_sys::Pointd { x: 0.0, y: 0.0 },
         crs: 0 };
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_getZoneCRSExtent_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zone: dggal_sys::DGGRSZone, crs: dggal_sys::CRS, extent: *mut dggal_sys::CRSExtent) = std::mem::transmute(cMethod);
            method(self.imp, zone, crs, std::ptr::from_mut(&mut extent));
         }
      }
      extent
   }

   pub fn compactZones(&self, mut zones: Vec<dggal_sys::DGGRSZone>)
   {
      unsafe
      {
         let c = dggal_sys::class_DGGRS;
         let vTbl = if self.imp != nullInst && (*self.imp)._vTbl != nullVTbl { (*self.imp)._vTbl } else { (*c)._vTbl };
         let cMethod: usize = std::mem::transmute(*vTbl.add(dggal_sys::DGGRS_compactZones_vTblID as usize));
         if cMethod != std::mem::transmute(0usize) {
            let mut n: usize = zones.len();
            if n != 0 {
               let method : unsafe extern "C" fn(dggrs: dggal_sys::DGGRS, zones: dggal_sys::template_Array_DGGRSZone) = std::mem::transmute(cMethod);
               let ac = ecrt_sys::__eCNameSpace__eC__types__eSystem_FindClass(self.mDGGAL, "Array<DGGRSZone>\0".as_ptr() as *const i8);
               let az: dggal_sys::template_Array_DGGRSZone = ecrt_sys::__eCNameSpace__eC__types__eInstance_New(ac) as dggal_sys::template_Array_DGGRSZone;
               let am: *const ecrt_sys::class_members_Array;
               let mut a: *mut dggal_sys::DGGRSZone;

               ecrt_sys::Array_set_size.unwrap()(az, n as u32);
               am = ((az as *const i8).wrapping_add((*ecrt_sys::class_Array).offset as usize)) as *const ecrt_sys::class_members_Array;
               a = (*am).array as *mut dggal_sys::DGGRSZone;
               ecrt_sys::memcpy(a as *mut c_void, zones.as_ptr() as *const c_void, (mem::size_of::<dggal_sys::DGGRSZone>() * n) as std::os::raw::c_ulong);
               method(self.imp, az);

               n = (*am).count as usize;
               a = (*am).array;

               zones.set_len(n);
               ecrt_sys::memcpy(zones.as_ptr() as *mut c_void, a as *const c_void, (mem::size_of::<dggal_sys::DGGRSZone>() * n) as std::os::raw::c_ulong);

               ecrt_sys::__eCNameSpace__eC__types__eInstance_DecRef(az);
            }
         }
      }
   }

   // These methods are NOT virtual:
   pub fn get64KDepth(&self) -> i32
   {
      let mut depth = -1;
      unsafe
      {
         if self.imp != nullInst {
            depth = dggal_sys::DGGRS_get64KDepth.unwrap()(self.imp);
         }
      }
      depth
   }

   pub fn getMaxDepth(&self) -> i32
   {
      let mut depth = -1;
      unsafe
      {
         if self.imp != nullInst {
            depth = dggal_sys::DGGRS_getMaxDepth.unwrap()(self.imp);
         }
      }
      depth
   }

   pub fn areZonesNeighbors(&self, a: dggal_sys::DGGRSZone, b: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_areZonesNeighbors.unwrap()(self.imp, a, b) != 0;
         }
      }
      result
   }

   pub fn areZonesSiblings(&self, a: dggal_sys::DGGRSZone, b: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_areZonesSiblings.unwrap()(self.imp, a, b) != 0;
         }
      }
      result
   }

   pub fn doZonesOverlap(&self, a: dggal_sys::DGGRSZone, b: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_doZonesOverlap.unwrap()(self.imp, a, b) != 0;
         }
      }
      result
   }

   pub fn doesZoneContain(&self, hayStack: dggal_sys::DGGRSZone, needle: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_doesZoneContain.unwrap()(self.imp, hayStack, needle) != 0;
         }
      }
      result
   }

   pub fn isZoneAncestorOf(&self, ancestor: dggal_sys::DGGRSZone, descendant: dggal_sys::DGGRSZone, maxDepth: i32) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_isZoneAncestorOf.unwrap()(self.imp, ancestor, descendant, maxDepth) != 0;
         }
      }
      result
   }

   pub fn isZoneContainedIn(&self, needle: dggal_sys::DGGRSZone, hayStack: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_isZoneContainedIn.unwrap()(self.imp, needle, hayStack) != 0;
         }
      }
      result
   }

   pub fn isZoneDescendantOf(&self, descendant: dggal_sys::DGGRSZone, ancestor: dggal_sys::DGGRSZone, maxDepth: i32) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_isZoneDescendantOf.unwrap()(self.imp, descendant, ancestor, maxDepth) != 0;
         }
      }
      result
   }

   pub fn isZoneImmediateChildOf(&self, child: dggal_sys::DGGRSZone, parent: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_isZoneImmediateChildOf.unwrap()(self.imp, child, parent) != 0;
         }
      }
      result
   }

   pub fn isZoneImmediateParentOf(&self, parent: dggal_sys::DGGRSZone, child: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_isZoneImmediateParentOf.unwrap()(self.imp, parent, child) != 0;
         }
      }
      result
   }

   pub fn zoneHasSubZone(&self, hayStack: dggal_sys::DGGRSZone, needle: dggal_sys::DGGRSZone) -> bool
   {
      let mut result: bool = false;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_zoneHasSubZone.unwrap()(self.imp, hayStack, needle) != 0;
         }
      }
      result
   }

   pub fn getLevelFromMetersPerSubZone(&self, physicalMetersPerSubZone: f64, relativeDepth: i32) -> i32
   {
      let mut result: i32 = 0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getLevelFromMetersPerSubZone.unwrap()(self.imp, physicalMetersPerSubZone, relativeDepth);
         }
      }
      result
   }

   pub fn getLevelFromPixelsAndExtent(&self, extent: &dggal_sys::GeoExtent, pixels: &ecrt_sys::Point, relativeDepth: i32) -> i32
   {
      let mut result: i32 = 0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getLevelFromPixelsAndExtent.unwrap()(self.imp, extent, pixels, relativeDepth);
         }
      }
      result
   }

   pub fn getLevelFromRefZoneArea(&self, metersSquared: f64) -> i32
   {
      let mut result: i32 = 0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getLevelFromRefZoneArea.unwrap()(self.imp, metersSquared);
         }
      }
      result
   }

   pub fn getLevelFromScaleDenominator(&self, scaleDenominator: f64, relativeDepth: i32, mmPerPixel: f64) -> i32
   {
      let mut result: i32 = 0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getLevelFromScaleDenominator.unwrap()(self.imp, scaleDenominator, relativeDepth, mmPerPixel);
         }
      }
      result
   }

   pub fn getMetersPerSubZoneFromLevel(&self, parentLevel: i32, relativeDepth: i32) -> f64
   {
      let mut result: f64 = 0.0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getMetersPerSubZoneFromLevel.unwrap()(self.imp, parentLevel, relativeDepth);
         }
      }
      result
   }

   pub fn getRefZoneArea(&self, level: i32) -> f64
   {
      let mut result: f64 = 0.0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getRefZoneArea.unwrap()(self.imp, level);
         }
      }
      result
   }

   pub fn getScaleDenominatorFromLevel(&self, parentLevel: i32, relativeDepth: i32, mmPerPixel: f64) -> f64
   {
      let mut result: f64 = 0.0;
      unsafe
      {
         if self.imp != nullInst {
            result = dggal_sys::DGGRS_getScaleDenominatorFromLevel.unwrap()(self.imp, parentLevel, relativeDepth, mmPerPixel);
         }
      }
      result
   }
}
impl Drop for DGGRS {
   fn drop(&mut self)
   {
      unsafe {
         ecrt_sys::__eCNameSpace__eC__types__eInstance_DecRef(self.imp as ecrt_sys::Instance);
      }
   }
}

// NOTE: We may eventually change the File argument to a proper Rust struct/impl when added to ecrt
// For now ecrt_sys::fileOpen() can be used to obtain a File from a file name
pub fn readDGGSJSON(f: ecrt_sys::File) -> Option<dggal_sys::DGGSJSON>
{
   let mut result: Option<dggal_sys::DGGSJSON> = None;
   unsafe
   {
      if f != nullInst {
         let r: dggal_sys::DGGSJSON = dggal_sys::readDGGSJSON.unwrap()(f);
         if r != nullInst {
            result = Some(r)
         }
      }
   }
   result
}