Subversion Repositories public

Compare Revisions

Ignore whitespace Rev 283 → Rev 284

/sportwatcher/trunk/src/wmsselectorwidgetbase.ui
7,7 → 7,7
<x>0</x>
<y>0</y>
<width>677</width>
<height>392</height>
<height>411</height>
</rect>
</property>
<property name="windowTitle">
40,10 → 40,10
<item row="0" column="1">
<widget class="KDoubleNumInput" name="edLat">
<property name="minimum">
<double>-90.000000000000000</double>
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
<double>180.000000000000000</double>
</property>
<property name="decimals">
<number>6</number>
60,10 → 60,10
<item row="1" column="1">
<widget class="KDoubleNumInput" name="edLon">
<property name="minimum">
<double>-180.000000000000000</double>
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
<double>90.000000000000000</double>
</property>
<property name="decimals">
<number>6</number>
155,7 → 155,7
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="1" colspan="3">
<widget class="KIntSpinBox" name="edBands">
<property name="minimum">
<number>1</number>
165,23 → 165,39
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<item row="1" column="3">
<widget class="QCheckBox" name="cbStyles">
<property name="text">
<string>Set styles</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="slideZoom">
<property name="toolTip">
<string>Slide to zoom map</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>With this slider you can change the toom level ov the map in 10 steps.</string>
</property>
<property name="maximum">
<number>9</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>199</width>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cbStyles">
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Set styles</string>
<string>Zoom</string>
</property>
</widget>
</item>
228,6 → 244,7
<tabstop>buttonBox</tabstop>
<tabstop>pbGetCapabilities</tabstop>
<tabstop>edBands</tabstop>
<tabstop>slideZoom</tabstop>
<tabstop>cbStyles</tabstop>
<tabstop>pbDetails</tabstop>
</tabstops>
388,11 → 405,59
<y>112</y>
</hint>
<hint type="destinationlabel">
<x>677</x>
<x>676</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>slideZoom</sender>
<signal>valueChanged(int)</signal>
<receiver>wmsSelectorWidgetBase</receiver>
<slot>slotValueChanged(int)</slot>
<hints>
<hint type="sourcelabel">
<x>500</x>
<y>108</y>
</hint>
<hint type="destinationlabel">
<x>370</x>
<y>121</y>
</hint>
</hints>
</connection>
<connection>
<sender>slideZoom</sender>
<signal>sliderReleased()</signal>
<receiver>wmsSelectorWidgetBase</receiver>
<slot>slotSliderReleased()</slot>
<hints>
<hint type="sourcelabel">
<x>440</x>
<y>104</y>
</hint>
<hint type="destinationlabel">
<x>371</x>
<y>98</y>
</hint>
</hints>
</connection>
<connection>
<sender>slideZoom</sender>
<signal>sliderPressed()</signal>
<receiver>wmsSelectorWidgetBase</receiver>
<slot>slotSliderPressed()</slot>
<hints>
<hint type="sourcelabel">
<x>554</x>
<y>109</y>
</hint>
<hint type="destinationlabel">
<x>677</x>
<y>66</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotURLChanged()</slot>
404,5 → 469,8
<slot>slotUp(QListWidgetItem*)</slot>
<slot>slotCities(QString)</slot>
<slot>slotStyles(bool)</slot>
<slot>slotValueChanged(int)</slot>
<slot>slotSliderReleased()</slot>
<slot>slotSliderPressed()</slot>
</slots>
</ui>
/sportwatcher/trunk/src/wmsselectorwidget.h
106,6 → 106,12
double lat;
}CITIES;
 
typedef struct
{
double x;
double y;
}ZOOM;
 
class wmsSelectorWidget : public QDialog,
public QXmlDefaultHandler,
private Ui::wmsSelectorWidgetBase
202,10 → 208,17
bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
bool endElement (const QString&, const QString&, const QString&);
bool characters (const QString&);
QString getServer() { return urlWMS->url().url(); };
QString getLayers();
int getBands() { return edBands->value(); };
QString getStyles();
 
 
public slots:
/*$PUBLIC_SLOTS$*/
virtual void slotValueChanged(int);
virtual void slotSliderPressed();
virtual void slotSliderReleased();
virtual void slotGetCapabilities();
virtual void slotDetails();
virtual void slotAdded(QListWidgetItem *);
242,10 → 255,10
 
private:
int id; // ID used during download
QString Data, MAP;
QString Data, MAP, Layers;
QHttp *http;
bool httpRequestAborted;
bool StyleCommas;
bool StyleCommas, Init;
QFile file;
KProgressDialog *progressDialog;
ELEMENT element, el2;
255,8 → 268,10
SERVICE Service;
REQUEST Request;
LAYER *Layer, *firstLayer;
int zLevel; // zoom level
int line; // actual line number during parsing
int lcount; // counts the deepnes of layers
bool sliderPressed;
};
 
#endif
/sportwatcher/trunk/src/wmsbase.cpp
67,7 → 67,13
 
if (dlg->exec() == QDialog::Accepted)
{
edServerURL->setUrl(dlg->getServer());
edLayer->setText(dlg->getLayers());
edBands->setValue(dlg->getBands());
edStyles->setText(dlg->getStyles());
}
 
delete dlg;
}
 
void wmsbase::bpCancelSlot()
/sportwatcher/trunk/src/wmsselectorwidget.cpp
21,6 → 21,7
#include <QListWidget>
#include <QPainter>
#include <QCheckBox>
#include <QSlider>
#include <KStandardDirs>
#include <KConfig>
#include <KLocale>
50,6 → 51,7
// The capital cities from all countries of the world
// Source: Wikipedia, Google
CITIES Cities[] = {
{ " - - - - - - -", 0.0, 0.0 },
{ "Abidjan", 5.3363, -4.0277 },
{ "Abu Dhabi", 24.4758, 54.3714 },
{ "Abuja", 9.0578, 7.4892 },
82,7 → 84,7
{ "Bern", 46.9479, 7.4479 },
{ "Bratislava", 48.1483, 17.1068 },
{ "Bridgetown", 13.0935, -59.6106 },
{ "Brüssel", 50.8462, 4.3545 },
{ "Bruessel", 50.8462, 4.3545 },
{ "Budapest", 47.4984, 19.0403 },
{ "Buenos Aires", -34.6084, -58.3733 },
{ "Bukarest", 44.4304, 26.1225 },
122,6 → 124,19
{ "", 0.0, 0.0 }
};
 
ZOOM zoom[] = {
{ 0.014108, 0.003554 },
{ 0.028216, 0.007108 },
{ 0.056432, 0.014216 },
{ 0.112864, 0.028432 },
{ 0.225728, 0.056864 },
{ 0.451456, 0.113728 },
{ 0.902912, 0.227456 },
{ 1.805824, 0.454912 },
{ 3.611648, 0.909824 },
{ 7.223296, 1.819648 }
};
 
wmsSelectorWidget::wmsSelectorWidget (QWidget* parent, Qt::WFlags fl)
: QDialog (parent, fl), Ui::wmsSelectorWidgetBase()
{
132,6 → 147,7
id = 0;
Layer = 0;
firstLayer = 0;
zLevel = 0;
initializeParser();
// Initialize the GUI elements
setupUi (this);
144,6 → 160,7
MAP = ic.readEntry("MAP", QDir::home().absolutePath() + "/.sportwatcher/track.wms");
file.setFileName(Data + "/capabilities.xml"); // File to save WMS capabilities
edBands->setValue(ic.readEntry("Bands", 3));
Layers = ic.readEntry("Layer", QString("modis,global_mosaic"));
StyleCommas = true;
cbStyles->setChecked(StyleCommas);
// Fill the cities combo box
168,6 → 185,7
connect(http, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));
#endif
getCapabilities();
Init = true;
}
 
wmsSelectorWidget::~wmsSelectorWidget()
271,6 → 289,37
StyleCommas = mode;
}
 
void wmsSelectorWidget::slotSliderPressed()
{
sliderPressed = true;
}
 
void wmsSelectorWidget::slotSliderReleased()
{
double minx, miny, maxx, maxy;
 
sliderPressed = false;
 
if (!sliderPressed && actionLayer->selectedListWidget()->count() > 0)
{
setDimension(minx, miny, maxx, maxy, 0);
grabPicture(minx, miny, maxx, maxy);
}
}
 
void wmsSelectorWidget::slotValueChanged(int val)
{
double minx, miny, maxx, maxy;
 
zLevel = val;
 
if (!sliderPressed && actionLayer->selectedListWidget()->count() > 0)
{
setDimension(minx, miny, maxx, maxy, 0);
grabPicture(minx, miny, maxx, maxy);
}
}
 
/*
* This functions try to get a small example picture from the WMS server
*/
292,7 → 341,7
 
QApplication::setOverrideCursor (QCursor(Qt::WaitCursor));
width = lbPreview->width();
height = lbPreview->height() - 2;
height = lbPreview->height() - 6; // necessary to prevent growing of dialog window
nXSize = nYSize = 0;
 
if (!writeWMSTag(minx, miny, maxx, maxy, width, height))
1040,6 → 1089,35
return true;
}
 
QString wmsSelectorWidget::getLayers()
{
QString la;
QListWidget *lw = actionLayer->selectedListWidget();
 
for (int i = 0; i < lw->count(); i++)
{
QListWidgetItem *item = lw->item(i);
la += item->text();
 
if (i < lw->count())
la += ",";
}
 
return la;
}
 
QString wmsSelectorWidget::getStyles()
{
QString la;
QListWidget *lw = actionLayer->selectedListWidget();
int anz = lw->count();
 
if (cbStyles->isChecked() && anz > 1)
la.fill(',', anz - 1);
 
return la;
}
 
void wmsSelectorWidget::cancelDownload()
{
httpRequestAborted = true;
1070,6 → 1148,33
else
{
parseWMS();
if (Init)
{
// Set the already selected layers to the selected box
// This will be done only, if the box with the available layers
// is not empty. Otherwise we've to assume, that there was an
// error getting the capabilities of the server.
if (actionLayer->availableListWidget()->count() > 0)
{
QListWidget *item = actionLayer->selectedListWidget();
QListWidget *av = actionLayer->availableListWidget();
QStringList laList = Layers.split(',');
 
for (int i = 0; i < laList.size(); i++)
{
QList<QListWidgetItem*> qlwi = av->findItems(laList.at(i), Qt::MatchExactly);
 
if (qlwi.size() == 1)
{
item->addItem(laList.at(i));
av->takeItem(av->row(qlwi.at(0)));
}
}
}
 
Init = false;
}
}
}
 
1327,7 → 1432,7
QString xml, s, srs, crs, styles, bSize, ext;
QDir dir = QDir::home();
QString path = dir.absolutePath();
int item;
//int item;
double _llat, _llon, _rlat, _rlon;
 
if (!fl.open(QIODevice::ReadWrite | QIODevice::Truncate))
1341,7 → 1446,12
 
xml = "<GDAL_WMS>\n";
xml += " <Service name=\"WMS\">\n";
xml += " <Version>" + WMSVersion + "</Version>\n";
 
if (!WMSVersion.isEmpty())
xml += " <Version>" + WMSVersion + "</Version>\n";
else
xml += " <Version>1.1.1</Version>\n";
 
xml += " <ServerURL>" + urlWMS->url().url() + "?</serverURL>\n";
_llon = llon;
_llat = llat;
1410,7 → 1520,7
 
xml += " <Projection>" + srs + "</Projection>\n";
xml += " <BandsCount>" + QString("%1").arg(edBands->value()) + "</BandsCount>\n";
item = wms.readEntry("Tile", 2);
/* item = wms.readEntry("Tile", 2);
 
switch (item)
{
1421,7 → 1531,8
case 4: bSize = QString("1024"); break;
default: bSize = QString("256");
}
 
*/
bSize = QString("256");
xml += " <BlockSizeX>" + bSize + "</BlockSizeX>\n";
xml += " <BlockSizeY>" + bSize + "</BlockSizeY>\n";
xml += " <OverviewCount>" + wms.readEntry("Overview", QString("10")) + "</OverviewCount>\n";
1446,45 → 1557,56
 
void wmsSelectorWidget::setDimension(double &minx, double &miny, double &maxx, double &maxy, QListWidgetItem *item = 0)
{
double cx, cy;
/*LAYER *akt;
double cx, cy, levX, levY;
LAYER *akt;
 
if (!firstLayer)
return;
//std::cout << "minx: " << firstLayer->LatLon.minx << "miny: " << firstLayer->LatLon.miny << "maxx: " << firstLayer->LatLon.maxx << "maxy: " << firstLayer->LatLon.maxy << std::endl;
cx = cy = 0.0;
akt = firstLayer;
 
while (akt)
if (zLevel >= 0 && zLevel < 10)
{
cx = akt->LatLon.minx + (akt->LatLon.maxx - akt->LatLon.minx) / 2.0;
cy = akt->LatLon.miny + (akt->LatLon.maxy - akt->LatLon.miny) / 2.0;
levX = zoom[zLevel].x;
levY = zoom[zLevel].y;
}
else
{
levX = zoom[0].x;
levY = zoom[0].y;
}
 
if ((cx != 0.0 || cy != 0.0) && !item)
break;
cx = edLat->value();
cy = edLon->value();
 
if (item && item->text() == akt->Name && cx != 0.0 && cy != 0.0)
break;
if (cx == 0.0 && cy == 0.0)
{
while (akt)
{
cx = akt->LatLon.minx + (akt->LatLon.maxx - akt->LatLon.minx) / 2.0;
cy = akt->LatLon.miny + (akt->LatLon.maxy - akt->LatLon.miny) / 2.0;
 
akt = akt->next;
}
if ((cx != 0.0 || cy != 0.0) && !item)
break;
 
if (cx == 0.0 && cy == 0.0)
{ // Schloss Schönbrunn in Vienna
cx = 16.298223 + (0.014108 / 2.0);
cy = 48.177103 + (0.003554 / 2.0);
if (item && item->text() == akt->Name && cx != 0.0 && cy != 0.0)
break;
 
akt = akt->next;
}
 
if (cx == 0.0 && cy == 0.0)
{ // Schloss Schoenbrunn in Vienna
cx = 16.298223 + (0.014108 / 2.0);
cy = 48.177103 + (0.003554 / 2.0);
}
 
edLat->setValue(cx);
edLon->setValue(cy);
}
*/
cx = edLat->value();
cy = edLon->value();
 
minx = cx - (0.014108 / 2.0);
maxx = cx + (0.014108 / 2.0);
miny = cy + (0.003554 / 2.0);
maxy = cy - (0.003554 / 2.0);
 
// edLat->setValue(cx);
// edLon->setValue(cy);
minx = cx - (levX / 2.0);
maxx = cx + (levX / 2.0);
miny = cy + (levY / 2.0);
maxy = cy - (levY / 2.0);
}
 
#include "wmsselectorwidget.moc"