Boost logo

Geometry :

Subject: [ggl] [order] 2: read_wkt to read
From: Barend Gehrels (barend)
Date: 2011-02-27 06:49:47


Hi,

Yesterday I mailed part 1 of the order of parameters (combine). This is
about read_wkt.

It's signature: void read_wkt(string, Geometry);

should probably change to read_wkt(Geometry, string) to conform to the
order GeometryIn, GeometryOut, others.

At the same time, read_wkt is currently an extension. It is extensively
used in nearly every testcase, many samples, etc. If we go to the
release-branche, we either should skip all extensions or move WKT to
something else.

To allow for all these changes at the same time, I propose the following.

1) We make a new folder "domains" which is subdivided as the
"extensions" are. So we now get a:
domains/gis/io/wkt for the WKT-parser.

2) We move wkt to there

3) At the higher level (in io, or in domains, or in algorithms) we make
one new algorithm called "read". This one has a required template
parameter denoting the format. And it reverses the arguments. So we get,
for example:

polygon_2d triangle;
boost::geometry::read<format_wkt>(triangle, "POLYGON((1 1,1 2,2 1,1 1))");

and we can get the same for format_wkb and possibly other formats we
will support for reading. There even might be a format_autodetect which
figures out the format from the string. In OGC this algorithm is called
geomfromtext, returning a geometry. I had this earlier but it was
discarded because there are so many text formats, but now we might
consider using that name again.

Changing all read_wkt to read<format_wkt> will be a bigger change
especially for me, because of all tests (reversing the arguments), but I
think it is manageable, and better like this. The read_wkt function
itself can stay in extensions for backwards compatiblity, with a
compiler warning that it is deprecated.

There is one tweak, because there is also:
read_wkt(std::string const& wkt, OutputIterator out)
only working for linestring and ring. This case is probably not used and
might be deprecated either (so no new function read<format_wkt> for it).

Objections to this all?

Regards, Barend

-- 
Barend Gehrels
http://about.me/barendgehrels

Geometry list run by mateusz at loskot.net