Since I'm porting the new geos::simplify package it might be worth discussing it a little bit making it a case study for further refactoring.
The DouglasPeuckerLineSimplifier class takes a list of Coordinates and returns a 'simplified' form of it, using the well known DP algorithm. The resulting point set is a subset of the input point set: no new points are added. In Java (JTS), both input and output are of type Coordinate[], with the return being a newly allocated list of newly allocated Coordinates. My first attempt at modelling this in C++ has been using std::vector<Coordinate> for both input and output, with return wrapped in an std::auto_ptr to model ownership transfer from the allocating class to the caller, and input being defined as 'const', to forbid modification of input. I committed it, so if anyone wants to take a look at possibly different implementation before proceeding that'd be appreciated. Note1: a possible improvement that comes into my mind at first is using Coordinate pointers rather then values, and maybe organized in a list rather then in a vector modifying input instead of allocating a new container and new values for output. Note2: every Geometry type has a CoordinateSequence as it's lowest level component. Current default implementation for that interface is CoordinateArraySequence, which is a vector of Coordinate values. The CoordinateSequence interface provides a toVector() function that returns that vector of Coordinates values as a const pointer. Wheter converting this "abstract" type to a more 'simplify-friendly' one is worth the conversion cost is not easy to tell as the CoordinateSequence implementation is opaque. Note3: the new class might as well directly work on CoordinateSequence. Will incurr in virtual calls penalty, but won't suffer from the 'conversion' problem in note2. That's all for now, I'll be debugging other parts of the code. --strk; /"\ ASCII Ribbon Campaign \ / Respect for low technology. X Keep e-mail messages readable by any computer system. / \ Keep it ASCII. _______________________________________________ geos-devel mailing list geos-devel@geos.refractions.net http://geos.refractions.net/mailman/listinfo/geos-devel