@@ -146,88 +146,6 @@ def test_ogr_interlis1_4():
146
146
pytest .fail ("field value wrong." )
147
147
148
148
149
- ###############################################################################
150
- # Write Ili1 transfer file without model.
151
-
152
-
153
- def test_ogr_interlis1_5 (tmp_path ):
154
-
155
- ds = ogr .Open ("data/ili/format-default.itf,data/ili/format-default.imd" )
156
-
157
- lyr = ds .GetLayerByName ("FormatTests__FormatTable" )
158
- feat = lyr .GetNextFeature ()
159
-
160
- driver = ogr .GetDriverByName ("Interlis 1" )
161
- outfile = tmp_path / "interlis1_5.itf"
162
-
163
- with gdal .quiet_errors ():
164
- dst_ds = driver .CreateDataSource (outfile )
165
-
166
- dst_lyr = dst_ds .CreateLayer ("FormatTests__FormatTable" )
167
-
168
- layer_defn = lyr .GetLayerDefn ()
169
- for i in range (layer_defn .GetFieldCount ()):
170
- dst_lyr .CreateField (layer_defn .GetFieldDefn (i ))
171
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
172
- dst_feat .SetFrom (feat )
173
- dst_lyr .CreateFeature (dst_feat )
174
-
175
- dst_ds = None
176
-
177
- with open (outfile ) as f :
178
- itf = f .read ()
179
- expected = """MTID INTERLIS1
180
- MODL OGR
181
- ETOP
182
- TOPI FormatTests
183
- TABL FormatTable
184
- OBJE 0 0 aa_bb cc^dd @ 1
185
- ETAB
186
- ETOP
187
- EMOD
188
- ENDE"""
189
- assert expected in itf , "Interlis output doesn't match."
190
-
191
-
192
- ###############################################################################
193
- # Write Ili1 transfer file.
194
-
195
-
196
- def test_ogr_interlis1_6 (tmp_path ):
197
-
198
- ds = ogr .Open ("data/ili/format-default.itf,data/ili/format-default.imd" )
199
- lyr = ds .GetLayerByName ("FormatTests__FormatTable" )
200
- feat = lyr .GetNextFeature ()
201
-
202
- driver = ogr .GetDriverByName ("Interlis 1" )
203
- outfile = tmp_path / "interlis1_6.itf"
204
- dst_ds = driver .CreateDataSource (f"{ outfile } ,data/ili/format-default.imd" )
205
-
206
- dst_lyr = dst_ds .CreateLayer ("test" )
207
-
208
- layer_defn = lyr .GetLayerDefn ()
209
- for i in range (layer_defn .GetFieldCount ()):
210
- dst_lyr .CreateField (layer_defn .GetFieldDefn (i ))
211
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
212
- dst_feat .SetFrom (feat )
213
- dst_lyr .CreateFeature (dst_feat )
214
-
215
- dst_ds = None
216
-
217
- with open (outfile ) as f :
218
- itf = f .read ()
219
- expected = """MTID INTERLIS1
220
- MODL FormatDefault
221
- TOPI FormatTests
222
- TABL test
223
- OBJE 1 0 aa_bb cc^dd @ 1
224
- ETAB
225
- ETOP
226
- EMOD
227
- ENDE"""
228
- assert expected in itf , "Interlis output doesn't match."
229
-
230
-
231
149
###############################################################################
232
150
# Ili1 character encoding test.
233
151
@@ -260,43 +178,6 @@ def test_ogr_interlis1_7(tmp_path):
260
178
print (feat .GetFieldAsString (i ))
261
179
pytest .fail ("field value wrong." )
262
180
263
- # Write back
264
- driver = ogr .GetDriverByName ("Interlis 1" )
265
- outfile = tmp_path / "interlis1_7.itf"
266
- dst_ds = driver .CreateDataSource (f"{ outfile } ,data/ili/format-default.imd" )
267
-
268
- dst_lyr = dst_ds .CreateLayer ("FormatTests__FormatTable" )
269
-
270
- layer_defn = lyr .GetLayerDefn ()
271
- for i in range (layer_defn .GetFieldCount ()):
272
- dst_lyr .CreateField (layer_defn .GetFieldDefn (i ))
273
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
274
- dst_feat .SetFrom (feat )
275
- dst_lyr .CreateFeature (dst_feat )
276
-
277
- dst_ds = None
278
-
279
- try :
280
- # Python 3
281
- f = open (outfile , encoding = "iso-8859-1" )
282
- except TypeError :
283
- f = open (outfile )
284
- itf = f .read ()
285
- expected = """MTID INTERLIS1
286
- MODL FormatDefault
287
- TABL FormatTable
288
- OBJE 2 0 äöü ÄÖÜ @ 1
289
- ETAB
290
- ETOP
291
- EMOD
292
- ENDE"""
293
- try :
294
- # Python 2
295
- expected = expected .decode ("utf8" ).encode ("iso-8859-1" )
296
- except Exception :
297
- pass
298
- assert expected in itf , "Interlis output doesn't match."
299
-
300
181
301
182
###############################################################################
302
183
# Ili1 VRT rename
@@ -801,51 +682,6 @@ def test_ogr_interlis1_13_linear():
801
682
ogrtest .check_feature_geometry (geom , geom_field_values [i ])
802
683
803
684
804
- ###############################################################################
805
- # Write Ili1 Arcs.
806
-
807
-
808
- def test_ogr_interlis1_14 (tmp_path ):
809
-
810
- ds = ogr .Open ("data/ili/Beispiel.itf,data/ili/Beispiel.imd" )
811
- lyr = ds .GetLayerByName ("Bodenbedeckung__Strasse" )
812
- feat = lyr .GetNextFeature ()
813
-
814
- driver = ogr .GetDriverByName ("Interlis 1" )
815
- outfile = tmp_path / "interlis1_14.itf"
816
- dst_ds = driver .CreateDataSource (f"{ outfile } ,data/ili/Beispiel.imd" )
817
-
818
- dst_lyr = dst_ds .CreateLayer ("Bodenbedeckung__Strasse" , None , ogr .wkbMultiCurve )
819
-
820
- layer_defn = lyr .GetLayerDefn ()
821
- for i in range (layer_defn .GetFieldCount ()):
822
- dst_lyr .CreateField (layer_defn .GetFieldDefn (i ))
823
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
824
- dst_feat .SetFrom (feat )
825
- dst_lyr .CreateFeature (dst_feat )
826
-
827
- dst_ds = None
828
-
829
- with open (outfile ) as f :
830
- itf = f .read ()
831
- expected = """////
832
- MTID INTERLIS1
833
- MODL Beispiel
834
- TABL Strasse
835
- OBJE 3 100
836
- STPT 190.26 208
837
- ARCP 187 186
838
- LIPT 173.1 171
839
- LIPT 141.08 152.94
840
- ELIN
841
- ETAB
842
- ETOP
843
- EMOD
844
- ENDE
845
- """
846
- assert expected in itf , "Interlis output doesn't match."
847
-
848
-
849
685
###############################################################################
850
686
# Reading Ili2 without model
851
687
@@ -950,95 +786,6 @@ def test_ogr_interlis2_2():
950
786
ogrtest .check_feature_geometry (geom , geom_field_values [i ])
951
787
952
788
953
- ###############################################################################
954
- # Write Ili2 transfer file.
955
-
956
-
957
- def test_ogr_interlis2_3 (tmp_path ):
958
-
959
- ds = ogr .Open ("data/ili/RoadsExdm2ien.xml,data/ili/RoadsExdm2ien.imd" )
960
-
961
- lyr = ds .GetLayerByName ("RoadsExdm2ien.RoadsExtended.RoadSign" )
962
- feat = lyr .GetNextFeature ()
963
-
964
- driver = ogr .GetDriverByName ("Interlis 2" )
965
- outfile = tmp_path / "interlis2_3.xtf"
966
- dst_ds = driver .CreateDataSource (f"{ outfile } ,data/ili/RoadsExdm2ien.imd" )
967
-
968
- dst_lyr = dst_ds .CreateLayer ("RoadsExdm2ien.RoadsExtended.RoadSign" )
969
-
970
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
971
- dst_feat .SetFrom (feat )
972
- dst_lyr .CreateFeature (dst_feat )
973
-
974
- lyr = ds .GetLayerByName ("RoadsExdm2ben.Roads.LandCover" )
975
- feat = lyr .GetNextFeature ()
976
-
977
- dst_lyr = dst_ds .CreateLayer ("RoadsExdm2ben.Roads.LandCover" )
978
-
979
- dst_feat = ogr .Feature (feature_def = dst_lyr .GetLayerDefn ())
980
- dst_feat .SetFrom (feat )
981
- dst_lyr .CreateFeature (dst_feat )
982
-
983
- dst_ds = None
984
-
985
- with open (outfile ) as f :
986
- xtf = f .read ()
987
- expected = """<?xml version="1.0" encoding="utf-8" ?>
988
- <TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3">
989
- <HEADERSECTION SENDER="OGR/GDAL"""
990
- assert expected in xtf , "Interlis output doesn't match."
991
- expected = """<MODELS>
992
- <MODEL NAME="RoadsExdm2ben" URI="http://www.interlis.ch/models" VERSION="2005-06-16"/>
993
- <MODEL NAME="RoadsExdm2ien" URI="http://www.interlis.ch/models" VERSION="2005-06-16"/>
994
- </MODELS>
995
- </HEADERSECTION>
996
- <DATASECTION>
997
- <RoadsExdm2ien.RoadsExtended BID="RoadsExdm2ien.RoadsExtended">
998
- <RoadsExdm2ien.RoadsExtended.RoadSign TID="501">
999
- <Position>
1000
- <COORD><C1>69.389</C1><C2>92.056</C2></COORD>
1001
- </Position>
1002
- <Type>prohibition.noparking</Type>
1003
- </RoadsExdm2ien.RoadsExtended.RoadSign>
1004
- <RoadsExdm2ben.Roads.LandCover TID="16">
1005
- <Geometry>
1006
- <SURFACE>
1007
- <BOUNDARY>
1008
- <POLYLINE>
1009
- <COORD><C1>39.038</C1><C2>60.315</C2></COORD>
1010
- <COORD><C1>41.2</C1><C2>59.302</C2></COORD>
1011
- <COORD><C1>43.362</C1><C2>60.315</C2></COORD>
1012
- <COORD><C1>44.713</C1><C2>66.268</C2></COORD>
1013
- <COORD><C1>45.794</C1><C2>67.66200000000001</C2></COORD>
1014
- <COORD><C1>48.766</C1><C2>67.408</C2></COORD>
1015
- <COORD><C1>53.36</C1><C2>64.11499999999999</C2></COORD>
1016
- <COORD><C1>56.197</C1><C2>62.595</C2></COORD>
1017
- <COORD><C1>57.818</C1><C2>63.862</C2></COORD>
1018
- <COORD><C1>58.899</C1><C2>68.928</C2></COORD>
1019
- <COORD><C1>55.927</C1><C2>72.348</C2></COORD>
1020
- <COORD><C1>47.955</C1><C2>75.515</C2></COORD>
1021
- <COORD><C1>42.281</C1><C2>75.38800000000001</C2></COORD>
1022
- <COORD><C1>39.308</C1><C2>73.235</C2></COORD>
1023
- <COORD><C1>36.741</C1><C2>69.688</C2></COORD>
1024
- <COORD><C1>35.525</C1><C2>66.268</C2></COORD>
1025
- <COORD><C1>35.661</C1><C2>63.735</C2></COORD>
1026
- <COORD><C1>37.957</C1><C2>61.455</C2></COORD>
1027
- <COORD><C1>39.038</C1><C2>60.315</C2></COORD>
1028
- </POLYLINE>
1029
- </BOUNDARY>
1030
- </SURFACE>
1031
- </Geometry>
1032
- <Type>water</Type>
1033
- </RoadsExdm2ben.Roads.LandCover>
1034
- </RoadsExdm2ien.RoadsExtended>
1035
- </DATASECTION>
1036
- </TRANSFER>"""
1037
- expected = expected .replace (".11499999999999" , ".115" )
1038
- xtf = xtf .replace (".11499999999999" , ".115" )
1039
- assert expected in xtf , "Interlis output doesn't match."
1040
-
1041
-
1042
789
###############################################################################
1043
790
# Ili2 Oereb model
1044
791
@@ -1199,22 +946,3 @@ def test_ogr_interlis_arc2():
1199
946
for i in range (feat .GetGeomFieldCount ()):
1200
947
geom = feat .GetGeomFieldRef (i )
1201
948
ogrtest .check_feature_geometry (geom , geom_field_values [i ])
1202
-
1203
-
1204
- ###############################################################################
1205
- # Test failure in creation of ILI2 dataset
1206
-
1207
-
1208
- def test_ogr_interlis2_create_file_error ():
1209
-
1210
- with pytest .raises (
1211
- Exception , match = "model file not specified in destination filename"
1212
- ):
1213
- ogr .GetDriverByName ("Interlis 2" ).CreateDataSource ("tmp/out.xtf" )
1214
-
1215
- with pytest .raises (
1216
- Exception , match = "Failed to create XTF file /i_do/not/exist/out.xtf"
1217
- ):
1218
- ogr .GetDriverByName ("Interlis 2" ).CreateDataSource (
1219
- "/i_do/not/exist/out.xtf,data/ili/ch.bazl.sicherheitszonenplan.oereb_20131118.imd"
1220
- )
0 commit comments