From 22ebf22a8b38d0ac20b931dbf422327bafd8498e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 30 Oct 2024 23:45:07 +0100 Subject: [PATCH] test: OpenFileGDB: verify that we can generate an output that is byte-identical to the expected golden file. --- .../polygon_golden.gdb/a00000001.gdbtable | Bin 0 -> 333 bytes .../polygon_golden.gdb/a00000001.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000002.gdbtable | Bin 0 -> 2067 bytes .../polygon_golden.gdb/a00000002.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000003.gdbtable | Bin 0 -> 770 bytes .../polygon_golden.gdb/a00000003.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000004.gdbtable | Bin 0 -> 4427 bytes .../polygon_golden.gdb/a00000004.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000005.gdbtable | Bin 0 -> 1717 bytes .../polygon_golden.gdb/a00000005.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000006.gdbtable | Bin 0 -> 275 bytes .../polygon_golden.gdb/a00000006.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000007.gdbtable | Bin 0 -> 2275 bytes .../polygon_golden.gdb/a00000007.gdbtablx | Bin 0 -> 4128 bytes .../polygon_golden.gdb/a00000009.gdbindexes | Bin 0 -> 116 bytes .../polygon_golden.gdb/a00000009.gdbtable | Bin 0 -> 604 bytes .../polygon_golden.gdb/a00000009.gdbtablx | Bin 0 -> 5152 bytes .../polygon_golden.gdb/a00000009.spx | Bin 0 -> 4118 bytes .../data/openfilegdb/polygon_golden.gdb/gdb | Bin 0 -> 8 bytes .../openfilegdb/polygon_golden.gdb/timestamps | 1 + autotest/ogr/ogr_openfilegdb_write.py | 30 +++++++++ ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h | 2 +- .../ogropenfilegdb_generate_uuid.cpp | 57 +++++++++++++----- .../ogropenfilegdbdatasource_write.cpp | 2 + 24 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000002.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000002.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000004.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000004.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000005.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000005.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000006.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000006.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbindexes create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtable create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtablx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.spx create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/gdb create mode 100644 autotest/ogr/data/openfilegdb/polygon_golden.gdb/timestamps diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..ca18a72cc503a9e7b56890f1a4153f320980aa8d GIT binary patch literal 333 zcmZvWTZ+Ok7=@2DBUDiF3gd%oa0}LAQM^F)eFze3A(~?AgS(jx%obdVTW|}WWb8am z;E?cr=l@9+fX@WX2UDI^<@Ysy1Hn5ACrjJ2Z_roa%@G1M;fXaQPEeHJu2G*Mg(jH6 z;6f!)a7YL|e(ui!JMAb8zP7i#P^YOZq&5j5T1?%VFxXws+z0e5cI8YKsnoGL^vUXxc`sGM(<_(j*>{`{^c% LBV`ub&6)%+%d$S+ literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000001.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..d3c0d9e20c025326ddd07149457a5d60155964f4 GIT binary patch literal 4128 zcmeI#F%7^l30QLYs_8O@fkCZ2S|y zz^CvF`~kvto3u{jLM5w?eeXHvUSD4~000MMgk&_yD1Q4}v)SwU!Up*t^pQ^O=p5Vt zpaC{N03Td~Zy*6F7?T~yws+2fM;1H~k?ov}6d3cb!lWe=pBMy$_!8K}C?&I)%n3T7 zZh~Jwe*W$ev_D&YMMaK|?M+8>v2uYA@E0GB{lJ?}aya&KF9;_-93^oOUQSal50kh< zbu2vh2)Q^CzQAzt6F0%X9-WDes@X@rh`pY*9@f)a7YE1(>w_#q}oL6 zuLLM7ReOs-nE@@__td4$>UD+mF;6N@lFyZJpVfGC#lIlJ)bv3aAu{@IJu5rvnozxX z3~MBu{tI_a@a(kKX%fVuQqDbcKP{vgZqcH4S&N#jm8~lG)6@&&tn68Qt9n_Bv_>+k z>=kN(PL}igL(@i@+(#JM3NF>QiQ3r?>#OWuFS2fV8Bq=eIqy={B3!<6Eee1Yr@%>| z-=I8qdHtF}??pvDyPr{#dEtmPq|DD@7_+Ow=lfWQxY7>UGr=OQRZzXoOHW2eOj6cA b-`HOWJ-E!wADbhgHQ(Oovmy?-{)zbuC0baI literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000002.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000002.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..29323984e52a12627a75978f1a2aeaec6f6926ad GIT binary patch literal 4128 zcmeI$u?>Pi7>3~wPjLYzK!&iTwY0Hy09b+!!wM#hU}C`n4q#{OOsHvWX?V{a?7mB$ z;&RD<$=lrpNeOmX1Aj3>e|%0xsYJF5m(#-~uk-0xsYJF5m(#@V^2)@qd2;@rDK3`w}_; literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..29b5907954ae360324c6349dc8738bb60ca1ed8a GIT binary patch literal 770 zcmZQ(U|?VZ;y*yl3dAtL#0+5>Km}NUw7ZL=4@ez|&A`aOz{9}g$>74kz{bMF7R(UD z5W?Wf5CJ5C3OGOnn;SzSLk>eRLn=_1ftiC9StJr7!XCj8$q>qr$B@ZT0#u2vDhetR zg-4AqRE;mX8g7u;Aq@FIH>5HY0o{_vkPKvj?cj>SDdUSv=HA+U@1KJF{%0biyQ{yu zb8xg0kcba=4~{pqv@lW9ad8X@^^I0?K@tiM@NfUX+@eSDu-ip`>G=XAr9s>gO2(G&eOJC=M1fG&eCd zHnKD_HMF!eF$QV{xr?D8?Er{kXb1z-4J~?(V1CvQFrT60umd{3_wCjN-;W)z`?K=n jCEug~dl)^qJ<3oC@eq_wJ$sg*M?e2zOX>1*#_%Wr1Usua literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000003.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..4cf22da58b1f323ad40ede26792206c5452032a7 GIT binary patch literal 4128 zcmeI$xeWjy3*G(i{iUmfQ*(44e^(+Rz*YNVNVx;aiCMt}eT0t5&UAV7cs0RjXF Ld@a!bfUfrdb<6-+ literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000004.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000004.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..e731d3f0c724cebe0b0fbdf92b1e1bb710030c98 GIT binary patch literal 4427 zcmdT{O>7%Q6no{)W*z!6}X%baiXKZg-@0#5W zafEO#2aRkHEefT!4!}panKmKmvFq zvOBT}i;i&M=6(Uz~j4?P^hc4ImCNf=FZ+ zwKyy>KtUUV3K`bX1KXV=0kA7_4^GnI92_2}0y?z8030FmkK@|*1T=REdlsPq^S&6B z(4jUiM8~g{i#40V{rQ5!fe-Do=McDzYQ!4!_2U~L=(oFU0(i({KXT@pVj>`~?_equOs z1IMi5=#CF%Tr^?9+Q2}yaBb920qAIyzldp4L7%A)G#nk5AFvWQPa5Y)vAOBIbj3Nu zQtqsKagzbI+Mm$|w$8A2>!o;s$ro=j8D9DP9^jb&kxhg2A(|m%LkwSc?^ZYjh{a(9b9?;&$&zczdHQx zq4}zjA6)yAJX*T+*w?wsKYsTSX2A;3IX>Er^y~cb?yOT7f?I6POk}y~d{mT5{s7}>p^bx}>LA ze8Fs$D>9!D;wjEG8(8X)%|oVT2nqgdbzWwc6RK|6irylD)xC|7YpKkw6P)AR z@sQVCJ~}=w78P63j80v#yZIH74~ta2p!5ju5WA|jW)i(L=qvgfSQ` zG);_2o`!mp{^GrO@#SkDeDTe%e|7c`tbXkBp40De zvEP4Ne*0FmR&JDuaayh|ux_bFy9ZVRm>vN778;Xh3-uCgJ$AqO>?g1n!1az&zv###!vnG>9{ z0HErkqI& zd}@YhEYzd6cOSUzY|x5%#Bx^Ty`YcdBQi()Ncs|LzKawDwb7Ab4sS%NU_5r{lp5^31ww;(j?H_eG```JqKS zeh$a@!QvF`-2H?KclRDqa+7H1Fr^>LFtrV1r)2t%uWa@z^ApZ_2i+sKPD1P)+R02N zHTi#pcbhC5fh?zz&C_c0Tqc>yq!O9rL^hWwOe7MLFmb9>oSYDZtdNzJ{eKtf5S~tMrM_^UiqP z&^9}Uj%UtS`((Bm;o`wK0ZNHj0IS}0h4o$VTnIeJVuM<_uh^=hRq&282jrRQg@DRWu9} zud0eo|7n2Ij#p*IAg&?^;TWVn0SmpxS zWNIp#NKM6sSTdK5Co@w?OrXis>T0ass8mZhLfIrl-%wj!E+)i<)!5=frHSK`4&n?- zOr@SU0v>_9CkX+}OSydy=w9?J;rL%Jw0t5&UAV7cs0RjXF O5FkL{S%LlsbUi<)AOXt& literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000005.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000005.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..d717f9fa1a7ccca3e538f9d5fa8cf85a6a3424ce GIT binary patch literal 1717 zcmZ{k4NMbP9Ka7KEjXa^VO-p@RYz-a&LOp9%rEE%r3_jqWiDZ2UXMpTXnXD570MKY z2#havMCTT5$&eD`G9)H~qK;)QBbi3$f|%(lnaefe)5*DJ0fCNc!gr3k4gisJE zC?!gt{8%Cr#1#>MU=ZOzgqf%#oM;{*(L;d&J+z|*Lhxzmy%YT-Gg34g?~iVJw12hg z;OAQ}PlyyPXz4$fK+i$@YP3Xe@yuO@DcXI@u4Ogf9y^VT!d%)`0hu&}%DvYYoR6i3 z4|fk7XfOX}4o725kfq%W3FQcG>%J{-Sg;qi$qYZA2G)997HI$nSjeR!_GbN^zoq$S zvyZO0|MmCFQ+2o-Wu_eK5NBE0bt8F$L+A6anYr*4m4$QhITn^<0Lhtw#Re6~xO+l4 zR2KBAo4gKh>fVxFxRGRnHo#G|gWX9vC2AXBS-xI+7t0L>wyD|#!;B%LFCEv!xe#z} z21*u#$UshIyNewjXnnh{_`BeeyD|yxB6pn?Q#mbFf555Y zbFBsuZpD~sCvBsxb+02B%F=(U&IxKp6ozG8)jbh7oKWIsYGB>Jzp6FTKi(Z#sq5T3 zu@xj8a^Xs13Aq#6Q3}Yg#TV~=>V+SNHdd)VIqtaUA3ZgOTOu<}+bpza4PwQQ+0h2Z znBANqac}=&UWl`?+fb;i6OeENqH7;?2YOeW(6(Pqf6EkkJ%H26PicwP!$Aj&YQtwY zN|shDKD1qT%6RT$v1;xx?j=5@!*TG61RjJ+72iOAM$~| z8-|xH>ghOy=v|Ksj_21oQw~*Y^cfkZtAt(EI;Wzu4zcSRW_R`7{-kR6JR;W zgoEIfhY>@{YubhU{41m<=O>s)HJDM1Pl{2)mRKeG{LX|igt%e6p{s)g4A_^3SJlj^>y0;Jtt9DP9QKx~jEb_NcAh9rh8hE#@Rh7tx( z1{VefHWnt9P=-(lhg*#asG^7=lOY|5^B{s;YAkFnKrO{EEkFU55Qa*I0-zuRki+E& zlqmsgOJXPmvOsDXcov;6aUeSAG`PyKUbrJi%!=e0*JzWk8B`eVhNCnjs0ce%^> Lt-kR5ILOxkzrH=A literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000006.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000006.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..92567c81d8c1463bcc7e6f912a8114cd652bebaa GIT binary patch literal 4128 zcmeI$!3h8$3 literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..3e11ac8a531f4d811a970f84358edd1ddca14a9c GIT binary patch literal 2275 zcmah~4NMeA6n^M|p!^*2b5&4Q8YvC7B4BM1wQ$G53EUNWq&1{5%iZ3wa_n-u3mg#} zi~Jozp^Y@D6j}lV!fz=ttwe2VNNpsxwA9!tAk{`%T4GVt5<+8V@AiOOO>dLQ%$xb% z`@VVeW_CRQNKu&{3~m6P;HiOJI0gjhfCCjM06Zk? zB-xN{H#SB{d^NxT2}U%*AzT4yp%e-Bs8Ui{QrZf5T_i)p%62U1X4B%-U3+X4%7XY?(5L-udZRK zkAC;Pe!;;`5I-76OBpG#`!J9Kq=Lu{3|iX#df zBtCMQ;&75;F@82cun0Y-q68v0u<$HL;&p8!%2Y+Q$4|X?KKt}Vm6_$vO}>$2m7HhP zF`d!Y)|-(h9~Wd;Bh+_>aN`M?0_Sj+;1Cgkb43gx*wPh3VIstt(+TW`vWvKT7c7&% z#`VcZQbN_eN$L!#9fw1|h&-L3^Hb0TD1j{? zkM-ZF!0+cKvdqPX`JM7=F3Cq}RB!OIu!XxS*B@>T-}UEQPV-W*aAa~5&ax^>OBd26 z+E^O)dLason@pux22SBdg2eKLBZZ&~2#z6jYJw}FnS57rc8KMy1i*v{0FAsZ zU1ikp2b*Ft-XHbUKRfVY?ulh{$?5h9P5Dk;i|qHdJz`y<&bowP!qK==6(&|CxI3y4 z(96T;N?F_J@BejbIT@gtI&@Da*0leE$F&wqW_r(3hw;5AD-oo{b4`Sbau(y`I49ex zYwCA+>d8kxWXr~4)ZJH7j%=?pPwy+*Tda>AOzpU2NhpgvHzrO;kaIe;1jC^F;3^L? zaUKLefI418Pfq-snR^EkYrFj`%^$yPC1X#vUp}f+jm!kxU-p_}#Ui#ki$KA3gh`3# zqH=MiWSdxt-5Ilc1A6R{o|($VqYW0Vd>|q2oA|f8D#Uuk=Mf;B$66uIr{RjWny0<1 zXr7H-+?>|f_L6#ZYV@FZ+w}nLbKb`^ElbM5^0NmXgk}+i48fw`hV2Q^7}lo6QMdNn ziaA5KteEKW7rg91fMQffB*mh literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000007.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..8a2df70bfbfb25c52f017037fbeb1b12dd6cef4d GIT binary patch literal 4128 zcmeI$I}Lz95Jk}k%dezI0vgb<9StZ!3r82#@ZuEo0f)4R%Q~HMj{InCz~Dg%DFHb V{rA@PeIEn{cK=Wbo?or+as&A53=;qV literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtable b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtable new file mode 100644 index 0000000000000000000000000000000000000000..5cde63fc1c8e5395467db1421f39199af3bf5bd7 GIT binary patch literal 604 zcmZuvJx>Bb5PioToQXfco|+Jj!w+I2BA7$s3E?0XYKSO)6`If(yDN=_m93qH7XAPm zbBQ$#g_YV^nkdG`g2K0ZOJbCr+|2CE+cz`2rvuRVy;4PKhig3&dMOn!Xq{qyS>S|k z=zxx>hZ6FrVi7Q5#x;jt1r7@Eu!gwunpmahp$Q9F%pk)|0!5yzqXAbUi_DHfd1Nn< zwMO10o)N60a8s}`O>RrtBvP!9merE9lgy?UeWe!~67~(n+Ga~v9jws?? yHU0!IxAz~So55_<(EQ;2yf?1&#oLqaOXWXbUQPH?!@qvKGo=cICl&P8X6FYhe{cH$ literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtablx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.gdbtablx new file mode 100644 index 0000000000000000000000000000000000000000..c8318b15c83414f99a0dd89e985d8e946dd01ab3 GIT binary patch literal 5152 zcmeI$!3h8$3-aqghxB=4G044wc literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.spx b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/a00000009.spx new file mode 100644 index 0000000000000000000000000000000000000000..44769469081c5b257ffbc01a78a1837d109dc375 GIT binary patch literal 4118 zcmZQzU|?VdVh~_N!eD_>Vl)IsLtr!nMnizy5KsVW6abd1U>e9?0OAAjC>RZa(GVC7 ffzc2c4S~@R7!85Z5Eu=C0SN&P2UxEkc@zKu*C7FB literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/gdb b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/gdb new file mode 100644 index 0000000000000000000000000000000000000000..506f9c6282948917a4e1036b503d10efe5d0ae2f GIT binary patch literal 8 PcmZQ&U|_hncHesd2pR)E literal 0 HcmV?d00001 diff --git a/autotest/ogr/data/openfilegdb/polygon_golden.gdb/timestamps b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/timestamps new file mode 100644 index 000000000000..05d2b9440ec0 --- /dev/null +++ b/autotest/ogr/data/openfilegdb/polygon_golden.gdb/timestamps @@ -0,0 +1 @@ +ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ \ No newline at end of file diff --git a/autotest/ogr/ogr_openfilegdb_write.py b/autotest/ogr/ogr_openfilegdb_write.py index ad2ccf036bb6..d2b0486267a4 100755 --- a/autotest/ogr/ogr_openfilegdb_write.py +++ b/autotest/ogr/ogr_openfilegdb_write.py @@ -13,6 +13,7 @@ # SPDX-License-Identifier: MIT ############################################################################### +import os import struct import sys @@ -4571,3 +4572,32 @@ def test_ogr_openfilegdb_write_OGRUnsetMarker(tmp_vsimem): lyr = ds.GetLayer(0) f = lyr.GetNextFeature() assert f["i32"] == -21121 + + +############################################################################### +# Verify that we can generate an output that is byte-identical to the expected golden file. + + +@pytest.mark.parametrize( + "src_directory", + [ + # Generated with: + # ogr2ogr autotest/ogr/data/openfilegdb/polygon_golden.gdb '{"type":"Feature","properties":{"foo":"bar"},"geometry":{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,0],[0,0]]]}}' --config OPENFILEGDB_CREATOR GDAL --config OPENFILEGDB_REPRODUCIBLE_UUID YES -f openfilegdb + "data/openfilegdb/polygon_golden.gdb", + ], +) +def test_ogr_openfilegdb_write_check_golden_file(tmp_path, src_directory): + + out_directory = str(tmp_path / "test.gdb") + with gdaltest.config_options( + {"OPENFILEGDB_CREATOR": "GDAL", "OPENFILEGDB_REPRODUCIBLE_UUID": "YES"} + ): + gdal.VectorTranslate(out_directory, src_directory, format="OpenFileGDB") + for filename in os.listdir(src_directory): + src_filename = os.path.join(src_directory, filename) + out_filename = os.path.join(out_directory, filename) + + assert os.stat(src_filename).st_size == os.stat(out_filename).st_size, filename + assert ( + open(src_filename, "rb").read() == open(out_filename, "rb").read() + ), filename diff --git a/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h b/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h index ae2a5f3e3d0f..36c29b23f3a9 100644 --- a/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h +++ b/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h @@ -28,7 +28,7 @@ using namespace OpenFileGDB; -std::string OFGDBGenerateUUID(); +std::string OFGDBGenerateUUID(bool bInit = false); int OGROpenFileGDBIsComparisonOp(int op); diff --git a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp index 4198263416ac..a8aa87b1341e 100644 --- a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp +++ b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp @@ -54,7 +54,7 @@ static int CPLGettimeofday(struct CPLTimeVal *tp, void * /* timezonep*/) // Probably not the best UUID generator ever. One issue is that mt19937 // uses only a 32-bit seed. CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW -std::string OFGDBGenerateUUID() +std::string OFGDBGenerateUUID(bool bInit) { struct CPLTimeVal tv; memset(&tv, 0, sizeof(tv)); @@ -62,57 +62,82 @@ std::string OFGDBGenerateUUID() const bool bReproducibleUUID = CPLTestBool(CPLGetConfigOption("OPENFILEGDB_REPRODUCIBLE_UUID", "NO")); + if (bInit) + { + if (bReproducibleUUID) + nCounter = 0; + return std::string(); + } + + uint32_t nCounterLocal = nCounter; + // From POSIX.1-2001 as an example of an implementation of rand() + // for reproducible output. + // We have to use that rather than relying on std::mt19937 + + // std::uniform_int_distribution since they don't given the same output + // from the same seed on all platforms. + const auto reproducibleRand = [&nCounterLocal]() + { + nCounterLocal = nCounterLocal * 1103515245U + 12345U; + return (nCounterLocal / 65536U) % 32768U; + }; + std::stringstream ss; { if (!bReproducibleUUID) + { CPLGettimeofday(&tv, nullptr); - std::mt19937 gen(++nCounter + - (bReproducibleUUID - ? 0 - : static_cast(tv.tv_sec ^ tv.tv_usec))); + ++nCounter; + } + std::mt19937 gen(nCounter + + static_cast(tv.tv_sec ^ tv.tv_usec)); std::uniform_int_distribution<> dis(0, 15); ss << "{"; ss << std::hex; for (int i = 0; i < 8; i++) { - ss << dis(gen); + ss << (bReproducibleUUID ? (reproducibleRand() % 16) : dis(gen)); } ss << "-"; for (int i = 0; i < 4; i++) { - ss << dis(gen); + ss << (bReproducibleUUID ? (reproducibleRand() % 16) : dis(gen)); } ss << "-4"; for (int i = 0; i < 3; i++) { - ss << dis(gen); + ss << (bReproducibleUUID ? (reproducibleRand() % 16) : dis(gen)); } } { if (!bReproducibleUUID) + { CPLGettimeofday(&tv, nullptr); - std::mt19937 gen(++nCounter + - (bReproducibleUUID - ? 0 - : static_cast(tv.tv_sec ^ tv.tv_usec))); + ++nCounter; + } + std::mt19937 gen(nCounter + + static_cast(tv.tv_sec ^ tv.tv_usec)); std::uniform_int_distribution<> dis(0, 15); std::uniform_int_distribution<> dis2(8, 11); ss << "-"; - ss << dis2(gen); + ss << (bReproducibleUUID ? 8 : dis2(gen)); for (int i = 0; i < 3; i++) { - ss << dis(gen); + ss << (bReproducibleUUID ? (reproducibleRand() % 16) : dis(gen)); } ss << "-"; for (int i = 0; i < 12; i++) { - ss << dis(gen); + ss << (bReproducibleUUID ? (reproducibleRand() % 16) : dis(gen)); }; ss << "}"; - return ss.str(); } + + if (bReproducibleUUID) + nCounter = nCounterLocal; + + return ss.str(); } diff --git a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource_write.cpp b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource_write.cpp index f6e54d500998..27ba3a2dd9f4 100644 --- a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource_write.cpp +++ b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource_write.cpp @@ -1299,6 +1299,8 @@ bool OGROpenFileGDBDataSource::Create(const char *pszName) return false; } + CPL_IGNORE_RET_VAL(OFGDBGenerateUUID(/* bInit = */ true)); + m_osDirName = pszName; eAccess = GA_Update;