Skip to content

Commit 7b350fb

Browse files
shtilmanandrewseidl
authored andcommitted
Support MULTIPOINT arguments in GeosRuntime
1 parent 571dd37 commit 7b350fb

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

QueryEngine/GeosRuntime.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ bool toWkb(WKB& wkb,
118118
}
119119
return point.getWkb(wkb);
120120
}
121+
if (static_cast<SQLTypes>(type) == kMULTIPOINT) {
122+
GeoMultiPoint multipoint(*cv);
123+
if (execute_transform && !multipoint.transform(srid_in, srid_out)) {
124+
return false;
125+
}
126+
if (best_planar_srid_ptr) {
127+
// A non-NULL pointer signifies a request to find the best planar srid
128+
// to transform this WGS84 geometry to, based on geometry's centroid.
129+
*best_planar_srid_ptr = multipoint.getBestPlanarSRID();
130+
if (!multipoint.transform(4326, *best_planar_srid_ptr)) {
131+
return false;
132+
}
133+
}
134+
return multipoint.getWkb(wkb);
135+
}
121136
if (static_cast<SQLTypes>(type) == kLINESTRING) {
122137
GeoLineString linestring(*cv);
123138
if (execute_transform && !linestring.transform(srid_in, srid_out)) {

Tests/GeospatialTest.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,18 @@ TEST_F(GeoSpatialTempTables, Geos) {
24082408
R"(SELECT ST_Distance(ST_Buffer(p, 1.0), 'POINT(0 3)') FROM geospatial_test WHERE id = 3;)",
24092409
dt)),
24102410
static_cast<double>(0.03)));
2411+
// ST_Buffer on a multipoint, 1.0 width: basically circles around each point
2412+
EXPECT_GPU_THROW(ASSERT_NEAR(
2413+
static_cast<double>(3.14159 * 3),
2414+
v<double>(run_simple_agg(
2415+
R"(SELECT ST_Area(ST_Buffer('MULTIPOINT(0 0, 10 0, 10 10)', 1.0));)", dt)),
2416+
static_cast<double>(0.03)));
2417+
EXPECT_GPU_THROW(ASSERT_NEAR(
2418+
static_cast<double>(3.14159 * 3.9018),
2419+
v<double>(run_simple_agg(
2420+
R"(SELECT ST_Area(ST_Buffer(mp, 1.0)) FROM geospatial_test WHERE id = 3;)",
2421+
dt)),
2422+
static_cast<double>(0.03)));
24112423
// ST_Buffer on a linestring, 1.0 width: two 10-unit segments
24122424
// each segment is buffered by ~2x10 wide stretch (2 * 2 * 10) plus circular areas
24132425
// around mid- and endpoints

0 commit comments

Comments
 (0)