Commit 06f949e5 authored by thillux's avatar thillux
Browse files

kml output with circles

parent 7f75caf1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
{
  "cityfilter" : {
    "citysizethreshold" : 300000
    "citysizethreshold" : 100000
  },

  "neighbourCluster" : {
@@ -42,6 +42,7 @@

  "kml_graph_output" : {
    "pins" : {
      "enabled" : false,
      "color" : "FF4F1B",
      "alpha" : 1.0
    },
@@ -54,6 +55,7 @@
      "alpha" : 1.0
    },
    "seacablepins" : {
      "enabled" : false,
      "color" : "80DCEA",
      "alpha" : 1.0
    },
+9 −1
Original line number Diff line number Diff line
@@ -29,7 +29,15 @@

#include "CMDArgs.hpp"

CMDArgs::CMDArgs(int argc, char** argv) : _desc("Allowed options"), _vm(), kmlOutput(false), graphOutput(false), jsonOutput(false), seed(), simNodesJSONPath(), jsonOutFile() {
CMDArgs::CMDArgs(int argc, char** argv)
    : _desc("Allowed options"),
      _vm(),
      kmlOutput(false),
      graphOutput(false),
      jsonOutput(false),
      seed(),
      simNodesJSONPath(),
      jsonOutFile() {
    _desc.add_options()("help", "produce help message")("kml", po::value<bool>(&kmlOutput)->zero_tokens())(
        "json", po::value<bool>(&jsonOutput)->zero_tokens())("graph", po::value<bool>(&graphOutput)->zero_tokens())(
        "seed", po::value<std::string>(&seed)->default_value("run1"))(
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@
#include <sys/types.h>
#include <unistd.h>

PopulationDensityReader::PopulationDensityReader(void) : _file(open(PredefinedValues::popDensityFilePath().c_str(), O_RDONLY)), _header(), _data(nullptr) {
PopulationDensityReader::PopulationDensityReader(void)
    : _file(open(PredefinedValues::popDensityFilePath().c_str(), O_RDONLY)), _header(), _data(nullptr) {
    assert(_file != -1);
    parseHeader();
    readData();
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ class ResultIterator {
    virtual Result getNext() = 0;

    virtual ~ResultIterator() {}

   protected:
    bool _rowAvailable;
};
+68 −20
Original line number Diff line number Diff line
@@ -42,7 +42,16 @@
#include <iterator>

KMLWriter::KMLWriter(BaseTopology_Ptr baseTopo)
    : _baseTopo(baseTopo), _graph(_baseTopo->getGraph()), _nodeInfos(_baseTopo->getNodeMap()), _pincolor(), _edgecolor(), _seacableColor(), _seacablePinColor(), _kmlOut() {
    : _baseTopo(baseTopo),
      _graph(_baseTopo->getGraph()),
      _nodeInfos(_baseTopo->getNodeMap()),
      _pincolor(),
      _edgecolor(),
      _seacableColor(),
      _seacablePinColor(),
      _kmlOut(),
      _drawLocationPins(true),
      _drawSeacablePins(true) {
    setEdgeColor("ffffff", 1.0);
    setPinColor("ffffff", 1.0);
}
@@ -76,7 +85,7 @@ void KMLWriter::createKML() {
        }

        {
            // set iconstyle
            // set linestyle
            _kmlOut << "<LineStyle>\n";
            _kmlOut << "<color>" << _edgecolor << "</color>\n";
            _kmlOut << "<colorMode>normal</colorMode>\n";
@@ -84,6 +93,16 @@ void KMLWriter::createKML() {
            _kmlOut << "</LineStyle>\n";
        }

        {
            // set polystyle
            _kmlOut << "<PolyStyle>\n";
            _kmlOut << "<color>" << _edgecolor << "</color>\n";
            _kmlOut << "<colorMode>normal</colorMode>\n";
            _kmlOut << "<fill>1</fill>\n";
            _kmlOut << "<outline>1</outline>\n";
            _kmlOut << "</PolyStyle>\n";
        }

        _kmlOut << "</Style>\n";
    }

@@ -110,8 +129,21 @@ void KMLWriter::createKML() {
        _kmlOut << "</Style>\n";
    }

    // iterate over all edges
    using namespace lemon;

    for (ListGraph::NodeIt node(*_graph); node != lemon::INVALID; ++node) {
        GeographicNode_Ptr place = (*_nodeInfos)[node];
        if (!place->isValid())
            continue;

        bool isCityNode = dynamic_cast<CityNode*>(place.get()) != nullptr;
        if (!isCityNode)
            continue;

        drawCircleAt(place->lat(), place->lon());
    }

    // iterate over all edges
    for (ListGraph::EdgeIt edge(*_graph); edge != lemon::INVALID; ++edge) {
        GeographicNode_Ptr n1 = (*_nodeInfos)[_graph->u(edge)];
        GeographicNode_Ptr n2 = (*_nodeInfos)[_graph->v(edge)];
@@ -156,10 +188,18 @@ void KMLWriter::createKML() {
        if (!place->isValid())
            continue;

        bool isCityNode = dynamic_cast<CityNode*>(place.get()) != nullptr;
        bool isSeaCableLandingPoint = dynamic_cast<SeaCableLandingPoint*>(place.get()) != nullptr;

        if (isCityNode && !_drawLocationPins)
            continue;

        if (isSeaCableLandingPoint && !_drawSeacablePins)
            continue;

        if (isCityNode || isSeaCableLandingPoint) {
            _kmlOut << "<Placemark>\n";

        if (dynamic_cast<CityNode*>(place.get()) != nullptr ||
            dynamic_cast<SeaCableLandingPoint*>(place.get()) != nullptr) {
            _kmlOut << "<name>";

            if (dynamic_cast<CityNode*>(place.get()) != nullptr) {
@@ -173,7 +213,6 @@ void KMLWriter::createKML() {
            }

            _kmlOut << "</name>\n";
        }

            _kmlOut << "<styleUrl>";

@@ -195,6 +234,7 @@ void KMLWriter::createKML() {

            _kmlOut << "</Placemark>\n";
        }
    }

    _kmlOut << "</Document>\n";
    _kmlOut << "</kml>\n";
@@ -227,6 +267,14 @@ std::string KMLWriter::alphaToHex(double alpha) {
    return intToHex(a_i);
}

void KMLWriter::disableSeacablePins() {
    _drawSeacablePins = false;
}

void KMLWriter::disableLocationsPins() {
    _drawLocationPins = false;
}

std::string KMLWriter::hexToKML(std::string hex) {
    assert(hex.length() == 6);

Loading