Subversion Repositories public

Rev

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

Rev 273 Rev 274
Line 1... Line 1...
1
//
1
//
2
// C++ Implementation: render
2
// C++ Implementation: SRender
3
//
3
//
4
// Description: Renders a map from some shape files. This class assumes,
4
// Description: Renders a map from some shape files. This class assumes,
5
//              that the shape files are in open street map format!
5
//              that the shape files are in open street map format!
6
//
6
//
7
//
7
//
Line 10... Line 10...
10
// Copyright: See COPYING file that comes with this distribution
10
// Copyright: See COPYING file that comes with this distribution
11
//
11
//
12
//
12
//
13
 
13
 
14
#define BOOST_SPIRIT_THREADSAFE
14
#define BOOST_SPIRIT_THREADSAFE
15
#include <mapnik/map.hpp>
15
#include <QLabel>
16
#include <mapnik/datasource_cache.hpp>
16
#include <QString>
17
#include <mapnik/font_engine_freetype.hpp>
17
#include <QXmlReader>
-
 
18
#include <QDir>
-
 
19
#include <QColor>
18
#include <mapnik/agg_renderer.hpp>
20
#include <KStandardDirs>
19
#include <mapnik/filter_factory.hpp>
21
#include <KConfig>
-
 
22
#include <KLocale>
20
#include <mapnik/color_factory.hpp>
23
#include <KMessageBox>
21
#include <mapnik/image_util.hpp>
24
#include <KGlobalSettings>
22
#include <mapnik/config_error.hpp>
25
#include <KConfigGroup>
23
 
26
 
24
#include "config.h"
27
#include "config.h"
25
#include "render.h"
28
#include "render.h"
-
 
29
#include <iostream>
26
 
30
 
27
#define CON_MAP			100
31
#define CON_MAP			100
28
#define CON_STYLE		101
32
#define CON_STYLE		101
29
#define CON_RULE		102
33
#define CON_RULE		102
30
#define CON_LINESYMBOLIZER	103
34
#define CON_LINESYMBOLIZER	103
Line 32... Line 36...
32
#define CON_POLYGONSYMBOLIZER	105
36
#define CON_POLYGONSYMBOLIZER	105
33
#define CON_TEXTSYMBOLIZER	106
37
#define CON_TEXTSYMBOLIZER	106
34
#define CON_POLYGONPATTERNSYMBOLIZER	107
38
#define CON_POLYGONPATTERNSYMBOLIZER	107
35
#define CON_LAYER		108
39
#define CON_LAYER		108
36
#define CON_DATASOURCE		109
40
#define CON_DATASOURCE		109
-
 
41
#define CON_SHIELDSYMBOLIZER	110
-
 
42
#define CON_LINEPATTERNSYMBOLIZER	111
37
 
43
 
38
#define FLD_FILTER		200
44
#define FLD_FILTER		200
39
#define FLD_CSSPARAMETER	201
45
#define FLD_CSSPARAMETER	201
40
#define FLD_MINSCALE		202
46
#define FLD_MINSCALE		202
41
#define FLD_MAXSCALE		203
47
#define FLD_MAXSCALE		203
Line 59... Line 65...
59
#define ATT_ALLOWOVERLAP	314
65
#define ATT_ALLOWOVERLAP	314
60
#define ATT_STATUS		315
66
#define ATT_STATUS		315
61
#define ATT_SRS			316
67
#define ATT_SRS			316
62
 
68
 
63
#define FIRST_CON		100
69
#define FIRST_CON		100
64
#define LAST_CON		109
70
#define LAST_CON		111
65
 
71
 
66
#define FIRST_FLD		200
72
#define FIRST_FLD		200
67
#define LAST_FLD		205
73
#define LAST_FLD		205
68
 
74
 
69
#define FIRST_ATT		300
75
#define FIRST_ATT		300
70
#define LAST_ATT		316
76
#define LAST_ATT		316
71
 
77
 
-
 
78
using std::cout;
-
 
79
using std::cerr;
-
 
80
using std::clog;
-
 
81
using std::endl;
-
 
82
 
72
KEYS keys[] = {
83
TOKEN token[] = {
73
	// Containers
84
	// Containers
74
	{ CON_MAP			QString("Map") },
85
	{ CON_MAP,			in_map,			QString("Map") },
75
	{ CON_STYLE			QString("Style") },
86
	{ CON_STYLE,			in_style,		QString("Style") },
76
	{ CON_RULE			QString("Rule") },
87
	{ CON_RULE,			in_rule,		QString("Rule") },
77
	{ CON_LINESYMBOLIZER		QString("LineSymbolizer") },
88
	{ CON_LINESYMBOLIZER,		in_linesymbolizer,	QString("LineSymbolizer") },
78
	{ CON_POINTSYMBOLIZER		QString("PointSymbolizer") },
89
	{ CON_POINTSYMBOLIZER,		in_pointsymbolizer,	QString("PointSymbolizer") },
79
	{ CON_POLYGONSYMBOLIZER		QString("PolygonSymbolizer") },
90
	{ CON_POLYGONSYMBOLIZER,	in_polygonsymbolizer,	QString("PolygonSymbolizer") },
80
	{ CON_TEXTSYMBOLIZER		QString("TextSymbolizer") },
91
	{ CON_TEXTSYMBOLIZER,		in_textsymbolizer,	QString("TextSymbolizer") },
81
	{ CON_POLYGONPATTERNSYMBOLIZER	QString("PolygonPatternSymbolizer") },
92
	{ CON_POLYGONPATTERNSYMBOLIZER,	in_polygonpatternsymbolizer,	QString("PolygonPatternSymbolizer") },
82
	{ CON_LAYER			QString("Layer") },
93
	{ CON_LAYER,			in_layer,		QString("Layer") },
83
	{ CON_DATASOURCE		QString("Datasource") },
94
	{ CON_DATASOURCE,		in_datasource,		QString("Datasource") },
-
 
95
	{ CON_SHIELDSYMBOLIZER,		in_shieldsymbolizer,	QString("ShieldSymbolizer") },
84
	// Fields
96
	// Fields
85
	{ FLD_FILTER			QString("Filter") },
97
	{ FLD_FILTER,			in_rule,		QString("Filter") },
86
	{ FLD_CSSPARAMETER		QString("CSSParameter") },
98
	{ FLD_CSSPARAMETER,		in_symbolizer,		QString("CSSParameter") },
87
	{ FLD_MINSCALE			QString("MinScaleDenominator") },
99
	{ FLD_MINSCALE,			in_rule,		QString("MinScaleDenominator") },
88
	{ FLD_MAXSCALE			QString("MaxScaleDenominator") },
100
	{ FLD_MAXSCALE,			in_rule,		QString("MaxScaleDenominator") },
89
	{ FLD_STYLENAME			QString("StyleName") },
101
	{ FLD_STYLENAME,		in_style,		QString("StyleName") },
90
	{ FLD_PARAMETER			QString("Parameter") },
102
	{ FLD_PARAMETER,		in_datasource,		QString("Parameter") },
91
	// Attributes
103
	// Attributes
92
	{ ATT_FILL			QString("fill") },
104
	{ ATT_FILL,			in_symbolizer,		QString("fill") },
93
	{ ATT_NAME			QString("name") },
105
	{ ATT_NAME,			in_symbolizer,		QString("name") },
94
	{ ATT_FILE			QString("file") },
106
	{ ATT_FILE,			in_symbolizer,		QString("file") },
95
	{ ATT_TYPE			QString("type") },
107
	{ ATT_TYPE,			in_symbolizer,		QString("type") },
96
	{ ATT_WIDTH			QString("width") },
108
	{ ATT_WIDTH,			in_symbolizer,		QString("width") },
97
	{ ATT_HEIGHT			QString("height") },
109
	{ ATT_HEIGHT,			in_symbolizer,		QString("height") },
98
	{ ATT_SIZE			QString("size") },
110
	{ ATT_SIZE,			in_symbolizer,		QString("size") },
99
	{ ATT_FACENAME			QString("face_name") },
111
	{ ATT_FACENAME,			in_symbolizer,		QString("face_name") },
100
	{ ATT_DY			QString("dy") },
112
	{ ATT_DY,			in_symbolizer,		QString("dy") },
101
	{ ATT_HALORADIUS		QString("halo_radius") },
113
	{ ATT_HALORADIUS,		in_symbolizer,		QString("halo_radius") },
102
	{ ATT_WRAPWIDTH			QString("wrap_width") },
114
	{ ATT_WRAPWIDTH,		in_symbolizer,		QString("wrap_width") },
103
	{ ATT_MINDISTANCE		QString("min_distance") },
115
	{ ATT_MINDISTANCE,		in_symbolizer,		QString("min_distance") },
104
	{ ATT_MAXDISTANCE		QString("max_distance") },
116
	{ ATT_MAXDISTANCE,		in_symbolizer,		QString("max_distance") },
105
	{ ATT_PLACEMAENT		QString("placement") },
117
	{ ATT_PLACEMENT,		in_symbolizer,		QString("placement") },
106
	{ ATT_ALLOWOVERLAP		QString("allow_overlap") },
118
	{ ATT_ALLOWOVERLAP,		in_symbolizer,		QString("allow_overlap") },
107
	{ ATT_STATUS			QString("status") },
119
	{ ATT_STATUS,			in_layer,		QString("status") },
108
	{ ATT_SRS			QString("srs") },
120
	{ ATT_SRS,			in_layer,		QString("srs") },
109
	{ 0				QString::null }
121
	{ 0,				in_root,		QString::null }
110
};
122
};
111
 
123
 
112
render::render()
124
SRender::SRender()
113
{
125
{
114
	Layer = 0;
126
	label = 0;
-
 
127
	shapePath = QString::null;
-
 
128
	XmlPath = QString::null;
115
	Style = 0;
129
	Lay = firstLayer = lastLayer = 0;
-
 
130
	Style = firstStyle = lastStyle = 0;
116
	Rule = 0;
131
	Rule = 0;
117
	LineSymbolizer = 0;
132
	LineSymbolizer = 0;
118
	PolygonSymbolizer = 0;
133
	PolygonSymbolizer = 0;
119
	TextSymbolizer = 0;
134
	TextSymbolizer = 0;
120
	PointSymbolizer = 0;
135
	PointSymbolizer = 0;
121
	PolygonPatternSymbolizer = 0;
136
	PolygonPatternSymbolizer = 0;
122
	ShieldSymbolizer = 0;
137
	ShieldSymbolizer = 0;
123
	LinePatternSymbolizer = 0;
138
	LinePatternSymbolizer = 0;
-
 
139
	// This is true, when a XML file was parsed successfully
-
 
140
	ControlSet = false;
-
 
141
 
-
 
142
	// Read settings from config file
-
 
143
	KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
-
 
144
	KConfigGroup ic (&cfg, "SportWatcher");
-
 
145
	KConfigGroup sh (&cfg, "ShapeFile");
-
 
146
	QString basePath = ic.readEntry("Data", QDir::home().absolutePath() + "/.sportwatcher");
-
 
147
	shapePath = ic.readEntry("MAP", basePath + "/shapefiles");
-
 
148
	// Read the shape specific informations
-
 
149
#ifdef MAPNIK_PLUGINS
-
 
150
	pluginPath = QString(MAPNIK_PLUGINS);
-
 
151
#else
-
 
152
	// Test some default path
-
 
153
	if (dir.exists(QString("/usr/lib/mapnik/input")))
-
 
154
	   pluginPath = sh.readEntry("PluginPath", QString("/usr/lib/mapnik/input"));
-
 
155
	else if (dir.exists(QString("/usr/local/lib/mapnik/input")))
-
 
156
	   pluginPath = sh.readEntry("PluginPath", QString("/usr/local/lib/mapnik/input"));
-
 
157
	else if (dir.exists(QString("/usr/lib/mapnik/0.6/input")))
-
 
158
	   pluginPath = sh.readEntry("PluginPath", QString("/usr/lib/mapnik/0.6/input"));
-
 
159
	else
-
 
160
	   pluginPath = sh.readEntry("PluginPath", QString(""));
-
 
161
#endif
-
 
162
#ifdef MAPNIK_FONTS
-
 
163
	fontPath = QString(MAPNIK_FONTS);
-
 
164
#else
-
 
165
	// Test some default path
-
 
166
	if (dir.exists(QString("/usr/lib/mapnik/fonts")))
-
 
167
	   fontPath = sh.readEntry("FontPath", QString("/usr/lib/mapnik/fonts"));
-
 
168
	else if (dir.exists(QString("/usr/local/lib/mapnik/fonts")))
-
 
169
	   fontPath = sh.readEntry("FontPath", QString("/usr/local/lib/mapnik/fonts"));
-
 
170
	else if (dir.exists(QString("/usr/share/mapnik/fonts")))
-
 
171
	   fontPath = sh.readEntry("FontPath", QString("/usr/share/mapnik/fonts"));
-
 
172
	else if (dir.exists(QString("/usr/share/fonts/truetype/ttf-dejavu")))
-
 
173
	   fontPath = sh.readEntry("FontPath", QString("/usr/share/fonts/truetype/ttf-dejavu"));
-
 
174
	else
-
 
175
	   fontPath = sh.readEntry("FontPath", QString(""));
-
 
176
#endif
-
 
177
	XmlPath = sh.readEntry("XmlFile", basePath + "/shapefiles/osm.xml");
-
 
178
}
-
 
179
 
-
 
180
SRender::~SRender()
-
 
181
{
-
 
182
	startDocument();	// Clean everything
-
 
183
	ControlSet = false;
124
}
184
}
125
 
185
 
126
bool render::startDocument()
186
bool SRender::startDocument()
127
{
187
{
128
	indent = 0;
188
	m.remove_all();		// delete styles and layers from map
129
 
189
 
130
	if (firstStyle)		// free if allocated
190
	if (firstStyle)		// free if allocated
131
	{
191
	{
132
	   Style = firstStyle;
192
	   Style = firstStyle;
133
 
193
 
134
	   while (Style)
194
	   while (Style)
135
	   {
195
	   {
-
 
196
	      STYLE *sakt = Style->next;
-
 
197
 
136
	      if (Style->rule)
198
	      if (Style->rule)
137
	      {
199
	      {
138
		 RULE *rule = Style->rule;
200
		 RULE *rule = Style->rule;
139
		 STYLE *sakt = Style->next;
-
 
140
 
201
 
141
		 while (rule)
202
		 while (rule)
142
		 {
203
		 {
143
		    RULE *rakt = rule->next;
204
		    RULE *rakt = rule->next;
144
		    LINESYMBOLIZER *LineSymbolizer = rule->LineSymbolizer;
205
		    LINESYMBOLIZER *LineSymbolizer = rule->LineSymbolizer;
145
		    POLYGONSYMBOLIZER *PolygonSymbolizer = rule->PolygonSymbolizer;
206
		    POLYGONSYMBOLIZER *PolygonSymbolizer = rule->PolygonSymbolizer;
146
		    TEXTSYMBOLIZER *TextSymbolizer = rule->TextSymbolizer;
207
		    TEXTSYMBOLIZER *TextSymbolizer = rule->TextSymbolizer;
147
		    POINTSYMBOLIZER *PointSymbolizer = rule->PointSymbolizer;
208
		    POINTSYMBOLIZER *PointSymbolizer = rule->PointSymbolizer;
148
		    POLYGONPATTERNSYMBOLIZER *PolygonPatternSymbolizer = rule->PolygonPatternSymbolizer;
209
		    POLYGONPATTERNSYMBOLIZER *PolygonPatternSymbolizer = rule->PolygonPatternSymbolizer;
149
		    SHIELDSYMBOLIZER *ShieldSymbolizer = rule->ShielSymbolizer;
210
		    SHIELDSYMBOLIZER *ShieldSymbolizer = rule->ShieldSymbolizer;
150
		    LINEPATTERNSYMBOLIZER *LinePatternSymbolizer = rule->LinePatternSymbolizer;
211
		    LINEPATTERNSYMBOLIZER *LinePatternSymbolizer = rule->LinePatternSymbolizer;
151
 
212
 
152
		    while (LineSymbolizer)
213
		    while (LineSymbolizer)
153
		    {
214
		    {
154
		       LINESYMBOLIZER *akt = LineSymbolizer->next;
215
		       LINESYMBOLIZER *akt = LineSymbolizer->next;
Line 207... Line 268...
207
	      Style = sakt;
268
	      Style = sakt;
208
	   }
269
	   }
209
	}
270
	}
210
 
271
 
211
	Style = firstStyle = lastStyle = 0;
272
	Style = firstStyle = lastStyle = 0;
-
 
273
 
-
 
274
	if (firstLayer)
-
 
275
	{
-
 
276
	   Lay = firstLayer;
-
 
277
 
-
 
278
	   while (Lay)
-
 
279
	   {
-
 
280
	   LAYER *akt;
-
 
281
 
-
 
282
	      akt = Lay->next;
-
 
283
	      delete Lay;
-
 
284
	      Lay = akt;
-
 
285
	   }
-
 
286
	}
-
 
287
 
-
 
288
	Lay = firstLayer = lastLayer = 0;
-
 
289
	Container = in_root;
212
	return true;
290
	return true;
213
}
291
}
214
 
292
 
215
/*
293
/*
216
 * This is called every time a new start element was parsed.
294
 * This is called every time a new start element was parsed.
217
 */
295
 */
218
bool render::startElement( const QString&, const QString&,
296
bool SRender::startElement( const QString&, const QString&,
219
                                    const QString& qName,
297
                                    const QString& qName,
220
                                    const QXmlAttributes& att)
298
                                    const QXmlAttributes& att)
221
{
299
{
222
int i = FIRST_CON;
300
int i = FIRST_CON;
223
int index;
301
int index;
-
 
302
QString hv0;
224
 
303
 
225
	indent++;
-
 
226
 
-
 
227
	while (i < LAST_CON)
304
	while (i <= LAST_CON)
228
	{
305
	{
229
	   if (qName.toLower() == getKey(i).toLower())
306
	   if (qName.toLower() == getKey(i).toLower())
230
	   {
307
	   {
-
 
308
	      Container = token[i].con;
-
 
309
 
231
	      switch (i)
310
	      switch (i)
232
	      {
311
	      {
233
		 case CON_MAP:
312
		 case CON_MAP:
-
 
313
		    Container = in_map;
-
 
314
 
-
 
315
		    if (ControlSet)	// Must be false here!
-
 
316
		    {
-
 
317
		       KMessageBox::error(0, i18n("Error parsing %1: There is another MAP! Only one map information is allowed!").arg(XmlPath));
-
 
318
		       return false;
-
 
319
		    }
-
 
320
 
234
		    if ((index = att.index(QString("bgcolor"))) != -1)
321
		    if ((index = att.index(QString("bgcolor"))) != -1)
235
		       MapPars.bgcolor = color_factory::from_string(att.value(index).toAscii().data());
322
		       MapPars.bgcolor = colorToUInt(att.value(index));
236
 
323
 
237
		    if ((index = att.index(QString("buffer_size"))) != -1)
324
		    if ((index = att.index(QString("buffer_size"))) != -1)
238
		       MapPars.buf_size = att.value(index).toInt();
325
		       MapPars.buf_size = att.value(index).toInt();
239
 
326
 
240
		    if ((index = att.index(QString("srs"))) != -1)
327
		    if ((index = att.index(QString("srs"))) != -1)
241
		       MapPars.srs = att.value(index);
328
		       MapPars.srs = att.value(index);
-
 
329
cout << "<Map bgcolor=" << MapPars.bgcolor << " buffer_size=" << MapPars.buf_size << " srs=" << MapPars.srs.toAscii().data() << ">" << endl;
242
		 break;
330
		 break;
243
 
331
 
244
		 case CON_STYLE:
332
		 case CON_STYLE:
-
 
333
		    Container = in_style;
-
 
334
 
245
		    if (!lastStyle)
335
		    if (!lastStyle)
246
		    {
336
		    {
247
		       Style = new STYLE;
337
		       Style = allocStyle();
248
		       fistStyle = lastStyle = Style;
338
		       firstStyle = lastStyle = Style;
249
		       memset (Style, 0, sizeof (STYLE));
-
 
250
		    }
339
		    }
251
		    else
340
		    else
252
		    {
341
		    {
253
		       Style = new STYLE;
342
		       Style = allocStyle();
254
		       memset (Style, 0, sizeof (STYLE));
-
 
255
		       lastStyle->next = Style;
343
		       lastStyle->next = Style;
256
		       lastStyle = Style;
344
		       lastStyle = Style;
257
		    }
345
		    }
258
 
346
 
259
		    if ((index = att.index(QString("name"))) != -1)
347
		    if ((index = att.index(QString("name"))) != -1)
260
		       Style->name = att.value(index);
348
		       Style->name = att.value(index);
261
		    else
349
		    else
262
		    {
350
		    {
263
		       KMessageBox::error(0, i18n("Error parsing %1: Open STYLE wihout a name!").arg(XmlPath));
351
		       KMessageBox::error(0, i18n("Error parsing %1: Open STYLE without a name!").arg(XmlPath));
264
		       return false;
352
		       return false;
265
		    }
353
		    }
-
 
354
cout << "   <Style name=" << Style->name.toAscii().data() << ">" << endl;
266
		 break;
355
		 break;
267
 
356
 
268
		 case CON_RULE:
357
		 case CON_RULE:
-
 
358
		    Container = in_rule;
-
 
359
 
269
		    if (!Style)
360
		    if (!Style)
270
		    {
361
		    {
271
		       KMessageBox::error(0, i18n("Error parsing %1: Open RULE outside of a STYLE!").arg(XmlPath));
362
		       KMessageBox::error(0, i18n("Error parsing %1: Open RULE outside of a STYLE!").arg(XmlPath));
272
		       return false;
363
		       return false;
273
		    }
364
		    }
274
 
365
 
275
		    Rule = getLastRule (Style->rule);
366
		    Rule = getLastRule (Style->rule);
276
 
367
 
277
		    if (!Rule)
368
		    if (!Rule)
278
		    {
369
		    {
279
		       Rule = new RULE;
370
		       Rule = allocRule();
280
		       memset (Rule, 0, sizeof(RULE));
-
 
281
		       Style->rule = Rule;
371
		       Style->rule = Rule;
282
		    }
372
		    }
283
		    else
373
		    else
284
		    {
374
		    {
285
		       Rule->next = new RULE;
375
		       Rule->next = allocRule();
286
		       Rule = Rule->next;
376
		       Rule = Rule->next;
287
		       memset (Rule, 0, sizeof(RULE));
-
 
288
		    }
377
		    }
-
 
378
cout << "      <Rule>" << endl;
-
 
379
		 break;
-
 
380
 
-
 
381
		 case CON_LAYER:
-
 
382
		    Container = in_layer;
-
 
383
 
-
 
384
		    if (!firstLayer)
-
 
385
		    {
-
 
386
		       Lay = allocLayer();
-
 
387
		       firstLayer = lastLayer = Lay;
-
 
388
		    }
-
 
389
		    else
-
 
390
		    {
-
 
391
		       Lay = allocLayer();
-
 
392
		       lastLayer->next = Lay;
-
 
393
		       lastLayer = Lay;
-
 
394
		    }
-
 
395
 
-
 
396
		    if ((index = att.index(QString("name"))) != -1)
-
 
397
		       Lay->name = att.value(index);
-
 
398
 
-
 
399
		    if ((index = att.index(QString("status"))) != -1)
-
 
400
		       Lay->status = getBool(att.value(index));
-
 
401
 
-
 
402
		    if ((index = att.index(QString("srs"))) != -1)
-
 
403
		       Lay->srs = att.value(index);
-
 
404
cout << "   <Layer name=" << Lay->name.toAscii().data() << " status=" << Lay->status << " srs=" << Lay->srs.toAscii().data() << ">" << endl;
-
 
405
		 break;
-
 
406
 
-
 
407
		 case CON_DATASOURCE:
-
 
408
		    Container = in_datasource;
289
		 break;
409
		 break;
290
 
410
 
291
		 case CON_POINTSYMBOLIZER:
411
		 case CON_POINTSYMBOLIZER:
-
 
412
		    Container = in_pointsymbolizer;
-
 
413
 
292
		    if (!Rule)
414
		    if (!Rule)
293
		    {
415
		    {
294
		       KMessageBox::error(0, i18n("Error parsing %1: Open POINTSYMBOLIZER outside of a RULE!").arg(XmlPath));
416
		       KMessageBox::error(0, i18n("Error parsing %1: Open POINTSYMBOLIZER outside of a RULE!").arg(XmlPath));
295
		       return false;
417
		       return false;
296
		    }
418
		    }
297
 
419
 
298
		    PointSymbolizer = getLastPointSymbolizer(Rule->PointSymbolizer);
420
		    PointSymbolizer = getLastPointSymbolizer(Rule->PointSymbolizer);
299
 
421
 
300
		    if (!PointSymbolizer)
422
		    if (!PointSymbolizer)
301
		    {
423
		    {
302
		       PointSymbolizer = new POINTSYMBOLIZER;
424
		       PointSymbolizer = allocPointSymbolizer();
303
		       memset (PointSymbolizer, 0, sizeof(POINTSYMBOLIZER));
-
 
304
		       Rule->PointSymbolizer = PointSymbolizer;
425
		       Rule->PointSymbolizer = PointSymbolizer;
305
		    }
426
		    }
306
		    else
427
		    else
307
		    {
428
		    {
308
		       PointSymbolizer->next = new POINTSYMBOLIZER;
429
		       PointSymbolizer->next = allocPointSymbolizer();
309
		       PointSymbolizer = PointSymbolizer->next;
430
		       PointSymbolizer = PointSymbolizer->next;
310
		       memset (PointSymbolizer, 0, sizeof(POINTSYMBOLIZER));
-
 
311
		    }
431
		    }
312
 
432
 
313
		    if ((index = att.index(QString("file"))) != -1)
433
		    if ((index = att.index(QString("file"))) != -1)
314
		       PointSymbolizer->file = att.value(index);
434
		       PointSymbolizer->file = att.value(index);
315
 
435
 
316
		    if ((index = att.index(QString("type"))) != -1)
436
		    if ((index = att.index(QString("type"))) != -1)
317
		    {
-
 
318
		       QString ty = att.value(index);
-
 
319
 
-
 
320
		       if (ty.toLower() == QString("png"))
-
 
321
			  PointSymbolizer->type = type_png;
-
 
322
		       else if (ty.toLower() == QString("gif"))
-
 
323
			  PointSymbolizer->type = type_gif;
-
 
324
		       else if (ty.toLower() == QString("jpg"))
-
 
325
			  PointSymbolizer->type = type_jpg;
-
 
326
		       else if (ty.toLower() == QString("xpm"))
-
 
327
			  PointSymbolizer->type = type_xpm;
-
 
328
		       else if (ty.toLower() == QString("bmp"))
-
 
329
			  PointSymbolizer->type = type_xmp;
-
 
330
		       else if (ty.toLower() == QString("tif") || ty.toLower() == QString("tiff"))
-
 
331
			  PointSymbolizer->type = type_tif;
437
		       PointSymbolizer->type = getType(att.value(index));
332
		    }
-
 
333
 
438
 
334
		    if ((index = add.index(QString("width"))) != -1)
439
		    if ((index = att.index(QString("width"))) != -1)
335
		       PointSymbolizer->width = att.value(index).toDouble();
440
		       PointSymbolizer->width = att.value(index).toDouble();
336
 
441
 
337
		    if ((index = add.index(QString("height"))) != -1)
442
		    if ((index = att.index(QString("height"))) != -1)
338
		       PointSymbolizer->height = att.value(index).toDouble();
443
		       PointSymbolizer->height = att.value(index).toDouble();
339
 
444
 
340
		    if ((index = add.index(QString("allow_overlap"))) != -1)
445
		    if ((index = att.index(QString("allow_overlap"))) != -1)
341
		    {
446
		    {
342
		       if (att.value(index).toLower() == QString("true"))
447
		       if (att.value(index).toLower() == QString("true"))
343
			  PointSymbolizer->allow_overlap = true;
448
			  PointSymbolizer->allow_overlap = true;
344
		       else
449
		       else
345
			  PointSymbolizer->allow_overlap = false;
450
			  PointSymbolizer->allow_overlap = false;
346
		    }
451
		    }
-
 
452
cout << "         <Pointsymbolizer file=" << PointSymbolizer->file.toAscii().data() << " ... >" << endl;
347
		 break;
453
		 break;
348
 
454
 
349
		 break;
455
		 break;
350
 
456
 
351
		 case CON_LINESYMBOLIZER:
457
		 case CON_LINESYMBOLIZER:
-
 
458
		    Container = in_linesymbolizer;
-
 
459
 
352
		    if (!Rule)
460
		    if (!Rule)
353
		    {
461
		    {
354
		       KMessageBox::error(0, i18n("Error parsing %1: Open LINESYMBOLIZER outside of a RULE!").arg(XmlPath));
462
		       KMessageBox::error(0, i18n("Error parsing %1: Open LINESYMBOLIZER outside of a RULE!").arg(XmlPath));
355
		       return false;
463
		       return false;
356
		    }
464
		    }
357
 
465
 
358
		    LineSymbolizer = getLastLineSymbolizer(Rule->LineSymbolizer);
466
		    LineSymbolizer = getLastLineSymbolizer(Rule->LineSymbolizer);
359
 
467
 
360
		    if (!LineSymbolizer)
468
		    if (!LineSymbolizer)
361
		    {
469
		    {
362
		       LineSymbolizer = new LINESYMBOLIZER;
470
		       LineSymbolizer = allocLineSymbolizer();
363
		       memset (LineSymbolizer, 0, sizeof(LINESYMBOLIZER));
-
 
364
		       Rule->LineSymbolizer = LineSymbolizer;
471
		       Rule->LineSymbolizer = LineSymbolizer;
365
		    }
472
		    }
366
		    else
473
		    else
367
		    {
474
		    {
368
		       LineSymbolizer->next = new LINESYMBOLIZER;
475
		       LineSymbolizer->next = allocLineSymbolizer();
369
		       LineSymbolizer = LineSymbolizer->next;
476
		       LineSymbolizer = LineSymbolizer->next;
370
		       memset (LineSymbolizer, 0, sizeof(LINESYMBOLIZER));
-
 
371
		    }
477
		    }
-
 
478
cout << "         <Linesymbolizer>" << endl;
372
		 break;
479
		 break;
373
 
480
 
374
		 case CON_POLYGONSYMBOLIZER:
481
		 case CON_POLYGONSYMBOLIZER:
-
 
482
		    Container = in_polygonsymbolizer;
-
 
483
 
375
		    if (!Rule)
484
		    if (!Rule)
376
		    {
485
		    {
377
		       KMessageBox::error(0, i18n("Error parsing %1: Open POLYGONSYMBOLIZER outside of a RULE!").arg(XmlPath));
486
		       KMessageBox::error(0, i18n("Error parsing %1: Open POLYGONSYMBOLIZER outside of a RULE!").arg(XmlPath));
378
		       return false;
487
		       return false;
379
		    }
488
		    }
380
 
489
 
381
		    PolygonSymbolizer = getLastPolygonSymbolizer(Rule->PolygonSymbolizer);
490
		    PolygonSymbolizer = getLastPolygonSymbolizer(Rule->PolygonSymbolizer);
382
 
491
 
383
		    if (!PolygonSymbolizer)
492
		    if (!PolygonSymbolizer)
384
		    {
493
		    {
385
		       PolygonSymbolizer = new POLYGONSYMBOLIZER;
494
		       PolygonSymbolizer = allocPolygonSymbolizer();
386
		       memset (PolygonSymbolizer, 0, sizeof(POLYGONSYMBOLIZER));
-
 
387
		       Rule->PolygonSymbolizer = PolygonSymbolizer;
495
		       Rule->PolygonSymbolizer = PolygonSymbolizer;
388
		    }
496
		    }
389
		    else
497
		    else
390
		    {
498
		    {
391
		       PolygonSymbolizer->next = new POLYGONSYMBOLIZER;
499
		       PolygonSymbolizer->next = allocPolygonSymbolizer();
392
		       PolygonSymbolizer = PolygonSymbolizer->next;
500
		       PolygonSymbolizer = PolygonSymbolizer->next;
393
		       memset (PolygonSymbolizer, 0, sizeof(POLYGONSYMBOLIZER));
-
 
394
		    }
501
		    }
-
 
502
cout << "         <Polygonsymbolizer>" << endl;
395
		 break;
503
		 break;
396
 
504
 
397
		 case CON_TEXTSYMBOLIZER:
505
		 case CON_TEXTSYMBOLIZER:
-
 
506
		    Container = in_textsymbolizer;
-
 
507
 
398
		    if (!Rule)
508
		    if (!Rule)
399
		    {
509
		    {
400
		       KMessageBox::error(0, i18n("Error parsing %1: Open TEXTSYMBOLIZER outside of a RULE!").arg(XmlPath));
510
		       KMessageBox::error(0, i18n("Error parsing %1: Open TEXTSYMBOLIZER outside of a RULE!").arg(XmlPath));
401
		       return false;
511
		       return false;
402
		    }
512
		    }
403
 
513
 
404
		    TextSymbolizer = getLastTextSymbolizer(Rule->TextSymbolizer);
514
		    TextSymbolizer = getLastTextSymbolizer(Rule->TextSymbolizer);
405
 
515
 
406
		    if (!TextSymbolizer)
516
		    if (!TextSymbolizer)
407
		    {
517
		    {
408
		       TextSymbolizer = new TEXTSYMBOLIZER;
518
		       TextSymbolizer = allocTextSymbolizer();
409
		       memset (TextSymbolizer, 0, sizeof(TEXTSYMBOLIZER));
-
 
410
		       Rule->TextSymbolizer = TextSymbolizer;
519
		       Rule->TextSymbolizer = TextSymbolizer;
411
		    }
520
		    }
412
		    else
521
		    else
413
		    {
522
		    {
414
		       TextSymbolizer->next = new TEXTSYMBOLIZER;
523
		       TextSymbolizer->next = allocTextSymbolizer();
415
		       TextSymbolizer = TextSymbolizer->next;
524
		       TextSymbolizer = TextSymbolizer->next;
416
		       memset (TextSymbolizer, 0, sizeof(TEXTSYMBOLIZER));
-
 
417
		    }
525
		    }
418
 
526
 
419
		    if ((index = att.index(QString("name"))) != -1)
527
		    if ((index = att.index(QString("name"))) != -1)
420
		       TextSymbolizer->name = att.value(index);
528
		       TextSymbolizer->name = att.value(index);
421
 
529
 
Line 424... Line 532...
424
 
532
 
425
		    if ((index = att.index(QString("size"))) != -1)
533
		    if ((index = att.index(QString("size"))) != -1)
426
		       TextSymbolizer->size = att.value(index).toDouble();
534
		       TextSymbolizer->size = att.value(index).toDouble();
427
 
535
 
428
		    if ((index = att.index(QString("fill"))) != -1)
536
		    if ((index = att.index(QString("fill"))) != -1)
429
		       TextSymbolizer->fill = 
537
		       TextSymbolizer->fill = colorToUInt(att.value(index));
-
 
538
 
-
 
539
		    if ((index = att.index(QString("halo_radius"))) != -1)
-
 
540
		       TextSymbolizer->halo_radius = att.value(index).toDouble();
-
 
541
 
-
 
542
		    if ((index = att.index(QString("wrap_width"))) != -1)
-
 
543
		       TextSymbolizer->wrap_width = att.value(index).toDouble();
-
 
544
 
-
 
545
		    if ((index = att.index(QString("dy"))) != -1)
-
 
546
		       TextSymbolizer->dy = att.value(index).toDouble();
-
 
547
 
-
 
548
		    if ((index = att.index(QString("max_distance"))) != -1)
-
 
549
		       TextSymbolizer->maxdistance = att.value(index).toDouble();
-
 
550
 
-
 
551
		    if ((index = att.index(QString("min_distance"))) != -1)
-
 
552
		       TextSymbolizer->mindistance = att.value(index).toDouble();
-
 
553
cout << "         <Textsymbolizer name=" << TextSymbolizer->name.toAscii().data() << " ... >" << endl;
-
 
554
		 break;
-
 
555
 
-
 
556
		 case CON_POLYGONPATTERNSYMBOLIZER:
-
 
557
		    Container = in_polygonpatternsymbolizer;
-
 
558
 
-
 
559
		    if (!Rule)
-
 
560
		    {
-
 
561
		       KMessageBox::error(0, i18n("Error parsing %1: Open POLYGONPATTERNSYMBOLIZER outside of a RULE!").arg(XmlPath));
-
 
562
		       return false;
-
 
563
		    }
-
 
564
 
-
 
565
		    PolygonPatternSymbolizer = getLastPolygonPatternSymbolizer(Rule->PolygonPatternSymbolizer);
-
 
566
 
-
 
567
		    if (!PolygonPatternSymbolizer)
-
 
568
		    {
-
 
569
		       PolygonPatternSymbolizer = allocPolygonPatternSymbolizer();
-
 
570
		       Rule->PolygonPatternSymbolizer = PolygonPatternSymbolizer;
-
 
571
		    }
-
 
572
		    else
-
 
573
		    {
-
 
574
		       PolygonPatternSymbolizer->next = allocPolygonPatternSymbolizer();
-
 
575
		       PolygonPatternSymbolizer = PolygonPatternSymbolizer->next;
-
 
576
		    }
-
 
577
 
-
 
578
		    if ((index = att.index(QString("file"))) != -1)
-
 
579
		       PolygonPatternSymbolizer->file = att.value(index);
-
 
580
 
-
 
581
		    if ((index = att.index(QString("type"))) != -1)
-
 
582
		       PolygonPatternSymbolizer->type = getType(att.value(index));
-
 
583
 
-
 
584
		    if ((index = att.index(QString("width"))) != -1)
-
 
585
		       PolygonPatternSymbolizer->width = att.value(index).toDouble();
-
 
586
 
-
 
587
		    if ((index = att.index(QString("height"))) != -1)
-
 
588
		       PolygonPatternSymbolizer->height = att.value(index).toDouble();
-
 
589
 
-
 
590
		    if ((index = att.index(QString("allow_overlap"))) != -1)
-
 
591
		       PolygonPatternSymbolizer->allow_overlap = getBool(att.value(index));
-
 
592
cout << "         <Polygonpatternsymbolizer file=" << PolygonPatternSymbolizer->file.toAscii().data() << " ... >" << endl;
430
		 break;
593
		 break;
-
 
594
 
-
 
595
		 case CON_SHIELDSYMBOLIZER:
-
 
596
		    Container = in_shieldsymbolizer;
-
 
597
 
-
 
598
		    if (!Rule)
-
 
599
		    {
-
 
600
		       KMessageBox::error(0, i18n("Error parsing %1: Open SHIELDSYMBOLIZER outside of a RULE!").arg(XmlPath));
-
 
601
		       return false;
-
 
602
		    }
-
 
603
 
-
 
604
		    ShieldSymbolizer = getLastShieldSymbolizer(Rule->ShieldSymbolizer);
-
 
605
 
-
 
606
		    if (!ShieldSymbolizer)
-
 
607
		    {
-
 
608
		       ShieldSymbolizer = allocShieldSymbolizer();
-
 
609
		       Rule->ShieldSymbolizer = ShieldSymbolizer;
-
 
610
		    }
-
 
611
		    else
-
 
612
		    {
-
 
613
		       ShieldSymbolizer->next = allocShieldSymbolizer();
-
 
614
		       ShieldSymbolizer = ShieldSymbolizer->next;
-
 
615
		    }
-
 
616
 
-
 
617
		    if ((index = att.index(QString("name"))) != -1)
-
 
618
		       ShieldSymbolizer->name = att.value(index);
-
 
619
 
-
 
620
		    if ((index = att.index(QString("face_name"))) != -1)
-
 
621
		       ShieldSymbolizer->face_name = att.value(index);
-
 
622
 
-
 
623
		    if ((index = att.index(QString("fill"))) != -1)
-
 
624
		       ShieldSymbolizer->fill = colorToUInt(att.value(index));
-
 
625
 
-
 
626
		    if ((index = att.index(QString("placement"))) != -1)
-
 
627
		       ShieldSymbolizer->placement = att.value(index);
-
 
628
 
-
 
629
		    if ((index = att.index(QString("file"))) != -1)
-
 
630
		       ShieldSymbolizer->file = att.value(index);
-
 
631
 
-
 
632
		    if ((index = att.index(QString("type"))) != -1)
-
 
633
		       ShieldSymbolizer->type = getType(att.value(index));
-
 
634
 
-
 
635
		    if ((index = att.index(QString("size"))) != -1)
-
 
636
		       ShieldSymbolizer->size = att.value(index).toDouble();
-
 
637
 
-
 
638
		    if ((index = att.index(QString("width"))) != -1)
-
 
639
		       ShieldSymbolizer->width = att.value(index).toDouble();
-
 
640
 
-
 
641
		    if ((index = att.index(QString("height"))) != -1)
-
 
642
		       ShieldSymbolizer->height = att.value(index).toDouble();
-
 
643
 
-
 
644
		    if ((index = att.index(QString("min_distance"))) != -1)
-
 
645
		       ShieldSymbolizer->mindistance = att.value(index).toDouble();
-
 
646
 
-
 
647
		    if ((index = att.index(QString("max_distance"))) != -1)
-
 
648
		       ShieldSymbolizer->maxdistance = att.value(index).toDouble();
-
 
649
cout << "         <Shieldsymbolizer name=" << ShieldSymbolizer->name.toAscii().data() << " ... >" << endl;
-
 
650
		 break;
-
 
651
 
-
 
652
		 case CON_LINEPATTERNSYMBOLIZER:
-
 
653
		    Container = in_linepatternsymbolizer;
-
 
654
 
-
 
655
		    if (!Rule)
-
 
656
		    {
-
 
657
		       KMessageBox::error(0, i18n("Error parsing %1: Open LINEPATTERNSYMBOLIZER outside of a RULE!").arg(XmlPath));
-
 
658
		       return false;
-
 
659
		    }
-
 
660
 
-
 
661
		    LinePatternSymbolizer = getLastLinePatternSymbolizer(Rule->LinePatternSymbolizer);
-
 
662
 
-
 
663
		    if (!LinePatternSymbolizer)
-
 
664
		    {
-
 
665
		       LinePatternSymbolizer = allocLinePatternSymbolizer();
-
 
666
		       Rule->LinePatternSymbolizer = LinePatternSymbolizer;
-
 
667
		    }
-
 
668
		    else
-
 
669
		    {
-
 
670
		       LinePatternSymbolizer->next = allocLinePatternSymbolizer();
-
 
671
		       LinePatternSymbolizer = LinePatternSymbolizer->next;
-
 
672
		    }
-
 
673
 
-
 
674
		    if ((index = att.index(QString("file"))) != -1)
-
 
675
		       LinePatternSymbolizer->file = att.value(index);
-
 
676
 
-
 
677
		    if ((index = att.index(QString("type"))) != -1)
-
 
678
		       LinePatternSymbolizer->type = getType(att.value(index));
-
 
679
 
-
 
680
		    if ((index = att.index(QString("width"))) != -1)
-
 
681
		       LinePatternSymbolizer->width = att.value(index).toDouble();
-
 
682
 
-
 
683
		    if ((index = att.index(QString("height"))) != -1)
-
 
684
		       LinePatternSymbolizer->height = att.value(index).toDouble();
-
 
685
cout << "         <Linepatternsymbolizer file=" << LinePatternSymbolizer->file.toAscii().data() << " ... >" << endl;
-
 
686
		 break;
-
 
687
	      }
-
 
688
	   }
-
 
689
 
-
 
690
	   i++;
431
	}
691
	}
-
 
692
 
-
 
693
	i = FIRST_FLD;
-
 
694
 
-
 
695
	while (i <= LAST_FLD)
-
 
696
	{
-
 
697
	   if (qName.toLower() == getKey(i).toLower())
-
 
698
	   {
-
 
699
	      Field = i;
-
 
700
 
-
 
701
	      switch(Container)
-
 
702
	      {
-
 
703
		 case in_linesymbolizer:
-
 
704
		    Names = empty;
-
 
705
 
-
 
706
		    if (i == FLD_CSSPARAMETER)
-
 
707
		    {
-
 
708
		       if ((index = att.index(QString("name"))) != -1)
-
 
709
		       {
-
 
710
			  if (att.value(index).toLower() == QString("stroke"))
-
 
711
			     Names = stroke_stroke;
-
 
712
			  else if (att.value(index).toLower() == QString("stroke-width"))
-
 
713
			     Names = stroke_width;
-
 
714
			  else if (att.value(index).toLower() == QString("stroke-opacity"))
-
 
715
			     Names = stroke_opacity;
-
 
716
			  else if (att.value(index).toLower() == QString("stroke-linejoin"))
-
 
717
			     Names = stroke_linejoin;
-
 
718
			  else if (att.value(index).toLower() == QString("stroke-linecap"))
-
 
719
			     Names = stroke_linecap;
-
 
720
			  else if (att.value(index).toLower() == QString("stroke-dasharray"))
-
 
721
			     Names = stroke_dasharray;
-
 
722
		       }
-
 
723
		       else
-
 
724
		       {
-
 
725
			  KMessageBox::error(0, i18n("Error parsing %1: Required attribute NAME is missing in CSSPARAMETER inside LINESYMBOLIZER!").arg(XmlPath));
-
 
726
			  return false;
-
 
727
		       }
-
 
728
		    }
-
 
729
		 break;
-
 
730
 
-
 
731
		 case in_polygonsymbolizer:
-
 
732
		    Names = empty;
-
 
733
 
-
 
734
		    if (i == FLD_CSSPARAMETER)
-
 
735
		    {
-
 
736
		       if ((index = att.index(QString("name"))) != -1)
-
 
737
		       {
-
 
738
			  if (att.value(index).toLower() == QString("fill"))
-
 
739
			     Names = fill;
-
 
740
			  else if (att.value(index).toLower() == QString("fill-opacity"))
-
 
741
			     Names = fill_opacity;
-
 
742
		       }
-
 
743
		       else
-
 
744
		       {
-
 
745
			  KMessageBox::error(0, i18n("Error parsing %1: Required attribute NAME is missing in CSSPARAMETER inside POLYGONSYMBOLIZER!").arg(XmlPath));
-
 
746
			  return false;
-
 
747
		       }
-
 
748
		    }
-
 
749
		 break;
-
 
750
 
-
 
751
		 case in_datasource:
-
 
752
		    Names = empty;
-
 
753
 
-
 
754
		    if (i == FLD_PARAMETER)
-
 
755
		    {
-
 
756
		       if ((index = att.index(QString("name"))) != -1)
-
 
757
		       {
-
 
758
			  if (att.value(index).toLower() == QString("type"))
-
 
759
			     Names = type;
-
 
760
			  else if (att.value(index).toLower() == QString("file"))
-
 
761
			     Names = file;
-
 
762
			  else if (att.value(index).toLower() == QString("host"))
-
 
763
			     Names = host;
-
 
764
			  else if (att.value(index).toLower() == QString("user"))
-
 
765
			     Names = user;
-
 
766
			  else if (att.value(index).toLower() == QString("dbname"))
-
 
767
			     Names = dbname;
-
 
768
			  else if (att.value(index).toLower() == QString("table"))
-
 
769
			     Names = table;
-
 
770
			  else if (att.value(index).toLower() == QString("estimate_extent"))
-
 
771
			     Names = estimate_extent;
-
 
772
			  else if (att.value(index).toLower() == QString("extent"))
-
 
773
			     Names = extent;
-
 
774
		       }
-
 
775
		       else
-
 
776
		       {
-
 
777
			  KMessageBox::error(0, i18n("Error parsing %1: Required attribute NAME is missing in PARAMETER inside DATASOURCE!").arg(XmlPath));
-
 
778
			  return false;
-
 
779
		       }
-
 
780
		    }
-
 
781
		 break;
-
 
782
 
-
 
783
		 case in_root:
-
 
784
		    Names = empty;
-
 
785
		 break;
-
 
786
		 case in_map:
-
 
787
		    Names = empty;
-
 
788
		 break;
-
 
789
		 case in_style:
-
 
790
		    Names = empty;
-
 
791
		 break;
-
 
792
		 case in_rule:
-
 
793
		    Names = empty;
-
 
794
		 break;
-
 
795
		 case in_pointsymbolizer:
-
 
796
		    Names = empty;
-
 
797
		 break;
-
 
798
		 case in_textsymbolizer:
-
 
799
		    Names = empty;
-
 
800
		 break;
-
 
801
		 case in_polygonpatternsymbolizer:
-
 
802
		    Names = empty;
-
 
803
		 break;
-
 
804
		 case in_layer:
-
 
805
		    Names = empty;
-
 
806
		 break;
-
 
807
		 case in_symbolizer:
-
 
808
		    Names = empty;
-
 
809
		 break;
-
 
810
		 case in_shieldsymbolizer:
-
 
811
		    Names = empty;
-
 
812
		 break;
-
 
813
		 case in_linepatternsymbolizer:
-
 
814
		    Names = empty;
-
 
815
		 break;
-
 
816
	      }
-
 
817
	   }
-
 
818
 
-
 
819
	   i++;
-
 
820
	}
-
 
821
 
-
 
822
	return true;
432
}
823
}
433
 
824
 
434
/*
825
/*
435
 * This is called every time an element is closed.
826
 * This is called every time an element is closed.
436
 */
827
 */
437
bool render::endElement( const QString&, const QString&, const QString& qName)
828
bool SRender::endElement( const QString&, const QString&, const QString& qName)
438
{
829
{
-
 
830
	if (qName.toLower() == QString("datasource"))
-
 
831
	   Container = in_layer;
-
 
832
	else if (qName.toLower() == QString("layer"))
-
 
833
	{
-
 
834
	   parameters p;
-
 
835
	   Container = in_map;
-
 
836
 
-
 
837
	   if (Lay->Datasource.type.toLower() == QString("shape"))
-
 
838
	   {
-
 
839
	      p["type"] = "shape";
-
 
840
	      p["file"] = Lay->Datasource.file.toAscii().constData();
-
 
841
	   }
-
 
842
	   else if (Lay->Datasource.type.toLower() == QString("postgis"))
-
 
843
	   {
-
 
844
	      p["type"] = "postgis";
-
 
845
	      p["host"] = Lay->Datasource.host.toAscii().constData();
-
 
846
	      p["user"] = Lay->Datasource.user.toAscii().constData();
-
 
847
	      p["dbname"] = Lay->Datasource.dbname.toAscii().constData();
-
 
848
	      p["table"] = Lay->Datasource.table.toAscii().constData();
-
 
849
	      p["estimate_extent"] = (Lay->Datasource.estimate_extent) ? "true" : "false";
-
 
850
	      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();
-
 
851
	   }
-
 
852
	   else
-
 
853
	   {
-
 
854
	      cerr << "Warning: Layer with no source! Ingnoring!" << endl;
-
 
855
	      return true;
-
 
856
	   }
-
 
857
 
-
 
858
	   Layer lyr(Lay->name.toAscii().data());
-
 
859
	   lyr.set_datasource(datasource_cache::instance()->create(p));
-
 
860
	   lyr.setActive(Lay->status);
-
 
861
 
-
 
862
	   if (!Lay->srs.isEmpty())
-
 
863
	      lyr.set_srs(Lay->srs.toAscii().constData());
-
 
864
 
-
 
865
	   // Add the styles
-
 
866
	   for (int i = 0; i < Lay->Styles.size(); i++)
-
 
867
	      lyr.add_style(Lay->Styles.at(i).toAscii().constData());
-
 
868
 
-
 
869
	   m.addLayer(lyr);
-
 
870
	}
-
 
871
	else if (qName.toLower() == QString("map"))
-
 
872
	{
-
 
873
	color col;
-
 
874
 
-
 
875
	   Container = in_root;
-
 
876
	   col.set_bgr(MapPars.bgcolor);
-
 
877
	   m.set_background(col);
-
 
878
	   m.set_buffer_size(MapPars.buf_size);
-
 
879
	   ControlSet = true;
-
 
880
	}
-
 
881
	else if (qName.toLower() == QString("pointsymbol") ||
-
 
882
		 qName.toLower() == QString("linesymbol") ||
-
 
883
		 qName.toLower() == QString("polygonsymbol") ||
-
 
884
		 qName.toLower() == QString("textsymbol") ||
-
 
885
		 qName.toLower() == QString("polygonpatternsymbol") ||
-
 
886
		 qName.toLower() == QString("shieldsymbol") ||
-
 
887
		 qName.toLower() == QString("linepatternsymbol") ||
-
 
888
		 qName.toLower() == QString("filter") ||
-
 
889
		 qName.toLower() == QString("maxscaledenominator") ||
-
 
890
		 qName.toLower() == QString("minscaledenominator"))
-
 
891
	   Container = in_rule;
-
 
892
	else if (qName.toLower() == QString("rule"))
-
 
893
	   Container = in_style;
-
 
894
	else if (qName.toLower() == QString("style"))
-
 
895
	{
-
 
896
	   Container = in_map;
-
 
897
	   feature_type_style style;
-
 
898
 
-
 
899
	   if (Style->rule)
-
 
900
	   {
-
 
901
	      rule_type rule;
-
 
902
	      Rule = Style->rule;
-
 
903
 
-
 
904
	      while (Rule)
-
 
905
	      {
-
 
906
		 if (Rule->minscale >= 0.0)
-
 
907
		    rule.set_min_scale(Rule->minscale);
-
 
908
 
-
 
909
		 if (Rule->maxscale >= 0.0)
-
 
910
		    rule.set_max_scale(Rule->maxscale);
-
 
911
 
-
 
912
		 if (!Rule->filter.isEmpty())
-
 
913
		    rule.set_filter(create_filter(Rule->filter.toAscii().data()));
-
 
914
 
-
 
915
		 LineSymbolizer = Rule->LineSymbolizer;
-
 
916
 
-
 
917
		 while (LineSymbolizer)
-
 
918
		 {
-
 
919
		    stroke st;
-
 
920
		    color col;
-
 
921
		    col.set_bgr(LineSymbolizer->stroke);
-
 
922
 
-
 
923
		    st.set_color (col);
-
 
924
		    st.set_width (LineSymbolizer->stroke_width);
-
 
925
 
-
 
926
		    if (!LineSymbolizer->stroke_linejoin.isEmpty())
-
 
927
		    {
-
 
928
		       if (LineSymbolizer->stroke_linejoin.toLower() == QString("miter"))
-
 
929
			   st.set_line_join (mapnik::MITER_JOIN);
-
 
930
		       else if (LineSymbolizer->stroke_linejoin.toLower() == QString("miter_revert") ||
-
 
931
			        LineSymbolizer->stroke_linejoin.toLower() == QString("miter-revert"))
-
 
932
			   st.set_line_join (mapnik::MITER_REVERT_JOIN);
-
 
933
		       else if (LineSymbolizer->stroke_linejoin.toLower() == QString("round"))
-
 
934
			   st.set_line_join (mapnik::ROUND_JOIN);
-
 
935
		       else if (LineSymbolizer->stroke_linejoin.toLower() == QString("bevel"))
-
 
936
			   st.set_line_join (mapnik::BEVEL_JOIN);
-
 
937
		       else
-
 
938
		       {
-
 
939
			   cerr << "Error parsing " << XmlPath.toAscii().data() << ": Unknown >>line_join<< \"" << LineSymbolizer->stroke_linejoin.toAscii().data() << "\" --> ignoring!" << endl;
-
 
940
			   LineSymbolizer = LineSymbolizer->next;
-
 
941
			   continue;
-
 
942
		       }
-
 
943
		    }
-
 
944
 
-
 
945
		    if (!LineSymbolizer->stroke_linecap.isEmpty())
-
 
946
		    {
-
 
947
		       if (LineSymbolizer->stroke_linecap.toLower() == QString("butt"))
-
 
948
			  st.set_line_cap (mapnik::BUTT_CAP);
-
 
949
		       else if (LineSymbolizer->stroke_linecap.toLower() == QString("square"))
-
 
950
			  st.set_line_cap (mapnik::SQUARE_CAP);
-
 
951
		       else if (LineSymbolizer->stroke_linecap.toLower() == QString("round"))
-
 
952
			  st.set_line_cap (mapnik::ROUND_CAP);
-
 
953
		       else
-
 
954
		       {
-
 
955
			   cerr << "Error parsing " << XmlPath.toAscii().data() << ": Unknown >>line_cap<< \"" << LineSymbolizer->stroke_linecap.toAscii().data() << "\" --> ignoring!" << endl;
-
 
956
			   LineSymbolizer = LineSymbolizer->next;
-
 
957
			   continue;
-
 
958
		       }
-
 
959
		    }
-
 
960
 
-
 
961
		    st.add_dash(LineSymbolizer->stroke_dasharray[0], LineSymbolizer->stroke_dasharray[1]);
-
 
962
		    st.set_opacity(LineSymbolizer->stroke_opacity);
-
 
963
		    rule.append(line_symbolizer(st));
-
 
964
		    LineSymbolizer = LineSymbolizer->next;
-
 
965
		 }
-
 
966
 
-
 
967
		 PointSymbolizer = Rule->PointSymbolizer;
-
 
968
 
-
 
969
		 while (PointSymbolizer)
-
 
970
		 {
-
 
971
		    if (PointSymbolizer->file.length() == 0 || PointSymbolizer->width == 0 || PointSymbolizer->height == 0)
-
 
972
		    {
-
 
973
		       cerr << "Warning parsing " << XmlPath.toAscii().data() << ": Ignoring empty POINTSYMBOLIZER!" << endl;
-
 
974
		       break;
-
 
975
		    }
-
 
976
 
-
 
977
		    point_symbolizer ps(PointSymbolizer->file.toAscii().data(), getTypeText(PointSymbolizer->type), PointSymbolizer->width, PointSymbolizer->height);
-
 
978
		    ps.set_allow_overlap (PointSymbolizer->allow_overlap);
-
 
979
		    rule.append(ps);
-
 
980
		    PointSymbolizer = PointSymbolizer->next;
-
 
981
		 }
-
 
982
 
-
 
983
		 PolygonSymbolizer = Rule->PolygonSymbolizer;
-
 
984
 
-
 
985
		 while (PolygonSymbolizer)
-
 
986
		 {
-
 
987
		    color col;
-
 
988
		    col.set_bgr(PolygonSymbolizer->fill);
-
 
989
 
-
 
990
		    polygon_symbolizer ps(col);
-
 
991
		    ps.set_opacity(PolygonSymbolizer->fill_opacity);
-
 
992
		    rule.append(ps);
-
 
993
		    PolygonSymbolizer = PolygonSymbolizer->next;
-
 
994
		 }
-
 
995
 
-
 
996
		 TextSymbolizer = Rule->TextSymbolizer;
-
 
997
 
-
 
998
		 while (TextSymbolizer)
-
 
999
		 {
-
 
1000
		    color col;
-
 
1001
		    col.set_bgr(TextSymbolizer->fill);
-
 
1002
 
-
 
1003
		    text_symbolizer ts(TextSymbolizer->name.toAscii().data(), TextSymbolizer->face_name.toAscii().data(), TextSymbolizer->size, col);
-
 
1004
		    ts.set_halo_radius((unsigned int)TextSymbolizer->halo_radius);
-
 
1005
		    ts.set_wrap_width((unsigned int)TextSymbolizer->wrap_width);
-
 
1006
		    ts.set_max_char_angle_delta(TextSymbolizer->dy);
-
 
1007
		    ts.set_displacement(TextSymbolizer->mindistance, TextSymbolizer->maxdistance);
-
 
1008
		    rule.append(ts);
-
 
1009
		    TextSymbolizer = TextSymbolizer->next;
-
 
1010
		 }
-
 
1011
 
-
 
1012
		 PolygonPatternSymbolizer = Rule->PolygonPatternSymbolizer;
-
 
1013
 
-
 
1014
		 while (PolygonPatternSymbolizer)
-
 
1015
		 {
-
 
1016
		    // FIXME: The file name must be variable and KDE like!!
-
 
1017
		    rule.append(polygon_pattern_symbolizer(PolygonPatternSymbolizer->file.toAscii().data(),
-
 
1018
							getTypeText(PolygonPatternSymbolizer->type),
-
 
1019
							PolygonPatternSymbolizer->width,
-
 
1020
							PolygonPatternSymbolizer->height));
-
 
1021
		    PolygonPatternSymbolizer = PolygonPatternSymbolizer->next;
-
 
1022
		 }
-
 
1023
 
-
 
1024
		 ShieldSymbolizer = Rule->ShieldSymbolizer;
-
 
1025
 
-
 
1026
		 while (ShieldSymbolizer)
-
 
1027
		 {
-
 
1028
		    color col;
-
 
1029
		    col.set_bgr(ShieldSymbolizer->fill);
-
 
1030
		    // FIXME: The file name must be variable and KDE like!!
-
 
1031
		    shield_symbolizer ss(ShieldSymbolizer->name.toAscii().data(),
-
 
1032
					ShieldSymbolizer->face_name.toAscii().data(),
-
 
1033
					ShieldSymbolizer->size, col,
-
 
1034
					ShieldSymbolizer->file.toAscii().data(),
-
 
1035
					getTypeText(ShieldSymbolizer->type),
-
 
1036
					ShieldSymbolizer->width, ShieldSymbolizer->height);
-
 
1037
		    ss.set_label_placement((ShieldSymbolizer->placement.toLower() == QString("point")) ? mapnik::POINT_PLACEMENT : mapnik::LINE_PLACEMENT);
-
 
1038
		    ss.set_displacement(ShieldSymbolizer->mindistance, ShieldSymbolizer->maxdistance);
-
 
1039
		    rule.append(ss);
-
 
1040
		    ShieldSymbolizer = ShieldSymbolizer->next;
-
 
1041
		 }
-
 
1042
 
-
 
1043
		 LinePatternSymbolizer = Rule->LinePatternSymbolizer;
-
 
1044
 
-
 
1045
		 while (LinePatternSymbolizer)
-
 
1046
		 {
-
 
1047
		    // FIXME: The file name must be variable and KDE like!!
-
 
1048
		    rule.append(line_pattern_symbolizer(LinePatternSymbolizer->file.toAscii().data(),
-
 
1049
							getTypeText(LinePatternSymbolizer->type),
-
 
1050
							LinePatternSymbolizer->width,
-
 
1051
							LinePatternSymbolizer->height));
-
 
1052
		    LinePatternSymbolizer = LinePatternSymbolizer->next;
-
 
1053
		 }
-
 
1054
 
-
 
1055
		 style.add_rule(rule);
-
 
1056
		 Rule = Rule->next;
-
 
1057
	      }
-
 
1058
	   }
-
 
1059
 
-
 
1060
	   // Add style to map
-
 
1061
	   m.insert_style(Style->name.toAscii().data(), style);
-
 
1062
	}
-
 
1063
 
-
 
1064
	return true;
439
}
1065
}
440
 
1066
 
441
/*
1067
/*
442
 * The reader calls this function when it has parsed a chunk of character data
1068
 * The reader calls this function when it has parsed a chunk of character data
443
 * - either normal character data or character data inside a CDATA section.
1069
 * - either normal character data or character data inside a CDATA section.
444
 */
1070
 */
445
bool render::characters (const QString& ch)
1071
bool SRender::characters (const QString& ch)
446
{
1072
{
-
 
1073
	if (ch.length() == 0 || ch.at(0) == QChar('\n'))
-
 
1074
	   return true;
-
 
1075
 
-
 
1076
	if (Container == in_rule && Rule)
-
 
1077
	{
-
 
1078
	   if (Field == FLD_FILTER)
-
 
1079
	      Rule->filter = ch;
-
 
1080
	   else if (Field == FLD_MAXSCALE)
-
 
1081
	      Rule->maxscale = ch.toDouble();
-
 
1082
	   else if (Field == FLD_MINSCALE)
-
 
1083
	      Rule->minscale = ch.toDouble();
-
 
1084
	}
-
 
1085
	else if (Container == in_linesymbolizer && LineSymbolizer)
-
 
1086
	{
-
 
1087
	   if (Field == FLD_CSSPARAMETER)
-
 
1088
	   {
-
 
1089
	      if (Names == stroke_stroke)
-
 
1090
		 LineSymbolizer->stroke = colorToUInt(ch);
-
 
1091
	      else if (Names == stroke_width)
-
 
1092
		 LineSymbolizer->stroke_width = ch.toDouble();
-
 
1093
	      else if (Names == stroke_linejoin)
-
 
1094
		 LineSymbolizer->stroke_linejoin = ch;
-
 
1095
	      else if (Names == stroke_linecap)
-
 
1096
		 LineSymbolizer->stroke_linecap = ch;
-
 
1097
	      else if (Names == stroke_opacity)
-
 
1098
		 LineSymbolizer->stroke_opacity = ch.toDouble();
-
 
1099
	      else if (Names == stroke_dasharray)
-
 
1100
	      {
-
 
1101
	      int pos;
-
 
1102
	      QString arr = ch;
-
 
1103
	      QStringList list;
-
 
1104
 
-
 
1105
		 list = arr.split(",", QString::SkipEmptyParts);
-
 
1106
 
-
 
1107
		 for (pos = 0; pos < list.size() && pos < 10; pos++)
-
 
1108
		 {
-
 
1109
		    LineSymbolizer->stroke_dasharray[pos] = list.at(pos).toDouble();
-
 
1110
		    pos++;
-
 
1111
		 }
-
 
1112
 
-
 
1113
		 LineSymbolizer->stroke_anz = pos;
-
 
1114
	      }
-
 
1115
	   }
-
 
1116
	}
-
 
1117
	else if (Container == in_polygonsymbolizer && PolygonSymbolizer)
-
 
1118
	{
-
 
1119
	   if (Field == FLD_CSSPARAMETER)
-
 
1120
	   {
-
 
1121
	      if (Names == fill)
-
 
1122
		 PolygonSymbolizer->fill = colorToUInt(ch);
-
 
1123
	      else if (Names == fill_opacity)
-
 
1124
		 PolygonSymbolizer->fill_opacity = ch.toDouble();
-
 
1125
	   }
-
 
1126
	}
-
 
1127
	else if (Container == in_layer && Lay)
-
 
1128
	{
-
 
1129
	   if (Field == FLD_STYLENAME)
-
 
1130
	      Lay->Styles << ch;
-
 
1131
	}
-
 
1132
	else if (Container == in_datasource && Lay)
-
 
1133
	{
-
 
1134
	   if (Field == FLD_PARAMETER)
-
 
1135
	   {
-
 
1136
	      if (Names == type)
-
 
1137
		 Lay->Datasource.type = ch;
-
 
1138
	      else if (Names == file)
-
 
1139
		 Lay->Datasource.file = ch;
-
 
1140
	      else if (Names == host)
-
 
1141
		 Lay->Datasource.host = ch;
-
 
1142
	      else if (Names == user)
-
 
1143
		 Lay->Datasource.user = ch;
-
 
1144
	      else if (Names == dbname)
-
 
1145
		 Lay->Datasource.dbname = ch;
-
 
1146
	      else if (Names == table)
-
 
1147
		 Lay->Datasource.table = ch;
-
 
1148
	      else if (Names == estimate_extent)
-
 
1149
		 Lay->Datasource.estimate_extent = getBool(ch);
-
 
1150
	      else if (Names == extent)
-
 
1151
	      {
-
 
1152
		 QString arr = ch;
-
 
1153
		 QStringList list;
-
 
1154
		 list = arr.split(",");
-
 
1155
		 Lay->Datasource.ext_lx = list.at(0).toDouble();
-
 
1156
		 Lay->Datasource.ext_ly = list.at(1).toDouble();
-
 
1157
		 Lay->Datasource.ext_rx = list.at(2).toDouble();
-
 
1158
		 Lay->Datasource.ext_ry = list.at(3).toDouble();
-
 
1159
	      }
-
 
1160
	   }
-
 
1161
	}
-
 
1162
 
-
 
1163
	return true;
447
}
1164
}
448
 
1165
 
449
QString render::getKey (int pos)
1166
QString SRender::getKey (int pos)
450
{
1167
{
451
int i = 0;
1168
int i = 0;
452
 
1169
 
453
	while (keys[i].id > 0)
1170
	while (token[i].id > 0)
454
	{
1171
	{
455
	   if (keys[i].id == pos)
1172
	   if (token[i].id == pos)
456
	      return keys[i].name;
1173
	      return token[i].name;
457
 
1174
 
458
	   i++;
1175
	   i++;
459
	}
1176
	}
460
 
1177
 
461
	return QString::null;
1178
	return QString::null;
462
}
1179
}
463
 
1180
 
464
bool render::getMap (double lx, double ly, double rx double ry)
1181
TYPES SRender::getType(QString ty)
465
{
1182
{
-
 
1183
	if (ty.toLower() == QString("png"))
-
 
1184
	   return type_png;
-
 
1185
	else if (ty.toLower() == QString("gif"))
466
int width, height;
1186
	   return type_gif;
-
 
1187
	else if (ty.toLower() == QString("jpg"))
-
 
1188
	   return type_jpg;
-
 
1189
	else if (ty.toLower() == QString("xpm"))
-
 
1190
	   return type_xpm;
-
 
1191
	else if (ty.toLower() == QString("bmp"))
-
 
1192
	   return type_bmp;
-
 
1193
	else if (ty.toLower() == QString("tif") || ty.toLower() == QString("tiff"))
-
 
1194
	   return type_tif;
467
 
1195
 
468
	datasource_cache::instance()->register_datasources(MAPNIK_PLUGIN_PATH + "/");
-
 
469
	freetype_engine::register_font(MAPNIK_FONTS + "/DejaVuSans.ttf");
1196
	return type_png;
-
 
1197
}
470
 
1198
 
471
	width = label.width();
1199
char *grTypes[] = { (char *)"png", (char *)"gif", (char *)"jpg", (char*)"xpm",
472
	height = label.height();
1200
		    (char *)"bmp", (char *)"tif" };
473
 
1201
 
-
 
1202
char *SRender::getTypeText(TYPES type)
-
 
1203
{
-
 
1204
	switch (type)
-
 
1205
	{
-
 
1206
	   case type_png: return grTypes[0]; break;
474
	Map m(width, height, "+proj=merc +datum=WGS84  +k=1.0 +units=m +over +no_defs");
1207
	   case type_gif: return grTypes[1]; break;
-
 
1208
	   case type_jpg: return grTypes[2]; break;
-
 
1209
	   case type_xpm: return grTypes[3]; break;
-
 
1210
	   case type_bmp: return grTypes[4]; break;
475
	m.set_background(color_factory::from_string("white"));
1211
	   case type_tif: return grTypes[5]; break;
-
 
1212
	}
476
 
1213
 
477
	// create styles
1214
	return 0;
478
	// world1
1215
}
479
	feature_type_style world1_style;
-
 
480
	addRule(&world1_style, 0, 6000000.0, 250000000000.0, Color(0xf2, 0xef, 0xe9), Color(0xb5, 0xd0, 0xd0), 0.5, 0, 0, 0);
-
 
481
 
1216
 
-
 
1217
bool SRender::getBool(QString b)
482
	// world
1218
{
483
	feature_type_style world_style;
1219
	if (b.toLower() == QString("true") ||
-
 
1220
	    b.toLower() == QString("on") ||
-
 
1221
	    b.toLower() == QString("1") ||
484
	addRule(&world_style, 0, 600000.0, 6000000.0, Color(0xf2, 0xef, 0xe9), 0, 0.0, 0, 0, 0);
1222
	    b.toLower() == QString("yes") ||
-
 
1223
	    b.toLower() == QString("t") ||
-
 
1224
	    b.toLower() == QString("y"))
-
 
1225
	   return true;
485
 
1226
 
486
	// coast_poly
1227
	return false;
487
	feature_type_style coast_poly_style;
-
 
488
	addRule(&coas_poly_style, 0, -1.0, 600000.0, Color(0xf2, 0xef, 0xe9), 0, 0.0, 0, 0, 0);
-
 
-
 
1228
}
489
 
1229
 
-
 
1230
bool SRender::getMap (double lx, double ly, double rx, double ry)
-
 
1231
{
-
 
1232
int width, height, pid;
-
 
1233
QXmlSimpleReader reader;
490
	// builtup
1234
QString hv0;
-
 
1235
QFile file(XmlPath);
-
 
1236
 
491
	feature_type_style builtup_style;
1237
	hv0 = pluginPath + "/";
492
	addRule(&builtup_style, 0, 500000.0, 2500000.0, Color(0x0d, 0x0d, 0x0d), 0, 0.0, 0, 0, 0);
1238
	datasource_cache::instance()->register_datasources(hv0.toAscii().data());
-
 
1239
	hv0 = fontPath + "/DejaVuSans.ttf";
-
 
1240
	freetype_engine::register_font(hv0.toAscii().data());
493
 
1241
 
494
	// places
-
 
495
	feature_type_style places_style;
1242
	width = label->width();
496
	text_symbolizer places_ts = addTextSymbolizer("place_name", "DejaVu Sans Book", 10, Color(0x04, 0x04, 0x04), 1, 0.0);
-
 
497
	places_style.append(places_ts);
1243
	height = label->height();
498
	addRule(&places_style, 0, 10000000.0, 50000000.0, 0, 0, 0.0, 0, 0, 0);
-
 
499
 
1244
 
500
	// stations
1245
	m.setWidth(width);
501
	feature_type_style stations_style;
1246
	m.setHeight(height);
502
	addRulePoint(&stations_style, "[railway]='station'", 25000.0, 250000.0, 0, 0, 0.0, QString("station_small.png"), 5, 5);
-
 
503
	addRulePoint(&stations_style, "[railway]='station'", -1.0, 25000.0, 0, 0, 0.0, QString("station.png", 9, 9);
-
 
504
	addRulePoint(&stations_style, "[railway]='halt' or [railway]='tram_stop'", -1.0, 100000.0, 0, 0, 0.0, QString("halt.png"), 3, 3);
-
 
505
 
1247
 
506
	text_symbolizer stations_ts = addTextSymbolizer("name", "DejaVu Sans Bold", 8, Color(0, 0, 0), 1, 0, -8.0);
1248
	if (!ControlSet)	// Initialize the map?
-
 
1249
	{
507
	stations_style.append(stations_ts);
1250
	   QXmlInputSource source (&file);
508
	addRulePoint(&stations_style, "[railway]='halt'", 25000.0, 50000.0, 0, 0, 0.0, 0, 0, 0, 0);
1251
	   reader.setContentHandler (this);
-
 
1252
	   reader.parse (source);
-
 
1253
	}
509
 
1254
 
-
 
1255
	// First we use Mapnik to create the map
-
 
1256
cout << lx << ", " << ly << ", " << rx << ", " << ry << endl;
510
	text_symbolizer stations_ts1 = addTextSymbolizer("name", "DejaVu Sans Bold", 10, Color(0, 0, 0), 1, 0, -14.0);
1257
//cout << DEG2RAD(lx) << ", " << DEG2RAD(ly) << ", " << DEG2RAD(rx) << ", " << DEG2RAD(ry) << endl;
-
 
1258
	m.zoomToBox(Envelope<double>(lx, ly, rx, ry));
-
 
1259
	Image32 buf(m.getWidth(), m.getHeight());
511
	stations_style.append(stations_ts1);
1260
	agg_renderer<Image32> ren(m, buf);
-
 
1261
	ren.apply();
-
 
1262
	// Create a unique file name
-
 
1263
	pid = getpid();
-
 
1264
	hv0.sprintf("/var/tmp/SportWatcher_%d", pid);
512
	addRule(&stations_style, "[railway] ='halt'", -1.0, 25000.0, 0, 0, 0.0, 0, 0, 0);
1265
	save_to_file<ImageData32>(buf.data(), hv0.toAscii().data(), "png");
-
 
1266
 
-
 
1267
	// Now we move the image into a QPixmap
-
 
1268
	QPixmap pm;
-
 
1269
	pm.load(hv0);
-
 
1270
	unlink(hv0.toAscii().data());	// delete the temporary file
-
 
1271
	label->setPixmap(pm);
-
 
1272
	return true;
-
 
1273
}
513
 
1274
 
514
	text_symbolizer stations_ts2 = addTextSymbolizer("name", "DejaVu Sans Bold", 9, Color(0, 0, 0), 1, 0, -8.0);
-
 
515
	stations_style.append(stations_ts2);
1275
RULE *SRender::getLastRule(RULE *first)
-
 
1276
{
516
	addRule(&stations_style, "[railway]='station'", 25000.0, 50000.0, 0, 0, 0.0, 0, 0, 0);
1277
RULE *akt = first;
517
 
1278
 
518
	text_symbolizer stations_ts3 = addTextSymbolizer("name", "DejaVu Sans Bold", 12, Color(0, 0, 0), 1, 0, -14.0);
-
 
-
 
1279
	while (akt)
-
 
1280
	{
519
	stations_style.append(stations_ts3);
1281
	   if (!akt->next)
520
	addRule(&stations_style, "[railway]='station'", -1.0, 25000.0, 0, 0, 0.0, 0, 0, 0);
1282
	      return akt;
521
	addRulePoint(&stations_style, "[railway]='level_crossing'", 10000.0, 50000.0, 0, 0, 0.0, QString("level_crossing.png"), 7, 7);
-
 
522
 
1283
 
523
	// leisure
-
 
524
	feature_type_style leisure_style;
1284
	   akt = akt->next;
-
 
1285
	}
525
 
1286
 
526
	addRule(&leisure_style, "[man_made] = 'pier'", -1.0, 100000.0, Color(0xed, 0xed, 0xed), color_factory::from_string("grey"), 0.3, 0, 0, 0);
-
 
527
	addRule(&leisure_style, "[highway] = 'residential'", -1.0, 50000.0, Color(255, 255, 255), Color(0x09, 0x09, 0x09), 1.0, 0, 0, 0);
-
 
528
	addRule(&leisure_style, "[highway] = 'pedestrian'", -1.0, 50000.0, Color(0xed, 0xed, 0xed), color_factory::from_string("grey"), 0.5, 0, 0, 0);
-
 
529
	addRule(&leisure_style, "[leisure] = 'playground'", -1.0, 100000.0, Color(0xcc, 0xff, 0xff), Color(0x06, 0x06, 0x06), 0.3, 0, 0, 0);
-
 
530
	addRule(&leisure_style, "[tourism] = 'attraction'", -1.0, 100000.0, Color(0xf2, 0xca, 0xea), 0, -1.0, 0, 0, 0);
-
 
531
	addRule(&leisure_style, "[landuse] = 'quarry'", -1.0, 500000.0, 0, color_factory::from_string("grey"), 0.5, QString("quarry2.png"), 30, 30);
-
 
532
	addRule(&leisure_style, "[leisure] = 'nature_reserve' or [landuse] = 'vineyard'", 100000.0, 1000000.0, Color(0xab, 0xdf, 0x96), 0, 0.0, 0, 0, 0);
-
 
533
	addRule(&leisure_style, "[landuse] = 'vineyard'", 20000.0, 100000.0, 0, 0, 0.0, QString("vineyard.png"), 19, 21);
-
 
534
	addRule(&leisure_style, "[landuse] = 'vineyard'", -1.0, 100000.0, 0, 0, 0.0, QString("vineyard.png"), 29, 29);
-
 
535
	addRule(&leisure_style, "[leisure] = 'nature_reserve'", 50000.0, 100000.0, 0, 0, 0.0, QString("nature_reserve.png"), 21, 24);
-
 
536
	addRule(&leisure_style, "[leisure] = 'nature_reserve'", -1.0, 50000.0, 0, 0, 0.0, QString("nature_reserve2.png"), 42, 48);
-
 
537
	addRule(&leisure_style, "[landuse] = 'cemetery'", 20000.0, 1000000.0, Color(0xaa, 0xcb, 0xaf), 0, 0.0, 0, 0, 0);
-
 
538
	addRule(&leisure_style, "[landuse] = 'residential'", 1000.0, 1000000.0, Color(0x0d, 0x0d, 0x0d), 0, 0.0, 0, 0, 0);
-
 
539
	addRule(&leisure_style, "[military] = 'barracks'", 1000.0, 1000000.0, Color(0xff, 0x8f, 0x8f), 0, 0.0, 0, 0, 0);
-
 
540
	addRule(&leisure_style, "[military] = 'danger_area'", 500000.0, 2000000.0, color_factory::from_string("pink"), 0, 0.0, 0, 0, 0); // FIXME: fill-opacity 0.3 is missing!
-
 
541
	addRule(&leisure_style, "[military] = 'danger_area'", 1000.0, 500000.0, 0, 0, 0.0, QString("danger.png"), 30, 30);
-
 
542
	addRule(&leisure_style, "[landuse] = 'cemetery'", -1.0, 50000.0, 0, 0, 0.0, QString("grave_yard.png"), 16, 16);
-
 
543
	addRule(&leisure_style, "[landuse] = 'meadow'", -1.0, 1000000.0, Color(0xcf, 0xec, 0xa8), 0, 0.0, 0, 0, 0);
-
 
544
	addRule(&leisure_style, "[leisure] = 'park'", -1.0, 1000000.0, Color(0xb6, 0xfd, 0xb6), 0, 0.0, 0, 0, 0);
-
 
545
	addRule(&leisure_style, "[tourism] = 'zoo'", -1.0, 1000000.0, 0, 0, 0.0, QString("zoo.png"), 21, 24);
-
 
546
	addRule(&leisure_style, "[leisure] = 'common'", -1.0, 1000000.0, Color(0xcf, 0xec, 0xa8), 0, 0.0, 0, 0, 0);
-
 
547
	addRule(&leisure_style, "[leisure] = 'garden'", -1.0, 1000000.0, Color(0xcf, 0xec, 0xa8), 0, 0.0, 0, 0, 0);
-
 
548
	addRule(&leisure_style, "[leisure] = 'golf_course'", -1.0, 1000000.0, Color(0xb5, 0xe3, 0xb5), 0, 0.0, 0, 0, 0);
-
 
549
	addRule(&leisure_style, "[landuse] = 'allotments'", -1.0, 1000000.0, Color(0xc8, 0xb0, 0x84), 0, 0.0, 0, 0, 0);
-
 
550
	addRule(&leisure_style, "[landuse] = 'forest'", 50000.0, 2000000.0, Color(0x8d, 0xc5, 0x6c), 0, 0.0, 0, 0, 0);
-
 
551
	addRule(&leisure_style, "[landuse] = 'forest'", -1.0, 50000.0, 0, 0, 0.0, QString("forest.png"), 21, 24);
-
 
552
	addRule(&leisure_style, "[landuse] = 'farm'", -1.0, 2000000.0, Color(0xea, 0xd8, 0xbd), 0, 0.0, 0, 0, 0);
-
 
553
	addRule(&leisure_style, "[landuse] = 'recreation_ground'", -1.0, 1000000.0, Color(0xcf, 0xec, 0xa8), 0, 0.0, 0, 0, 0);
-
 
554
	addRule(&leisure_style, "[landuse] = 'village_green'", -1.0, 500000.0, Color(0xcf, 0xec, 0xa8), 0, 0.0, 0, 0, 0);
-
 
555
	addRule(&leisure_style, "[landuse] = 'retail'", -1.0, 1000000.0, Color(0xf1, 0xda, 0xda), 0, 0.0, 0, 0, 0);
-
 
556
	addRule(&leisure_style, "[landuse] = 'retail'", -1.0, 25000.0, 0, color_factory::from_string("red"), 0.3, 0, 0, 0);
-
 
557
	addRule(&leisure_style, "[landuse] = 'industrial'", -1.0, 1000000.0, Color(0xff, 0xae, 0xb9), 0, 0.0, 0, 0, 0);
-
 
558
	addRule(&leisure_style, "[power] = 'station'", 200000.0, 1000000.0, Color(0x0b, 0x0b, 0x0b), 0, 0.0, 0, 0, 0);
-
 
559
	addRule(&leisure_style, "[power] = 'station'", -1.0, 200000.0, Color(0x0b, 0x0b, 0x0b), Color(0x05, 0x05, 0x05), 0.4, 0, 0, 0);
-
 
560
	addRule(&leisure_style, "[power] = 'sub_station'", -1.0, 100000.0, Color(0x0b, 0x0b, 0x0b), Color(0x05, 0x05, 0x05), 0.4, 0, 0, 0);
-
 
561
	addRule(&leisure_style, "[landuse] = 'commercial'", -1.0, 1000000.0, Color(0xef, 0xc8, 0xc8), 0, 0.0, 0, 0, 0);
-
 
562
	addRule(&leisure_style, "[landuse] = 'brownfield' or [landuse]='landfill'", -1, 1000000.0, Color(0x9d, 0x9d, 0x6c), 0, 0.0, 0, 0, 0);
-
 
563
	addRule(&leisure_style, "[natural] = 'wood' or [landuse] = 'wood'", -1.0, 1000000.0, Color(0xae, 0xd1, 0xa0), 0, 0.0, 0, 0, 0);
-
 
564
	addRule(&leisure_style, "[natural] = 'heath'", -1.0, 1000000.0, Color(0xff, 0xff, 0xc0), 0, 0.0, 0, 0, 0);
-
 
565
	addRule(&leisure_style, "[landuse] = 'basin'", -1.0, 5000000.0, Color(0xb5, 0xd0, 0xd0), 0, 0.0, 0, 0, 0);
-
 
566
	addRule(&leisure_style, "[amenity] = 'university' or [amenity] = 'college' or [amenity] = 'school' or [amenity]='hospital'", -1.0, 1000000.0, Color(0xf0, 0xf0, 0xd8), 0, 0.0, 0, 0, 0);
-
 
567
	addRule(&leisure_style, "[amenity] = 'university' or [amenity] = 'college' or [amenity] = 'school' or [amenity]='hospital'", -1.0, 250000.0, 0, color_factory::from_string("brown"), 0.3, 0, 0, 0);
-
 
568
	addRule(&leisure_style, "[amenity] = 'parking'", -1.0, 1000000.0, Color(0xf7, 0xef, 0xb7),  0, 0.0, 0, 0, 0);
-
 
569
	addRule(&leisure_style, "[amenity] = 'parking'", -1.0, 25000.0, 0, Color(0xee, 0xee, 0xd1), 0.3, 0, 0, 0);
-
 
570
	addRule(&leisure_style, "[railway] = 'station' or [building] = 'station'", -1.0, 1000000.0, Color(0xff, 0xf6, 0x8f), 0, 0.0, 0, 0, 0); // FIXME: fill-opacity = 0.5 is missing!
-
 
571
	addRule(&leisure_style, "[building] = 'supermarket'", -1.0, 1000000.0, color_factory::from_string("pink"), 0, 0.0, 0, 0, 0); // FIXME: fill-opacity = 0.5 is missing!
-
 
572
	addRule(&leisure_style, "[building] <> 'station' and [building] <> 'supermarket' and [building] <> ''", -1.0, 1000000.0, Color(0xcc, 0x99, 0x99), 0, 0.0, 0, 0, 0);
-
 
573
	addRule(&leisure_style, "[amenity] = 'place_of_worship'", 20000.0, 1000000.0, Color(0x07, 0x07, 0x07), 0, 0.0, 0, 0, 0); // FIXME: fill-opacity = 0.5 is missing!
-
 
574
	addRule(&leisure_style, "[amenity] = 'place_of_worship'", -1.0, 20000.0, Color(0x07, 0x07, 0x07), Color(0x01, 0x01, 0x01), 0.3, 0, 0, 0);
-
 
575
	addRule(&leisure_style, "[leisure] = 'sports_centre' or [leisure]='stadium' or [leisure]='track'", -1.0, 1000000.0, Color(0x33, 0xcc, 0x99), 0, 0.0, 0, 0, 0);
-
 
576
	addRule(&leisure_style, "[leisure] = 'pitch'", -1.0, 1000000.0, Color(0x8a, 0xd3, 0xaf), 0, 0.0, 0, 0, 0);
-
 
577
	addRule(&leisure_style, "[aeroway] = 'terminal'", -1.0, 200000.0, Color(0xcc, 0x99, 0xff), 0, 0.0, 0, 0, 0);
-
 
578
	addRule(&leisure_style, "[aeroway] = 'terminal'", -1.0, 50000.0, 0, Color(0x33, 0x00, 0x66), 0.2, 0, 0, 0);
-
 
579
	addRule(&leisure_style, "[aeroway] = 'apron'", -1.0, 200000.0, Color(0xf0, 0xe0, 0xff), 0, 0.0, 0, 0, 0);
-
 
580
	addRule(&leisure_style, "[natural] = 'beach'", -1.0, 100000.0, 0, 0, 0.0, QString("beach.png"), 10, 10);
1287
	return 0;
581
}
1288
}
582
 
1289
 
583
void render::addRule (feature_type_style &fts, char *filter, double minscale, double maxscale, Color &polcol, Color &symcol, double symwidth, QString &pattern, int pw, int ph)
1290
POINTSYMBOLIZER *SRender::getLastPointSymbolizer(POINTSYMBOLIZER *first)
584
{
1291
{
585
	rule_type rule;
-
 
586
 
-
 
587
	if (minscale >= 0.0)
-
 
588
	   rule.set_min_scale(minscale);
1292
POINTSYMBOLIZER *akt = first;
589
 
-
 
590
	if (maxscale >= 0.0)
-
 
591
	   rule.set_max_scale(maxscale);
-
 
592
 
1293
 
593
	if (pattern && pw > 0 && ph > 0)
1294
	while (akt)
594
	{
1295
	{
-
 
1296
	   if (!akt->next)
595
	QString ptf = KStandardDirs::findRessource("icon", pattern);
1297
	      return akt;
596
 
1298
 
597
	   rule.append(polygon_pattern_symbolizer(ptf.toAscii().data(), "png", pw, ph));
1299
	   akt = akt->next;
598
	}
1300
	}
599
 
1301
 
600
	if (filter)
1302
	return 0;
601
	   rule.set_filter(create_filter(filter));
-
 
-
 
1303
}
602
 
1304
 
-
 
1305
LINESYMBOLIZER *SRender::getLastLineSymbolizer(LINESYMBOLIZER *first)
603
	if (polcol)
1306
{
604
	   rule.append(polygon_symbolizer(polcol));
1307
LINESYMBOLIZER *akt = first;
605
 
1308
 
606
	if (symcol)
1309
	while (akt)
607
	{
1310
	{
608
	   stroke stk (symcol);
-
 
609
 
-
 
610
	   if (symwidth >= 0.0)
1311
	   if (!akt->next)
611
	      stk.set_width(0.3);
1312
	      return akt;
612
 
1313
 
613
	   rule.append(line_symbolizer(stk));
1314
	   akt = akt->next;
614
	}
1315
	}
615
 
1316
 
616
	fts.add_rule(rule);
1317
	return 0;
617
}
1318
}
618
 
1319
 
619
void render::addRulePoint (feature_type_style &fts, char *filter, double minscale, double maxscale, Color &polcol, Color &symcol, double symwidth, QString &pattern, int pw, int ph)
1320
POLYGONSYMBOLIZER *SRender::getLastPolygonSymbolizer(POLYGONSYMBOLIZER *first)
620
{
1321
{
621
	rule_type rule;
-
 
622
 
-
 
623
	if (minscale >= 0.0)
-
 
624
	   rule.set_min_scale(minscale);
-
 
625
 
-
 
626
	if (maxscale >= 0.0)
-
 
627
	   rule.set_max_scale(maxscale);
1322
POLYGONSYMBOLIZER *akt = first;
628
 
1323
 
629
	if (pattern && pw > 0 && ph > 0)
1324
	while (akt)
630
	{
1325
	{
-
 
1326
	   if (!akt->next)
631
	QString ptf = KStandardDirs::findRessource("icon", pattern);
1327
	      return akt;
632
 
1328
 
633
	   rule.append(point_symbolizer(ptf.toAscii().data(), "png", pw, ph));
1329
	   akt = akt->next;
634
	}
1330
	}
635
 
1331
 
636
	if (filter)
1332
	return 0;
637
	   rule.set_filter(create_filter(filter));
-
 
-
 
1333
}
638
 
1334
 
-
 
1335
TEXTSYMBOLIZER *SRender::getLastTextSymbolizer(TEXTSYMBOLIZER *first)
639
	if (polcol)
1336
{
640
	   rule.append(polygon_symbolizer(polcol));
1337
TEXTSYMBOLIZER *akt = first;
641
 
1338
 
642
	if (symcol)
1339
	while (akt)
643
	{
1340
	{
644
	   stroke stk (symcol);
-
 
645
 
-
 
646
	   if (symwidth >= 0.0)
1341
	   if (!akt->next)
647
	      stk.set_width(0.3);
1342
	      return akt;
648
 
1343
 
649
	   rule.append(line_symbolizer(stk));
1344
	   akt = akt->next;
650
	}
1345
	}
651
 
1346
 
652
	fts.add_rule(rule);
1347
	return 0;
653
}
1348
}
654
 
1349
 
655
text_symbolizer &render::addTextSymbolizer (char *name, char *font, int size, Color &col, int radius, int wrap, double dy)
1350
POLYGONPATTERNSYMBOLIZER *SRender::getLastPolygonPatternSymbolizer(POLYGONPATTERNSYMBOLIZER *first)
656
{
1351
{
657
text_symbolizer ts(name, font, size, Color(0, 0, 0));
1352
POLYGONPATTERNSYMBOLIZER *akt = first;
658
 
1353
 
659
	if (vol && radius > 0)
1354
	while (akt)
660
	{
1355
	{
-
 
1356
	   if (!akt->next)
661
	   ts.set_halo_fill(halo);
1357
	      return akt;
-
 
1358
 
662
	   ts.set_halo_radius(radius);
1359
	   akt = akt->next;
663
	}
1360
	}
664
 
1361
 
-
 
1362
	return 0;
-
 
1363
}
-
 
1364
 
-
 
1365
SHIELDSYMBOLIZER *SRender::getLastShieldSymbolizer(SHIELDSYMBOLIZER *first)
-
 
1366
{
-
 
1367
SHIELDSYMBOLIZER *akt = first;
-
 
1368
 
-
 
1369
	while (akt)
-
 
1370
	{
665
	if (dy < 0.0)
1371
	   if (!akt->next)
666
	   ts.set_max_char_angle_delta(dy);
1372
	      return akt;
667
 
1373
 
668
	if (wrap >= 0)
-
 
669
	   ts.set_wrap_width(wrap);
1374
	   akt = akt->next;
-
 
1375
	}
670
 
1376
 
671
	return &ts;
1377
	return 0;
672
}
1378
}
673
 
1379
 
674
RULE *render::getLastRule(RULE *first)
1380
LINEPATTERNSYMBOLIZER *SRender::getLastLinePatternSymbolizer(LINEPATTERNSYMBOLIZER *first)
675
{
1381
{
676
RULE *akt = first;
1382
LINEPATTERNSYMBOLIZER *akt = first;
677
 
1383
 
678
	while (akt)
1384
	while (akt)
679
	{
1385
	{
680
	   if (!akt->next)
1386
	   if (!akt->next)
681
	      return akt;
1387
	      return akt;
Line 684... Line 1390...
684
	}
1390
	}
685
 
1391
 
686
	return 0;
1392
	return 0;
687
}
1393
}
688
 
1394
 
689
POINTSYMBOLIZER *render::getLastPointSymbolizer(POINTSYMBOLIZER *first)
1395
STYLE *SRender::findStyle(QString name)
690
{
1396
{
691
POINTSYMBOLIZER *akt = first;
1397
STYLE *akt = firstStyle;
692
 
1398
 
693
	while (akt)
1399
	while (akt)
694
	{
1400
	{
695
	   if (!akt->next)
1401
	   if (akt->name.toLower() == name.toLower())
696
	      return akt;
1402
	      return akt;
697
 
1403
 
698
	   akt = akt->next;
1404
	   akt = akt->next;
699
	}
1405
	}
700
 
1406
 
701
	return 0;
1407
	return 0;
702
}
1408
}
-
 
1409
 
-
 
1410
unsigned SRender::colorToUInt(QString col)
-
 
1411
{
-
 
1412
QColor qc(col);
-
 
1413
 
-
 
1414
	return (qc.red() * 65536) + (qc.green() * 256) + qc.blue();
-
 
1415
}
-
 
1416
 
-
 
1417
STYLE *SRender::allocStyle()
-
 
1418
{
-
 
1419
STYLE *St = new STYLE;
-
 
1420
 
-
 
1421
	St->name.clear();
-
 
1422
	St->rule = 0;
-
 
1423
	St->next = 0;
-
 
1424
	return St;
-
 
1425
}
-
 
1426
 
-
 
1427
RULE *SRender::allocRule()
-
 
1428
{
-
 
1429
RULE *Ru = new RULE;
-
 
1430
 
-
 
1431
	Ru->maxscale = 0;
-
 
1432
	Ru->minscale = 0;
-
 
1433
	Ru->filter.clear();
-
 
1434
	Ru->LineSymbolizer = 0;
-
 
1435
	Ru->PolygonSymbolizer = 0;
-
 
1436
	Ru->TextSymbolizer = 0;
-
 
1437
	Ru->PointSymbolizer = 0;
-
 
1438
	Ru->PolygonPatternSymbolizer = 0;
-
 
1439
	Ru->ShieldSymbolizer = 0;
-
 
1440
	Ru->LinePatternSymbolizer = 0;
-
 
1441
	Ru->next = 0;
-
 
1442
	return Ru;
-
 
1443
}
-
 
1444
 
-
 
1445
LAYER *SRender::allocLayer()
-
 
1446
{
-
 
1447
LAYER *La = new LAYER;
-
 
1448
 
-
 
1449
	La->name.clear();	// The unique name
-
 
1450
	La->status = false;	// Is it active?
-
 
1451
	La->srs.clear();	// Projection
-
 
1452
	La->Datasource.type.clear();
-
 
1453
	La->Datasource.file.clear();
-
 
1454
	La->Datasource.host.clear();
-
 
1455
	La->Datasource.user.clear();
-
 
1456
	La->Datasource.dbname.clear();
-
 
1457
	La->Datasource.table.clear();
-
 
1458
	La->Datasource.estimate_extent = false;
-
 
1459
	La->Datasource.ext_lx = 0.0;
-
 
1460
	La->Datasource.ext_ly = 0.0;
-
 
1461
	La->Datasource.ext_rx = 0.0;
-
 
1462
	La->Datasource.ext_ry = 0.0;
-
 
1463
	La->next = 0;
-
 
1464
	return La;
-
 
1465
}
-
 
1466
 
-
 
1467
LINEPATTERNSYMBOLIZER *SRender::allocLinePatternSymbolizer()
-
 
1468
{
-
 
1469
LINEPATTERNSYMBOLIZER *lps = new LINEPATTERNSYMBOLIZER;
-
 
1470
 
-
 
1471
	lps->file.clear();
-
 
1472
	lps->type = type_png;		// enum TYPES
-
 
1473
	lps->width = 0.0;
-
 
1474
	lps->height = 0.0;
-
 
1475
	lps->next = 0;
-
 
1476
	return lps;
-
 
1477
}
-
 
1478
 
-
 
1479
SHIELDSYMBOLIZER *SRender::allocShieldSymbolizer()
-
 
1480
{
-
 
1481
SHIELDSYMBOLIZER *ss = new SHIELDSYMBOLIZER;
-
 
1482
 
-
 
1483
	ss->name.clear();
-
 
1484
	ss->face_name.clear();
-
 
1485
	ss->size = 0.0;
-
 
1486
	ss->fill = 0;		// Color
-
 
1487
	ss->placement.clear();
-
 
1488
	ss->file.clear();
-
 
1489
	ss->type = type_png;		// enum TYPES
-
 
1490
	ss->width = 0.0;
-
 
1491
	ss->height = 0.0;
-
 
1492
	ss->mindistance = 0.0;
-
 
1493
	ss->maxdistance = 0.0;
-
 
1494
	ss->next = 0;
-
 
1495
	return ss;
-
 
1496
}
-
 
1497
 
-
 
1498
POLYGONPATTERNSYMBOLIZER *SRender::allocPolygonPatternSymbolizer()
-
 
1499
{
-
 
1500
POLYGONPATTERNSYMBOLIZER *pps = new POLYGONPATTERNSYMBOLIZER;
-
 
1501
 
-
 
1502
	pps->file.clear();
-
 
1503
	pps->type = type_png;		// enum TYPES
-
 
1504
	pps->width = 0.0;
-
 
1505
	pps->height = 0.0;
-
 
1506
	pps->allow_overlap = false;
-
 
1507
	pps->next = 0;
-
 
1508
	return pps;
-
 
1509
}
-
 
1510
 
-
 
1511
POINTSYMBOLIZER *SRender::allocPointSymbolizer()
-
 
1512
{
-
 
1513
POINTSYMBOLIZER *ps = new POINTSYMBOLIZER;
-
 
1514
 
-
 
1515
	ps->file.clear();
-
 
1516
	ps->type = type_png;		// enum TYPES
-
 
1517
	ps->width = 0.0;
-
 
1518
	ps->height = 0.0;
-
 
1519
	ps->allow_overlap = false;
-
 
1520
	ps->next = 0;
-
 
1521
	return ps;
-
 
1522
}
-
 
1523
 
-
 
1524
TEXTSYMBOLIZER *SRender::allocTextSymbolizer()
-
 
1525
{
-
 
1526
TEXTSYMBOLIZER *ts = new TEXTSYMBOLIZER;
-
 
1527
 
-
 
1528
	ts->name.clear();
-
 
1529
	ts->face_name.clear();
-
 
1530
	ts->size = 0;
-
 
1531
	ts->fill = 0;			// Color
-
 
1532
	ts->halo_radius = 0;
-
 
1533
	ts->wrap_width = 0;
-
 
1534
	ts->dy = 0.0;
-
 
1535
	ts->mindistance = 0.0;
-
 
1536
	ts->maxdistance = 0.0;
-
 
1537
	ts->next = 0;
-
 
1538
	return ts;
-
 
1539
}
-
 
1540
 
-
 
1541
POLYGONSYMBOLIZER *SRender::allocPolygonSymbolizer()
-
 
1542
{
-
 
1543
POLYGONSYMBOLIZER *ps = new POLYGONSYMBOLIZER;
-
 
1544
 
-
 
1545
	memset (ps, 0, sizeof(POLYGONSYMBOLIZER));
-
 
1546
	return ps;
-
 
1547
}
-
 
1548
 
-
 
1549
LINESYMBOLIZER *SRender::allocLineSymbolizer()
-
 
1550
{
-
 
1551
LINESYMBOLIZER *ls = new LINESYMBOLIZER;
-
 
1552
 
-
 
1553
	ls->stroke = 0;		// Color
-
 
1554
	ls->stroke_width = 0.0;
-
 
1555
	ls->stroke_linejoin.clear();
-
 
1556
	ls->stroke_linecap.clear();
-
 
1557
 
-
 
1558
	for (int i = 0; i < 10; i++)
-
 
1559
	   ls->stroke_dasharray[i] = 0.0;
-
 
1560
 
-
 
1561
	ls->stroke_anz = 0;		// number of entries in dasharray
-
 
1562
	ls->stroke_opacity = 0.0;
-
 
1563
	ls->next = 0;
-
 
1564
	return ls;
-
 
1565
}