[Gdal-dev] importFromWkt() problem

Mateusz Loskot mateusz at loskot.net
Sat Sep 2 10:38:17 EDT 2006


Petteri Packalen wrote:
> Frank, list,
> 
> Once again, I struggled with the weird problem until I understood to
> look at the documentation... The problem was that, within
> importFromWkt(), the pointer was updated to pointer after the consumed
> text. However, I don't still understand why the first *corrected*
> solution does not work properly. I want to reset the geometry of an
> existing feature based on WKT representation. Below are two examples in
> which only the latter one works properly. An example 1 crashes due to
> illegal memory access. geo_trans is a buffer which stores WKT.
> 
> EXAMPLE 1
> =========
> OGRPolygon * poPoly = new OGRPolygon();
> poPoly->importFromWkt( &geo_trans );

Please show your geo_trans declaration and initialization.

> In the comment within the ogrgeometryfactory.cpp it states that
> "createFromWkt() now updates pointer to text to indicate how much text
> was consumed". I understand that this can be useful in many occasions
> although I don't understand why it is implemented this way. Anyway, why
> the first solution does not work?

I believe Frank is able to answer this question.

> In addition, in an example 1 the
> problem occurres only after very many (>million) calls to
> importFromWkt(). Something is happening in the background (related to
> reference counting etc.?) I don't understand.

You mean, you're importing ~1 million geometries from WKT strings?
Are you sure you're doing fresh WKT initialization for every geometry?

Please, show us more complete piece of code, with declarations and
definitions of all variables that play in the example 1.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Gdal-dev mailing list