#include "DiffKMLNetOutput.h" #include "StarLink.h" #include "StarNetwork.h" #include #include #include #include #include #include DiffKMLNetOutput::DiffKMLNetOutput(StarNetwork* net, const std::vector& flowDiff, FPType tolerance) : KMLNetOutput(net), flowDiff_(flowDiff), scaleFactor_(1), tolerance_(tolerance) { calcScalingFactor(); }; void DiffKMLNetOutput::calcScalingFactor(){ FPType maxDiff = 0.0; FPType minDiff = std::numeric_limits::infinity(); for (size_t i = 0; i < flowDiff_.size(); ++i){ FPType absDiff = fabs(flowDiff_[i]); if (absDiff > maxDiff) maxDiff = absDiff; if (absDiff < minDiff) minDiff = absDiff; } std::cout << "maxDiff = " << maxDiff << " minDiff = " << minDiff << std::endl; scaleFactor_ = maxDiff / maxLength_; assert(scaleFactor_ != 0); }; DiffKMLNetOutput::DiffKMLNetOutput(StarNetwork* net, const std::string& logFileForMissingIDs, const std::vector& flowDiff, FPType tolerance) : KMLNetOutput(net, logFileForMissingIDs), flowDiff_(flowDiff), tolerance_(tolerance) { }; DiffKMLNetOutput::~DiffKMLNetOutput(){ }; FPType DiffKMLNetOutput::calcLineWidth(StarLink* link){ return flowDiff_[link->getIndex()] / scaleFactor_; }; std::string DiffKMLNetOutput::createColorFromLineWidth(FPType lineWidth){ if (lineWidth == 0) return getGreenColor(); if (lineWidth < 0.0) return "50F0C814";//getBlueColor(); return "501478FF";//getRedColor(); }; std::string DiffKMLNetOutput::createLineWidth(FPType lineWidth){ if (lineWidth == 0) lineWidth = 3; std::stringstream ss; ss << fabs(lineWidth); return ss.str(); }; bool DiffKMLNetOutput::shouldCreatePlacemark(StarLink* link) { return true; }; std::string DiffKMLNetOutput::createDescriptionString(StarLink* link) { std::stringstream ss; ss << "difference: " << flowDiff_[link->getIndex()]; return ss.str(); };