1391{
1392 ArrayType *array;
1393 int nelems;
1397 uint32 ngeoms;
1399
1400 ArrayIterator iterator;
1402 bool isnull;
1403
1404 POSTGIS_DEBUGF(2, "%s called", __func__);
1405
1406
1407 if (PG_ARGISNULL(0))
1408 PG_RETURN_NULL();
1409
1410
1411 array = PG_GETARG_ARRAYTYPE_P(0);
1412
1413
1414 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1415
1416 POSTGIS_DEBUGF(3, "%s: array has %d elements", __func__, nelems);
1417
1418
1419 if (nelems == 0)
1420 PG_RETURN_NULL();
1421
1422
1423
1424
1425
1426
1427
1428
1429 geoms = palloc(
sizeof(
LWGEOM *) * nelems);
1430 ngeoms = 0;
1431
1432 iterator = array_create_iterator(array, 0, NULL);
1433
1434 while (array_iterate(iterator, &value, &isnull))
1435 {
1437
1438 if (isnull)
1439 continue;
1440
1442
1445 {
1446 continue;
1447 }
1448
1450
1451
1452 if (ngeoms == 1)
1453 {
1454
1455 srid = geoms[ngeoms - 1]->
srid;
1456
1457 }
1458 else
1460
1461 POSTGIS_DEBUGF(3, "%s: element %d deserialized", __func__, ngeoms);
1462 }
1463 array_free_iterator(iterator);
1464
1465
1466 if (ngeoms == 0)
1467 {
1468
1469 elog(NOTICE, "No points or linestrings in input array");
1470 PG_RETURN_NULL();
1471 }
1472
1473 POSTGIS_DEBUGF(3, "LWGEOM_makeline_garray: elements: %d", ngeoms);
1474
1476
1478
1479 PG_RETURN_POINTER(result);
1480}
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
LWLINE * lwline_from_lwgeom_array(int32_t srid, uint32_t ngeoms, LWGEOM **geoms)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)