Subversion Repositories public

Rev

Rev 151 | Rev 154 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 152
Line 20... Line 20...
20
#include "config.h"
20
#include "config.h"
21
#include "managefile.h"
21
#include "managefile.h"
22
#include "sportwatcherwidget.h"
22
#include "sportwatcherwidget.h"
23
#include "settingswidget.h"
23
#include "settingswidget.h"
24
#include "progresswidget.h"
24
#include "progresswidget.h"
-
 
25
#include "wmsbase.h"
25
// #undef GDAL
26
// #undef GDAL
26
#include <string.h>
27
#include <string.h>
27
 
28
 
28
#include <iostream>
29
#include <iostream>
29
#include <kfiledialog.h>
30
#include <kfiledialog.h>
Line 1111... Line 1112...
1111
	   Units = cfg->readNumEntry("Units");
1112
	   Units = cfg->readNumEntry("Units");
1112
	   delete cfg;
1113
	   delete cfg;
1113
	}
1114
	}
1114
 
1115
 
1115
	delete dlg;
1116
	delete dlg;
1116
	
1117
}
1117
	if (poDataset)
-
 
1118
	   GDALClose (poDataset);
-
 
1119
 
1118
 
-
 
1119
void sportwatcherWidget::extrasWMSSettings()
-
 
1120
{
1120
	poDataset = (GDALDataset *)GDALOpen (MAP.ascii(), GA_ReadOnly);
1121
wmsbase *dlg = new wmsbase(this, "wmswidgetbase", TRUE, 0);
1121
 
1122
 
-
 
1123
	dlg->exec();
1122
	if( poDataset == NULL )
1124
	delete dlg;
1123
	   KMessageBox::error(this, i18n("Error opening or initializing the MAP-Database!\nThere will be no map available."));
-
 
1124
}
1125
}
1125
 
1126
 
1126
/*
1127
/*
1127
 * Functions to fill in the boxes of the main mask.
1128
 * Functions to fill in the boxes of the main mask.
1128
 */
1129
 */
Line 1466... Line 1467...
1466
int a, top, left, panX, panY;
1467
int a, top, left, panX, panY;
1467
uint32 i;
1468
uint32 i;
1468
double coordW, coordH, tick;
1469
double coordW, coordH, tick;
1469
double meterW, dist;
1470
double meterW, dist;
1470
QPainter paint;
1471
QPainter paint;
1471
posn_type posNW, posSE;
1472
posn_type posNW, posSE, posLXY, posRXY;
1472
POINT *point;
1473
POINT *point;
-
 
1474
bool Fgeo = false;
1473
#ifdef GDAL
1475
#ifdef GDAL
1474
GDALDataset *poDataset;
1476
GDALDataset *poDataset;
1475
//double adfGeoTransform[6];
1477
//double adfGeoTransform[6];
1476
GDALRasterBand *poBand;
1478
GDALRasterBand *poBand;
1477
unsigned char *pafScanline;
1479
unsigned char *pafScanline;
Line 1502... Line 1504...
1502
	   mapPan = pan;
1504
	   mapPan = pan;
1503
	   panX = mapPan.right() - mapPan.left();
1505
	   panX = mapPan.right() - mapPan.left();
1504
	   panY = mapPan.bottom() - mapPan.top();
1506
	   panY = mapPan.bottom() - mapPan.top();
1505
	   oldTransX += (double)panX;
1507
	   oldTransX += (double)panX;
1506
	   oldTransY += (double)panY;
1508
	   oldTransY += (double)panY;
1507
//	   paint.translate(oldTransX, oldTransY);
-
 
1508
	}
1509
	}
1509
 
1510
 
1510
	memset(&posNW, 0, sizeof(posn_type));
1511
	memset(&posNW, 0, sizeof(posn_type));
1511
	memset(&posSE, 0, sizeof(posn_type));
1512
	memset(&posSE, 0, sizeof(posn_type));
1512
 
1513
 
Line 1552... Line 1553...
1552
	meterW = ds.earth_distance(posNW.lat, posNW.lon, posNW.lat, posSE.lon);
1553
	meterW = ds.earth_distance(posNW.lat, posNW.lon, posNW.lat, posSE.lon);
1553
 
1554
 
1554
	// define the ticks to translate the GPS coordinates into pixels.
1555
	// define the ticks to translate the GPS coordinates into pixels.
1555
	// The track should be centered and we have to calculate the
1556
	// The track should be centered and we have to calculate the
1556
	// rectangular within we draw the track.
1557
	// rectangular within we draw the track.
1557
	if (width > height)
1558
	if (coordW < coordH)
1558
	{
1559
	{
1559
	   if (coordW > coordH)
-
 
1560
	      tick = (double)height / coordW + (double)zoom;
1560
	   tick = (double)width / coordW + (double)zoom;
1561
	   else
-
 
1562
	      tick = (double)height / coordH + (double)zoom;
-
 
1563
 
1561
 
1564
	   left = (width - tick * coordW) / 2;
1562
	   if ((tick * coordH) > height)
1565
	   top = (height - tick * coordH) / 2;
1563
	      tick = (double)height / coordH + (double)zoom;
1566
	}
1564
	}
1567
	else
1565
	else
1568
	{
1566
	{
1569
	   if (coordW > coordH)
-
 
1570
	      tick = (double)width / coordW + (double)zoom;
-
 
1571
	   else
-
 
1572
	      tick = (double)width / coordH + (double)zoom;
1567
	   tick = (double)height / coordH + (double)zoom;
1573
 
1568
 
1574
	   left = (width - tick * coordW) / 2;
1569
	   if ((tick * coordW) > width)
1575
	   top = (height - tick * coordH) / 2;
1570
	      tick = (double)width / coordW + (double)zoom;
1576
	}
1571
	}
1577
 
1572
 
-
 
1573
	left = (width - tick * coordW) / 2;
-
 
1574
	top = (height - tick * coordH) / 2;
-
 
1575
 
1578
	a = tick * coordW;
1576
	a = tick * coordW;
1579
	dist = meterW / a;
1577
	dist = meterW / a;
1580
#ifdef GDAL
1578
#ifdef GDAL
1581
	/*
1579
	/*
1582
	 * If we have a map file, we try to read it and if successfull,
1580
	 * If we have a map file, we try to read it and if successfull,
1583
	 * we should get a map painted.
1581
	 * we should get a map painted.
1584
	 */
1582
	 */
1585
	if (!MAP.isEmpty())
1583
	if (!MAP.isEmpty() && coordW != 9999 && coordH != 9999)
1586
	{
1584
	{
-
 
1585
	   posLXY.lon = posNW.lon - (left + oldTransX) / tick;
-
 
1586
	   posLXY.lat = posNW.lat + (top + oldTransY) / tick;
-
 
1587
	   posRXY.lon = posSE.lon + (width - left - a - oldTransX) / tick;
-
 
1588
	   posRXY.lat = posSE.lat - (height - top - (tick * coordH) - oldTransY) / tick;
-
 
1589
 
1587
	   if (writeWMSTag(posNW.lon, posNW.lat, posSE.lon, posSE.lat, width, height))
1590
	   if (writeWMSTag(posLXY.lon, posLXY.lat, posRXY.lon, posRXY.lat, width, height))
1588
	   {
1591
	   {
1589
	      if ((poDataset = (GDALDataset *)GDALOpen (MAP.ascii(), GA_ReadOnly)) != NULL)
1592
	      if ((poDataset = (GDALDataset *)GDALOpen (MAP.ascii(), GA_ReadOnly)) != NULL)
1590
	      {
1593
	      {
1591
		 QPixmap bild;
1594
		 QPixmap bild;
1592
//		 int nRasterXSize = poDataset->GetRasterXSize();
-
 
1593
//		 int nRasterYSize = poDataset->GetRasterYSize();
-
 
1594
		 int nRasterCount = poDataset->GetRasterCount();
1595
		 int nRasterCount = poDataset->GetRasterCount();
1595
		 int nXBlock, nYBlock;
1596
		 int nXBlock, nYBlock;
1596
		 BMP_HEADER bmpH;
-
 
1597
		 BMP_INFO bmpI;
-
 
1598
		 int bmpSize = sizeof(BMP_HEADER) + sizeof(BMP_INFO) + 2;
1597
		 GDALColorTable *pCT, *pCTb, *pCTr, *pCTg;
1599
 
1598
 
1600
//		 int             nBlockXSize, nBlockYSize;
-
 
1601
		 int             bGotMin, bGotMax;
1599
		 int             bGotMin, bGotMax;
1602
		 int		 tTypeLen, tColor, tColorEntrys;
1600
		 int		 tTypeLen, tColor, tColorEntrys;
1603
		 GDALDataType    tRasterType;
1601
		 GDALDataType    tRasterType;
1604
		 double          adfMinMax[2];
1602
		 double          adfMinMax[2];
1605
 
1603
 
-
 
1604
		 pafScanlineRed = pafScanlineGreen = pafScanlineBlue = 0;
-
 
1605
 
1606
		 for (a = 1; a <= nRasterCount; a++)
1606
		 for (a = 1; a <= nRasterCount; a++)
1607
		 {
1607
		 {
1608
		    poBand = poDataset->GetRasterBand (a);
1608
		    poBand = poDataset->GetRasterBand (a);
1609
		    poBand->GetBlockSize (&nXBlock, &nYBlock);
1609
		    poBand->GetBlockSize (&nXBlock, &nYBlock);
1610
		    nXSize = poBand->GetXSize();
1610
		    nXSize = poBand->GetXSize();
Line 1617... Line 1617...
1617
		    adfMinMax[1] = poBand->GetMaximum (&bGotMax);
1617
		    adfMinMax[1] = poBand->GetMaximum (&bGotMax);
1618
 
1618
 
1619
		    if (!(bGotMin && bGotMax))
1619
		    if (!(bGotMin && bGotMax))
1620
		       GDALComputeRasterMinMax ((GDALRasterBandH)poBand, TRUE, adfMinMax);
1620
		       GDALComputeRasterMinMax ((GDALRasterBandH)poBand, TRUE, adfMinMax);
1621
 
1621
 
1622
		    if (poBand->GetColorTable() != NULL)
1622
		    if ((pCT = poBand->GetColorTable()) != NULL)
1623
		       tColorEntrys = poBand->GetColorTable()->GetColorEntryCount();
1623
		       tColorEntrys = poBand->GetColorTable()->GetColorEntryCount();
1624
 
1624
 
1625
		    switch (a)
1625
		    switch (a)
1626
		    {
1626
		    {
1627
		       case 1: pafScanlineRed   = new unsigned char[tTypeLen * nXBlock * nYBlock]; pafScanline = pafScanlineRed; break;
1627
		       case 1: pafScanlineRed   = new unsigned char[tTypeLen * nXSize * nYSize]; pafScanline = pafScanlineRed; pCTr = pCT; break;
1628
		       case 2: pafScanlineGreen = new unsigned char[tTypeLen * nXBlock * nYBlock]; pafScanline = pafScanlineGreen; break;
1628
		       case 2: pafScanlineGreen = new unsigned char[tTypeLen * nXSize * nYSize]; pafScanline = pafScanlineGreen; pCTg = pCT; break;
1629
		       case 3: pafScanlineBlue  = new unsigned char[tTypeLen * nXBlock * nYBlock]; pafScanline = pafScanlineBlue; break;
1629
		       case 3: pafScanlineBlue  = new unsigned char[tTypeLen * nXSize * nYSize]; pafScanline = pafScanlineBlue; pCTb = pCT; break;
1630
		    }
1630
		    }
1631
 
1631
 
1632
		    memset (pafScanline, 0, tTypeLen * nXBlock * nYSize);
1632
		    memset (pafScanline, 0, tTypeLen * nXSize * nYSize);
1633
 
1633
 
1634
		    if (poBand->RasterIO (GF_Read, 0, 0, nXSize, nYSize, pafScanline, nXBlock, nYBlock, tRasterType, 0, 0) == CE_Failure)
1634
		    if (poBand->RasterIO (GF_Read, 0, 0, nXSize, nYSize, pafScanline, nXSize, nYSize, tRasterType, 0, 0) == CE_Failure)
-
 
1635
		    {
1635
		       KMessageBox::error(this, i18n("Error reading a raster band!"));
1636
		       KMessageBox::error(this, i18n("Error reading a raster band!"));
-
 
1637
		       Fgeo = false;
-
 
1638
		       break;
-
 
1639
		    }
-
 
1640
		    else
-
 
1641
		       Fgeo = true;
1636
		 }
1642
		 }
1637
 
1643
 
1638
		 unsigned char *pCombinedBytes = new unsigned char[(tTypeLen * nXBlock * nYBlock * nRasterCount) + bmpSize];
-
 
1639
		 int offset;
1644
		 if (Fgeo)
1640
 
-
 
1641
		 for (a = 0; a < nYSize; a++)
-
 
1642
		 {
1645
		 {
-
 
1646
		 unsigned char *pCombinedBytes = new unsigned char[(tTypeLen * nXSize * nYSize * nRasterCount)];
-
 
1647
		 unsigned char *ptr_dest, *ptr_src;
-
 
1648
		 int j;
-
 
1649
 
1643
		    for (int j = 0; j < nXBlock; j++)
1650
		    for (a = 0, j = 0; a < (nXSize * nYSize * nRasterCount); a += nRasterCount, j++)
1644
		    {
1651
		    {
-
 
1652
		       int k = a;
-
 
1653
 
1645
		       offset = a * nXBlock * 3 + (j * 3) + bmpSize;
1654
		       for (int m = nRasterCount - 1; m >= 0; m--, k++)
-
 
1655
		       {
-
 
1656
		       unsigned char *pBytes;
-
 
1657
 
-
 
1658
			  switch (m)
-
 
1659
			  {
1646
		       pCombinedBytes[offset]     = *(pafScanlineBlue + ((nYSize - a) * nXBlock + j));
1660
			     case 2: pBytes = pafScanlineBlue; pCT = pCTb; break;
1647
		       pCombinedBytes[offset + 1] = *(pafScanlineGreen + ((nYSize - a) * nXBlock + j));
1661
			     case 1: pBytes = pafScanlineGreen; pCT = pCTg; break;
1648
		       pCombinedBytes[offset + 2] = *(pafScanlineRed + ((nYSize - a) * nXBlock + j));
1662
			     default: pBytes = pafScanlineRed; pCT = pCTr;
-
 
1663
			  }
-
 
1664
 
-
 
1665
			  ptr_dest = pCombinedBytes + k;
-
 
1666
			  unsigned char b = pBytes[j];
-
 
1667
 
-
 
1668
			  if (pCT != NULL)
-
 
1669
			  {
-
 
1670
			     GDALColorEntry ce;
-
 
1671
			     unsigned int c = (unsigned int)b;
-
 
1672
			     c = pCT->GetColorEntryAsRGB (c, &ce);
-
 
1673
 
-
 
1674
			     if  (m == 0) c = ce.c1;
-
 
1675
			     if  (m == 1) c = ce.c2;
-
 
1676
			     if  (m == 2) c = ce.c3;
-
 
1677
 
-
 
1678
			     b = (unsigned char)c;
-
 
1679
			  }
-
 
1680
 
-
 
1681
			  ptr_src = &b;
-
 
1682
			  memcpy (ptr_dest, ptr_src, 1);
-
 
1683
		       }
1649
		    }
1684
		    }
-
 
1685
 
-
 
1686
		    x1 = y1 = 0;
-
 
1687
 
-
 
1688
		    for (a = 0; a < (nXSize * nYSize * nRasterCount); a += 3)
-
 
1689
		    {
-
 
1690
		       paint.setPen (QPen(QColor((int)pCombinedBytes[a+2], (int)pCombinedBytes[a+1], (int)pCombinedBytes[a]), QPen::SolidLine));
-
 
1691
		       paint.drawPoint(x1, y1);
-
 
1692
		       x1++;
-
 
1693
 
-
 
1694
		       if (x1 >= nXSize)
-
 
1695
		       {
-
 
1696
			  x1 = 0;
-
 
1697
			  y1++;
-
 
1698
		       }
-
 
1699
		    }
-
 
1700
 
-
 
1701
		    delete pCombinedBytes;
1650
		 }
1702
		 }
1651
 
1703
 
1652
		 fillBMPHeader (&bmpH, &bmpI, nXBlock, nYSize, nRasterCount);
-
 
1653
		 memcpy (pCombinedBytes+2, &bmpH, sizeof(BMP_HEADER));
-
 
1654
		 memcpy (pCombinedBytes + sizeof(BMP_HEADER) + 2, &bmpI, sizeof(BMP_INFO));
-
 
1655
		 *pCombinedBytes = 'B';
-
 
1656
		 *(pCombinedBytes+1) = 'M';
1704
		 if (pafScanlineRed)
1657
/* QFile qf(QString("/tmp/testbild.bmp"));
-
 
1658
qf.open(IO_ReadWrite | IO_Truncate);
-
 
1659
write(qf.handle(), pCombinedBytes, (tTypeLen * nXSize * nYSize * nRasterCount) + bmpSize);
-
 
1660
qf.close(); */
-
 
1661
		 if (!bild.loadFromData (pCombinedBytes, (tTypeLen * nXBlock * nYSize * nRasterCount) + bmpSize, "BMP"))
-
 
1662
		    KMessageBox::error(this, i18n("Error reading the binary data!"));
-
 
1663
		 else
-
 
1664
		    paint.drawPixmap (0, 0, bild);
1705
		    delete pafScanlineRed;
1665
 
1706
 
1666
		 delete pafScanlineRed;
1707
		 if (pafScanlineGreen)
1667
		 delete pafScanlineGreen;
1708
		    delete pafScanlineGreen;
-
 
1709
 
1668
		 delete pafScanlineBlue;
1710
		 if (pafScanlineBlue)
1669
		 delete pCombinedBytes;
1711
		    delete pafScanlineBlue;
-
 
1712
 
-
 
1713
		 GDALClose (poDataset);
-
 
1714
		 poDataset = 0;
1670
	      }
1715
	      }
1671
	      else
1716
	      else
1672
		 KMessageBox::error(this, i18n("Error opening WMS file!"));
1717
		 KMessageBox::error(this, i18n("Error opening WMS file!"));
1673
 
-
 
1674
	      GDALClose (poDataset);
-
 
1675
	      poDataset = 0;
-
 
1676
	   }
1718
	   }
1677
	}
1719
	}
1678
#endif
1720
#endif
1679
	// Colors and fonts
1721
	// Colors and fonts
1680
	QColor background(220, 220, 220);
1722
	QColor background(220, 220, 220);
Line 1686... Line 1728...
1686
	fntNormal.setStyleHint(QFont::Helvetica);
1728
	fntNormal.setStyleHint(QFont::Helvetica);
1687
	QPen dot(red, 4, QPen::SolidLine);
1729
	QPen dot(red, 4, QPen::SolidLine);
1688
	QPen line(black, 1, QPen::SolidLine);
1730
	QPen line(black, 1, QPen::SolidLine);
1689
	QPen yline(yellow, 3, QPen::SolidLine);
1731
	QPen yline(yellow, 3, QPen::SolidLine);
1690
	// Fill background with background colors
1732
	// Fill background with background colors
1691
#ifndef GDAL
1733
	if (!Fgeo)
1692
	paint.fillRect(0, 0, width+2, height+2, background);
1734
	   paint.fillRect(0, 0, width+2, height+2, background);
1693
#endif
1735
 
1694
	paint.setPen(line);
1736
	paint.setPen(line);
1695
	paint.drawLine(10, height - 9, 10, height - 4);
1737
	paint.drawLine(10, height - 9, 10, height - 4);
1696
	paint.drawLine(10, height - 4, 10 + (1000 / dist), height - 4);
1738
	paint.drawLine(10, height - 4, 10 + (1000 / dist), height - 4);
1697
	paint.drawLine(10 + (1000 / dist), height - 9, 10 + (1000 / dist), height - 4);
1739
	paint.drawLine(10 + (1000 / dist), height - 9, 10 + (1000 / dist), height - 4);
1698
	paint.setFont(fntNormal);
1740
	paint.setFont(fntNormal);
Line 2219... Line 2261...
2219
 
2261
 
2220
#ifdef GDAL
2262
#ifdef GDAL
2221
bool sportwatcherWidget::writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height)
2263
bool sportwatcherWidget::writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height)
2222
{
2264
{
2223
QFile fl(MAP);
2265
QFile fl(MAP);
-
 
2266
QString xml, s, srs, crs, styles, bSize, ext;
-
 
2267
QDir dir = QDir::home();
2224
QString xml, s;
2268
QString path = dir.absPath();
-
 
2269
int item;
-
 
2270
bool flag;
2225
 
2271
 
2226
	if (!fl.open(IO_ReadWrite | IO_Truncate))
2272
	if (!fl.open(IO_ReadWrite | IO_Truncate))
2227
	{
2273
	{
2228
	   KMessageBox::error (this, i18n("Error opening or creating the WMS tag file!\nPlease check file name and/or permissions."));
2274
	   KMessageBox::error (this, i18n("Error opening or creating the WMS tag file!\nPlease check file name and/or permissions."));
2229
	   return false;
2275
	   return false;
2230
	}
2276
	}
2231
 
2277
 
-
 
2278
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"));
-
 
2279
	cfg->setGroup(QString("WMS"));
-
 
2280
	styles = cfg->readEntry("Styles");
-
 
2281
 
2232
	xml = "<GDAL_WMS>\n";
2282
	xml = "<GDAL_WMS>\n";
2233
	xml += "   <Service name=\"WMS\">\n";
2283
	xml += "   <Service name=\"WMS\">\n";
2234
	xml += "      <Version>1.1.1</Version>\n";
2284
	xml += "      <Version>1.1.1</Version>\n";
2235
	xml += "      <ServerURL>http://openaerialmap.org/wms/?</serverURL>\n";
2285
	xml += "      <ServerURL>" + cfg->readEntry("ServerURL", "http://onearth.jpl.nasa.gov/wms.cgi") + "?</serverURL>\n";
-
 
2286
	item = cfg->readNumEntry("SRS", 0);
-
 
2287
 
-
 
2288
	switch (item)
-
 
2289
	{
-
 
2290
	   case 0: srs = QString("EPSG:4326"); break;
-
 
2291
	   default: srs = QString("EPSG:4326");
-
 
2292
	}
-
 
2293
 
2236
	xml += "      <SRS>EPSG:4326</SRS>\n";
2294
	xml += "      <SRS>" + srs + "</SRS>\n";
-
 
2295
	item = cfg->readNumEntry("CRS", 0);
-
 
2296
 
-
 
2297
	switch (item)
-
 
2298
	{
-
 
2299
	   case 0: crs = QString("CRS:83"); break;
-
 
2300
	   default: crs = QString("CRS:83"); break;
-
 
2301
	}
-
 
2302
 
2237
	xml += "      <CRS>CRS:83</CRS>\n";
2303
	xml += "      <CRS>" + crs + "</CRS>\n";
-
 
2304
	item = cfg->readNumEntry("Image", 2);
2238
	xml += "      <ImageFormat>image/png</ImageFormat>\n";
2305
	xml += "      <ImageFormat>image/";
-
 
2306
 
-
 
2307
	switch (item)
-
 
2308
	{
-
 
2309
	   case 0: xml += "gif"; ext = QString(".gif"); break;
-
 
2310
	   case 1: xml += "jpeg"; ext = QString(".jpg"); break;
-
 
2311
	   case 2: xml += "png"; ext = QString(".png"); break;
-
 
2312
	   case 3: xml += "tiff"; ext = QString(".tif"); break;
-
 
2313
	   default: xml += "png"; ext = QString(".png");
-
 
2314
	}
-
 
2315
 
-
 
2316
	xml += "</ImageFormat>\n";
-
 
2317
 
2239
	xml += "      <Layers>world</Layers>\n";
2318
	xml += "      <Layers>" + cfg->readEntry("Layer") + "</Layers>\n";
-
 
2319
 
-
 
2320
	if (!styles.isEmpty())
2240
//	xml += "      <Styles></Styles>\n";
2321
	   xml += "      <Styles>" + styles + "</Styles>\n";
-
 
2322
 
2241
	xml += "      <BBoxOrder>xyXY</BBoxOrder>\n";
2323
	xml += "      <BBoxOrder>xyXY</BBoxOrder>\n";
2242
	xml += "   </Service>\n";
2324
	xml += "   </Service>\n";
2243
	xml += "   <DataWindow>\n";
2325
	xml += "   <DataWindow>\n";
2244
	s.sprintf ("%f", llat);
2326
	s.sprintf ("%f", llat);
2245
	xml += "      <UpperLeftX>" + s + "</UpperLeftX>\n";
2327
	xml += "      <UpperLeftX>" + s + "</UpperLeftX>\n";
Line 2253... Line 2335...
2253
	xml += "      <SizeX>" + s + "</SizeX>\n";
2335
	xml += "      <SizeX>" + s + "</SizeX>\n";
2254
	s.sprintf ("%d", height);
2336
	s.sprintf ("%d", height);
2255
	xml += "      <SizeY>" + s + "</SizeY>\n";
2337
	xml += "      <SizeY>" + s + "</SizeY>\n";
2256
	xml += "   </DataWindow>\n";
2338
	xml += "   </DataWindow>\n";
2257
	xml += "   <Projection>EPSG:4326</Projection>\n";
2339
	xml += "   <Projection>EPSG:4326</Projection>\n";
2258
	xml += "   <BandsCount>3</BandsCount>\n";
2340
	xml += "   <BandsCount>" + cfg->readEntry("Bands", "3") + "</BandsCount>\n";
-
 
2341
	item = cfg->readNumEntry("Tile", 2);
-
 
2342
 
-
 
2343
	switch (item)
-
 
2344
	{
-
 
2345
	   case 0: bSize = QString("64"); break;
-
 
2346
	   case 1: bSize = QString("128"); break;
-
 
2347
	   case 2: bSize = QString("256"); break;
-
 
2348
	   case 3: bSize = QString("512"); break;
-
 
2349
	   case 4: bSize = QString("1024"); break;
-
 
2350
	   default: bSize = QString("256");
-
 
2351
	}
-
 
2352
 
2259
	xml += "   <BlockSizeX>1024</BlockSizeX>\n";
2353
	xml += "   <BlockSizeX>" + bSize + "</BlockSizeX>\n";
2260
	xml += "   <BlockSizeY>1024</BlockSizeY>\n";
2354
	xml += "   <BlockSizeY>" + bSize + "</BlockSizeY>\n";
2261
	xml += "   <OverviewCount>10</OverviewCount>\n";
2355
	xml += "   <OverviewCount>" + cfg->readEntry("Overview", "10") + "</OverviewCount>\n";
2262
	xml += "   <Cache>\n";
2356
	xml += "   <Cache>\n";
2263
	xml += "      <Path>./gdalwmscache</Path>\n";
2357
	xml += "      <Path>" + path + "/.gdalwmscache" + "</Path>\n";
2264
	xml += "      <Depth>2</Depth>\n";
2358
	xml += "      <Depth>" + cfg->readEntry("Depth", "2") + "</Depth>\n";
2265
	xml += "      <Extension>.png</Extension>\n";
2359
	xml += "      <Extension>" + ext + "</Extension>\n";
2266
	xml += "   </Cache>\n";
2360
	xml += "   </Cache>\n";
-
 
2361
	QString off((cfg->readBoolEntry("Offline", false)) ? "true" : "false");
-
 
2362
	QString adv((cfg->readBoolEntry("Advice", false)) ? "true" : "false");
-
 
2363
	QString ver((cfg->readBoolEntry("Verify", true)) ? "true" : "false");
2267
	xml += "   <OfflineMode>false</OfflineMode>\n";
2364
	xml += "   <OfflineMode>" + off + "</OfflineMode>\n";
2268
	xml += "   <AdviseRead>false</AdviseRead>\n";
2365
	xml += "   <AdviseRead>" + adv + "</AdviseRead>\n";
2269
	xml += "   <VerifyAdviseRead>true</VerifyAdviseRead>\n";
2366
	xml += "   <VerifyAdviseRead>" + ver + "</VerifyAdviseRead>\n";
2270
	xml += "</GDAL_WMS>\n";
2367
	xml += "</GDAL_WMS>\n";
2271
 
2368
 
2272
	write (fl.handle(), xml.ascii(), strlen (xml.ascii()));
2369
	write (fl.handle(), xml.ascii(), strlen (xml.ascii()));
2273
	fl.close();
2370
	fl.close();
-
 
2371
	delete cfg;
2274
	return true;
2372
	return true;
2275
}
2373
}
2276
 
2374
 
2277
void sportwatcherWidget::fillBMPHeader (BMP_HEADER *bmpH, BMP_INFO *bmpI, int nXSize, int nYSize, int nRasterCount)
2375
void sportwatcherWidget::fillBMPHeader (BMP_HEADER *bmpH, BMP_INFO *bmpI, int nXSize, int nYSize, int nRasterCount)
2278
{
2376
{