void KMLNetOutput::createKML(const std::string& fileWithNodes, const std::string& kmlFileName){ std::cout << "KML will be written to: " << kmlFileName << std::endl; int nbNodes = net_->getNbNodes(); std::vector<FPType> xCoord(nbNodes, 0); std::vector<FPType> yCoord(nbNodes, 0); std::vector<int> nodeID(nbNodes, 0); readCoord(fileWithNodes, xCoord, yCoord, nodeID); FileWriter writeKml(kmlFileName); writeKml.writeLine(createKmlHeader()); for (StarLink* link = net_->beginOnlyLink(); link != NULL; link = net_->getNextOnlyLink()) { if (shouldCreatePlacemark(link)) { int tail = link->getNodeFromIndex(); int head = link->getNodeToIndex(); FPType x1 = xCoord[tail]; FPType y1 = yCoord[tail]; FPType x2 = xCoord[head]; FPType y2 = yCoord[head]; if (x1 == 0 && y1 == 0) std::cout << "Missing node coordinate: " << link->getNodeFrom() << " link: " << link->toString() << std::endl; if (x2 == 0 && y2 == 0) std::cout << "Missing node coordinate: " << link->getNodeTo() << " link: " << link->toString() << std::endl; if (x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0) writeKml.writeLine(createPlacemark(x1, y1, x2, y2, link)); } } writeKml.writeLine(createKmlFooter()); };
int findLinkIndex(int tail, int head, StarNetwork* net, int guessIndex){ StarLink* link = net->getLink(guessIndex); assert(link != NULL); if (link->getNodeFrom() == tail && link->getNodeTo() == head) { return link->getIndex(); } return -1; };