Subversion Repositories public

Rev

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

Rev 251 Rev 274
Line 22... Line 22...
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
#include "wmsbase.h"
26
#include "coordinateswidget.h"
26
#include "coordinateswidget.h"
-
 
27
#include "shapewidget.h"
27
#include <string.h>
28
#include <string.h>
28
 
29
 
29
#include <iostream>
30
#include <iostream>
30
#include <kfiledialog.h>
31
#include <kfiledialog.h>
31
#include <kmessagebox.h>
32
#include <kmessagebox.h>
Line 56... Line 57...
56
#endif
57
#endif
57
 
58
 
58
#include "garmin.h"
59
#include "garmin.h"
59
#include "transform.h"
60
#include "transform.h"
60
#include "import.h"
61
#include "import.h"
-
 
62
#include "render.h"
61
 
63
 
62
//#define DEBUG	1
64
//#define DEBUG	1
63
 
65
 
64
using std::cout;
66
using std::cout;
65
using std::cerr;
67
using std::cerr;
Line 1738... Line 1740...
1738
	   coordinatesWidget *idlg = new coordinatesWidget(this);
1740
	   coordinatesWidget *idlg = new coordinatesWidget(this);
1739
	   idlg->exec();
1741
	   idlg->exec();
1740
	   delete idlg;
1742
	   delete idlg;
1741
	   return;
1743
	   return;
1742
	}
1744
	}
1743
	
1745
 
1744
	if (MapType != MPT_WMS)
1746
	if (MapType == MPT_WMS)
-
 
1747
	{
-
 
1748
	   wmsbase *dlg = new wmsbase(this);
-
 
1749
	   dlg->exec();
-
 
1750
	   delete dlg;
-
 
1751
	}
-
 
1752
 
-
 
1753
	if (MapType == MPT_SHP)
-
 
1754
	{
-
 
1755
	   shapeWidget *dlg = new shapeWidget(this);
-
 
1756
	   dlg->exec();
-
 
1757
	   delete dlg;
-
 
1758
	}
-
 
1759
 
-
 
1760
	if (MapType != MPT_WMS && MapType != MPT_SHP)
1745
	{
1761
	{
1746
	   KMessageBox::detailedSorry(this,
1762
	   KMessageBox::detailedSorry(this,
1747
	      i18n("You have not choosen a WMS tag file!"),
1763
	      i18n("You have not choosen a WMS tag file or shape file directory!"),
1748
	      i18n("This dialog is especialy to set WMS specific parameters. ") +
1764
	      i18n("This dialog is especialy to set map specific parameters. ") +
1749
	      i18n("Therefore this dialog is temporary disabled. It will be ") +
1765
	      i18n("Therefore this dialog is temporary disabled. It will be ") +
1750
	      i18n("available again, as soon as you choose \"WMS server\" as ") +
1766
	      i18n("available again, as soon as you choose \"WMS server\" or ") +
1751
	      i18n("your map type."));
1767
	      i18n("Shape file as your map type."));
1752
	      return;
1768
	      return;
1753
	}
1769
	}
1754
 
-
 
1755
	wmsbase *dlg = new wmsbase(this);
-
 
1756
	dlg->exec();
-
 
1757
	delete dlg;
-
 
1758
#else
1770
#else
1759
	KMessageBox::detailedSorry(this,
1771
	KMessageBox::detailedSorry(this,
1760
	   i18n("This function was disabled at compile time because of missing GDAL v1.5.x!"),
1772
	   i18n("This function was disabled at compile time because of missing GDAL v1.5.x!"),
1761
	   i18n("Sportwatcher needs GDAL v1.5.x to enable this function.\n") +
1773
	   i18n("Sportwatcher needs GDAL v1.5.x to enable this function.\n") +
1762
	   i18n("If you like this to be working, install GDAL version 1.5.x and recompile the source!"));
1774
	   i18n("If you like this to be working, install GDAL version 1.5.x and recompile the source!"));
Line 2740... Line 2752...
2740
		    KMessageBox::error(this, i18n("There is no shape file in directory ") + MAP);
2752
		    KMessageBox::error(this, i18n("There is no shape file in directory ") + MAP);
2741
		    Fgeo = false;
2753
		    Fgeo = false;
2742
		 }
2754
		 }
2743
		 else
2755
		 else
2744
		 {
2756
		 {
2745
		 OGRDataSource *poDS = 0;
-
 
2746
		 OGRLayer *poLy;
2757
		 SRender rd;
2747
		 OGRFeature *poFeat;
-
 
2748
		 OGRFeatureDefn *poFDefn;
-
 
2749
		 OGRFieldDefn *poFieldDefn;
-
 
2750
		 OGRGeometry *poGeometry;
-
 
2751
		 OGRPoint *poPoint;
-
 
2752
		 int nLayers, iField;
-
 
2753
		 QString sfn;
-
 
2754
 
-
 
2755
		    OGRRegisterAll ();
-
 
2756
		    // read all shape files and put them together
-
 
2757
		    for (a = 0; (uint)a < shpd.count(); a++)
-
 
2758
		    {
-
 
2759
		       sfn = MAP + shpd[a];
-
 
2760
		       poDS = OGRSFDriverRegistrar::Open(sfn.toAscii().data(), false);
-
 
2761
 
-
 
2762
		       if (!poDS)
-
 
2763
		       {
-
 
2764
			  cerr << "Error opening the file " << sfn.toAscii().data() << "!" << endl;
-
 
2765
			  break;
-
 
2766
		       }
-
 
2767
 
2758
 
2768
		       nLayers = poDS->GetLayerCount ();
-
 
2769
 
-
 
2770
		       // Read all layers of a shape file
-
 
2771
		       for (int j = 0; j< nLayers; j++)
-
 
2772
		       {
-
 
2773
			  if ((poLy = poDS->GetLayer (j)) == NULL)
-
 
2774
			  {
-
 
2775
			     cerr << "Error getting layer " << j << "!" << endl;
-
 
2776
			     continue;
2759
		    paint.end();
2777
			  }
-
 
2778
 
-
 
2779
			  poLy->SetSpatialFilterRect (geoRect.llon, geoRect.llat, geoRect.rlon, geoRect.rlat);
-
 
2780
 
-
 
2781
			  // Read all features of a layer and get the fields
2760
		    rd.setDrawArea(*ui_sportwatcherWidgetBase.imgMap);
2782
			  // of the features
-
 
2783
			  poLy->ResetReading();
-
 
2784
 
-
 
2785
			  while ((poFeat = poLy->GetNextFeature()) != NULL)
2761
		    rd.getMap(posLXY.lat, posLXY.lon, posRXY.lat, posRXY.lon);
2786
			  {
-
 
2787
			     if ((poFDefn = poLy->GetLayerDefn()) == NULL)
-
 
2788
			     {
-
 
2789
			        cerr << "Error getting a layer defination!" << endl;
2762
		    pmMap = *ui_sportwatcherWidgetBase.imgMap->pixmap();
2790
			        continue;
2763
		    paint.begin(&pmMap);
2791
			     }
-
 
2792
 
-
 
2793
			     poGeometry = poFeat->GetGeometryRef();
-
 
2794
 
-
 
2795
			     if (poGeometry != NULL && wkbFlatten (poGeometry->getGeometryType()) == wkbPoint)
-
 
2796
			     {
-
 
2797
			        poPoint = (OGRPoint *) poGeometry;
-
 
2798
			        cout << "pointX: " << poPoint->getX() << ", pointY: " << poPoint->getY() << endl;
-
 
2799
			     }
-
 
2800
 
-
 
2801
			     for (iField = 0; iField < poFDefn->GetFieldCount(); iField++)
-
 
2802
			     {
-
 
2803
			        poFieldDefn = poFDefn->GetFieldDefn (iField);
-
 
2804
 
-
 
2805
				if (poFieldDefn->GetType() == OFTInteger)
-
 
2806
				   cout << "Layer: " << j << " int: " << poFeat->GetFieldAsInteger (iField) << endl;
-
 
2807
				else if (poFieldDefn->GetType() == OFTReal)
-
 
2808
				   cout << "Layer: " << j << " float: " << poFeat->GetFieldAsDouble (iField) << endl;
-
 
2809
				else if (poFieldDefn->GetType() == OFTString)
-
 
2810
				   cout << "Layer: " << j << " string: " << poFeat->GetFieldAsString (iField) << endl;
-
 
2811
				else
-
 
2812
				   cout << "Layer: " << j << " Unkn.: " << poFeat->GetFieldAsString (iField) << endl;
-
 
2813
			     }
-
 
2814
 
-
 
2815
			     cout << "----------------------------" << endl;
-
 
2816
        		  }
-
 
2817
 
-
 
2818
        		  OGRFeature::DestroyFeature (poFeat);
-
 
2819
		       }
-
 
2820
 
-
 
2821
		       OGRDataSource::DestroyDataSource(poDS);
-
 
2822
		    }
-
 
2823
		 }
2764
		 }
2824
	      }
2765
	      }
2825
	      else
2766
	      else
2826
	      {
2767
	      {
2827
		 KMessageBox::error(this, i18n("Error opening map file!"));
2768
		 KMessageBox::error(this, i18n("Error opening map file!"));
Line 3727... Line 3668...
3727
QPainter ptHR, ptElevation, ptSpeed;
3668
QPainter ptHR, ptElevation, ptSpeed;
3728
int width, height, wdHR, htHR, wdElev, htElev, wdSpeed, htSpeed;
3669
int width, height, wdHR, htHR, wdElev, htElev, wdSpeed, htSpeed;
3729
int i, secs, cuType;
3670
int i, secs, cuType;
3730
int lineHeight, margin_left, margin_right, margin_bottom;
3671
int lineHeight, margin_left, margin_right, margin_bottom;
3731
int x1, y1, x2, y2;		// Coordinates
3672
int x1, y1, x2, y2;		// Coordinates
3732
bool meter, meterHR, meterElev, meterSpeed;
3673
bool meterHR;
3733
double maxHeight, minHeight, maxSpeed, minSpeed;
3674
double maxHeight, minHeight, maxSpeed, minSpeed;
3734
int maxHr, minHr, rh, rhHR, rhElev, rhSpeed;
3675
int maxHr, minHr, rh, rhHR, rhElev, rhSpeed;
3735
POINT *point;
3676
POINT *point;
3736
RUN_NODE *rn;
3677
RUN_NODE *rn;
3737
LAP *lp;
3678
LAP *lp;