From: Sandro Santilli Date: Wed, 30 Sep 2015 15:37:40 +0000 (+0000) Subject: Honour topology-wide precision configuration (#3304) X-Git-Tag: 2.2.0~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40ee7755ea706e66b0ecd7539605762270155bd5;p=postgis Honour topology-wide precision configuration (#3304) NOTE: only 2.2.0-RC1 was published with this bug present git-svn-id: http://svn.osgeo.org/postgis/trunk@14156 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c index 337b18ec1..e46ac1f2c 100644 --- a/topology/postgis_topology.c +++ b/topology/postgis_topology.c @@ -77,7 +77,7 @@ struct LWT_BE_TOPOLOGY_T { char *name; int id; int srid; - int precision; + double precision; int hasZ; }; @@ -156,7 +156,7 @@ cb_loadTopologyByName(const LWT_BE_DATA* be, const char *name) MemoryContext oldcontext = CurrentMemoryContext; initStringInfo(sql); - appendStringInfo(sql, "SELECT id,srid FROM topology.topology " + appendStringInfo(sql, "SELECT id,srid,precision FROM topology.topology " "WHERE name = '%s'", name); spi_result = SPI_execute(sql->data, !be->data_changed, 0); MemoryContextSwitchTo( oldcontext ); /* switch back */ @@ -208,10 +208,17 @@ cb_loadTopologyByName(const LWT_BE_DATA* be, const char *name) topo->srid = SRID_UNKNOWN; } - topo->precision = 0; /* needed ? */ + dat = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 3, &isnull); + if ( isnull ) { + lwnotice("Topology '%s' has null precision, taking as 0", name); + topo->precision = 0; /* TODO: should this be -1 instead ? */ + } else { + topo->precision = DatumGetFloat8(dat); + } - POSTGIS_DEBUGF(1, "cb_loadTopologyByName: topo '%s' has id %d, srid %d", - name, topo->id, topo->srid); + POSTGIS_DEBUGF(1, "cb_loadTopologyByName: topo '%s' has " + "id %d, srid %d, precision %g", + name, topo->id, topo->srid, topo->precision); return topo; }