Skip to content

Commit 34b66c6

Browse files
committed
Make OGR_G_SetPointXXXX and OGR_G_AddPointXXXXX functions return a OGRErr
Fixes OSGeo#13772
1 parent 7c7a42e commit 34b66c6

File tree

5 files changed

+250
-100
lines changed

5 files changed

+250
-100
lines changed

autotest/ogr/ogr_geom.py

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,12 @@ def test_ogr_geom_linestring_limits():
11101110
with pytest.raises(Exception):
11111111
geom.SetPoint_2D((1 << 31) - 1, 5, 6)
11121112

1113+
with pytest.raises(Exception):
1114+
geom.SetPointM((1 << 31) - 1, 5, 6, 7)
1115+
1116+
with pytest.raises(Exception):
1117+
geom.SetPointZM((1 << 31) - 1, 5, 6, 7, 8)
1118+
11131119
geom = ogr.CreateGeometryFromWkt("LINESTRING(0 0)")
11141120
assert geom.Length() == 0
11151121
geom = ogr.CreateGeometryFromWkt("LINESTRING(0 0, 1 0)")
@@ -3480,47 +3486,107 @@ def test_ogr_geom_GT_GetLinear(gt, res):
34803486
# Limit cases
34813487

34823488

3489+
@gdaltest.enable_exceptions()
34833490
def test_ogr_geom_api_limit_tests():
34843491

34853492
p = ogr.Geometry(ogr.wkbPoint)
34863493
lyr = ogr.Geometry(ogr.wkbLineString)
34873494
poly = ogr.Geometry(ogr.wkbPolygon)
34883495

3489-
with gdal.quiet_errors():
3496+
with pytest.raises(Exception):
34903497
p.GetX(1)
3498+
3499+
with pytest.raises(Exception):
34913500
p.GetY(1)
3501+
3502+
with pytest.raises(Exception):
34923503
p.GetZ(1)
34933504

3505+
with pytest.raises(Exception):
34943506
lyr.GetX(1)
3507+
3508+
with pytest.raises(Exception):
34953509
lyr.GetY(1)
3510+
3511+
with pytest.raises(Exception):
34963512
lyr.GetZ(1)
34973513

3514+
with pytest.raises(Exception):
34983515
poly.GetX()
3516+
3517+
with pytest.raises(Exception):
34993518
poly.GetY()
3519+
3520+
with pytest.raises(Exception):
35003521
poly.GetZ()
35013522

3523+
with pytest.raises(Exception):
35023524
poly.GetPoints()
35033525

3526+
with pytest.raises(Exception):
35043527
p.GetPoint(1)
3528+
3529+
with pytest.raises(Exception):
35053530
lyr.GetPoint(1)
3531+
3532+
with pytest.raises(Exception):
35063533
poly.GetPoint(1)
35073534

3535+
with pytest.raises(Exception):
35083536
p.SetPoint(1, 0, 0)
3537+
3538+
with pytest.raises(Exception):
35093539
lyr.SetPoint(-1, 0, 0)
3540+
3541+
with pytest.raises(Exception):
35103542
poly.SetPoint(0, 0, 0)
35113543

3544+
with pytest.raises(Exception):
35123545
p.SetPoint_2D(1, 0, 0)
3546+
3547+
with pytest.raises(Exception):
35133548
lyr.SetPoint_2D(-1, 0, 0)
3549+
3550+
with pytest.raises(Exception):
35143551
poly.SetPoint_2D(0, 0, 0)
35153552

3553+
with pytest.raises(Exception):
3554+
p.SetPointM(1, 0, 0, 0)
3555+
3556+
with pytest.raises(Exception):
3557+
lyr.SetPointM(-1, 0, 0, 0)
3558+
3559+
with pytest.raises(Exception):
3560+
poly.SetPointM(0, 0, 0, 0)
3561+
3562+
with pytest.raises(Exception):
3563+
p.SetPointZM(1, 0, 0, 0, 0)
3564+
3565+
with pytest.raises(Exception):
3566+
lyr.SetPointZM(-1, 0, 0, 0, 0)
3567+
3568+
with pytest.raises(Exception):
3569+
poly.SetPointZM(0, 0, 0, 0, 0)
3570+
3571+
with pytest.raises(Exception):
35163572
poly.AddPoint(0, 0)
35173573

3574+
with pytest.raises(Exception):
3575+
poly.AddPointM(0, 0, 0)
3576+
3577+
with pytest.raises(Exception):
3578+
poly.AddPointZM(0, 0, 0, 0, 0)
3579+
3580+
with pytest.raises(Exception):
35183581
poly.AddPoint_2D(0, 0)
35193582

3583+
with pytest.raises(Exception):
35203584
p.GetGeometryRef(1)
35213585

3586+
with pytest.raises(Exception):
35223587
p.AddGeometry(p)
35233588

3589+
with pytest.raises(Exception):
35243590
p.AddGeometryDirectly(p)
35253591

35263592

doc/source/user/migration_guide.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ Migration guide
77
From GDAL 3.12 to GDAL 3.13
88
---------------------------
99

10+
- C API changes:
11+
12+
* the following functions now return a ``OGRErr`` whereas they returned void
13+
before: :cpp:func:`OGR_G_SetPointCount`, :cpp:func:`OGR_G_SetPoint`,
14+
:cpp:func:`OGR_G_SetPoint_2D`, :cpp:func:`OGR_G_SetPointM`,
15+
:cpp:func:`OGR_G_SetPointZM`, :cpp:func:`OGR_G_AddPoint`,
16+
:cpp:func:`OGR_G_AddPoint_2D`, :cpp:func:`OGR_G_AddPointM`,
17+
:cpp:func:`OGR_G_AddPointZM`, :cpp:func:`OGR_G_SetPoints` and
18+
:cpp:func:`OGR_G_SetPointsZM`.
19+
1020
- Changes impacting out-of-tree vector drivers:
1121

1222
* :cpp:func:`GDALDataset::Close` takes now 2 input parameters ``(GDALProgressFunc pfnProgress, void *pProgressData)``,

0 commit comments

Comments
 (0)