Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #171

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu_24.04/expected_ogrinfo_formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Supported Formats: (ro:read-only, rw:read-write, +:update, v:virtual-I/O s:subda
GeoJSONSeq -vector- (rw+v): GeoJSON Sequence (*.geojsonl, *.geojsons)
ESRIJSON -vector- (rov): ESRIJSON (*.json)
TopoJSON -vector- (rov): TopoJSON (*.json, *.topojson)
Interlis 1 -vector- (rw+v): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rw+v): Interlis 2 (*.xtf, *.xml, *.ili)
Interlis 1 -vector- (rov): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rov): Interlis 2 (*.xtf, *.xml, *.ili)
OGR_GMT -vector- (rw+v): GMT ASCII Vectors (.gmt) (*.gmt)
GPKG -raster,vector- (rw+vs): GeoPackage (*.gpkg, *.gpkg.zip)
SQLite -raster,vector- (rw+v): SQLite / Spatialite / RasterLite2 (*.sqlite, *.db)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows_conda_expected_ogrinfo_formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Supported Formats: (ro:read-only, rw:read-write, +:update, v:virtual-I/O s:subda
GeoJSONSeq -vector- (rw+v): GeoJSON Sequence (*.geojsonl, *.geojsons)
ESRIJSON -vector- (rov): ESRIJSON (*.json)
TopoJSON -vector- (rov): TopoJSON (*.json, *.topojson)
Interlis 1 -vector- (rw+v): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rw+v): Interlis 2 (*.xtf, *.xml, *.ili)
Interlis 1 -vector- (rov): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rov): Interlis 2 (*.xtf, *.xml, *.ili)
OGR_GMT -vector- (rw+v): GMT ASCII Vectors (.gmt) (*.gmt)
GPKG -raster,vector- (rw+vs): GeoPackage (*.gpkg, *.gpkg.zip)
SQLite -vector- (rw+v): SQLite / Spatialite (*.sqlite, *.db)
Expand Down
14 changes: 6 additions & 8 deletions autotest/gcore/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,14 @@ def test_cog_creation_of_overviews_with_compression():
assert ds.GetRasterBand(1).GetOverviewCount() == 2
assert ds.GetMetadata("IMAGE_STRUCTURE")["COMPRESSION"] == "LZW"

ds_overview_a = gdal.Open("GTIFF_DIR:2:" + filename)
assert ds_overview_a.GetMetadata("IMAGE_STRUCTURE")["COMPRESSION"] == "JPEG"
assert ds_overview_a.GetMetadata("IMAGE_STRUCTURE")["JPEG_QUALITY"] == "50"
with gdal.Open("GTIFF_DIR:2:" + filename) as ds_overview:
assert ds_overview.GetMetadata("IMAGE_STRUCTURE")["COMPRESSION"] == "JPEG"
assert ds_overview.GetMetadata("IMAGE_STRUCTURE")["JPEG_QUALITY"] == "50"

ds_overview_b = gdal.Open("GTIFF_DIR:3:" + filename)
assert ds_overview_b.GetMetadata("IMAGE_STRUCTURE")["COMPRESSION"] == "JPEG"
assert ds_overview_a.GetMetadata("IMAGE_STRUCTURE")["JPEG_QUALITY"] == "50"
with gdal.Open("GTIFF_DIR:3:" + filename) as ds_overview:
assert ds_overview.GetMetadata("IMAGE_STRUCTURE")["COMPRESSION"] == "JPEG"
assert ds_overview.GetMetadata("IMAGE_STRUCTURE")["JPEG_QUALITY"] == "50"

ds_overview_a = None
ds_overview_b = None
ds = None

src_ds = None
Expand Down
272 changes: 0 additions & 272 deletions autotest/ogr/ogr_ili.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,88 +146,6 @@ def test_ogr_interlis1_4():
pytest.fail("field value wrong.")


###############################################################################
# Write Ili1 transfer file without model.


def test_ogr_interlis1_5(tmp_path):

ds = ogr.Open("data/ili/format-default.itf,data/ili/format-default.imd")

lyr = ds.GetLayerByName("FormatTests__FormatTable")
feat = lyr.GetNextFeature()

driver = ogr.GetDriverByName("Interlis 1")
outfile = tmp_path / "interlis1_5.itf"

with gdal.quiet_errors():
dst_ds = driver.CreateDataSource(outfile)

dst_lyr = dst_ds.CreateLayer("FormatTests__FormatTable")

layer_defn = lyr.GetLayerDefn()
for i in range(layer_defn.GetFieldCount()):
dst_lyr.CreateField(layer_defn.GetFieldDefn(i))
dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

dst_ds = None

with open(outfile) as f:
itf = f.read()
expected = """MTID INTERLIS1
MODL OGR
ETOP
TOPI FormatTests
TABL FormatTable
OBJE 0 0 aa_bb cc^dd @ 1
ETAB
ETOP
EMOD
ENDE"""
assert expected in itf, "Interlis output doesn't match."


###############################################################################
# Write Ili1 transfer file.


def test_ogr_interlis1_6(tmp_path):

ds = ogr.Open("data/ili/format-default.itf,data/ili/format-default.imd")
lyr = ds.GetLayerByName("FormatTests__FormatTable")
feat = lyr.GetNextFeature()

driver = ogr.GetDriverByName("Interlis 1")
outfile = tmp_path / "interlis1_6.itf"
dst_ds = driver.CreateDataSource(f"{outfile},data/ili/format-default.imd")

dst_lyr = dst_ds.CreateLayer("test")

layer_defn = lyr.GetLayerDefn()
for i in range(layer_defn.GetFieldCount()):
dst_lyr.CreateField(layer_defn.GetFieldDefn(i))
dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

dst_ds = None

with open(outfile) as f:
itf = f.read()
expected = """MTID INTERLIS1
MODL FormatDefault
TOPI FormatTests
TABL test
OBJE 1 0 aa_bb cc^dd @ 1
ETAB
ETOP
EMOD
ENDE"""
assert expected in itf, "Interlis output doesn't match."


###############################################################################
# Ili1 character encoding test.

Expand Down Expand Up @@ -260,43 +178,6 @@ def test_ogr_interlis1_7(tmp_path):
print(feat.GetFieldAsString(i))
pytest.fail("field value wrong.")

# Write back
driver = ogr.GetDriverByName("Interlis 1")
outfile = tmp_path / "interlis1_7.itf"
dst_ds = driver.CreateDataSource(f"{outfile},data/ili/format-default.imd")

dst_lyr = dst_ds.CreateLayer("FormatTests__FormatTable")

layer_defn = lyr.GetLayerDefn()
for i in range(layer_defn.GetFieldCount()):
dst_lyr.CreateField(layer_defn.GetFieldDefn(i))
dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

dst_ds = None

try:
# Python 3
f = open(outfile, encoding="iso-8859-1")
except TypeError:
f = open(outfile)
itf = f.read()
expected = """MTID INTERLIS1
MODL FormatDefault
TABL FormatTable
OBJE 2 0 äöü ÄÖÜ @ 1
ETAB
ETOP
EMOD
ENDE"""
try:
# Python 2
expected = expected.decode("utf8").encode("iso-8859-1")
except Exception:
pass
assert expected in itf, "Interlis output doesn't match."


###############################################################################
# Ili1 VRT rename
Expand Down Expand Up @@ -801,51 +682,6 @@ def test_ogr_interlis1_13_linear():
ogrtest.check_feature_geometry(geom, geom_field_values[i])


###############################################################################
# Write Ili1 Arcs.


def test_ogr_interlis1_14(tmp_path):

ds = ogr.Open("data/ili/Beispiel.itf,data/ili/Beispiel.imd")
lyr = ds.GetLayerByName("Bodenbedeckung__Strasse")
feat = lyr.GetNextFeature()

driver = ogr.GetDriverByName("Interlis 1")
outfile = tmp_path / "interlis1_14.itf"
dst_ds = driver.CreateDataSource(f"{outfile},data/ili/Beispiel.imd")

dst_lyr = dst_ds.CreateLayer("Bodenbedeckung__Strasse", None, ogr.wkbMultiCurve)

layer_defn = lyr.GetLayerDefn()
for i in range(layer_defn.GetFieldCount()):
dst_lyr.CreateField(layer_defn.GetFieldDefn(i))
dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

dst_ds = None

with open(outfile) as f:
itf = f.read()
expected = """////
MTID INTERLIS1
MODL Beispiel
TABL Strasse
OBJE 3 100
STPT 190.26 208
ARCP 187 186
LIPT 173.1 171
LIPT 141.08 152.94
ELIN
ETAB
ETOP
EMOD
ENDE
"""
assert expected in itf, "Interlis output doesn't match."


###############################################################################
# Reading Ili2 without model

Expand Down Expand Up @@ -950,95 +786,6 @@ def test_ogr_interlis2_2():
ogrtest.check_feature_geometry(geom, geom_field_values[i])


###############################################################################
# Write Ili2 transfer file.


def test_ogr_interlis2_3(tmp_path):

ds = ogr.Open("data/ili/RoadsExdm2ien.xml,data/ili/RoadsExdm2ien.imd")

lyr = ds.GetLayerByName("RoadsExdm2ien.RoadsExtended.RoadSign")
feat = lyr.GetNextFeature()

driver = ogr.GetDriverByName("Interlis 2")
outfile = tmp_path / "interlis2_3.xtf"
dst_ds = driver.CreateDataSource(f"{outfile},data/ili/RoadsExdm2ien.imd")

dst_lyr = dst_ds.CreateLayer("RoadsExdm2ien.RoadsExtended.RoadSign")

dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

lyr = ds.GetLayerByName("RoadsExdm2ben.Roads.LandCover")
feat = lyr.GetNextFeature()

dst_lyr = dst_ds.CreateLayer("RoadsExdm2ben.Roads.LandCover")

dst_feat = ogr.Feature(feature_def=dst_lyr.GetLayerDefn())
dst_feat.SetFrom(feat)
dst_lyr.CreateFeature(dst_feat)

dst_ds = None

with open(outfile) as f:
xtf = f.read()
expected = """<?xml version="1.0" encoding="utf-8" ?>
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3">
<HEADERSECTION SENDER="OGR/GDAL"""
assert expected in xtf, "Interlis output doesn't match."
expected = """<MODELS>
<MODEL NAME="RoadsExdm2ben" URI="http://www.interlis.ch/models" VERSION="2005-06-16"/>
<MODEL NAME="RoadsExdm2ien" URI="http://www.interlis.ch/models" VERSION="2005-06-16"/>
</MODELS>
</HEADERSECTION>
<DATASECTION>
<RoadsExdm2ien.RoadsExtended BID="RoadsExdm2ien.RoadsExtended">
<RoadsExdm2ien.RoadsExtended.RoadSign TID="501">
<Position>
<COORD><C1>69.389</C1><C2>92.056</C2></COORD>
</Position>
<Type>prohibition.noparking</Type>
</RoadsExdm2ien.RoadsExtended.RoadSign>
<RoadsExdm2ben.Roads.LandCover TID="16">
<Geometry>
<SURFACE>
<BOUNDARY>
<POLYLINE>
<COORD><C1>39.038</C1><C2>60.315</C2></COORD>
<COORD><C1>41.2</C1><C2>59.302</C2></COORD>
<COORD><C1>43.362</C1><C2>60.315</C2></COORD>
<COORD><C1>44.713</C1><C2>66.268</C2></COORD>
<COORD><C1>45.794</C1><C2>67.66200000000001</C2></COORD>
<COORD><C1>48.766</C1><C2>67.408</C2></COORD>
<COORD><C1>53.36</C1><C2>64.11499999999999</C2></COORD>
<COORD><C1>56.197</C1><C2>62.595</C2></COORD>
<COORD><C1>57.818</C1><C2>63.862</C2></COORD>
<COORD><C1>58.899</C1><C2>68.928</C2></COORD>
<COORD><C1>55.927</C1><C2>72.348</C2></COORD>
<COORD><C1>47.955</C1><C2>75.515</C2></COORD>
<COORD><C1>42.281</C1><C2>75.38800000000001</C2></COORD>
<COORD><C1>39.308</C1><C2>73.235</C2></COORD>
<COORD><C1>36.741</C1><C2>69.688</C2></COORD>
<COORD><C1>35.525</C1><C2>66.268</C2></COORD>
<COORD><C1>35.661</C1><C2>63.735</C2></COORD>
<COORD><C1>37.957</C1><C2>61.455</C2></COORD>
<COORD><C1>39.038</C1><C2>60.315</C2></COORD>
</POLYLINE>
</BOUNDARY>
</SURFACE>
</Geometry>
<Type>water</Type>
</RoadsExdm2ben.Roads.LandCover>
</RoadsExdm2ien.RoadsExtended>
</DATASECTION>
</TRANSFER>"""
expected = expected.replace(".11499999999999", ".115")
xtf = xtf.replace(".11499999999999", ".115")
assert expected in xtf, "Interlis output doesn't match."


###############################################################################
# Ili2 Oereb model

Expand Down Expand Up @@ -1199,22 +946,3 @@ def test_ogr_interlis_arc2():
for i in range(feat.GetGeomFieldCount()):
geom = feat.GetGeomFieldRef(i)
ogrtest.check_feature_geometry(geom, geom_field_values[i])


###############################################################################
# Test failure in creation of ILI2 dataset


def test_ogr_interlis2_create_file_error():

with pytest.raises(
Exception, match="model file not specified in destination filename"
):
ogr.GetDriverByName("Interlis 2").CreateDataSource("tmp/out.xtf")

with pytest.raises(
Exception, match="Failed to create XTF file /i_do/not/exist/out.xtf"
):
ogr.GetDriverByName("Interlis 2").CreateDataSource(
"/i_do/not/exist/out.xtf,data/ili/ch.bazl.sicherheitszonenplan.oereb_20131118.imd"
)
12 changes: 2 additions & 10 deletions doc/source/drivers/vector/ili.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.. build_dependencies:: Xerces

| OGR has support for INTERLIS reading and writing.
| OGR has support for INTERLIS reading.
| `INTERLIS <http://www.interlis.ch/>`__ is a standard which has been
especially composed in order to fulfill the requirements of modeling
and the integration of geodata into contemporary and future geographic
Expand Down Expand Up @@ -37,16 +37,14 @@ limitations:
Driver capabilities
-------------------

.. supports_create::

.. supports_georeferencing::

.. supports_virtualio::

Model support
-------------

Data is read and written into transfer files which have different
Data is read from transfer files which have different
formats in INTERLIS 1 (.itf) and INTERLIS 2 (.xtf). Models are passed in
IlisMeta format by using "a_filename.xtf,models.imd" as a connection
string.
Expand Down Expand Up @@ -84,12 +82,6 @@ Some possible transformations using :ref:`ogr2ogr`.

ogr2ogr --config OGR_STROKE_CURVE TRUE -SQL 'SELECT Rechtsstatus,publiziertAb,MetadatenGeobasisdaten,Eigentumsbeschraenkung,ZustaendigeStelle,Flaeche FROM "OeREBKRM09trsfr.Transferstruktur.Geometrie"' shpdir ch.bazl.sicherheitszonenplan.oereb_20131118.xtf,OeREBKRM09vs.imd OeREBKRM09trsfr.Transferstruktur.Geometrie

- Shape -> Interlis 2:

::

ogr2ogr -f "Interlis 2" LandCover.xml,RoadsExdm2ien.imd RoadsExdm2ben.Roads.LandCover.shp

- Importing multiple Interlis 1 files into PostGIS:

::
Expand Down
Loading
Loading