Skip to content

Commit

Permalink
Interlis 1: remove write support
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 22, 2025
1 parent 00bc255 commit 80ca659
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 612 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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 1 -vector- (rov): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rw+v): Interlis 2 (*.xtf, *.xml, *.ili)
OGR_GMT -vector- (rw+v): GMT ASCII Vectors (.gmt) (*.gmt)
GPKG -raster,vector- (rw+vs): GeoPackage (*.gpkg, *.gpkg.zip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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 1 -vector- (rov): Interlis 1 (*.itf, *.ili)
Interlis 2 -vector- (rw+v): Interlis 2 (*.xtf, *.xml, *.ili)
OGR_GMT -vector- (rw+v): GMT ASCII Vectors (.gmt) (*.gmt)
GPKG -raster,vector- (rw+vs): GeoPackage (*.gpkg, *.gpkg.zip)
Expand Down
164 changes: 0 additions & 164 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
16 changes: 0 additions & 16 deletions ogr/ogrsf_frmts/ili/ogr_ili1.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class OGRILI1Layer final : public OGRLayer

GIntBig GetFeatureCount(int bForce = TRUE) override;

OGRErr ICreateFeature(OGRFeature *poFeature) override;
int GeometryAppend(OGRGeometry *poGeometry);

OGRFeatureDefn *GetLayerDefn() override
Expand All @@ -69,9 +68,6 @@ class OGRILI1Layer final : public OGRLayer
return oGeomFieldInfos;
}

OGRErr CreateField(const OGRFieldDefn *poField,
int bApproxOK = TRUE) override;

int TestCapability(const char *) override;

GDALDataset *GetDataset() override;
Expand All @@ -95,8 +91,6 @@ class OGRILI1DataSource final : public GDALDataset
private:
ImdReader *poImdReader;
IILI1Reader *poReader;
VSILFILE *fpTransfer;
char *pszTopic;
int nLayers;
OGRILI1Layer **papoLayers;

Expand All @@ -107,7 +101,6 @@ class OGRILI1DataSource final : public GDALDataset
virtual ~OGRILI1DataSource();

int Open(const char *, char **papszOpenOptions, int bTestOpen);
int Create(const char *pszFile, char **papszOptions);

int GetLayerCount() override
{
Expand All @@ -117,15 +110,6 @@ class OGRILI1DataSource final : public GDALDataset
OGRLayer *GetLayer(int) override;
OGRILI1Layer *GetLayerByName(const char *) override;

VSILFILE *GetTransferFile()
{
return fpTransfer;
}

OGRLayer *ICreateLayer(const char *pszName,
const OGRGeomFieldDefn *poGeomFieldDefn,
CSLConstList papszOptions) override;

int TestCapability(const char *) override;
};

Expand Down
Loading

0 comments on commit 80ca659

Please sign in to comment.