void TessellateOperator::operator()( Feature* feature, FilterContext& context ) const { if (_numPartitions <= 1 || !feature || !feature->getGeometry() || feature->getGeometry()->getComponentType() == Geometry::TYPE_POINTSET ) { return; } bool isGeo = context.profile() ? context.profile()->getSRS()->isGeographic() : true; GeoInterpolation interp = feature->geoInterp().isSet() ? *feature->geoInterp() : _defaultInterp; GeometryIterator i( feature->getGeometry(), true ); while( i.hasMore() ) { Geometry* g = i.next(); bool isRing = dynamic_cast<Ring*>( g ) != 0L; Vec3dVector newVerts; newVerts.reserve( g->size() * _numPartitions ); for( Geometry::const_iterator v = g->begin(); v != g->end(); ++v ) { const osg::Vec3d& p0 = *v; if ( v != g->end()-1 ) // not last vert { if ( isGeo ) tessellateGeo( *v, *(v+1), _numPartitions, interp, newVerts ); else tessellateLinear( *v, *(v+1), _numPartitions, newVerts ); } else if ( isRing ) { if ( isGeo ) tessellateGeo( *v, *g->begin(), _numPartitions, interp, newVerts ); else tessellateLinear( *v, *g->begin(), _numPartitions, newVerts ); } else { // get the final vert. newVerts.push_back( *v ); } } g->swap( newVerts ); } }