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 );
71 int sizeOfDoubleX =
sizeof( double );
72 int sizeOfDoubleY = hasZValue ? 2 *
sizeof( double ) :
sizeof(
double );
82 double cw = e.
width() / 10;
double ch = e.
height() / 10;
88 pts.resize( nPoints );
90 QPointF* ptr = pts.data();
91 for (
unsigned int i = 0; i < nPoints; ++i, ++ptr )
93 memcpy( &x, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleX;
94 memcpy( &y, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleY;
96 *ptr = QPointF( x, y );
106 QPointF* ptr = pts.data();
107 for (
int i = 0; i < pts.size(); ++i, ++ptr )
119 unsigned int wkbType = *((
int* ) wkb );
120 wkb +=
sizeof(
unsigned int );
121 unsigned int numRings = *((
int* ) wkb );
122 wkb +=
sizeof(
unsigned int );
129 int sizeOfDoubleX =
sizeof( double );
130 int sizeOfDoubleY = hasZValue ? 2 *
sizeof( double ) :
sizeof(
double );
138 double cw = e.
width() / 10;
double ch = e.
height() / 10;
141 for (
unsigned int idx = 0; idx < numRings; idx++ )
143 unsigned int nPoints = *((
int* )wkb );
144 wkb +=
sizeof(
unsigned int );
146 QPolygonF poly( nPoints );
149 QPointF* ptr = poly.data();
150 for (
unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
152 memcpy( &x, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleX;
153 memcpy( &y, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleY;
155 *ptr = QPointF( x, y );
162 QRectF ptsRect = poly.boundingRect();
173 for (
int i = 0; i < poly.size(); ++i, ++ptr )
181 holes.append( poly );
204 : mType( type ), mUsingSymbolLevels( false ),
206 mCurrentVertexMarkerSize( 3 )
219 if ( symbol == NULL )
238 QgsDebugMsg(
"point can be drawn only with marker symbol!" );
243 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
255 QgsDebugMsg(
"linestring can be drawn only with line symbol!" );
260 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
262 if ( drawVertexMarker )
272 QgsDebugMsg(
"polygon can be drawn only with fill symbol!" );
276 QList<QPolygonF> holes;
278 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
280 if ( drawVertexMarker )
290 QgsDebugMsg(
"multi-point can be drawn only with marker symbol!" );
294 const unsigned char* wkb = geom->
asWkb();
295 unsigned int num = *((
int* )( wkb + 5 ) );
296 const unsigned char* ptr = wkb + 9;
299 for (
unsigned int i = 0; i < num; ++i )
302 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
315 QgsDebugMsg(
"multi-linestring can be drawn only with line symbol!" );
319 const unsigned char* wkb = geom->
asWkb();
320 unsigned int num = *((
int* )( wkb + 5 ) );
321 const unsigned char* ptr = wkb + 9;
324 for (
unsigned int i = 0; i < num; ++i )
327 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
329 if ( drawVertexMarker )
340 QgsDebugMsg(
"multi-polygon can be drawn only with fill symbol!" );
344 const unsigned char* wkb = geom->
asWkb();
345 unsigned int num = *((
int* )( wkb + 5 ) );
346 const unsigned char* ptr = wkb + 9;
348 QList<QPolygonF> holes;
350 for (
unsigned int i = 0; i < num; ++i )
353 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
355 if ( drawVertexMarker )
362 QgsDebugMsg( QString(
"feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.
id() ).arg( geom->
wkbType(), 0, 16 ) );
368 return "UNKNOWN RENDERER\n";
376 if ( element.isNull() )
380 QString rendererType = element.attribute(
"type" );
402 QDomElement element = node.toElement();
403 if ( element.isNull() )
407 QDomElement userStyleElem = element.firstChildElement(
"UserStyle" );
408 if ( userStyleElem.isNull() )
411 errorMessage =
"Info: UserStyle element not found.";
416 QDomElement featTypeStyleElem = userStyleElem.firstChildElement(
"FeatureTypeStyle" );
417 if ( featTypeStyleElem.isNull() )
419 errorMessage =
"Info: FeatureTypeStyle element not found.";
426 bool needRuleRenderer =
false;
429 QDomElement ruleElem = featTypeStyleElem.firstChildElement(
"Rule" );
430 while ( !ruleElem.isNull() )
437 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
438 needRuleRenderer =
true;
442 QDomElement ruleChildElem = ruleElem.firstChildElement();
443 while ( !ruleChildElem.isNull() )
446 if ( ruleChildElem.localName() ==
"Filter" ||
447 ruleChildElem.localName() ==
"MinScaleDenominator" ||
448 ruleChildElem.localName() ==
"MaxScaleDenominator" )
450 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
451 needRuleRenderer =
true;
455 ruleChildElem = ruleChildElem.nextSiblingElement();
458 if ( needRuleRenderer )
463 ruleElem = ruleElem.nextSiblingElement(
"Rule" );
466 QString rendererType;
467 if ( needRuleRenderer )
469 rendererType =
"RuleRenderer";
473 rendererType =
"singleSymbol";
475 QgsDebugMsg( QString(
"Instantiating a '%1' renderer..." ).arg( rendererType ) );
481 errorMessage = QString(
"Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
491 QDomElement userStyleElem = doc.createElement(
"UserStyle" );
493 QDomElement nameElem = doc.createElement(
"se:Name" );
494 nameElem.appendChild( doc.createTextNode( layer.
name() ) );
495 userStyleElem.appendChild( nameElem );
497 QDomElement featureTypeStyleElem = doc.createElement(
"se:FeatureTypeStyle" );
498 toSld( doc, featureTypeStyleElem );
499 userStyleElem.appendChild( featureTypeStyleElem );
501 return userStyleElem;
506 Q_UNUSED( iconSize );
513 Q_UNUSED( scaleDenominator );
533 foreach ( QPointF pt, pts )
539 foreach ( QPointF pt, pts )
544 foreach ( QPolygonF ring, *rings )
546 foreach ( QPointF pt, ring )
556 if ( s ) lst.append( s );