[geos-devel] WKB parser templates, Safe patches, GEOS<3>

strk at refractions.net strk at refractions.net
Wed Apr 20 13:22:56 EDT 2005


On Wed, Apr 20, 2005 at 01:07:48PM +0200, strk at refractions.net wrote:
> On Wed, Apr 20, 2005 at 11:48:20AM +0100, Artem Pavlenko wrote:
> > I don't know all the details, but sounds like a good idea,
> > I cannot think about any system that spits out WKB stream, but who knows?
> > 
> > template<typename IStream>
> > struct WKBReader
> > {  
> >        ByteOrderDataInStream<IStream> in;
> > };
> >  
> > Then IStream can be sstream, fstream etc.
> 
> I'll give a try to ByteOrderDataInStream class template
> and report here for review.

As promised I've implemented the two templates and committed
them to CVS. The code can't currently work as the WKBReader
class requires a new interface on CoordinateSequence to take
higher-dimensioned Coordinate to be used.

You can review the template code at
source/headers/geos/WKBReaderT.h and
source/headers/geosByteOrderDataInStreamT.h

I used a 'T' prefix to allow for later typedefs to provide
a default implementation (ie. typedef WKBReaderT<istream> WKBReader).

Meanwhile I received the patches from Safe software, I'm going to
stop work on WKB parser for now and apply those patches, next I'd
approach the CoordinateSequence changes as introduced in JTS.

Again we might choose to use templates there as the big problem with
CoordinateSeuquence is that we can't inline due to virtual interface.

I really think this is matter for GEOS<3> branch and invite everyone
to express on this. I don't think we can keep current ABI porting new
JTS functionalities anyway...

--strk;

> 
> --strk;
> 
> > 
> > Java-ish interfaces dont work well in c++:(
> > 
> > PS. I wonder how you're going to swap doubles. Macros?
> > 
> > >In the process of porting the WKB parser from JTS
> > >to GEOS I encoutered one of the situation which in
> > >the past have led to poor-performing code.
> > >
> > >JTS WKBReader object uses an ByteOrderDataInStream
> > >object to read a byte, an int, a long and a double.
> > >The ByteOrderDataInStream object can be initialized
> > >with an InStream object to set it's input source.
> > >WKBReader object can also accept an InStream object
> > >to initialize its internal ByteOrderDataInStream.
> > >
> > >Now, for JTS InStream is an INTERFACE. 
> > >This has been in the past ported to a virtual base
> > >class.
> > >
> > >My understanding of it is that it is intended to
> > >be used to abstract reading from a memory buffer
> > >and reading from a stream. Currently only reading
> > >from a memory buffer is implemented using the
> > >derived class ByteArrayInStream.
> > >
> > >Is this a good candidate for templating ?
> > >Shouldn't we use standard C++ templates for this ?
> > >Would InStream really be an istream ?
> > >
> > >Comments welcome.
> > >
> > >--strk;
> > >_______________________________________________
> > >geos-devel mailing list
> > >geos-devel at geos.refractions.net
> > >http://geos.refractions.net/mailman/listinfo/geos-devel
> > >
> > >
> > > 
> > >
> > 
> > _______________________________________________
> > geos-devel mailing list
> > geos-devel at geos.refractions.net
> > http://geos.refractions.net/mailman/listinfo/geos-devel
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel



More information about the geos-devel mailing list