double WeightedSet::weight(IdentifierType id) const { Set::range_iterator rit = rangeLowerBound(id); if (rit != rangeEnd() && rit.low() <= id && id <= rit.high()) { return rangeWeight(rit.low()); } else { throw ErrorException(ErrorException::ERROR_INTERNAL, "element id out of range"); } }
static int32_t countOverlapsEntry(GTFtree *t, GTFentry *e, uint32_t start, uint32_t end, int strand, int matchType, int strandType, int direction, int32_t max, FILTER_ENTRY_FUNC ffunc) { int dir; int32_t cnt = 0; if(!e) return cnt; switch(matchType) { case GTF_MATCH_EXACT : if((dir = rangeExact(start, end, e)) == 0) { cnt = 1; } break; case GTF_MATCH_WITHIN : if((dir = rangeAny(start, end, e)) == 0) { if(rangeWithin(start, end, e) == 0) cnt = 1; } break; case GTF_MATCH_CONTAIN : if((dir = rangeAny(start, end, e)) == 0) { if(rangeContains(start, end, e) == 0) cnt = 1; } break; case GTF_MATCH_START : if((dir = rangeStart(start, end, e)) == 0) { cnt = 1; } break; case GTF_MATCH_END : if((dir = rangeEnd(start, end, e)) == 0) { cnt = 1; } break; default : if((dir = rangeAny(start, end, e)) == 0) { cnt = 1; } break; } if(cnt) { if(!matchingStrand(e, strand, strandType)) cnt = 0; } if(cnt && ffunc) { if(!ffunc(t, e)) cnt = 0; } if(max && cnt >= max) return max; if(direction) { if(dir > 0) return cnt; return cnt + countOverlapsEntry(t, e->right, start, end, strand, matchType, strandType, direction, max, ffunc); } else { if(dir < 0) return cnt; return cnt + countOverlapsEntry(t, e->left, start, end, strand, matchType, strandType, direction, max, ffunc); } }
std::string LineFeatureObs::toString() const { stringstream ss; ss << "LIN s=["<<rangeStart()<<","<<bearingStart()*180.0/M_PI<<"deg],e=[" << rangeEnd()<<","<<bearingEnd()*180.0/M_PI<<"deg] " << "(t="<<featureType()<<",pf="<<pFalsePositive()<<",pt="<<pTruePositive()<<")"; ss << endl << " (rho="<<rho()<<",a="<<alpha()*180.0/M_PI<<"deg), sd=("<<rhoSd()<<","<<alphaSd()*180.0/M_PI<<"deg)"; return ss.str(); }
static void pushOverlaps(overlapSet *os, GTFtree *t, GTFentry *e, uint32_t start, uint32_t end, int comparisonType, int direction, FILTER_ENTRY_FUNC ffunc) { int dir; int keep = 1; if(!e) return; if(ffunc) keep = ffunc(t, e); switch(comparisonType) { case GTF_MATCH_EXACT : if((dir = rangeExact(start, end, e)) == 0) { if(keep) os_push(os, e); } break; case GTF_MATCH_WITHIN : if((dir = rangeAny(start, end, e)) == 0) { if(keep) if(rangeWithin(start, end ,e) == 0) os_push(os, e); } break; case GTF_MATCH_CONTAIN : if((dir = rangeAny(start, end, e)) == 0) { if(keep) if(rangeContains(start, end, e) == 0) os_push(os, e); } break; case GTF_MATCH_START : if((dir = rangeStart(start, end, e)) == 0) { if(keep) os_push(os, e); } break; case GTF_MATCH_END : if((dir = rangeEnd(start, end, e)) == 0) { if(keep) os_push(os, e); } break; default : if((dir = rangeAny(start, end, e)) == 0) { if(keep) os_push(os, e); } break; } if(direction) { if(dir > 0) return; pushOverlaps(os, t, e->right, start, end, comparisonType, direction, ffunc); } else { if(dir < 0) return; pushOverlaps(os, t, e->left, start, end, comparisonType, direction, ffunc); } }
bool LineFeatureObs::isSane() const { if ( !hydrofeatureobs::isSane( pFalsePositive(), pTruePositive() ) ) return false; if ( rangeStart() < 0 ) return false; if ( bearingStart() < -M_PI || bearingStart() > M_PI ) return false; if ( rangeEnd() < 0 ) return false; if ( bearingEnd() < -M_PI || bearingEnd() > M_PI ) return false; if ( rho() < 0 ) return false; if ( alpha() < -M_PI || alpha() > M_PI ) return false; if ( rhoSd() < 0 || alphaSd() < 0 ) return false; return true; }
bool Set::intersection(const Set* set, Set** intersection, Set** complement) const { if (complement) { (*complement) = new Set(); } if (!set) { if (intersection) { (*intersection) = new Set(*this); } return true; } if (intersection) { (*intersection) = new Set(); } bool hasIntersection = false; Set::range_iterator filterIt = set->rangeBegin(); Set::range_iterator setIt = rangeBegin(); Set::range_iterator setEnd = rangeEnd(); Set::range_iterator filterEnd = set->rangeEnd(); for (; setIt != setEnd; ++setIt) { IdentifierType setLow = setIt.low(); IdentifierType setHigh = setIt.high(); if (filterIt == filterEnd) { if (!intersection && !complement) { return false; } if (complement) { (*complement)->insertRange(setLow, setHigh); } else { break; } } else { IdentifierType setCurr = setLow; while (filterIt != filterEnd) { IdentifierType filterLow = filterIt.low(); IdentifierType filterHigh = filterIt.high(); if (filterHigh < setLow) { ++filterIt; } else if (filterLow > setHigh) { break; } else { hasIntersection = true; if (!intersection && !complement) { return true; } if (complement && setCurr < filterLow) { (*complement)->insertRange(setCurr, filterLow - 1); } setCurr = min(setHigh, filterHigh); if (intersection) { (*intersection)->insertRange(max(filterLow, setLow), setCurr); } ++setCurr; if (filterHigh > setHigh) { break; } else { ++filterIt; } } } if (complement && setCurr <= setHigh) { (*complement)->insertRange(setCurr, setHigh); } } } return hasIntersection; }