31 #include <QDomElement>
32 #include <QDomDocument>
40 unsigned int wkbType = *((
int* ) wkb );
41 wkb +=
sizeof(
unsigned int );
43 double x = *((
double * ) wkb ); wkb +=
sizeof( double );
44 double y = *((
double * ) wkb ); wkb +=
sizeof( double );
47 wkb +=
sizeof( double );
64 unsigned int wkbType = *((
int* ) wkb );
65 wkb +=
sizeof(
unsigned int );
66 unsigned int nPoints = *((
int* ) wkb );
67 wkb +=
sizeof(
unsigned int );
78 double cw = e.
width() / 10;
double ch = e.
height() / 10;
84 pts.resize( nPoints );
86 QPointF* ptr = pts.data();
87 for (
unsigned int i = 0; i < nPoints; ++i, ++ptr )
89 x = *((
double * ) wkb );
90 wkb +=
sizeof( double );
91 y = *((
double * ) wkb );
92 wkb +=
sizeof( double );
95 wkb +=
sizeof( double );
97 *ptr = QPointF( x, y );
107 QPointF* ptr = pts.data();
108 for (
int i = 0; i < pts.size(); ++i, ++ptr )
120 unsigned int wkbType = *((
int* ) wkb );
121 wkb +=
sizeof(
unsigned int );
122 unsigned int numRings = *((
int* ) wkb );
123 wkb +=
sizeof(
unsigned int );
135 double cw = e.
width() / 10;
double ch = e.
height() / 10;
138 for (
unsigned int idx = 0; idx < numRings; idx++ )
140 unsigned int nPoints = *((
int* )wkb );
141 wkb +=
sizeof(
unsigned int );
143 QPolygonF poly( nPoints );
146 QPointF* ptr = poly.data();
147 for (
unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
149 x = *((
double * ) wkb ); wkb +=
sizeof( double );
150 y = *((
double * ) wkb ); wkb +=
sizeof( double );
152 *ptr = QPointF( x, y );
155 wkb +=
sizeof( double );
172 for (
int i = 0; i < poly.size(); ++i, ++ptr )
180 holes.append( poly );
203 : mType( type ), mUsingSymbolLevels( false ),
205 mCurrentVertexMarkerSize( 3 )
218 if ( symbol == NULL )
237 QgsDebugMsg(
"point can be drawn only with marker symbol!" );
242 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
254 QgsDebugMsg(
"linestring can be drawn only with line symbol!" );
259 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
261 if ( drawVertexMarker )
271 QgsDebugMsg(
"polygon can be drawn only with fill symbol!" );
275 QList<QPolygonF> holes;
277 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
279 if ( drawVertexMarker )
289 QgsDebugMsg(
"multi-point can be drawn only with marker symbol!" );
293 const unsigned char* wkb = geom->
asWkb();
294 unsigned int num = *((
int* )( wkb + 5 ) );
295 const unsigned char* ptr = wkb + 9;
298 for (
unsigned int i = 0; i < num; ++i )
301 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
314 QgsDebugMsg(
"multi-linestring can be drawn only with line symbol!" );
318 const unsigned char* wkb = geom->
asWkb();
319 unsigned int num = *((
int* )( wkb + 5 ) );
320 const unsigned char* ptr = wkb + 9;
323 for (
unsigned int i = 0; i < num; ++i )
326 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
328 if ( drawVertexMarker )
339 QgsDebugMsg(
"multi-polygon can be drawn only with fill symbol!" );
343 const unsigned char* wkb = geom->
asWkb();
344 unsigned int num = *((
int* )( wkb + 5 ) );
345 const unsigned char* ptr = wkb + 9;
347 QList<QPolygonF> holes;
349 for (
unsigned int i = 0; i < num; ++i )
352 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
354 if ( drawVertexMarker )
361 QgsDebugMsg( QString(
"feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.
id() ).arg( geom->
wkbType(), 0, 16 ) );
367 return "UNKNOWN RENDERER\n";
375 if ( element.isNull() )
379 QString rendererType = element.attribute(
"type" );
401 QDomElement element = node.toElement();
402 if ( element.isNull() )
406 QDomElement userStyleElem = element.firstChildElement(
"UserStyle" );
407 if ( userStyleElem.isNull() )
410 errorMessage =
"Info: UserStyle element not found.";
415 QDomElement featTypeStyleElem = userStyleElem.firstChildElement(
"FeatureTypeStyle" );
416 if ( featTypeStyleElem.isNull() )
418 errorMessage =
"Info: FeatureTypeStyle element not found.";
425 bool needRuleRenderer =
false;
428 QDomElement ruleElem = featTypeStyleElem.firstChildElement(
"Rule" );
429 while ( !ruleElem.isNull() )
436 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
437 needRuleRenderer =
true;
441 QDomElement ruleChildElem = ruleElem.firstChildElement();
442 while ( !ruleChildElem.isNull() )
445 if ( ruleChildElem.localName() ==
"Filter" ||
446 ruleChildElem.localName() ==
"MinScaleDenominator" ||
447 ruleChildElem.localName() ==
"MaxScaleDenominator" )
449 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
450 needRuleRenderer =
true;
454 ruleChildElem = ruleChildElem.nextSiblingElement();
457 if ( needRuleRenderer )
462 ruleElem = ruleElem.nextSiblingElement(
"Rule" );
465 QString rendererType;
466 if ( needRuleRenderer )
468 rendererType =
"RuleRenderer";
472 rendererType =
"singleSymbol";
474 QgsDebugMsg( QString(
"Instantiating a '%1' renderer..." ).arg( rendererType ) );
480 errorMessage = QString(
"Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
490 QDomElement userStyleElem = doc.createElement(
"UserStyle" );
492 QDomElement nameElem = doc.createElement(
"se:Name" );
493 nameElem.appendChild( doc.createTextNode( layer.
name() ) );
494 userStyleElem.appendChild( nameElem );
496 QDomElement featureTypeStyleElem = doc.createElement(
"se:FeatureTypeStyle" );
497 toSld( doc, featureTypeStyleElem );
498 userStyleElem.appendChild( featureTypeStyleElem );
500 return userStyleElem;
505 Q_UNUSED( iconSize );
530 foreach ( QPointF pt, pts )
536 foreach ( QPointF pt, pts )
541 foreach ( QPolygonF ring, *rings )
543 foreach ( QPointF pt, ring )
553 if ( s ) lst.append( s );