Commit 567ba507 authored by Raúl Marín's avatar Raúl Marín

Avoid division by zero in kmeans

Closes #4188
Closes https://github.com/postgis/postgis/pull/309


git-svn-id: http://svn.osgeo.org/postgis/trunk@16860 b70326c6-7e19-0410-871a-916f4a2858ee
parent 35db4ea0
Pipeline #31696662 passed with stage
in 23 minutes and 23 seconds
......@@ -20,6 +20,7 @@ PostGIS 3.0.0
- #4176, ST_Intersects supports GEOMETRYCOLLECTION (Darafei Praliaskouski)
- #4181, St_AsMVTGeom: Avoid type changes due to validation (Raúl Marín)
- #4183, St_AsMVTGeom: Drop invalid geometries after simplification (Raúl Marín)
- #4188, Avoid division by zero in kmeans (Raúl Marín)
PostGIS 2.5.0
2018/09/23
......
......@@ -82,8 +82,11 @@ update_means(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, uint3
}
for (i = 0; i < k; i++)
{
centers[i]->x /= weights[i];
centers[i]->y /= weights[i];
if (weights[i])
{
centers[i]->x /= weights[i];
centers[i]->y /= weights[i];
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment