Skip to content

Commit

Permalink
Support new array_create_iterator in 9.5
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/postgis/trunk@13524 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information
pramsey committed May 19, 2015
1 parent a844035 commit 27453e9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion liblwgeom/liblwgeom_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* Define to enable pre-version 2.2 geodesic functions for geography types
(e.g. Vincenty for ST_Distance); otherwise use GeographicLib */
#define USE_PRE22GEODESIC
#undef USE_PRE22GEODESIC
/* #undef USE_PRE22GEODESIC */

/**
* Floating point comparators.
Expand Down
10 changes: 9 additions & 1 deletion postgis/lwgeom_functions_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,8 +1244,12 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
lwgeoms = palloc(sizeof(LWGEOM*) * nelems);
count = 0;
outtype = 0;


#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif

while( array_iterate(iterator, &value, &isnull) )
{
Expand Down Expand Up @@ -1432,7 +1436,11 @@ Datum LWGEOM_makeline_garray(PG_FUNCTION_ARGS)
geoms = palloc(sizeof(LWGEOM *) * nelems);
ngeoms = 0;

#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif

while( array_iterate(iterator, &value, &isnull) )
{
Expand Down
20 changes: 20 additions & 0 deletions postgis/lwgeom_geos.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
if ( nelems == 0 ) PG_RETURN_NULL();

/* Quick scan for nulls */
#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif
while( array_iterate(iterator, &value, &isnull) )
{
/* Skip null array items */
Expand Down Expand Up @@ -316,7 +320,11 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
** We need to convert the array of GSERIALIZED into a GEOS collection.
** First make an array of GEOS geometries.
*/
#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif
while( array_iterate(iterator, &value, &isnull) )
{
GSERIALIZED *gser_in;
Expand Down Expand Up @@ -464,7 +472,11 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
** If they are, we can use UnionCascaded for faster results.
*/
count = 0;
#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif
while( array_iterate(iterator, &value, &isnull) )
{
GSERIALIZED *pggeom;
Expand Down Expand Up @@ -523,7 +535,11 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
** We need to convert the array of GSERIALIZED into a GEOS MultiPolygon.
** First make an array of GEOS Polygons.
*/
#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif
while( array_iterate(iterator, &value, &isnull) )
{
GEOSGeometry* g;
Expand Down Expand Up @@ -620,7 +636,11 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
** Heterogeneous result, let's slog through this one union at a time.
*/

#if POSTGIS_PGSQL_VERSION >= 95
iterator = array_create_iterator(array, 0, NULL);
#else
iterator = array_create_iterator(array, 0);
#endif
while( array_iterate(iterator, &value, &isnull) )
{
GSERIALIZED *geom;
Expand Down
6 changes: 6 additions & 0 deletions postgis/lwgeom_inout.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@ Datum TWKBFromLWGEOMArray(PG_FUNCTION_ARGS)

/* Loop through array and build a collection of geometry and */
/* a simple array of ids. If either side is NULL, skip it */

#if POSTGIS_PGSQL_VERSION >= 95
iter_geoms = array_create_iterator(arr_geoms, 0, NULL);
iter_ids = array_create_iterator(arr_ids, 0, NULL);
#else
iter_geoms = array_create_iterator(arr_geoms, 0);
iter_ids = array_create_iterator(arr_ids, 0);
#endif

while( array_iterate(iter_geoms, &val_geom, &null_geom) &&
array_iterate(iter_ids, &val_id, &null_id) )
Expand Down

0 comments on commit 27453e9

Please sign in to comment.