32 auto size = points.
size();
34 for (int64_t i = 0; i < size; i++) {
39 const auto point = points[i];
52 auto size = points.
size();
54 for (int64_t i = 0; i < size; i++) {
58 auto point = points[i];
61 shifted_points.
setItem(i, point);
73 auto size = points.
size();
75 for (int64_t i = 0; i < size; i++) {
80 const auto point = points[i][n - 1];
109 auto size = polygons.
size();
112 for (int64_t i = 0; i < size; i++) {
116 int64_t sz = polygons[i].
size();
117 if (n < 1 || n > sz) {
120 const auto poly = polygons[i];
121 const auto ring = poly[n - 1];
135 auto size = rings.
size();
141 for (int64_t i = 0; i < size; i++) {
147 std::vector<std::vector<double>> polygon_coords;
149 polygon_coords.push_back(rings[i].toCoords());
151 polygon_coords.push_back(holes1[i].toCoords());
153 polygon_coords.push_back(holes2[i].toCoords());
157 auto polygon = polygons[i];
158 auto status = polygon.fromCoords(polygon_coords);
160 if (status != FlatBufferManager::Status::Success) {
161 return mgr.ERROR_MESSAGE(
"fromCoords failed: " + ::
toString(status));
164 for (
size_t j = 0; j < polygon.size(); j++) {
165 nofpoints += polygon.size(j);
167 sizes[i] = nofpoints;
172 if (count_nulls == 0) {
173 return mgr.ERROR_MESSAGE(
"counting null test failed: count_nulls=" +
174 ::
toString(count_nulls) +
", expected non-zero.");
177 for (int64_t i = 0; i < size; i++) {
181 std::vector<std::vector<double>> polygon_coords;
182 polygon_coords.push_back(rings[i].toCoords());
184 polygon_coords.push_back(holes1[i].toCoords());
187 polygon_coords.push_back(holes2[i].toCoords());
194 auto nof_lines = polygons[i].
size();
196 if (nof_lines != polygon_coords.size()) {
197 return mgr.ERROR_MESSAGE(
198 "polygon size test failed: nof_lines=" + ::
toString(nof_lines) +
199 ", expected " + ::
toString(polygon_coords.size()) +
".");
201 std::vector<std::vector<double>> poly_coords = polygons[i].toCoords();
202 if (nof_lines != poly_coords.size()) {
203 return mgr.ERROR_MESSAGE(
204 "polygon toCoords size test failed: poly_coords.size()=" +
205 ::
toString(poly_coords.size()) +
", expected " + ::
toString(nof_lines) +
".");
208 auto poly = polygons[i];
210 for (
size_t j = 0; j < poly.size(); j++) {
212 std::vector<double> line_coords = line.
toCoords();
213 auto nof_points = polygon_coords[j].size() / 2;
214 if (poly.size(j) != nof_points) {
215 return mgr.ERROR_MESSAGE(
"polygon linestring size test failed: poly.size(" +
217 ", expected " + ::
toString(nof_points) +
".");
219 if (line.
size() != nof_points) {
220 return mgr.ERROR_MESSAGE(
"polygon linestring size test failed: line.size()=" +
224 if (poly_coords[j].size() != nof_points * 2) {
225 return mgr.ERROR_MESSAGE(
226 "polygon linestring coords size test failed: poly_coords[j].size()=" +
227 ::
toString(poly_coords[j].size()) +
", expected " +
230 if (line_coords.size() != nof_points * 2) {
231 return mgr.ERROR_MESSAGE(
232 "polygon linestring coords size test failed: line_coords.size()=" +
233 ::
toString(line_coords.size()) +
", expected " +
236 for (
size_t k = 0; k < nof_points; k++) {
237 if (std::abs(polygon_coords[j][2 * k] - line_coords[2 * k]) > 1e-7) {
238 return mgr.ERROR_MESSAGE(
239 "polygon linestring X coord test failed: line_coords[2*k]=" +
240 ::
toString(line_coords[2 * k]) +
", expected " +
241 ::
toString(polygon_coords[j][2 * k]) +
".");
243 if (std::abs(polygon_coords[j][2 * k] - poly_coords[j][2 * k]) > 1e-7) {
244 return mgr.ERROR_MESSAGE(
"polygon X coord test failed: poly_coords[j][2*k]=" +
245 ::
toString(poly_coords[j][2 * k]) +
", expected " +
246 ::
toString(polygon_coords[j][2 * k]) +
".");
248 if (std::abs(polygon_coords[j][2 * k] - line[k].x) > 1e-7) {
249 return mgr.ERROR_MESSAGE(
250 "polygon linestring X coord test failed: line[k].x=" +
251 ::
toString(line[k].x) +
", expected " +
252 ::
toString(polygon_coords[j][2 * k]) +
".");
254 if (std::abs(polygon_coords[j][2 * k + 1] - line_coords[2 * k + 1]) > 1e-7) {
255 return mgr.ERROR_MESSAGE(
256 "polygon linestring Y coord test failed: line_coords[2*k+1]=" +
257 ::
toString(line_coords[2 * k + 1]) +
", expected " +
258 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
260 if (std::abs(polygon_coords[j][2 * k + 1] - poly_coords[j][2 * k + 1]) > 1e-7) {
261 return mgr.ERROR_MESSAGE(
262 "polygon Y coord test failed: poly_coords[j][2*k+1]=" +
263 ::
toString(poly_coords[j][2 * k + 1]) +
", expected " +
264 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
266 if (std::abs(polygon_coords[j][2 * k + 1] - line[k].y) > 1e-7) {
267 return mgr.ERROR_MESSAGE(
268 "polygon linestring X coord test failed: line[k].y=" +
269 ::
toString(line[k].y) +
", expected " +
270 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
277 if (count_nulls != 0) {
278 return mgr.ERROR_MESSAGE(
"counting null test failed: count_nulls=" +
279 ::
toString(count_nulls) +
", expected 0.");
291 auto size = x.
size();
294 for (int64_t i = 0; i < size; i++) {
298 std::vector<double>
line{x[i], y[i], x[i] + dx, y[i] + dy};
299 linestrings[i].fromCoords(
line);
309 auto size = polygons.
size();
315 for (int64_t i = 0; i < size; i++) {
320 std::vector<std::vector<std::vector<double>>> mpolygon_coords;
321 mpolygon_coords.reserve(1);
322 std::vector<std::vector<double>> polygon_coords = polygons[i].toCoords();
323 mpolygon_coords.push_back(polygon_coords);
324 auto status = mpolygons[i].fromCoords(mpolygon_coords);
325 if (status != FlatBufferManager::Status::Success) {
326 return mgr.ERROR_MESSAGE(
"fromCoords failed: " + ::
toString(status));
332 if (count_nulls == 0) {
333 return mgr.ERROR_MESSAGE(
"counting null test failed: count_nulls=" +
334 ::
toString(count_nulls) +
", expected non-zero.");
337 for (int64_t i = 0; i < size; i++) {
338 if (mpolygons.
isNull(i)) {
341 std::vector<std::vector<double>> polygon_coords = polygons[i].toCoords();
348 auto nof_polygons = mpolygons[i].
size();
349 if (nof_polygons != 1) {
350 return mgr.ERROR_MESSAGE(
"multipolygon size test failed: nof_polygons=" +
351 ::
toString(nof_polygons) +
", expected 1.");
354 std::vector<std::vector<std::vector<double>>> mpolygon_coords =
355 mpolygons[i].toCoords();
356 if (nof_polygons != mpolygon_coords.size()) {
357 return mgr.ERROR_MESSAGE(
358 "multipolygon toCoords size test failed: mpolygon_coords.size()=" +
359 ::
toString(mpolygon_coords.size()) +
", expected " +
364 std::vector<std::vector<double>> poly_coords = mpolygon_coords[0];
365 if (poly.
size() != polygon_coords.size()) {
366 return mgr.ERROR_MESSAGE(
"multipolygon polygon size test failed: poly.size()=" +
368 ::
toString(polygon_coords.size()) +
".");
371 if (poly_coords.size() != polygon_coords.size()) {
372 return mgr.ERROR_MESSAGE(
373 "multipolygon polygon coords size test failed: poly_coords.size()=" +
374 ::
toString(poly_coords.size()) +
", expected " +
375 ::
toString(polygon_coords.size()) +
".");
378 for (
size_t j = 0; j < poly.
size(); j++) {
380 std::vector<double> line_coords = line.
toCoords();
381 auto nof_points = polygon_coords[j].size() / 2;
382 if (poly.
size(j) != nof_points) {
383 return mgr.ERROR_MESSAGE(
384 "multipolygon polygon linestring size test failed: poly.size(" +
388 if (line.
size() != nof_points) {
389 return mgr.ERROR_MESSAGE(
390 "multipolygon polygon linestring size test failed: line.size()=" +
393 if (poly_coords[j].size() != nof_points * 2) {
394 return mgr.ERROR_MESSAGE(
395 "multipolygon polygon linestring coords size test failed: "
396 "poly_coords[j].size()=" +
397 ::
toString(poly_coords[j].size()) +
", expected " +
400 if (line_coords.size() != nof_points * 2) {
401 return mgr.ERROR_MESSAGE(
402 "multipolygon polygon linestring coords size test failed: "
403 "line_coords.size()=" +
404 ::
toString(line_coords.size()) +
", expected " +
408 for (
size_t k = 0; k < nof_points; k++) {
409 if (std::abs(polygon_coords[j][2 * k] - line_coords[2 * k]) > 1e-7) {
410 return mgr.ERROR_MESSAGE(
411 "multipolygon polygon linestring X coord test failed: line_coords[2*k]=" +
412 ::
toString(line_coords[2 * k]) +
", expected " +
413 ::
toString(polygon_coords[j][2 * k]) +
".");
415 if (std::abs(polygon_coords[j][2 * k] - poly_coords[j][2 * k]) > 1e-7) {
416 return mgr.ERROR_MESSAGE(
417 "multipolygon polygon X coord test failed: poly_coords[j][2*k]=" +
418 ::
toString(poly_coords[j][2 * k]) +
", expected " +
419 ::
toString(polygon_coords[j][2 * k]) +
".");
421 if (std::abs(polygon_coords[j][2 * k] - line[k].x) > 1e-7) {
422 return mgr.ERROR_MESSAGE(
423 "multipolygon polygon linestring X coord test failed: line[k].x=" +
424 ::
toString(line[k].x) +
", expected " +
425 ::
toString(polygon_coords[j][2 * k]) +
".");
427 if (std::abs(polygon_coords[j][2 * k + 1] - line_coords[2 * k + 1]) > 1e-7) {
428 return mgr.ERROR_MESSAGE(
429 "multipolygon polygon linestring Y coord test failed: "
430 "line_coords[2*k+1]=" +
431 ::
toString(line_coords[2 * k + 1]) +
", expected " +
432 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
434 if (std::abs(polygon_coords[j][2 * k + 1] - poly_coords[j][2 * k + 1]) > 1e-7) {
435 return mgr.ERROR_MESSAGE(
436 "multipolygon polygon Y coord test failed: poly_coords[j][2*k+1]=" +
437 ::
toString(poly_coords[j][2 * k + 1]) +
", expected " +
438 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
440 if (std::abs(polygon_coords[j][2 * k + 1] - line[k].y) > 1e-7) {
441 return mgr.ERROR_MESSAGE(
442 "multipolygon polygon linestring X coord test failed: line[k].y=" +
443 ::
toString(line[k].y) +
", expected " +
444 ::
toString(polygon_coords[j][2 * k + 1]) +
".");
451 if (count_nulls != 0) {
452 return mgr.ERROR_MESSAGE(
"counting null test failed: count_nulls=" +
453 ::
toString(count_nulls) +
", expected 0.");
463 auto size = mpolygons.
size();
466 for (int64_t i = 0; i < size; i++) {
467 if (mpolygons.
isNull(i)) {
470 polygons.
setItem(i, mpolygons[i][n - 1]);
480 auto size = polygons.
size();
486 for (int64_t i = 0; i < size; i++) {
491 std::vector<std::vector<double>> polygon_coords = polygons[i].toCoords();
492 status = mlinestrings[i].fromCoords(polygon_coords);
493 if (status != FlatBufferManager::Status::Success) {
494 return mgr.ERROR_MESSAGE(
"fromCoords failed: " + ::
toString(status));
505 auto size = mlinestrings.
size();
511 for (int64_t i = 0; i < size; i++) {
512 if (mlinestrings.
isNull(i)) {
516 std::vector<std::vector<double>> polygon_coords;
517 status = mlinestrings[i].toCoords(polygon_coords);
518 if (status != FlatBufferManager::Status::Success) {
519 return mgr.ERROR_MESSAGE(
"toCoords failed: " + ::
toString(status));
521 status = polygons[i].fromCoords(polygon_coords);
522 if (status != FlatBufferManager::Status::Success) {
523 return mgr.ERROR_MESSAGE(
"fromCoords failed: " + ::
toString(status));
530 #endif // #ifndef __CUDACC__
void set_output_row_size(int64_t num_rows)
#define EXTENSION_NOINLINE
DEVICE int64_t size() const
std::vector< CT > toCoords() const
DEVICE int64_t size() const
DEVICE void setNull(int64_t index)
EXTENSION_NOINLINE int32_t ct_to_multilinestring__cpu_(TableFunctionManager &mgr, const Column< GeoPolygon > &polygons, Column< GeoMultiLineString > &mlinestrings)
int64_t getNofValues() const
EXTENSION_NOINLINE int32_t ct_make_linestring2__cpu_(TableFunctionManager &mgr, const Column< double > &x, const Column< double > &y, double dx, double dy, Column< GeoLineString > &linestrings)
std::string toString(const Executor::ExtModuleKinds &kind)
EXTENSION_NOINLINE int32_t ct_shift__cpu_(TableFunctionManager &mgr, const Column< GeoPoint > &points, const double x, const double y, Column< GeoPoint > &shifted_points)
EXTENSION_NOINLINE int32_t ct_coords__cpu_(TableFunctionManager &mgr, const Column< GeoPoint > &points, Column< double > &xcoords, Column< double > &ycoords)
DEVICE bool isNull(int64_t index) const
EXTENSION_NOINLINE int32_t ct_make_multipolygon__cpu_(TableFunctionManager &mgr, const Column< GeoPolygon > &polygons, Column< GeoMultiPolygon > &mpolygons)
DEVICE bool isNull(int64_t index) const
DEVICE void setNull(int64_t index)
EXTENSION_NOINLINE int32_t ct_make_polygon3__cpu_(TableFunctionManager &mgr, const Column< GeoLineString > &rings, const Column< GeoLineString > &holes1, const Column< GeoLineString > &holes2, Column< GeoPolygon > &polygons, Column< int > &sizes)
void set_output_item_values_total_number(int32_t index, int64_t output_item_values_total_number)
DEVICE int64_t size() const
EXTENSION_NOINLINE int32_t ct_linestringn__cpu_(TableFunctionManager &mgr, const Column< GeoPolygon > &polygons, int64_t n, Column< GeoLineString > &linestrings)
DEVICE void setItem(int64_t index, const Geo::Point2D &other)
EXTENSION_NOINLINE int32_t ct_to_polygon__cpu_(TableFunctionManager &mgr, const Column< GeoMultiLineString > &mlinestrings, Column< GeoPolygon > &polygons)
NEVER_INLINE HOST int32_t ct_pointn__cpu_template(TableFunctionManager &mgr, const Column< T > &points, int64_t n, Column< double > &xcoords, Column< double > &ycoords)
DEVICE void setNull(int64_t index)
DEVICE bool isNull(int64_t index) const
EXTENSION_NOINLINE int32_t ct_polygonn__cpu_(TableFunctionManager &mgr, const Column< GeoMultiPolygon > &mpolygons, int64_t n, Column< GeoPolygon > &polygons)
DEVICE void setItem(int64_t index, const RowType &item)