[postgis-devel] Re: [postgis-users] how to identify the_geom that cause : RelateOperation called withLWGEOMCOLLECTION type
Kevin Neufeld
kneufeld at refractions.net
Wed Dec 10 12:48:52 PST 2008
Yup, that's makes sense ... it's similar to what I have in errorIfGeometryCollection.
Doing a little testing, however, I'm not clear on what you were expecting to see based on certain inputs - my expected
results don't match the function output. I put the function in a little test.c file to test the method where:
char* str = "abcdefghijklmnopqrstuvwxyz";
// Assuming 0-based indexing
lwmessage_truncate(str, 0, strlen(str)-1, 26, 0);
expected: "abcdefghijklmnopqrstuvwxyz"
output: "abcdefghijklmnopqrstuvwxy"
lwmessage_truncate(str, 0, strlen(str)-1, 26, 1);
expected: "abcdefghijklmnopqrstuvwxyz"
output: "abcdefghijklmnopqrstuvwxy"
lwmessage_truncate(str, 0, strlen(str)-1, 25, 0);
expected: "...efghijklmnopqrstuvwxyz"
output: "abcdefghijklmnopqrstuvwxy"
lwmessage_truncate(str, 0, strlen(str)-1, 25, 1);
expected: "abcdefghijklmnopqrstuv..."
output: "abcdefghijklmnopqrstuvwxy"
lwmessage_truncate(str, 0, strlen(str)-1, 10, 1);
expected: "abcdefg..."
output: "abcdefg..."
lwmessage_truncate(str, 2, strlen(str)-1, 10, 1);
expected: "cdefghi..."
output: "abcdefg..."
lwmessage_truncate(str, 4, strlen(str)-1, 10, 1);
expected: "efghijk..."
output: "abcdefg..."
lwmessage_truncate(str, 0, strlen(str)-1, 10, 0);
expected: "...tuvwxyz"
output: "...stuvwxy"
lwmessage_truncate(str, 0, strlen(str)-3, 10, 0);
expected: "...rstuvwx"
output: "...qrstuvw"
lwmessage_truncate(str, 0, strlen(str)-5, 10, 0);
expected: "...pqrstuv"
output: "...opqrstu"
lwmessage_truncate(str, 0, strlen(str)-1, 4, 1);
expected: "a..."
output: "a..."
lwmessage_truncate(str, 0, strlen(str)-1, 3, 1);
expected: "a.."
output: "..."
lwmessage_truncate(str, 0, strlen(str)-1, 2, 1);
expected: "a."
output: "abcdefghijklmnopqrstuvwxyz..."
*** glibc detected *** free(): invalid next size (fast): 0x08b88028 ***
Aborted
Am I using it correctly?
Cheers,
Kevin
Mark Cave-Ayland wrote:
> Kevin Neufeld wrote:
>
>> Thanx Mark,
>>
>> Here's an updated patch. I didn't put the truncation logic in a
>> separate function yet since I'm not sure about freeing the memory of a
>> returned char* (looking through the code, sometimes pfree is called,
>> and other times it's not).
>>
>> Cheers,
>> Kevin
>
>
> Hi Kevin,
>
> Please see the new lwmessage_truncate() function I have just committed
> to liblwgeom in trunk - it should now just be a matter of feeding in the
> right numbers :)
>
> Note the function returns a newly-palloced() string, but in the case of
> throwing an ERROR, I suspect that the query memory context is destroyed
> automatically and hence will pfree() the string as part of that process.
>
>
> HTH,
>
> Mark.
>
More information about the postgis-devel
mailing list