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" |