[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3452: Use a custom KML Style and styleUrl to specify the image to (vidalia/branches/marble/src/vidalia/network)
Author: edmanm
Date: 2009-01-17 20:48:51 -0500 (Sat, 17 Jan 2009)
New Revision: 3452
Modified:
vidalia/branches/marble/src/vidalia/network/netviewer.cpp
vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp
vidalia/branches/marble/src/vidalia/network/tormapwidget.h
Log:
Use a custom KML Style and styleUrl to specify the image to load for relay
placemarks. Also specify the description, address and country code fields. Use
a non-standard role value (which are limited to a single character
unfortunately) so we can differentiate relay placemarks from, say, the Titanic
when the user clicks on the map.
Modified: vidalia/branches/marble/src/vidalia/network/netviewer.cpp
===================================================================
--- vidalia/branches/marble/src/vidalia/network/netviewer.cpp 2009-01-18 01:39:15 UTC (rev 3451)
+++ vidalia/branches/marble/src/vidalia/network/netviewer.cpp 2009-01-18 01:48:51 UTC (rev 3452)
@@ -470,8 +470,7 @@
/* Save the location information in the descriptor */
router->setLocation(geoip);
/* Plot the router on the map */
- _map->addRouter(router->descriptor(),
- geoip.latitude(), geoip.longitude());
+ _map->addRouter(router->descriptor(), geoip);
}
}
}
Modified: vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp
===================================================================
--- vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp 2009-01-18 01:39:15 UTC (rev 3451)
+++ vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp 2009-01-18 01:48:51 UTC (rev 3452)
@@ -47,25 +47,38 @@
/** Adds a router to the map. */
void
-TorMapWidget::addRouter(const RouterDescriptor &desc,
- float latitude, float longitude)
+TorMapWidget::addRouter(const RouterDescriptor &desc, const GeoIp &geoip)
{
QString kml;
+ qreal lon = geoip.longitude();
+ qreal lat = geoip.latitude();
- kml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- kml.append("<kml xmlns=\"http://earth.google.com/kml/2.0\">");
- kml.append("<Document><Placemark>");
+ kml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<kml xmlns=\"http://earth.google.com/kml/2.0\">"
+ "<Document>"
+ " <Style id=\"normalPlacemark\">"
+ " <IconStyle><Icon><href>:/images/icons/placemark-relay.png</href></Icon></IconStyle>"
+ " </Style>"
+ );
+
+ kml.append("<Placemark>");
+ kml.append("<styleUrl>#normalPlacemark</styleUrl>");
kml.append(QString("<name>%1</name>").arg(desc.name()));
- kml.append("<description></description>");
- kml.append(QString("<Point><coordinates>%1,%2</coordinates></Point>")
- .arg(longitude).arg(latitude));
- kml.append("</Placemark></Document>");
- kml.append("</kml>");
+ kml.append(QString("<description>%1</description>").arg(desc.id()));
+ kml.append(QString("<role>1</role>"));
+ kml.append(QString("<address>%1</address>").arg(geoip.toString()));
+ kml.append(QString("<CountryNameCode>%1</CountryNameCode>").arg(geoip.country()));
+// kml.append(QString("<pop>%1</pop>").arg(desc.observedBandwidth()));
+ kml.append(QString("<Point>"
+ " <coordinates>%1,%2</coordinates>"
+ "</Point>").arg(lon).arg(lat));
+ kml.append("</Placemark>");
+ kml.append("</Document></kml>");
QString id = desc.id();
addPlaceMarkData(kml, id);
- _routerPlacemarks.insert(id,
- GeoDataCoordinates(longitude, latitude, 0.0, GeoDataCoordinates::Degree));
+ _routerPlacemarks.insert(id, GeoDataCoordinates(lon, lat, 0.0,
+ GeoDataCoordinates::Degree));
}
/** Adds a circuit to the map using the given ordered list of router IDs. */
Modified: vidalia/branches/marble/src/vidalia/network/tormapwidget.h
===================================================================
--- vidalia/branches/marble/src/vidalia/network/tormapwidget.h 2009-01-18 01:39:15 UTC (rev 3451)
+++ vidalia/branches/marble/src/vidalia/network/tormapwidget.h 2009-01-18 01:48:51 UTC (rev 3452)
@@ -23,6 +23,7 @@
#include <routerdescriptor.h>
#include <circuit.h>
#include <stream.h>
+#include <network/geoip.h>
#include <MarbleWidget.h>
#include <GeoPainter.h>
@@ -43,8 +44,7 @@
~TorMapWidget();
/** Plots the given router on the map using the given coordinates. */
- void addRouter(const RouterDescriptor &desc,
- float latitude, float longitude);
+ void addRouter(const RouterDescriptor &desc, const GeoIp &geoip);
/** Plots the given circuit on the map. */
void addCircuit(const CircuitId &circid, const QStringList &path);
/** Selects and hightlights a router on the map. */