Skip to content

Commit

Permalink
Merge branch 'OSGeo:master' into i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
yoichigmf authored Jul 10, 2024
2 parents 3326f1e + 428881b commit b239457
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 270 deletions.
172 changes: 80 additions & 92 deletions apps/ogr2ogr_lib.cpp

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions autotest/alg/polygonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def test_polygonize_1(is_int_polygonize):
"POLYGON ((440720 3751200,440720 3751020,440900 3751020,440900 3751200,440720 3751200),(440780 3751140,440840 3751140,440840 3751080,440780 3751080,440780 3751140))",
)

feat_read.Destroy()


###############################################################################
# Test a simple case without masking.
Expand Down Expand Up @@ -173,8 +171,6 @@ def test_polygonize_3():
"POLYGON ((6 -3,6 -40,19 -40,19 -39,25 -39,25 -38,27 -38,27 -37,28 -37,28 -36,29 -36,29 -35,30 -35,30 -34,31 -34,31 -25,30 -25,30 -24,29 -24,29 -23,28 -23,28 -22,27 -22,27 -21,24 -21,24 -20,23 -20,23 -19,26 -19,26 -18,27 -18,27 -17,28 -17,28 -16,29 -16,29 -8,28 -8,28 -7,27 -7,27 -6,26 -6,26 -5,24 -5,24 -4,18 -4,18 -3,6 -3),(11 -7,23 -7,23 -8,24 -8,24 -9,25 -9,25 -16,24 -16,24 -17,23 -17,23 -18,11 -18,11 -7),(11 -22,24 -22,24 -23,26 -23,26 -25,27 -25,27 -33,26 -33,26 -35,24 -35,24 -36,11 -36,11 -22))",
)

feat_read.Destroy()


###############################################################################
# Test a simple case without masking but with 8-connectedness.
Expand Down
7 changes: 0 additions & 7 deletions autotest/ogr/ogr_db2_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ def test_ogr_db2_hack_1():
# XDR Case.
geom = ogr.CreateGeometryFromWkt("POINT(10 20)")
wkb = geom.ExportToWkb(byte_order=ogr.wkbXDR).decode("latin1")
geom.Destroy()

assert wkb[0] == "0", "WKB wkbXDR point geometry has wrong byte order"

# NDR Case.
geom = ogr.CreateGeometryFromWkt("POINT(10 20)")
wkb = geom.ExportToWkb(byte_order=ogr.wkbNDR).decode("latin1")
geom.Destroy()

assert wkb[0] == "1", "WKB wkbNDR point geometry has wrong byte order"

Expand All @@ -65,14 +63,12 @@ def test_ogr_db2_hack_1():
# XDR Case.
geom = ogr.CreateGeometryFromWkt("POINT(10 20)")
wkb = geom.ExportToWkb(byte_order=ogr.wkbXDR).decode("latin1")
geom.Destroy()

assert wkb[0] == chr(0), "WKB wkbXDR point geometry has wrong byte order"

# NDR Case.
geom = ogr.CreateGeometryFromWkt("POINT(10 20)")
wkb = geom.ExportToWkb(byte_order=ogr.wkbNDR).decode("latin1")
geom.Destroy()

assert wkb[0] == chr(1), "WKB wkbNDR point geometry has wrong byte order"

Expand All @@ -90,7 +86,6 @@ def test_ogr_db2_hack_3():

geom = ogr.CreateGeometryFromWkt(wkt)
wkb = geom.ExportToWkb()
geom.Destroy()

# Check primary byte order value.
assert (
Expand All @@ -107,6 +102,4 @@ def test_ogr_db2_hack_3():
"Conversion to/from DB2 format seems to have " "corrupted geometry."
)

geom.Destroy()

ogr.SetGenerate_DB2_V72_BYTE_ORDER(0)
4 changes: 2 additions & 2 deletions autotest/ogr/ogr_hana.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def test_ogr_hana_18():
feat_new = ogr.Feature(feature_def=layer.GetLayerDefn())
feat_new.SetField("PRFEDEA", "9999")
layer.CreateFeature(feat_new)
feat_new.Destroy()
feat_new = None

layer.SetAttributeFilter("PRFEDEA = '9999'")
feat = layer.GetNextFeature()
Expand All @@ -438,7 +438,7 @@ def test_ogr_hana_18():
assert layer.SetFeature(feat) == 0, "SetFeature() method failed."

fid = feat.GetFID()
feat.Destroy()
feat = None

feat = layer.GetFeature(fid)
assert feat is not None, "GetFeature(%d) failed." % fid
Expand Down
3 changes: 0 additions & 3 deletions autotest/ogr/ogr_mssqlspatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ def test_ogr_mssqlspatial_4(mssql_ds, mssql_has_z_m):

ogrtest.check_feature_geometry(feat_read, geom)

feat_read.Destroy()

dst_feat.Destroy()
mssqlspatial_lyr.ResetReading() # to close implicit transaction


Expand Down
5 changes: 0 additions & 5 deletions autotest/ogr/ogr_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ def test_ogr_mysql_6(mysql_ds):
max_error=1e-3,
)

feat_read.Destroy()

sql_lyr.ResetReading()

with ogrtest.spatial_filter(sql_lyr, "LINESTRING(-10 -10,0 0)"):
Expand Down Expand Up @@ -556,7 +554,6 @@ def test_ogr_mysql_20(mysql_ds):
# We are obliged to create a fake geometry
dst_feat.SetGeometryDirectly(ogr.CreateGeometryFromWkt("POINT(0 1)"))
layer.CreateFeature(dst_feat)
dst_feat.Destroy()

layer = mysql_ds.GetLayerByName("select")
layer.ResetReading()
Expand Down Expand Up @@ -602,8 +599,6 @@ def test_ogr_mysql_22(mysql_ds):

layer.CreateFeature(dst_feat)

dst_feat.Destroy()

layer.ResetReading()
feat = layer.GetNextFeature()
assert feat is not None
Expand Down
97 changes: 34 additions & 63 deletions autotest/ogr/ogr_oci.py

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions autotest/ogr/ogr_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,6 @@ def test_ogr_pg_4(pg_ds):

ogrtest.check_feature_geometry(feat_read, geom)

feat_read.Destroy()

dst_feat.Destroy()
pg_lyr.ResetReading() # to close implicit transaction


Expand Down Expand Up @@ -915,7 +912,6 @@ def test_ogr_pg_10(pg_ds):
pg_lyr.SetAttributeFilter(None)

fid = feat.GetFID()
feat.Destroy()

assert pg_lyr.DeleteFeature(fid) == 0, "DeleteFeature() method failed."

Expand Down Expand Up @@ -1173,7 +1169,6 @@ def test_ogr_pg_20(pg_ds):
geom = feat.GetGeometryRef()
assert geom is not None, "did not get geometry, expected %s" % geoms[1]
wkt = geom.ExportToIsoWkt()
feat.Destroy()
feat = None

assert wkt == geoms[1], "WKT do not match: expected %s, got %s" % (
Expand All @@ -1195,23 +1190,17 @@ def test_ogr_pg_21(pg_ds):
layer = pg_ds.ExecuteSQL("SELECT wkb_geometry FROM testgeom")
assert layer is not None, "did not get testgeom layer"

feat = layer.GetNextFeature()
while feat is not None:
for feat in layer:
geom = feat.GetGeometryRef()
if (
ogr.GT_HasZ(geom.GetGeometryType()) == 0
or ogr.GT_HasM(geom.GetGeometryType()) == 0
):
feat.Destroy()
feat = None
pg_ds.ReleaseResultSet(layer)
layer = None
pytest.fail("expected feature with type >3000")

feat.Destroy()
feat = layer.GetNextFeature()

feat = None
pg_ds.ReleaseResultSet(layer)
layer = None

Expand Down Expand Up @@ -1259,7 +1248,6 @@ def test_ogr_pg_21_subgeoms(pg_ds):
), "did not get the expected subgeometry, expected %s" % (
subgeom_TIN[j]
)
feat.Destroy()
feat = None


Expand Down Expand Up @@ -1772,7 +1760,6 @@ def test_ogr_pg_33(pg_ds):
# eacute in UTF8 : 0xc3 0xa9
dst_feat.SetField("SHORTNAME", "\xc3\xa9")
pg_lyr.CreateFeature(dst_feat)
dst_feat.Destroy()


###############################################################################
Expand Down Expand Up @@ -2412,7 +2399,6 @@ def test_ogr_pg_47(pg_ds, pg_postgis_version, pg_postgis_schema):
)
field_defn = ogr.FieldDefn("test_string", ogr.OFTString)
lyr.CreateField(field_defn)
field_defn.Destroy()

feature_defn = lyr.GetLayerDefn()

Expand Down
5 changes: 1 addition & 4 deletions autotest/ogr/ogr_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def test_ogr_spatialite_2(sqlite_test_db):
dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn())
dst_feat.SetGeometry(geom)
lyr.CreateFeature(dst_feat)
dst_feat.Destroy()
dst_feat = None

lyr.CommitTransaction()

Expand Down Expand Up @@ -1577,7 +1577,6 @@ def test_ogr_spatialite_2(sqlite_test_db):

geom = ogr.CreateGeometryFromWkt("POLYGON((2 2,2 8,8 8,8 2,2 2))")
lyr.SetSpatialFilter(geom)
geom.Destroy()

assert lyr.TestCapability(ogr.OLCFastFeatureCount) is not True
assert lyr.TestCapability(ogr.OLCFastSpatialFilter) is not True
Expand Down Expand Up @@ -1638,7 +1637,6 @@ def test_ogr_spatialite_4(sqlite_test_db):
feat = lyr.GetNextFeature()
geom = feat.GetGeometryRef()
assert geom is not None and geom.ExportToWkt() == "POINT (0 1)"
feat.Destroy()

# Check that triggers and index are restored (#3474)
with sqlite_test_db.ExecuteSQL("SELECT * FROM sqlite_master") as lyr:
Expand All @@ -1656,7 +1654,6 @@ def test_ogr_spatialite_4(sqlite_test_db):
feat = ogr.Feature(lyr.GetLayerDefn())
feat.SetGeometryDirectly(ogr.CreateGeometryFromWkt("POINT(100 -100)"))
lyr.CreateFeature(feat)
feat.Destroy()

# Check that the trigger is functional (#3474).
with sqlite_test_db.ExecuteSQL("SELECT * FROM idx_geomspatialite_GEOMETRY") as lyr:
Expand Down
8 changes: 0 additions & 8 deletions autotest/ogr/ogr_wkbwkt_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def test_wkbwkt_geom(filename):
# print geom_wkt.ExportToWkt()
# return 'fail'

geom_wkb.Destroy()

######################################################################
# Convert geometry to WKB and back to verify that WKB encoding is
# working smoothly.
Expand All @@ -109,17 +107,11 @@ def test_wkbwkt_geom(filename):

assert str(geom_wkb) == str(geom_wkt), "XDR WKB encoding/decoding failure."

geom_wkb.Destroy()

wkb_ndr = geom_wkt.ExportToWkb(ogr.wkbNDR)
geom_wkb = ogr.CreateGeometryFromWkb(wkb_ndr)

assert str(geom_wkb) == str(geom_wkt), "NDR WKB encoding/decoding failure."

geom_wkb.Destroy()

geom_wkt.Destroy()


###############################################################################
# Test geometry with very large exponents of coordinate values.
Expand Down
5 changes: 1 addition & 4 deletions autotest/ogr/ogr_wktempty.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ def test_empty_wkt(test_input, expected):
except AttributeError:
pytest.skip()

try:
assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry"
finally:
geom.Destroy()
assert geom.IsEmpty(), "IsEmpty returning false for an empty geometry"


def test_ogr_wktempty_test_partial_empty_geoms():
Expand Down
1 change: 0 additions & 1 deletion autotest/utilities/test_ogr2ogr_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ def test_ogr2ogr_lib_21():
gdal.VectorTranslate(ds, src_ds, accessMode="append", selectFields=["foo"])

ds = None
f.Destroy()
src_ds = None


Expand Down
1 change: 1 addition & 0 deletions ogr/ogrfeaturedefn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void OGR_FD_Release(OGRFeatureDefnH hDefn)
* \brief Create a copy of this feature definition.
*
* Creates a deep copy of the feature definition.
* The reference counter of the copy is initialized at 0.
*
* @return the copy.
*/
Expand Down
7 changes: 3 additions & 4 deletions swig/python/gdal-utils/osgeo_utils/gdal_retile.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def createTileIndex(Verbose, dsName, fieldName, srs, driverName):

OGRDataSource = OGRDriver.Open(dsName)
if OGRDataSource is not None:
OGRDataSource.Destroy()
OGRDataSource.Close()
OGRDriver.DeleteDataSource(dsName)
if Verbose:
print("truncating index " + dsName)
Expand Down Expand Up @@ -791,11 +791,10 @@ def addFeature(TileIndexFieldName, OGRDataSource, location, xlist, ylist):
OGRFeature.SetGeometryDirectly(OGRGeometry)

OGRLayer.CreateFeature(OGRFeature)
OGRFeature.Destroy()


def closeTileIndex(OGRDataSource):
OGRDataSource.Destroy()
OGRDataSource.Close()


def buildPyramid(g, minfo, createdTileIndexDS, tileWidth, tileHeight, overlap):
Expand Down Expand Up @@ -1130,7 +1129,7 @@ def main(args=None, g=None):

if not g.PyramidOnly:
dsCreatedTileIndex = tileImage(g, minfo, ti)
tileIndexDS.Destroy()
tileIndexDS.Close()
else:
dsCreatedTileIndex = tileIndexDS

Expand Down
Loading

0 comments on commit b239457

Please sign in to comment.