[postgis-tickets] r14453 - gserialized_from_lwgeom get rid of is_geodetic ignored arg ,
Regina Obe
lr at pcorp.us
Mon Nov 30 08:24:58 PST 2015
Author: robe
Date: 2015-11-30 08:24:57 -0800 (Mon, 30 Nov 2015)
New Revision: 14453
Modified:
trunk/liblwgeom/cunit/cu_geodetic.c
trunk/liblwgeom/cunit/cu_libgeom.c
trunk/liblwgeom/cunit/cu_surface.c
trunk/liblwgeom/g_serialized.c
trunk/liblwgeom/liblwgeom.h.in
trunk/libpgcommon/lwgeom_pg.c
trunk/postgis/geography_measurement.c
trunk/postgis/lwgeom_dumppoints.c
trunk/postgis/lwgeom_geos.c
trunk/raster/rt_pg/rtpg_geometry.c
Log:
gserialized_from_lwgeom get rid of is_geodetic ignored arg ,
force geography_serialize to always return a geography
closes pull request #72
closes ticket #3361
Modified: trunk/liblwgeom/cunit/cu_geodetic.c
===================================================================
--- trunk/liblwgeom/cunit/cu_geodetic.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/liblwgeom/cunit/cu_geodetic.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -345,7 +345,7 @@
GSERIALIZED *g;
lwg = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
- g = gserialized_from_lwgeom(lwg, 1, 0);
+ g = gserialized_from_lwgeom(lwg, 0);
lwgeom_free(lwg);
return lwgeom_from_gserialized(g);
}
@@ -799,7 +799,7 @@
lwg = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
FLAGS_SET_GEODETIC(lwg->flags, 1);
- *g = gserialized_from_lwgeom(lwg, 1, 0);
+ *g = gserialized_from_lwgeom(lwg, 0);
lwgeom_free(lwg);
return lwgeom_from_gserialized(*g);
}
@@ -901,7 +901,7 @@
geom = lwgeom_from_wkt("POINT(0 0.2)", LW_PARSER_CHECK_NONE);
FLAGS_SET_GEODETIC(geom->flags, 1);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
type = gserialized_get_type(g);
CU_ASSERT_EQUAL( type, POINTTYPE );
inspect = (double*)g;
@@ -911,7 +911,7 @@
geom = lwgeom_from_wkt("POLYGON((-1 -1, -1 2.5, 2 2, 2 -1, -1 -1), (0 0, 0 1, 1 1, 1 0, 0 0))", LW_PARSER_CHECK_NONE);
FLAGS_SET_GEODETIC(geom->flags, 1);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
type = gserialized_get_type(g);
CU_ASSERT_EQUAL( type, POLYGONTYPE );
inspect = (double*)g;
@@ -921,7 +921,7 @@
geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 1 1),(0 0.1, 1 1))", LW_PARSER_CHECK_NONE);
FLAGS_SET_GEODETIC(geom->flags, 1);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
type = gserialized_get_type(g);
CU_ASSERT_EQUAL( type, MULTILINETYPE );
inspect = (double*)g;
Modified: trunk/liblwgeom/cunit/cu_libgeom.c
===================================================================
--- trunk/liblwgeom/cunit/cu_libgeom.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/liblwgeom/cunit/cu_libgeom.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -283,7 +283,7 @@
geom = lwgeom_from_wkt(in_ewkt, LW_PARSER_CHECK_NONE);
lwgeom_add_bbox(geom);
if ( geom->bbox ) gbox_float_round(geom->bbox);
- g = gserialized_from_lwgeom(geom, 0, 0);
+ g = gserialized_from_lwgeom(geom, 0);
geom2 = lwgeom_from_gserialized(g);
out_ewkt = lwgeom_to_ewkt(geom2);
@@ -337,7 +337,7 @@
{
// i = 11;
LWGEOM *lw = lwgeom_from_wkt(cases[i].wkt, LW_PARSER_CHECK_NONE);
- GSERIALIZED *g = gserialized_from_lwgeom(lw, 0, 0);
+ GSERIALIZED *g = gserialized_from_lwgeom(lw, 0);
int ie = gserialized_is_empty(g);
// printf("%s: we say %d, they say %d\n", cases[i].wkt, cases[i].isempty, ie);
CU_ASSERT_EQUAL(ie, cases[i].isempty);
@@ -420,7 +420,7 @@
lwgeom = lwgeom_from_wkt("MULTIPOINT(-1 -1,-1 2.5,2 2,2 -1,1 1,2 2,4 5)", LW_PARSER_CHECK_NONE);
CU_ASSERT_EQUAL(lwgeom_count_vertices(lwgeom),7);
- g_ser1 = gserialized_from_lwgeom(lwgeom, 1, &ret_size);
+ g_ser1 = gserialized_from_lwgeom(lwgeom, &ret_size);
lwgeom_free(lwgeom);
lwgeom = lwgeom_from_gserialized(g_ser1);
@@ -1055,7 +1055,7 @@
/* Serializing a GBOX with precise coordinates renders the boxes not strictly equal,
* but still equal according to gbox_same_2d_float.
*/
- GSERIALIZED* s3 = gserialized_from_lwgeom(g3, LW_FALSE, NULL);
+ GSERIALIZED* s3 = gserialized_from_lwgeom(g3, NULL);
GBOX s3box;
gserialized_read_gbox_p(s3, &s3box);
Modified: trunk/liblwgeom/cunit/cu_surface.c
===================================================================
--- trunk/liblwgeom/cunit/cu_surface.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/liblwgeom/cunit/cu_surface.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -99,7 +99,7 @@
/* geography support */
geom = lwgeom_from_wkt("TRIANGLE((0 1 2,3 4 5,6 7 8,0 1 2))", LW_PARSER_CHECK_NONE);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
CU_ASSERT_EQUAL(gserialized_get_type(g), TRIANGLETYPE);
lwgeom_free(geom);
lwfree(g);
@@ -225,7 +225,7 @@
/* geography support */
geom = lwgeom_from_wkt("TIN(((0 1 2,3 4 5,6 7 8,0 1 2)))", LW_PARSER_CHECK_NONE);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
CU_ASSERT_EQUAL(gserialized_get_type(g), TINTYPE);
lwgeom_free(geom);
lwfree(g);
@@ -362,7 +362,7 @@
/* geography support */
geom = lwgeom_from_wkt("POLYHEDRALSURFACE(((0 1 2,3 4 5,6 7 8,0 1 2)))", LW_PARSER_CHECK_NONE);
- g = gserialized_from_lwgeom(geom, 1, 0);
+ g = gserialized_from_lwgeom(geom, 0);
CU_ASSERT_EQUAL(gserialized_get_type(g), POLYHEDRALSURFACETYPE);
lwgeom_free(geom);
lwfree(g);
Modified: trunk/liblwgeom/g_serialized.c
===================================================================
--- trunk/liblwgeom/g_serialized.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/liblwgeom/g_serialized.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -903,7 +903,7 @@
/* Public function */
-GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
+GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
{
size_t expected_size = 0;
size_t return_size = 0;
Modified: trunk/liblwgeom/liblwgeom.h.in
===================================================================
--- trunk/liblwgeom/liblwgeom.h.in 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/liblwgeom/liblwgeom.h.in 2015-11-30 16:24:57 UTC (rev 14453)
@@ -1900,7 +1900,7 @@
* will contain the size of the final output, which is useful for setting the PgSQL
* VARSIZE information.
*/
-extern GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size);
+extern GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, size_t *size);
/**
* Allocate a new #LWGEOM from a #GSERIALIZED. The resulting #LWGEOM will have coordinates
Modified: trunk/libpgcommon/lwgeom_pg.c
===================================================================
--- trunk/libpgcommon/lwgeom_pg.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/libpgcommon/lwgeom_pg.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -217,11 +217,12 @@
*/
GSERIALIZED* geography_serialize(LWGEOM *lwgeom)
{
- static int is_geodetic = 1;
size_t ret_size = 0;
GSERIALIZED *g = NULL;
+ /** force to geodetic in case it's not **/
+ lwgeom_set_geodetic(lwgeom, true);
- g = gserialized_from_lwgeom(lwgeom, is_geodetic, &ret_size);
+ g = gserialized_from_lwgeom(lwgeom, &ret_size);
if ( ! g ) lwpgerror("Unable to serialize lwgeom.");
SET_VARSIZE(g, ret_size);
return g;
@@ -234,11 +235,10 @@
*/
GSERIALIZED* geometry_serialize(LWGEOM *lwgeom)
{
- static int is_geodetic = 0;
size_t ret_size = 0;
GSERIALIZED *g = NULL;
- g = gserialized_from_lwgeom(lwgeom, is_geodetic, &ret_size);
+ g = gserialized_from_lwgeom(lwgeom, &ret_size);
if ( ! g ) lwpgerror("Unable to serialize lwgeom.");
SET_VARSIZE(g, ret_size);
return g;
Modified: trunk/postgis/geography_measurement.c
===================================================================
--- trunk/postgis/geography_measurement.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/postgis/geography_measurement.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -673,7 +673,7 @@
GSERIALIZED *g = NULL;
GSERIALIZED *g_out = NULL;
size_t g_out_size;
- LWPOINT *lwpoint = NULL;
+ LWGEOM *lwpoint = NULL;
POINT2D pt;
/* Get our geometry object loaded into memory. */
@@ -691,9 +691,12 @@
/* Get an exterior point, based on this gbox */
gbox_pt_outside(&gbox, &pt);
- lwpoint = lwpoint_make2d(4326, pt.x, pt.y);
-
- g_out = gserialized_from_lwgeom((LWGEOM*)lwpoint, 1, &g_out_size);
+ lwpoint = (LWGEOM*) lwpoint_make2d(4326, pt.x, pt.y);
+ /* TODO: Investigate where this is used, this was probably not
+ * returning a geography object before. How did this miss checking
+ */
+ lwgeom_set_geodetic(lwpoint, true);
+ g_out = gserialized_from_lwgeom(lwpoint, &g_out_size);
SET_VARSIZE(g_out, g_out_size);
PG_FREE_IF_COPY(g, 0);
Modified: trunk/postgis/lwgeom_dumppoints.c
===================================================================
--- trunk/postgis/lwgeom_dumppoints.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/postgis/lwgeom_dumppoints.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -233,7 +233,7 @@
pathpt[0] = PointerGetDatum(construct_array(state->path, state->pathlen+1,
INT4OID, state->typlen, state->byval, state->align));
- pathpt[1] = PointerGetDatum(gserialized_from_lwgeom((LWGEOM*)lwpoint,0,0));
+ pathpt[1] = PointerGetDatum(gserialized_from_lwgeom((LWGEOM*)lwpoint,0));
tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
result = HeapTupleGetDatum(tuple);
Modified: trunk/postgis/lwgeom_geos.c
===================================================================
--- trunk/postgis/lwgeom_geos.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/postgis/lwgeom_geos.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -1375,7 +1375,7 @@
if (lwgeom_result == NULL)
lwpgerror("ST_OffsetCurve: lwgeom_offsetcurve returned NULL");
- gser_result = gserialized_from_lwgeom(lwgeom_result, 0, 0);
+ gser_result = gserialized_from_lwgeom(lwgeom_result, 0);
lwgeom_free(lwgeom_input);
lwgeom_free(lwgeom_result);
PG_RETURN_POINTER(gser_result);
@@ -3566,7 +3566,7 @@
result_array_data = palloc(nclusters * sizeof(Datum));
for (i=0; i<nclusters; ++i)
{
- result_array_data[i] = PointerGetDatum(gserialized_from_lwgeom(lw_results[i], 0, NULL));
+ result_array_data[i] = PointerGetDatum(gserialized_from_lwgeom(lw_results[i], NULL));
lwgeom_free(lw_results[i]);
}
pfree(lw_results);
Modified: trunk/raster/rt_pg/rtpg_geometry.c
===================================================================
--- trunk/raster/rt_pg/rtpg_geometry.c 2015-11-30 16:11:51 UTC (rev 14452)
+++ trunk/raster/rt_pg/rtpg_geometry.c 2015-11-30 16:24:57 UTC (rev 14453)
@@ -102,7 +102,7 @@
PG_RETURN_NULL();
}
- gser = gserialized_from_lwgeom(geom, 0, &gser_size);
+ gser = gserialized_from_lwgeom(geom, &gser_size);
lwgeom_free(geom);
SET_VARSIZE(gser, gser_size);
@@ -181,7 +181,7 @@
PG_RETURN_NULL();
}
- gser = gserialized_from_lwgeom(geom, 0, &gser_size);
+ gser = gserialized_from_lwgeom(geom, &gser_size);
lwgeom_free(geom);
SET_VARSIZE(gser, gser_size);
@@ -323,7 +323,7 @@
memset(nulls, FALSE, sizeof(bool) * values_length);
/* convert LWGEOM to GSERIALIZED */
- gser = gserialized_from_lwgeom(lwpoly_as_lwgeom(geomval2[call_cntr].geom), 0, &gser_size);
+ gser = gserialized_from_lwgeom(lwpoly_as_lwgeom(geomval2[call_cntr].geom), &gser_size);
lwgeom_free(lwpoly_as_lwgeom(geomval2[call_cntr].geom));
values[0] = PointerGetDatum(gser);
@@ -625,7 +625,7 @@
memset(nulls, FALSE, sizeof(bool) * values_length);
/* convert LWGEOM to GSERIALIZED */
- gser = gserialized_from_lwgeom(pix2[call_cntr].geom, 0, &gser_size);
+ gser = gserialized_from_lwgeom(pix2[call_cntr].geom, &gser_size);
lwgeom_free(pix2[call_cntr].geom);
values[0] = PointerGetDatum(gser);
More information about the postgis-tickets
mailing list