187,6 → 187,7 |
fontPath = sh.readEntry("FontPath", QString("")); |
#endif |
XmlPath = sh.readEntry("XmlFile", basePath + "/shapefiles/osm.xml"); |
geographic = sh.readEntry("Geographic", false); |
} |
|
SRender::~SRender() |
193,9 → 194,6 |
{ |
startDocument(); // Clean everything |
ControlSet = false; |
|
if (!OutBuf.isEmpty()) |
unlink (OutBuf.toAscii().data()); |
} |
|
bool SRender::startDocument() |
347,11 → 345,8 |
|
if ((index = att.index(QString("bgcolor"))) != -1) |
{ |
color col; |
|
MapPars.bgcolor = colorToUInt(att.value(index)); |
col.set_bgr(MapPars.bgcolor); |
m.set_background(col); |
m.set_background(setColor(MapPars.bgcolor)); |
} |
|
if ((index = att.index(QString("buffer_size"))) != -1) |
1044,11 → 1039,8 |
} |
|
stroke st; |
color col; |
col.set_bgr(LineSymbolizer->stroke); |
st.set_color (setColor(LineSymbolizer->stroke)); |
|
st.set_color (col); |
|
if (LineSymbolizer->stroke_width != 0.0) |
st.set_width (LineSymbolizer->stroke_width); |
|
1097,11 → 1089,8 |
return false; |
} |
|
color col; |
col.set_bgr(PolygonSymbolizer->fill); |
polygon_symbolizer ps(setColor(PolygonSymbolizer->fill)); |
|
polygon_symbolizer ps(col); |
|
if (PolygonSymbolizer->fill_opacity > 0.0) |
ps.set_opacity(PolygonSymbolizer->fill_opacity); |
|
1117,14 → 1106,11 |
return false; |
} |
|
color col; |
col.set_bgr(TextSymbolizer->fill); |
|
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); |
text_symbolizer ts(TextSymbolizer->name.toAscii().data(), TextSymbolizer->face_name.toAscii().data(), TextSymbolizer->size, setColor(TextSymbolizer->fill)); |
|
if (TextSymbolizer->halo_radius != 0.0) |
ts.set_halo_radius((unsigned int)TextSymbolizer->halo_radius); |
1193,11 → 1179,9 |
return false; |
} |
|
color col; |
col.set_bgr(ShieldSymbolizer->fill); |
shield_symbolizer ss(ShieldSymbolizer->name.toAscii().data(), |
ShieldSymbolizer->face_name.toAscii().data(), |
ShieldSymbolizer->size, col, |
ShieldSymbolizer->size, setColor(ShieldSymbolizer->fill), |
findIcon(ShieldSymbolizer->file).toAscii().data(), |
getTypeText(ShieldSymbolizer->type), |
ShieldSymbolizer->width, ShieldSymbolizer->height); |
1497,9 → 1481,9 |
QXmlSimpleReader reader; |
QString hv0; |
QFile file(XmlPath); |
QDir dir(fontPath); |
double plx, ply, prx, pry; |
|
OutBuf.clear(); |
hv0 = pluginPath; |
|
if (hv0.right(1) != QString("/")) |
1511,15 → 1495,36 |
if (hv0.right(1) != QString("/")) |
hv0 += "/"; |
|
hv0 += "DejaVuSans.ttf"; |
freetype_engine::register_font(hv0.toAscii().data()); |
// Load all fonts in directory |
if (!dir.exists()) |
{ |
KMessageBox::error(0, i18n("The font directory does not exist! Please select a valid directory with at least one true type font in it!")); |
return false; |
} |
|
QStringList filters; |
filters << "*.ttf"; |
dir.setNameFilters(filters); |
dir.setFilter(QDir::Readable | QDir::Files); |
QFileInfoList list = dir.entryInfoList(); |
|
for (int i = 0; i < list.size(); ++i) |
{ |
QString f; |
|
QFileInfo fileInfo = list.at(i); |
f = hv0 + fileInfo.fileName(); |
freetype_engine::register_font(f.toAscii().data()); |
} |
|
// hv0 += "DejaVuSans.ttf"; // Default font |
// freetype_engine::register_font(hv0.toAscii().data()); |
|
width = label->width(); |
height = label->height(); |
|
m.setWidth(width); |
m.setHeight(height); |
// load_map(m, XmlPath.toAscii().data()); |
|
try |
{ |
1530,8 → 1535,6 |
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; |
1538,43 → 1541,22 |
pry = ry; |
projection pj(m.srs()); |
|
if (pj.is_geographic()) |
if (!geographic && pj.is_geographic()) |
{ |
pj.inverse(plx, ply); |
pj.inverse(prx, pry); |
cout << "Geographic! Inverse projection." << endl; |
} |
else |
|
if (geographic && pj.is_geographic()) |
{ |
// pj.forward(plx, ply); |
// pj.forward(prx, pry); |
cout << "NOT geographic!" << endl; |
pj.forward(plx, ply); |
pj.forward(prx, pry); |
} |
|
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)); |
|
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; |
|
// Here we render the map to an image buffer |
Image32 buf(m.getWidth(), m.getHeight()); |
agg_renderer<Image32> ren(m, buf); |
ren.apply(); |
1582,10 → 1564,6 |
// 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) |
1653,6 → 1631,23 |
return ptf; |
} |
|
color SRender::setColor(unsigned col) |
{ |
color c; |
#if MAPNIK_VERSION == 600 |
c.set_bgr(col); |
#else |
int r, g, b; |
b = col / 65536; |
g = (col - (b * 65536)) / 256; |
r = col - ((b* 65536) + (g * 256)); |
c.set_red(r); |
c.set_green(g); |
c.set_blue(b); |
#endif |
return c; |
} |
|
RULE *SRender::getLastRule(RULE *first) |
{ |
RULE *akt = first; |