Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3034 closed defect (fixed)

ST_AsTWKBagg does not check the input precision

Reported by: javisantana Owned by: nicklas
Priority: medium Milestone:
Component: postgis Version: master
Keywords: Cc:

Description

running the following query

test_postgis=# select ST_AsTWKBagg(st_makepoint(10,10), 10) from generate_series(1, 10);
ERROR:  Output TWKB is not the same size as the allocated buffer (precalculated size:31, allocated size:33)

if you use st_astwkb you get

test_postgis=# select ST_AsTWKB(st_makepoint(10,10), 10);
ERROR:  precision cannot be more than 7

ST_AsTWKBagg method lacks of checking (see attached path) but I'm pretty sure that check should be done at encoding level.

Also I'm not sure why the precision is limited to 7

Attachments (1)

twkb_agg.patch (447 bytes ) - added by javisantana 10 years ago.

Download all attachments as: .zip

Change History (5)

by javisantana, 10 years ago

Attachment: twkb_agg.patch added

comment:1 by pramsey, 10 years ago

Owner: changed from pramsey to nicklas

comment:2 by nicklas, 10 years ago

Thanks javisantana!

I didn't read properly so I added the check a little later in the file. I missed the patch. Your placing of the check is more logical, but I leave it where it is. I will commit some major rework of the twkb-code anyway soon. Then I think as Sandro proposed some time ago that the aggregation code should go in a separate file.

THe reason of the limit of 7 decimals is because it is stored in 4 bts, and as discussed here: https://github.com/TWKB/Specification/issues/5 and here https://github.com/TWKB/Specification/issues/9 there should probably be possible to use negative values too, for meter based projections on low zoom-levels. So, since there is still no conclusion about that I have left space for allowing negative numbers in one way or another (will need 1 bit no matter how it is done I guess).

Is there a need for more than 7 decimals? Well, it can be of course, maybe it should be. I don't know.

There is still the fourth bit available, but I would like to use that for zoom-levels (Is there a bitmap included for zoom-levels). But I have to prove that it is usable first :-)

Anyway this is not the place for this discussion. Github is better as an issue for the twkb spec.

comment:3 by nicklas, 10 years ago

Resolution: fixed
Status: newclosed
Version: 2.1.xtrunk

Oh, forget the revision number

fixed at r13209

comment:4 by javisantana, 10 years ago

Hey, thanks for the explanation nicklass. I think 7 is more than needed for the majority of apps, i just wanted to know the reason.

Note: See TracTickets for help on using tickets.