Subversion Repositories public

Compare Revisions

Ignore whitespace Rev 275 → Rev 276

/sportwatcher/trunk/src/shapewidget.cpp
15,6 → 15,7
#include <KConfig>
#include <KUrlRequester>
#include <KLineEdit>
#include <KMessageBox>
#include <QDir>
 
shapeWidget::shapeWidget (QWidget* parent, Qt::WFlags fl)
24,6 → 25,7
QDir dir = QDir::home();
QString path = dir.absolutePath();
 
__maptype = MAP_SHAPE; // default map type
setupUi (this);
// Make sure we are useing only existing files on the local system.
edShapeFileSet->setMode(KFile::ExistingOnly | KFile::LocalOnly);
76,6 → 78,27
}
 
/*$SPECIALIZATION$*/
void shapeWidget::setMapType(maptype mt)
{
switch (mt)
{
case MAP_SHAPE:
label->setText(i18n("Path to shape file set"));
break;
 
case MAP_GIS:
label->setText(i18n("Domain of machine with database"));
break;
 
case MAP_OSM:
label->setText(i18n("Path and name of OSM file"));
break;
 
default:
KMessageBox::error(this, i18n("Internal error: Unknown map type was set!"));
}
}
 
void shapeWidget::accept()
{
KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
/sportwatcher/trunk/src/render.cpp
42,6 → 42,7
#define CON_DATASOURCE 109
#define CON_SHIELDSYMBOLIZER 110
#define CON_LINEPATTERNSYMBOLIZER 111
#define CON_ELSEFILTER 112
 
#define FLD_FILTER 200
#define FLD_CSSPARAMETER 201
68,15 → 69,16
#define ATT_STATUS 315
#define ATT_SRS 316
#define ATT_DX 317
#define ATT_ALIGNMENT 318
 
#define FIRST_CON 100
#define LAST_CON 111
#define LAST_CON 112
 
#define FIRST_FLD 200
#define LAST_FLD 205
 
#define FIRST_ATT 300
#define LAST_ATT 317
#define LAST_ATT 318
 
using std::cout;
using std::cerr;
97,6 → 99,7
{ CON_DATASOURCE, in_datasource, QString("Datasource") },
{ CON_SHIELDSYMBOLIZER, in_shieldsymbolizer, QString("ShieldSymbolizer") },
{ CON_LINEPATTERNSYMBOLIZER, in_linepatternsymbolizer, QString("LinePatternSymbolizer") },
{ CON_ELSEFILTER, in_rule, QString("ElseFilter") },
// Fields
{ FLD_FILTER, in_rule, QString("Filter") },
{ FLD_CSSPARAMETER, in_symbolizer, QString("CSSParameter") },
123,6 → 126,7
{ ATT_ALLOWOVERLAP, in_symbolizer, QString("allow_overlap") },
{ ATT_STATUS, in_layer, QString("status") },
{ ATT_SRS, in_layer, QString("srs") },
{ ATT_ALIGNMENT, in_symbolizer, QString("alignment") },
{ 0, in_root, QString::null }
};
 
143,6 → 147,7
LinePatternSymbolizer = 0;
_lx = _ly = 180.0;
_rx = _ry = -180.0;
__map_type = MAP_SHAPE; // The default map type
// This is true, when a XML file was parsed successfully
ControlSet = false;
 
407,8 → 412,30
Rule->next = allocRule();
Rule = Rule->next;
}
 
if ((index = att.index(QString("name"))) != -1)
{
Rule->name = att.value(index);
Rule->rl.set_name(Rule->name.toAscii().data());
}
 
if ((index = att.index(QString("title"))) != -1)
{
Rule->title = att.value(index);
Rule->rl.set_title(Rule->title.toAscii().data());
}
break;
 
case CON_ELSEFILTER:
Container = in_elsefilter;
 
if (!Rule)
{
KMessageBox::error(0, i18n("Error parsing %1, line %2: Open ELSEFILTER outside of a RULE!").arg(XmlPath).arg(XmlLine));
return false;
}
break;
 
case CON_LAYER:
Container = in_layer;
 
438,6 → 465,18
 
if ((index = att.index(QString("maxzoom"))) != -1)
Lay->maxzoom = att.value(index).toDouble();
 
if ((index = att.index(QString("queryable"))) != -1)
Lay->queryable = getBool(att.value(index));
 
if ((index = att.index(QString("title"))) != -1)
Lay->title = att.value(index);
 
if ((index = att.index(QString("abstract"))) != -1)
Lay->abstract = att.value(index);
 
if ((index = att.index(QString("clear_label_cache"))) != -1)
Lay->clear_label = getBool(att.value(index));
break;
 
case CON_DATASOURCE:
479,12 → 518,7
PointSymbolizer->height = att.value(index).toDouble();
 
if ((index = att.index(QString("allow_overlap"))) != -1)
{
if (att.value(index).toLower() == QString("true"))
PointSymbolizer->allow_overlap = true;
else
PointSymbolizer->allow_overlap = false;
}
PointSymbolizer->allow_overlap = getBool(att.value(index));
break;
 
break;
563,6 → 597,9
if ((index = att.index(QString("face_name"))) != -1)
TextSymbolizer->face_name = att.value(index);
 
if ((index = att.index(QString("placement"))) != -1)
TextSymbolizer->placement = att.value(index);
 
if ((index = att.index(QString("size"))) != -1)
TextSymbolizer->size = att.value(index).toDouble();
 
575,6 → 612,9
if ((index = att.index(QString("wrap_width"))) != -1)
TextSymbolizer->wrap_width = att.value(index).toDouble();
 
if ((index = att.index(QString("alignment"))) != -1)
TextSymbolizer->alignment = att.value(index);
 
if ((index = att.index(QString("dx"))) != -1)
TextSymbolizer->dx = att.value(index).toDouble();
 
809,6 → 849,12
Names = estimate_extent;
else if (att.value(index).toLower() == QString("extent"))
Names = extent;
else if (att.value(index).toLower() == QString("parser"))
Names = parser__;
else if (att.value(index).toLower() == QString("url"))
Names = url;
else if (att.value(index).toLower() == QString("bbox"))
Names = bbox;
}
else
{
851,6 → 897,9
case in_linepatternsymbolizer:
Names = empty;
break;
case in_elsefilter:
Names = empty;
break;
}
}
 
872,21 → 921,48
parameters p;
Container = in_map;
 
if (Lay->Datasource.type.toLower() == QString("shape"))
if (Lay->Datasource.type.toLower() == QString("shape") && __map_type == MAP_SHAPE)
{
QFileInfo qdi(Lay->Datasource.file);
QString hv0;
 
hv0 = qdi.fileName();
 
if (shapePath.right(1) == QChar('/'))
hv0 = shapePath + hv0;
else
hv0 = shapePath + "/" + hv0;
 
p["type"] = "shape";
p["file"] = Lay->Datasource.file.toAscii().constData();
p["file"] = hv0.toAscii().data();
}
else if (Lay->Datasource.type.toLower() == QString("postgis"))
else if (Lay->Datasource.type.toLower() == QString("postgis") && __map_type == MAP_GIS)
{
p["type"] = "postgis";
p["host"] = Lay->Datasource.host.toAscii().constData();
p["user"] = Lay->Datasource.user.toAscii().constData();
p["dbname"] = Lay->Datasource.dbname.toAscii().constData();
p["table"] = Lay->Datasource.table.toAscii().constData();
p["host"] = Lay->Datasource.host.toAscii().data();
p["user"] = Lay->Datasource.user.toAscii().data();
p["dbname"] = Lay->Datasource.dbname.toAscii().data();
p["table"] = Lay->Datasource.table.toAscii().data();
p["estimate_extent"] = (Lay->Datasource.estimate_extent) ? "true" : "false";
p["extent"] = QString("%1,%2,%3,%4").arg(Lay->Datasource.ext_lx).arg(Lay->Datasource.ext_ly).arg(Lay->Datasource.ext_rx).arg(Lay->Datasource.ext_ry).toAscii().data();
}
else if (Lay->Datasource.type.toAscii() == QString("osm") && __map_type == MAP_OSM)
{
p["type"] = "osm";
 
if (Lay->Datasource.parser.length() <= 0)
p["parser"] = "libxml2";
else
p["parser"] = Lay->Datasource.parser.toAscii().data();
 
if (!Lay->Datasource.url.isEmpty() && !Lay->Datasource.bbox.isEmpty())
{
p["url"] = Lay->Datasource.url.toAscii().data();
p["bbox"] = Lay->Datasource.bbox.toAscii().data();
}
else
p["file"] = shapePath.toAscii().data();
}
else
{
cerr << "Warning file " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Layer with no source! Ingnoring!" << endl;
894,9 → 970,18
}
 
Layer lyr(Lay->name.toAscii().data());
lyr.set_title(Lay->name.toAscii().data());
 
if (!Lay->title.isEmpty())
lyr.set_title(Lay->title.toAscii().data());
 
if (!Lay->abstract.isEmpty())
lyr.set_abstract(Lay->abstract.toAscii().data());
 
lyr.set_datasource(datasource_cache::instance()->create(p));
 
if (!Lay->srs.isEmpty())
lyr.set_srs(Lay->srs.toAscii().data());
 
if (Lay->minzoom > 0.0)
lyr.setMinZoom(Lay->minzoom);
 
903,19 → 988,19
if (Lay->maxzoom > 0.0)
lyr.setMaxZoom(Lay->maxzoom);
 
if (!Lay->srs.isEmpty())
lyr.set_srs(Lay->srs.toAscii().constData());
lyr.set_clear_label_cache(Lay->clear_label);
 
// Add the styles
for (int i = 0; i < Lay->Styles.size(); i++)
{
if (findStyle (Lay->Styles.at(i)) != 0)
lyr.add_style(Lay->Styles.at(i).toAscii().constData());
lyr.add_style(Lay->Styles.at(i).toAscii().data());
else
cerr << "Warning file " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Style \"" << Lay->Styles.at(i).toAscii().data() << "\" does not exist!" << endl;
}
 
lyr.setActive(Lay->status);
lyr.setQueryable(true);
m.addLayer(lyr);
Envelope <double>le(lyr.envelope());
setMaxExtent(le.minx(), le.miny(), le.maxx(), le.maxy());
943,7 → 1028,7
}
else
{
point_symbolizer ps(PointSymbolizer->file.toAscii().data(), getTypeText(PointSymbolizer->type), PointSymbolizer->width, PointSymbolizer->height);
point_symbolizer ps(findIcon(PointSymbolizer->file).toAscii().data(), getTypeText(PointSymbolizer->type), PointSymbolizer->width, PointSymbolizer->height);
ps.set_allow_overlap (PointSymbolizer->allow_overlap);
Rule->rl.append(ps);
}
1035,21 → 1120,48
color col;
col.set_bgr(TextSymbolizer->fill);
 
text_symbolizer ts(TextSymbolizer->name.toAscii().data(), TextSymbolizer->face_name.toAscii().data(), TextSymbolizer->size, col);
if (TextSymbolizer->name.length() <= 0 || TextSymbolizer->face_name.length() <= 0 || TextSymbolizer->size <= 0)
cerr << "Error parsing " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Empty TEXTSYMBOLIZER found --> ignoring!" << endl;
else
{
text_symbolizer ts(TextSymbolizer->name.toAscii().data(), TextSymbolizer->face_name.toAscii().data(), TextSymbolizer->size, col);
 
if (TextSymbolizer->halo_radius != 0.0)
ts.set_halo_radius((unsigned int)TextSymbolizer->halo_radius);
if (TextSymbolizer->halo_radius != 0.0)
ts.set_halo_radius((unsigned int)TextSymbolizer->halo_radius);
 
if (TextSymbolizer->wrap_width != 0.0)
ts.set_wrap_width((unsigned int)TextSymbolizer->wrap_width);
if (TextSymbolizer->wrap_width != 0.0)
ts.set_wrap_width((unsigned int)TextSymbolizer->wrap_width);
 
if (TextSymbolizer->mindistance != 0)
ts.set_label_spacing(TextSymbolizer->mindistance);
if (TextSymbolizer->mindistance != 0)
ts.set_label_spacing(TextSymbolizer->mindistance);
 
if (TextSymbolizer->dx != 0 || TextSymbolizer->dy != 0)
ts.set_displacement(TextSymbolizer->dx, TextSymbolizer->dy);
if (!TextSymbolizer->placement.isEmpty())
{
if (TextSymbolizer->placement.toLower() == QString("point"))
ts.set_label_placement(mapnik::POINT_PLACEMENT);
else if (TextSymbolizer->placement.toLower() == QString("line"))
ts.set_label_placement(mapnik::LINE_PLACEMENT);
else
cerr << "Error parsing " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Unknown >>label placement<< \"" << TextSymbolizer->placement.toAscii().data() << "\" --> ignoring!" << endl;
}
 
Rule->rl.append(ts);
if (!TextSymbolizer->alignment.isEmpty())
{
if (TextSymbolizer->alignment.toLower() == QString("top"))
ts.set_vertical_alignment(mapnik::TOP);
else if (TextSymbolizer->alignment.toLower() == QString("middle"))
ts.set_vertical_alignment(mapnik::MIDDLE);
else if (TextSymbolizer->alignment.toLower() == QString("bottom"))
ts.set_vertical_alignment(mapnik::BOTTOM);
else
cerr << "Error parsing " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Unknown >>vertical placement<< \"" << TextSymbolizer->alignment.toAscii().data() << "\" --> ignoring!" << endl;
}
 
if (TextSymbolizer->dx != 0 || TextSymbolizer->dy != 0)
ts.set_displacement(TextSymbolizer->dx, TextSymbolizer->dy);
 
Rule->rl.append(ts);
}
}
else if (qName.toLower() == QString("polygonpatternsymbolizer"))
{
1061,11 → 1173,15
return false;
}
 
Rule->rl.append(polygon_pattern_symbolizer(findIcon(PolygonPatternSymbolizer->file).toAscii().data(),
if (PolygonPatternSymbolizer->file.length() <= 0)
cerr << "Error parsing " << XmlPath.toAscii().data() << ", line " << XmlLine << ": Incomplete POLYGONPATTERNSYMBOLIZER --> ignoring!" << endl;
else
{
Rule->rl.append(polygon_pattern_symbolizer(findIcon(PolygonPatternSymbolizer->file).toAscii().data(),
getTypeText(PolygonPatternSymbolizer->type),
PolygonPatternSymbolizer->width,
PolygonPatternSymbolizer->height));
PolygonPatternSymbolizer = PolygonPatternSymbolizer->next;
}
}
else if (qName.toLower() == QString("shieldsymbolizer"))
{
1118,6 → 1234,18
Container = in_rule;
else if (qName.toLower() == QString("rule"))
Container = in_style;
else if (qName.toLower() == QString("elsefilter"))
{
Container = in_rule;
 
if (!Rule)
{
KMessageBox::error(0, i18n("Error parsing %1, line %2: Ending of ELSEFILTER outside of a RULE detected!").arg(XmlPath).arg(XmlLine));
return false;
}
 
Rule->rl.set_else(true);
}
else if (qName.toLower() == QString("style"))
{
Container = in_map;
1147,17 → 1275,17
*/
bool SRender::characters (const QString& chraw)
{
if (chraw.at(0) == QChar('\n'))
{
XmlLine++;
return true;
}
 
QString ch = chraw.trimmed();
 
if (ch.length() == 0)
return true;
 
if (ch.at(0) == QChar('\n'))
{
XmlLine++;
return true;
}
 
if (Container == in_rule && Rule)
{
if (Field == FLD_FILTER)
1165,7 → 1293,7
Rule->filter = ch;
 
if (!Rule->filter.isEmpty())
Rule->rl.set_filter(create_filter(Rule->filter.toAscii().data()));
Rule->rl.set_filter(create_filter(Rule->filter.toLatin1().data(), "latin1"));
else
cerr << "Warning in file " << XmlPath.toAscii().data() << " at line " << XmlLine << ": Ignoring empty filter!" << endl;
}
1241,16 → 1369,30
hv0 += "/";
 
hv0 += qf.fileName();
qf.setFile (hv0 + ".shp");
 
if (__map_type == MAP_SHAPE)
qf.setFile (hv0 + ".shp");
else if (__map_type == MAP_OSM)
qf.setFile (hv0 + ".osm");
 
if (!qf.exists())
{
KMessageBox::error(0, i18n("The shape file \"%1\" at line %2 does not exist!").arg(hv0+".shp").arg(XmlLine));
if (__map_type == MAP_SHAPE)
KMessageBox::error(0, i18n("The shape file \"%1\" at line %2 does not exist!").arg(hv0+".shp").arg(XmlLine));
else if (__map_type == MAP_OSM)
KMessageBox::error(0, i18n("The OSM file \"%1\" at line %2 does not exist!").arg(hv0+".osm").arg(XmlLine));
 
return false;
}
 
Lay->Datasource.file = hv0;
}
else if (Names == parser__)
Lay->Datasource.parser = ch;
else if (Names == url)
Lay->Datasource.url = ch;
else if (Names == bbox)
Lay->Datasource.bbox = ch;
else if (Names == host)
Lay->Datasource.host = ch;
else if (Names == user)
1379,65 → 1521,91
m.setHeight(height);
// load_map(m, XmlPath.toAscii().data());
 
if (!ControlSet) // Initialize the map?
try
{
QXmlInputSource source (&file);
reader.setContentHandler (this);
reader.parse (source);
}
if (!ControlSet) // Initialize the map?
{
QXmlInputSource source (&file);
reader.setContentHandler (this);
reader.parse (source);
}
 
save_map(m, "/home/andreas/.sportwatcher/spw.xml");
// save_map(m, "/home/andreas/.sportwatcher/spw1.xml");
plx = lx;
ply = ly;
prx = rx;
pry = ry;
projection pj(m.srs());
save_map(m, "/home/andreas/.sportwatcher/spw.xml");
// save_map(m, "/home/andreas/.sportwatcher/spw1.xml");
plx = lx;
ply = ly;
prx = rx;
pry = ry;
projection pj(m.srs());
 
if (pj.is_geographic())
{
pj.inverse(plx, ply);
pj.inverse(prx, pry);
if (pj.is_geographic())
{
pj.inverse(plx, ply);
pj.inverse(prx, pry);
cout << "Geographic! Inverse projection." << endl;
}
else
{
// pj.forward(plx, ply);
// pj.forward(prx, pry);
}
else
{
// pj.forward(plx, ply);
// pj.forward(prx, pry);
cout << "NOT geographic!" << endl;
}
}
 
for (unsigned i = 0; i < m.layerCount(); i++)
{
bool vis = m.getLayer(i).isVisible(m.scale_denominator());
// bool vis = m.getLayer(i).isVisible(m.scale());
cout << "Layer " << i << ": " << m.getLayer(i).name();
cout << ", Visible: " << vis;
cout << ", Active: " << m.getLayer(i).isActive();
Envelope <double>e(m.getLayer(i).envelope());
cout << ", Extent: " << e.minx() << ", " << e.miny() << ", " << e.maxx() << ", " << e.maxy() << endl;
}
 
// First we use Mapnik to create the map
m.zoomToBox(Envelope<double>(plx, ply, prx, pry));
// First we use Mapnik to create the map
m.zoomToBox(Envelope<double>(plx, ply, prx, pry));
 
Envelope <double>e(m.getCurrentExtent());
cout << std::setprecision(16) << "Parameter envelope: " << lx << ", " << ly << ", " << rx << ", " << ry << endl;
cout << std::setprecision(16) << "Converted envelope: " << plx << ", " << ply << ", " << prx << ", " << pry << endl;
cout << std::setprecision(16) << "Current extent: " << e.minx() << ", " << e.miny() << ", " << e.maxx() << ", " << e.maxy() << endl;
Envelope <double>x(m.get_buffered_extent());
cout << std::setprecision(16) << "Current buf.extent: " << x.minx() << ", " << x.miny() << ", " << x.maxx() << ", " << x.maxy() << endl;
cout << "SRS: " << m.srs() << endl;
cout << std::setprecision(16) << "Scale: " << m.scale() << ", scale denominator: " << m.scale_denominator() << endl;
cout << "width=" << m.getWidth() << ", height=" << m.getHeight() << endl;
 
Image32 buf(m.getWidth(), m.getHeight());
agg_renderer<Image32> ren(m, buf);
ren.apply();
// Put the image into a Qt object
QImage image((uchar*)buf.raw_data(), m.getWidth(), m.getHeight(), QImage::Format_ARGB32);
label->setPixmap(QPixmap::fromImage(image.rgbSwapped()));
// Create a unique file name
// pid = getpid();
// OutBuf.sprintf("/var/tmp/SportWatcher_%d.png", pid);
// save_to_file<ImageData32>(buf.data(), OutBuf.toAscii().data(), "png");
Image32 buf(m.getWidth(), m.getHeight());
agg_renderer<Image32> ren(m, buf);
ren.apply();
 
// Put the image into a Qt object
QImage image((uchar*)buf.raw_data(), m.getWidth(), m.getHeight(), QImage::Format_ARGB32);
label->setPixmap(QPixmap::fromImage(image.rgbSwapped()));
// Create a unique file name
// pid = getpid();
// OutBuf.sprintf("/var/tmp/SportWatcher_%d.png", pid);
// save_to_file<ImageData32>(buf.data(), OutBuf.toAscii().data(), "png");
}
 
catch (const mapnik::config_error &ex)
{
KMessageBox::error(0, i18n("Configuration error: %1").arg(ex.what()));
return false;
}
 
catch (const std::exception &ex)
{
KMessageBox::error(0, i18n("Exception at file %1: %2").arg(XmlPath).arg(ex.what()));
return false;
}
 
catch (...)
{
KMessageBox::error(0, i18n("Unknown exception occured!"));
return false;
}
 
return true;
}
 
1641,8 → 1809,11
{
RULE *Ru = new RULE;
 
Ru->name.clear();
Ru->title.clear();
Ru->maxscale = 0;
Ru->minscale = 0;
Ru->elsefilter = false;
Ru->filter.clear();
Ru->LineSymbolizer = 0;
Ru->PolygonSymbolizer = 0;
1660,12 → 1831,19
LAYER *La = new LAYER;
 
La->name.clear(); // The unique name
La->title.clear();
La->abstract.clear();
La->status = false; // Is it active?
La->clear_label = false;
La->srs.clear(); // Projection
La->minzoom = 0.0;
La->maxzoom = 0.0;
La->queryable = false;
La->Datasource.type.clear();
La->Datasource.file.clear();
La->Datasource.parser.clear();
La->Datasource.url.clear();
La->Datasource.bbox.clear();
La->Datasource.host.clear();
La->Datasource.user.clear();
La->Datasource.dbname.clear();
1744,6 → 1922,8
 
ts->name.clear();
ts->face_name.clear();
ts->placement.clear();
ts->alignment.clear();
ts->size = 0;
ts->fill = 0; // Color
ts->halo_radius = 0;
/sportwatcher/trunk/src/garmin.h
1580,7 → 1580,7
A011_Cmnd_Transfer_Prx = 0x0011,
A011_Cmnd_Transfer_Time = 0x0014,
A011_Cmnd_Transfer_Wpt = 0x0015,
A011_Cmnd_Turn_Off_Pwr = 0x001a,
A011_Cmnd_Turn_Off_Pwr = 0x001a
} A011_command_id;
 
 
/sportwatcher/trunk/src/CMakeLists.txt
23,7 → 23,7
sportwatcherwidgetbase.ui
wmswidgetbase.ui)
 
add_definitions(-fexceptions -D_REENTRANT)
add_definitions(-pedantic -fexceptions -Wextra -D_REENTRANT)
 
kde4_add_ui_files(sportwatcher_SRCS ${sportwatcher_UI})
kde4_add_app_icon(sportwatcher_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../src/hi*-app-sportwatcher.png")
/sportwatcher/trunk/src/sportwatcherwidget.h
52,7 → 52,8
MPT_PNG = 4,
MPT_SGI = 5,
MPT_TIF = 6,
MPT_WMS = 7
MPT_WMS = 7,
MPT_OSM = 8
} MPT;
 
typedef struct GEORECT
/sportwatcher/trunk/src/shapewidget.h
18,6 → 18,15
 
class shapeWidget : public QDialog, private Ui::shapeWidgetBase
{
public:
enum maptype
{
MAP_SHAPE,
MAP_GIS,
MAP_OSM,
maptype_MAX
};
 
Q_OBJECT
 
public:
24,10 → 33,14
shapeWidget (QWidget* parent = 0, Qt::WFlags fl = 0);
~shapeWidget();
/*$PUBLIC_FUNCTIONS$*/
void setMapType (maptype mt);
 
public slots:
/*$PUBLIC_SLOTS$*/
virtual void accept();
 
private:
maptype __maptype;
};
 
#endif
/sportwatcher/trunk/src/render.h
13,8 → 13,6
#define _RENDER_H
 
#include <mapnik/map.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/save_map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/agg_renderer.hpp>
22,9 → 20,8
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/color.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/rule.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/save_map.hpp>
 
/* conversions */
 
69,6 → 66,8
{
QString name;
QString face_name;
QString placement;
QString alignment;
double size;
unsigned fill; // Color
double halo_radius;
129,9 → 128,12
 
typedef struct RULE
{
QString name;
QString title;
double maxscale;
double minscale;
QString filter;
bool elsefilter;
LINESYMBOLIZER *LineSymbolizer;
POLYGONSYMBOLIZER *PolygonSymbolizer;
TEXTSYMBOLIZER *TextSymbolizer;
154,6 → 156,9
{
QString type;
QString file;
QString parser;
QString url;
QString bbox;
QString host;
QString user;
QString dbname;
168,10 → 173,14
typedef struct LAYER
{
QString name; // The unique name
QString title; // The title of the layer (optional)
QString abstract; // Some short description (optional)
bool status; // Is it active?
bool clear_label; // Clear label cache?
QString srs; // Projection
double minzoom;
double maxzoom;
bool queryable;
QStringList Styles; // The names of the Styles
DATASOURCE Datasource;
LAYER *next; // Pointer to next layer
201,7 → 210,10
dbname = 112,
table = 113,
estimate_extent = 114,
extent = 115
extent = 115,
parser__ = 116,
url = 117,
bbox = 118
}NAMES;
 
typedef enum {
218,7 → 230,8
in_datasource = 109,
in_symbolizer = 110,
in_shieldsymbolizer = 111,
in_linepatternsymbolizer = 112
in_linepatternsymbolizer = 112,
in_elsefilter = 113
}CONTAINER;
 
typedef struct
233,6 → 246,15
class SRender : public QXmlDefaultHandler
{
public:
enum map_type
{
MAP_SHAPE,
MAP_GIS,
MAP_OSM,
map_type_MAX
};
 
public:
SRender();
~SRender();
 
241,6 → 263,8
void setXmlPath(const QString &path) { if (path.isNull()) return; XmlPath = path; };
bool getMap(double lx, double ly, double rx, double ry);
QString getOutBuf () { return OutBuf; };
inline void setMapType(map_type mt) { __map_type = mt; }
inline map_type getMapType() { return __map_type; }
 
// Functions to parse the XML file
bool startDocument ();
286,6 → 310,7
QString fontPath;
QString XmlPath;
QString OutBuf;
map_type __map_type;
CONTAINER Container;
bool ControlSet;
int Field;
/sportwatcher/trunk/src/sportwatcherwidget.cpp
1750,14 → 1750,20
delete dlg;
}
 
if (MapType == MPT_SHP)
if (MapType == MPT_SHP || MapType == MPT_OSM)
{
shapeWidget *dlg = new shapeWidget(this);
 
if (MapType == MPT_SHP)
dlg->setMapType(shapeWidget::MAP_SHAPE);
else
dlg->setMapType(shapeWidget::MAP_OSM);
 
dlg->exec();
delete dlg;
}
 
if (MapType != MPT_WMS && MapType != MPT_SHP)
if (MapType != MPT_WMS && MapType != MPT_SHP && MapType != MPT_OSM)
{
KMessageBox::detailedSorry(this,
i18n("You have not choosen a WMS tag file or shape file directory!"),
2762,12 → 2768,12
else
rd.setDrawArea(*ui_sportwatcherWidgetBase.grMap);
 
rd.setMapType(SRender::MAP_SHAPE);
 
if (rd.getMap(posLXY.lon, posLXY.lat, posRXY.lon, posRXY.lat))
{
paint.fillRect(0, 0, width+2, height+2, bg);
// QPixmap qpx;
// qpx.load(rd.getOutBuf());
//cout << "Pixmap loaded from: " << rd.getOutBuf().toAscii().data() << endl;
 
if (curTab == 0)
paint.drawPixmap(0, 0, *ui_sportwatcherWidgetBase.imgMap->pixmap());
else
2779,6 → 2785,42
Fgeo = false;
}
}
else if (MapType == MPT_OSM)
{
QFileInfo osmf(MAP);
 
if (!osmf.exists())
{
KMessageBox::error(this, i18n("The OSM file %1 does not exist!").arg(MAP));
Fgeo = false;
}
else
{
SRender rd;
QColor bg(220, 220, 220); // background color
 
if (curTab == 0)
rd.setDrawArea(*ui_sportwatcherWidgetBase.imgMap);
else
rd.setDrawArea(*ui_sportwatcherWidgetBase.grMap);
 
rd.setMapType(SRender::MAP_OSM);
 
if (rd.getMap(posLXY.lon, posLXY.lat, posRXY.lon, posRXY.lat))
{
paint.fillRect(0, 0, width+2, height+2, bg);
 
if (curTab == 0)
paint.drawPixmap(0, 0, *ui_sportwatcherWidgetBase.imgMap->pixmap());
else
paint.drawPixmap(0, 0, *ui_sportwatcherWidgetBase.grMap->pixmap());
 
Fgeo = true;
}
else
Fgeo = false;
}
}
else
{
KMessageBox::error(this, i18n("Error opening map file!"));
/sportwatcher/trunk/src/settingswidgetbase.ui
9,7 → 9,7
<x>0</x>
<y>0</y>
<width>508</width>
<height>613</height>
<height>629</height>
</rect>
</property>
<property name="windowTitle">
629,6 → 629,11
<string>WMS Server (tag file)</string>
</property>
</item>
<item>
<property name="text">
<string>OSM Open Streetmap (file)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2" colspan="3">