[geos-devel] Ability to preallocate the WKT stringstream buffer for really large geometries?

Mats Taraldsvik mats.taraldsvik at norkart.no
Thu Feb 21 04:30:57 PST 2013


> -----Opprinnelig melding-----
> Fra: geos-devel-bounces at lists.osgeo.org [mailto:geos-devel-
> bounces at lists.osgeo.org] På vegne av Mateusz Loskot
> Sendt: 21. februar 2013 12:43
> Til: GEOS Development List
> Emne: Re: [geos-devel] Ability to preallocate the WKT stringstream buffer for
> really large geometries?
> 
> On 21 February 2013 09:41, Sandro Santilli <strk at keybit.net> wrote:
> > On Thu, Feb 21, 2013 at 09:22:36AM +0000, Mats Taraldsvik wrote:
> >
> >> Locally, I have modified the WKTWriter::writeNumber(double d) method
> to use boost::spirit::karma::real_generator for conversion of numbers,
> instead of std::stringstream. This improves writing WKT by 6x-10x on my
> datasets (tested with linestrings with up to 10000 points). This change *is
> not* part of the patch for two reasons:
> >>
> >> - I don't know whether you want to introduce a dependency on
> boost::spirit::karma, although it is header-only, so it might not be a large
> barrier.
> >>
> >> - The precision and fixed notation parametres are changed by using
> policies, essentially structs with static methods that return the precision,
> trailing_zeros etc. I might be incorrect, but I would have to make policies
> (structs) for every combination of fixed and decimalPlaces and determine at
> runtime which of them to use, to make the approach suitable for GEOS. This
> is easily done, but I don't know if you think it is worth it?
> >
> > No, I don't think we should introduce a dependency on boost yet.
> 
> Any chance to at least conditionally-compile for C++11 and use
> 
> http://en.cppreference.com/w/cpp/string/basic_string/stof

If you do, consider similar functions for the reverse conversion :

http://en.cppreference.com/w/cpp/string/basic_string/to_string

Both simpler and faster than std::stringstream. :)

> 
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel

Vennlig hilsen

Mats Taraldsvik
+47 901 65 934


More information about the geos-devel mailing list