/*public*/ void OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts, double nDistance, vector<CoordinateSequence*>& lineList) { distance = nDistance; // a zero or (non-singlesided) negative width buffer of a line/point is empty if (distance == 0.0) return; if (distance < 0.0 && ! bufParams.isSingleSided()) return; double posDistance = std::abs(distance); std::auto_ptr<OffsetSegmentGenerator> segGen = getSegGen(posDistance); if (inputPts->getSize() <= 1) { computePointCurve(inputPts->getAt(0), *segGen); } else { if (bufParams.isSingleSided()) { bool isRightSide = distance < 0.0; computeSingleSidedBufferCurve(*inputPts, isRightSide, *segGen); } else { computeLineBufferCurve(*inputPts, *segGen); } } segGen->getCoordinates(lineList); }
/*public*/ void OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts, double distance, vector<CoordinateSequence*>& lineList) { // a zero or negative width buffer of a line/point is empty if (distance<= 0.0) return; init(distance); if (inputPts->getSize() <= 1) { switch (bufParams.getEndCapStyle()) { case BufferParameters::CAP_ROUND: addCircle(inputPts->getAt(0), distance); break; case BufferParameters::CAP_SQUARE: addSquare(inputPts->getAt(0), distance); break; default: // default is for buffer to be empty // (e.g. for a butt line cap); break; } } else { computeLineBufferCurve(*inputPts); } // NOTE: we take ownership of lineCoord here ... CoordinateSequence *lineCoord=vertexList->getCoordinates(); // ... and we give it away here lineList.push_back(lineCoord); }
/*public*/ void OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts, double distance, vector<CoordinateSequence*>& lineList) { // a zero or negative width buffer of a line/point is empty if (distance<= 0.0) return; init(distance); if (inputPts->getSize() < 2) { switch (endCapStyle) { case BufferOp::CAP_ROUND: addCircle(inputPts->getAt(0), distance); break; case BufferOp::CAP_SQUARE: addSquare(inputPts->getAt(0), distance); break; // default is for buffer to be empty (e.g. for a butt line cap); } } else { computeLineBufferCurve(*inputPts); } CoordinateSequence *lineCoord=vertexList->getCoordinates(); lineList.push_back(lineCoord); }
/*public*/ void OffsetCurveBuilder::getSingleSidedLineCurve(const CoordinateSequence* inputPts, double distance, vector<CoordinateSequence*>& lineList, bool leftSide, bool rightSide) { // A zero or negative width buffer of a line/point is empty. if ( distance <= 0.0 ) return ; init( distance ) ; if ( inputPts->getSize() < 2 ) { // No cap, so just return. return ; } else { computeLineBufferCurve( *inputPts ) ; } // NOTE: we take ownership of lineCoord here ... std::auto_ptr<CoordinateSequence> lineCoord (vertexList->getCoordinates()); // [strk] Oct 1, 2009 // Left side: index [n-1] to [endCapIndex] // Right side: index [endCapIndex+1] to [n-2] // Where n is the last index (size-1). int n = lineCoord->size() - 1 ; // Add the left side curve to the line list. if ( leftSide ) { CoordinateArraySequence* coordSeq = new CoordinateArraySequence() ; //coordSeq->add( ( *lineCoord )[n-2] ) ; coordSeq->add( ( *lineCoord )[n-1] ) ; for ( int i = 0 ; i <= endCapIndex ; ++i ) { coordSeq->add( ( *lineCoord )[i] ) ; } lineList.push_back( coordSeq ) ; } // Add the right side curve to the line list. if ( rightSide ) { CoordinateArraySequence* coordSeq = new CoordinateArraySequence() ; for ( int i = endCapIndex+1 ; i <= n-2 ; ++i ) { coordSeq->add( ( *lineCoord )[i] ) ; } lineList.push_back( coordSeq ) ; } }