/*private*/ void BufferOp::bufferReducedPrecision() { // try and compute with decreasing precision, // up to a min, to avoid gross results // (not in JTS, see http://trac.osgeo.org/geos/ticket/605) #define MIN_PRECISION_DIGITS 6 for (int precDigits=MAX_PRECISION_DIGITS; precDigits >= MIN_PRECISION_DIGITS; precDigits--) { #if GEOS_DEBUG std::cerr<<"BufferOp::computeGeometry: trying with precDigits "<<precDigits<<std::endl; #endif try { bufferReducedPrecision(precDigits); } catch (const util::TopologyException& ex) { saveException=ex; // don't propagate the exception - it will be detected by fact that resultGeometry is null } if (resultGeometry!=NULL) { // debug //if ( saveException ) std::cerr<<saveException->toString()<<std::endl; return; } } // tried everything - have to bail throw saveException; }
/*private*/ void BufferOp::bufferReducedPrecision() { // try and compute with decreasing precision for (int precDigits=MAX_PRECISION_DIGITS; precDigits >= 0; precDigits--) { #if GEOS_DEBUG std::cerr<<"BufferOp::computeGeometry: trying with precDigits "<<precDigits<<std::endl; #endif try { bufferReducedPrecision(precDigits); } catch (const util::TopologyException& ex) { saveException=ex; // don't propagate the exception - it will be detected by fact that resultGeometry is null } if (resultGeometry!=NULL) { // debug //if ( saveException ) std::cerr<<saveException->toString()<<std::endl; return; } } // tried everything - have to bail throw saveException; }
/*private*/ void BufferOp::computeGeometry() { #if GEOS_DEBUG std::cerr<<"BufferOp::computeGeometry: trying with original precision"<<std::endl; #endif bufferOriginalPrecision(); if (resultGeometry!=NULL) return; #if GEOS_DEBUG std::cerr << "bufferOriginalPrecision failed (" << saveException.what() << "), trying with reduced precision" << std::endl; #endif const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel()); if ( argPM.getType() == PrecisionModel::FIXED ) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }