34 #include <QDomDocument>
36 #include <QDomElement>
44 return QString(
"%1,%2,%3,%4" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ).arg( color.alpha() );
49 QStringList lst = str.split(
"," );
50 if ( lst.count() < 3 )
54 int red, green, blue, alpha;
56 green = lst[1].toInt();
57 blue = lst[2].toInt();
59 if ( lst.count() > 3 )
61 alpha = lst[3].toInt();
63 return QColor( red, green, blue, alpha );
68 return QString::number( alpha / 255.0,
'f', 2 );
74 double alpha = str.toDouble( &ok );
75 if ( !ok || alpha > 1 )
86 case QFont::StyleNormal:
return "normal";
87 case QFont::StyleItalic:
return "italic";
88 case QFont::StyleOblique:
return "oblique";
95 if ( str ==
"normal" )
return QFont::StyleNormal;
96 if ( str ==
"italic" )
return QFont::StyleItalic;
97 if ( str ==
"oblique" )
return QFont::StyleOblique;
98 return QFont::StyleNormal;
103 if ( weight == 50 )
return "normal";
104 if ( weight == 75 )
return "bold";
108 if ( weight < 0 )
return "100";
109 if ( weight > 99 )
return "900";
110 return QString::number( weight * 800 / 99 + 100 );
116 int weight = str.toInt( &ok );
117 if ( !ok )
return (
int ) QFont::Normal;
121 if ( weight > 900 )
return 99;
122 if ( weight < 100 )
return 0;
123 return ( weight - 100 ) * 99 / 800;
130 case Qt::NoPen:
return "no";
131 case Qt::SolidLine:
return "solid";
132 case Qt::DashLine:
return "dash";
133 case Qt::DotLine:
return "dot";
134 case Qt::DashDotLine:
return "dash dot";
135 case Qt::DashDotDotLine:
return "dash dot dot";
136 default:
return "???";
142 if ( str ==
"no" )
return Qt::NoPen;
143 if ( str ==
"solid" )
return Qt::SolidLine;
144 if ( str ==
"dash" )
return Qt::DashLine;
145 if ( str ==
"dot" )
return Qt::DotLine;
146 if ( str ==
"dash dot" )
return Qt::DashDotLine;
147 if ( str ==
"dash dot dot" )
return Qt::DashDotDotLine;
148 return Qt::SolidLine;
155 case Qt::BevelJoin:
return "bevel";
156 case Qt::MiterJoin:
return "miter";
157 case Qt::RoundJoin:
return "round";
158 default:
return "???";
164 if ( str ==
"bevel" )
return Qt::BevelJoin;
165 if ( str ==
"miter" )
return Qt::MiterJoin;
166 if ( str ==
"round" )
return Qt::RoundJoin;
167 return Qt::BevelJoin;
174 case Qt::BevelJoin:
return "bevel";
175 case Qt::MiterJoin:
return "mitre";
176 case Qt::RoundJoin:
return "round";
183 if ( str ==
"bevel" )
return Qt::BevelJoin;
184 if ( str ==
"mitre" )
return Qt::MiterJoin;
185 if ( str ==
"round" )
return Qt::RoundJoin;
186 return Qt::BevelJoin;
193 case Qt::SquareCap:
return "square";
194 case Qt::FlatCap:
return "flat";
195 case Qt::RoundCap:
return "round";
196 default:
return "???";
202 if ( str ==
"square" )
return Qt::SquareCap;
203 if ( str ==
"flat" )
return Qt::FlatCap;
204 if ( str ==
"round" )
return Qt::RoundCap;
205 return Qt::SquareCap;
212 case Qt::SquareCap:
return "square";
213 case Qt::FlatCap:
return "butt";
214 case Qt::RoundCap:
return "round";
221 if ( str ==
"square" )
return Qt::SquareCap;
222 if ( str ==
"butt" )
return Qt::FlatCap;
223 if ( str ==
"round" )
return Qt::RoundCap;
224 return Qt::SquareCap;
231 case Qt::SolidPattern :
return "solid";
232 case Qt::HorPattern :
return "horizontal";
233 case Qt::VerPattern :
return "vertical";
234 case Qt::CrossPattern :
return "cross";
235 case Qt::BDiagPattern :
return "b_diagonal";
236 case Qt::FDiagPattern :
return "f_diagonal";
237 case Qt::DiagCrossPattern :
return "diagonal_x";
238 case Qt::Dense1Pattern :
return "dense1";
239 case Qt::Dense2Pattern :
return "dense2";
240 case Qt::Dense3Pattern :
return "dense3";
241 case Qt::Dense4Pattern :
return "dense4";
242 case Qt::Dense5Pattern :
return "dense5";
243 case Qt::Dense6Pattern :
return "dense6";
244 case Qt::Dense7Pattern :
return "dense7";
245 case Qt::NoBrush :
return "no";
246 default:
return "???";
252 if ( str ==
"solid" )
return Qt::SolidPattern;
253 if ( str ==
"horizontal" )
return Qt::HorPattern;
254 if ( str ==
"vertical" )
return Qt::VerPattern;
255 if ( str ==
"cross" )
return Qt::CrossPattern;
256 if ( str ==
"b_diagonal" )
return Qt::BDiagPattern;
257 if ( str ==
"f_diagonal" )
return Qt::FDiagPattern;
258 if ( str ==
"diagonal_x" )
return Qt::DiagCrossPattern;
259 if ( str ==
"dense1" )
return Qt::Dense1Pattern;
260 if ( str ==
"dense2" )
return Qt::Dense2Pattern;
261 if ( str ==
"dense3" )
return Qt::Dense3Pattern;
262 if ( str ==
"dense4" )
return Qt::Dense4Pattern;
263 if ( str ==
"dense5" )
return Qt::Dense5Pattern;
264 if ( str ==
"dense6" )
return Qt::Dense6Pattern;
265 if ( str ==
"dense7" )
return Qt::Dense7Pattern;
266 if ( str ==
"no" )
return Qt::NoBrush;
267 return Qt::SolidPattern;
274 case Qt::CrossPattern:
return "cross";
275 case Qt::DiagCrossPattern:
return "x";
281 case Qt::HorPattern:
return "horline";
282 case Qt::VerPattern:
return "line";
283 case Qt::BDiagPattern:
return "slash";
284 case Qt::FDiagPattern:
return "backslash";
287 case Qt::Dense1Pattern:
288 case Qt::Dense2Pattern:
289 case Qt::Dense3Pattern:
290 case Qt::Dense4Pattern:
291 case Qt::Dense5Pattern:
292 case Qt::Dense6Pattern:
293 case Qt::Dense7Pattern:
303 if ( str ==
"horline" )
return Qt::HorPattern;
304 if ( str ==
"line" )
return Qt::VerPattern;
305 if ( str ==
"cross" )
return Qt::CrossPattern;
306 if ( str ==
"slash" )
return Qt::BDiagPattern;
307 if ( str ==
"backshash" )
return Qt::FDiagPattern;
308 if ( str ==
"x" )
return Qt::DiagCrossPattern;
310 if ( str.startsWith(
"brush://" ) )
318 return QString(
"%1,%2" ).arg( point.x() ).arg( point.y() );
323 QStringList lst = str.split(
',' );
324 if ( lst.count() != 2 )
325 return QPointF( 0, 0 );
326 return QPointF( lst[0].toDouble(), lst[1].toDouble() );
331 return QString(
"%1,%2" ).arg( mapUnitScale.
minScale ).arg( mapUnitScale.
maxScale );
336 QStringList lst = str.split(
',' );
337 if ( lst.count() != 2 )
363 else if ( str ==
"MapUnit" )
367 else if ( str ==
"Pixel" )
382 *scaleFactor = 0.001;
383 return "http://www.opengeospatial.org/se/units/metre";
399 if ( str ==
"http://www.opengeospatial.org/se/units/metre" )
402 *scaleFactor = 1000.0;
405 else if ( str ==
"http://www.opengeospatial.org/se/units/foot" )
408 *scaleFactor = 304.8;
415 *scaleFactor = 1 / 0.00028;
421 QString vectorString;
422 QVector<qreal>::const_iterator it = v.constBegin();
423 for ( ; it != v.constEnd(); ++it )
425 if ( it != v.constBegin() )
427 vectorString.append(
";" );
429 vectorString.append( QString::number( *it ) );
436 QVector<qreal> resultVector;
438 QStringList realList = s.split(
";" );
439 QStringList::const_iterator it = realList.constBegin();
440 for ( ; it != realList.constEnd(); ++it )
442 resultVector.append( it->toDouble() );
450 QString vectorString;
451 QVector<qreal>::const_iterator it = v.constBegin();
452 for ( ; it != v.constEnd(); ++it )
454 if ( it != v.constBegin() )
456 vectorString.append(
" " );
458 vectorString.append( QString::number( *it ) );
465 QVector<qreal> resultVector;
467 QStringList realList = s.split(
" " );
468 QStringList::const_iterator it = realList.constBegin();
469 for ( ; it != realList.constEnd(); ++it )
471 resultVector.append( it->toDouble() );
479 QString encodedValue;
481 switch ( scaleMethod )
484 encodedValue =
"diameter";
487 encodedValue =
"area";
497 if ( str ==
"diameter" )
511 if ( s.compare(
"Lighten", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
512 if ( s.compare(
"Screen", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
513 if ( s.compare(
"Dodge", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
514 if ( s.compare(
"Addition", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
515 if ( s.compare(
"Darken", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
516 if ( s.compare(
"Multiply", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
517 if ( s.compare(
"Burn", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
518 if ( s.compare(
"Overlay", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
519 if ( s.compare(
"SoftLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
520 if ( s.compare(
"HardLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
521 if ( s.compare(
"Difference", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
522 if ( s.compare(
"Subtract", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
523 return QPainter::CompositionMode_SourceOver;
535 QPixmap pixmap( size );
536 pixmap.fill( Qt::transparent );
538 painter.begin( &pixmap );
539 painter.setRenderHint( QPainter::Antialiasing );
554 maxBleed = layerMaxBleed > maxBleed ? layerMaxBleed : maxBleed;
562 QPixmap pixmap( size );
563 pixmap.fill( Qt::transparent );
565 painter.begin( &pixmap );
566 painter.setRenderHint( QPainter::Antialiasing );
571 return QIcon( pixmap );
581 QPixmap pixmap( size );
582 pixmap.fill( Qt::transparent );
585 painter.begin( &pixmap );
592 for (
int i = 0; i < size.width(); i++ )
594 QPen pen( ramp->
color((
double ) i / size.width() ) );
595 painter.setPen( pen );
596 painter.drawLine( i, 0, i, size.height() - 1 );
605 uchar pixDataRGB[] = { 255, 255, 255, 255,
610 QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
612 int width = ( rect.width() < rect.height() ) ?
613 rect.width() / 2.5 : rect.height() / 2.5;
614 QPixmap pix = QPixmap::fromImage( img.scaled( width, width ) );
617 brush.setTexture( pix );
618 painter->fillRect( rect, brush );
627 #if !defined(GEOS_VERSION_MAJOR) || !defined(GEOS_VERSION_MINOR) || \
628 ((GEOS_VERSION_MAJOR<3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR<3)))
632 double x1 = p1.x(), y1 = p1.y(), x2 = p2.x(), y2 = p2.y();
634 if ( x1 == x2 && y1 == y2 )
638 t = ( x1 == x2 ? DBL_MAX : ( y2 - y1 ) / ( x2 - x1 ) );
642 angle = ( y2 > y1 ?
M_PI / 2 :
M_PI * 3 / 2 );
644 angle = ( x2 > x1 ? 0 :
M_PI );
646 angle = ( y2 > y1 ? atan( t ) :
M_PI + atan( t ) );
648 angle = ( y2 > y1 ?
M_PI + atan( t ) : atan( t ) );
656 return QPointF( pt.x() + dist * cos( angle ), pt.y() + dist * sin( angle ) );
663 if (( t1 == DBL_MAX && t2 == DBL_MAX ) || qAbs( atan( t1 ) - atan( t2 ) ) < 0.175 )
667 if ( t1 == DBL_MAX || t2 == DBL_MAX )
673 QPointF pSwp = p1; p1 = p2; p2 = pSwp;
674 double tSwp = t1; t1 = t2; t2 = tSwp;
682 x = (( p1.y() - p2.y() ) + t2 * p2.x() - t1 * p1.x() ) / ( t2 - t1 );
685 y = p1.y() + t1 * ( x - p1.x() );
686 return QPointF( x, y );
689 static QPolygonF makeOffsetGeometry(
const QgsPolyline& polyline )
691 int i, pointCount = polyline.count();
693 QPolygonF resultLine;
694 resultLine.resize( pointCount );
696 const QgsPoint* tempPtr = polyline.data();
698 for ( i = 0; i < pointCount; ++i, tempPtr++ )
699 resultLine[i] = QPointF( tempPtr->
x(), tempPtr->
y() );
703 static QList<QPolygonF> makeOffsetGeometry(
const QgsPolygon& polygon )
705 QList<QPolygonF> resultGeom;
706 for (
int ring = 0; ring < polygon.size(); ++ring )
707 resultGeom.append( makeOffsetGeometry( polygon[ ring ] ) );
714 QList<QPolygonF> resultLine;
716 if ( polyline.count() < 2 )
718 resultLine.append( polyline );
725 #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
726 ((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
728 unsigned int i, pointCount = polyline.count();
731 QPointF* tempPtr = polyline.data();
732 for ( i = 0; i < pointCount; ++i, tempPtr++ )
733 tempPolyline[i] =
QgsPoint( tempPtr->rx(), tempPtr->ry() );
738 int quadSegments = 0;
739 double mitreLimit = 2.0;
742 offsetGeom = tempGeometry->
buffer( -dist, quadSegments, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, mitreLimit );
744 offsetGeom = tempGeometry->
offsetCurve( dist, quadSegments, GEOSBUF_JOIN_MITRE, mitreLimit );
749 tempGeometry = offsetGeom;
753 resultLine.append( makeOffsetGeometry( tempGeometry->
asPolyline() ) );
759 resultLine.append( makeOffsetGeometry( tempGeometry->
asPolygon() ) );
767 for (
int part = 0; part < tempMPolyline.count(); ++part )
769 resultLine.append( makeOffsetGeometry( tempMPolyline[ part ] ) );
778 for (
int part = 0; part < tempMPolygon.count(); ++part )
780 resultLine.append( makeOffsetGeometry( tempMPolygon[ part ] ) );
790 resultLine.append( polyline );
795 double angle = 0.0, t_new, t_old = 0;
796 QPointF pt_old, pt_new;
797 QPointF p1 = polyline[0], p2;
798 bool first_point =
true;
800 for (
int i = 1; i < polyline.count(); i++ )
804 if ( !
lineInfo( p1, p2, angle, t_new ) )
814 if ( !pt_tmp.isNull() )
818 newLine.append( pt_new );
828 newLine.append( pt_new );
830 resultLine.append( newLine );
836 QList<QPolygonF>
offsetLine( QPolygonF polyline,
double dist )
839 int pointCount = polyline.count();
841 if ( pointCount > 3 && polyline[ 0 ].x() == polyline[ pointCount - 1 ].x() && polyline[ 0 ].y() == polyline[ pointCount - 1 ].y() )
845 else if ( pointCount > 1 )
849 return offsetLine( polyline, dist, geometryType );
858 QDomNode layerNode = element.firstChild();
860 while ( !layerNode.isNull() )
862 QDomElement e = layerNode.toElement();
865 if ( e.tagName() !=
"layer" )
876 QDomElement s = e.firstChildElement(
"symbol" );
883 QgsDebugMsg(
"symbol layer refused subsymbol: " + s.attribute(
"name" ) );
886 layers.append( layer );
890 layerNode = layerNode.nextSibling();
893 if ( layers.count() == 0 )
899 QString symbolType = element.attribute(
"type" );
902 if ( symbolType ==
"line" )
904 else if ( symbolType ==
"fill" )
906 else if ( symbolType ==
"marker" )
910 QgsDebugMsg(
"unknown symbol type " + symbolType );
914 if ( element.hasAttribute(
"outputUnit" ) )
918 if ( element.hasAttribute((
"mapUnitScale" ) ) )
921 mapUnitScale.
minScale = element.attribute(
"mapUnitMinScale",
"0.0" ).toDouble();
922 mapUnitScale.
maxScale = element.attribute(
"mapUnitMaxScale",
"0.0" ).toDouble();
925 symbol->
setAlpha( element.attribute(
"alpha",
"1.0" ).toDouble() );
932 QString layerClass = element.attribute(
"class" );
933 bool locked = element.attribute(
"locked" ).toInt();
934 int pass = element.attribute(
"pass" ).toInt();
968 QDomElement symEl = doc.createElement(
"symbol" );
970 symEl.setAttribute(
"name", name );
971 symEl.setAttribute(
"alpha", QString::number( symbol->
alpha() ) );
978 QDomElement layerEl = doc.createElement(
"layer" );
979 layerEl.setAttribute(
"class", layer->
layerType() );
980 layerEl.setAttribute(
"locked", layer->
isLocked() );
985 QString subname = QString(
"@%1@%2" ).arg( name ).arg( i );
987 layerEl.appendChild( subEl );
989 symEl.appendChild( layerEl );
1002 if ( element.isNull() )
1007 QString symbolizerName = element.localName();
1009 if ( symbolizerName ==
"PointSymbolizer" )
1012 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1013 if ( graphicElem.isNull() )
1015 QgsDebugMsg(
"Graphic element not found in PointSymbolizer" );
1051 if ( symbolizerName ==
"LineSymbolizer" )
1054 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1055 if ( strokeElem.isNull() )
1057 QgsDebugMsg(
"Stroke element not found in LineSymbolizer" );
1085 if ( symbolizerName ==
"PolygonSymbolizer" )
1088 QDomElement fillElem = element.firstChildElement(
"Fill" );
1089 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1090 if ( fillElem.isNull() && strokeElem.isNull() )
1092 QgsDebugMsg(
"neither Fill nor Stroke element not found in PolygonSymbolizer" );
1146 QDomElement fillElem = element.firstChildElement(
"Fill" );
1147 if ( fillElem.isNull() )
1169 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1170 if ( strokeElem.isNull() )
1188 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1189 if ( graphicElem.isNull() )
1211 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1212 if ( graphicElem.isNull() )
1215 QDomElement externalGraphicElem = graphicElem.firstChildElement(
"ExternalGraphic" );
1216 if ( externalGraphicElem.isNull() )
1220 QDomElement formatElem = externalGraphicElem.firstChildElement(
"Format" );
1221 if ( formatElem.isNull() )
1224 QString format = formatElem.firstChild().nodeValue();
1225 if ( format !=
"image/svg+xml" )
1227 QgsDebugMsg(
"unsupported External Graphic format found: " + format );
1232 QDomElement onlineResourceElem = externalGraphicElem.firstChildElement(
"OnlineResource" );
1233 QDomElement inlineContentElem = externalGraphicElem.firstChildElement(
"InlineContent" );
1234 if ( !onlineResourceElem.isNull() )
1239 else if ( !inlineContentElem.isNull() )
1252 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1253 if ( graphicElem.isNull() )
1256 QDomElement markElem = graphicElem.firstChildElement(
"Mark" );
1257 if ( markElem.isNull() )
1260 QDomElement wellKnownNameElem = markElem.firstChildElement(
"WellKnownName" );
1261 if ( wellKnownNameElem.isNull() )
1270 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1271 if ( graphicElem.isNull() )
1274 QDomElement markElem = graphicElem.firstChildElement(
"Mark" );
1275 if ( markElem.isNull() )
1279 QDomElement formatElem = markElem.firstChildElement(
"Format" );
1280 if ( formatElem.isNull() )
1283 QString format = formatElem.firstChild().nodeValue();
1284 if ( format !=
"ttf" )
1286 QgsDebugMsg(
"unsupported Graphic Mark format found: " + format );
1291 QDomElement onlineResourceElem = markElem.firstChildElement(
"OnlineResource" );
1292 QDomElement inlineContentElem = markElem.firstChildElement(
"InlineContent" );
1293 if ( !onlineResourceElem.isNull() )
1296 QDomElement markIndexElem = markElem.firstChildElement(
"MarkIndex" );
1297 if ( !markIndexElem.isNull() )
1300 else if ( !inlineContentElem.isNull() )
1315 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1316 if ( graphicElem.isNull() )
1320 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
1322 if ( it.key() ==
"widthHeightFactor" )
1333 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1334 if ( strokeElem.isNull() )
1337 QDomElement graphicStrokeElem = strokeElem.firstChildElement(
"GraphicStroke" );
1338 if ( graphicStrokeElem.isNull() )
1346 QDomElement fillElem = element.firstChildElement(
"Fill" );
1347 if ( fillElem.isNull() )
1350 QDomElement graphicFillElem = fillElem.firstChildElement(
"GraphicFill" );
1351 if ( graphicFillElem.isNull() )
1354 QDomElement graphicElem = graphicFillElem.firstChildElement(
"Graphic" );
1355 if ( graphicElem.isNull() )
1361 QColor fillColor, borderColor;
1362 double size, borderWidth;
1363 Qt::PenStyle borderStyle;
1364 if ( !
wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
1367 if ( name !=
"horline" )
1375 double angle = angleFunc.toDouble( &ok );
1376 if ( !ok || angle == 0 )
1384 Q_UNUSED( element );
1390 QDomElement fillElem = element.firstChildElement(
"Fill" );
1391 if ( fillElem.isNull() )
1394 QDomElement graphicFillElem = fillElem.firstChildElement(
"GraphicFill" );
1395 if ( graphicFillElem.isNull() )
1415 QDomElement fillElem = element.firstChildElement(
"Fill" );
1416 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1420 bool validFill =
false, validBorder =
false;
1425 Qt::BrushStyle fillStyle;
1427 if (
fillFromSld( fillElem, fillStyle, fillColor ) )
1433 Qt::PenStyle borderStyle;
1434 double borderWidth = 1.0, dashOffset = 0.0;
1435 QVector<qreal> customDashPattern;
1437 if (
lineFromSld( strokeElem, borderStyle, borderColor, borderWidth,
1438 0, 0, &customDashPattern, &dashOffset ) )
1441 if ( validFill || validBorder )
1444 map[
"name"] =
"square";
1445 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1446 map[
"color_border"] =
encodeColor( validBorder ? borderColor : Qt::transparent );
1447 map[
"size"] = QString::number( 6 );
1448 map[
"angle"] = QString::number( 0 );
1456 bool validFill =
false, validBorder =
false;
1459 QString name, format;
1461 QColor fillColor, borderColor;
1462 double borderWidth = 1.0,
size = 0.0,
angle = 0.0;
1463 QPointF anchor, offset;
1466 QDomElement graphicFillElem = fillElem.firstChildElement(
"GraphicFill" );
1467 if ( !graphicFillElem.isNull() )
1470 QDomElement graphicElem = graphicFillElem.firstChildElement(
"Graphic" );
1471 if ( !graphicElem.isNull() )
1477 QDomElement graphicChildElem = graphicElem.firstChildElement();
1478 while ( !graphicChildElem.isNull() )
1480 if ( graphicChildElem.localName() ==
"Mark" )
1483 QDomElement wellKnownNameElem = graphicChildElem.firstChildElement(
"WellKnownName" );
1484 if ( !wellKnownNameElem.isNull() )
1486 name = wellKnownNameElem.firstChild().nodeValue();
1492 if ( graphicChildElem.localName() ==
"ExternalGraphic" || graphicChildElem.localName() ==
"Mark" )
1495 QDomElement formatElem = graphicChildElem.firstChildElement(
"Format" );
1496 if ( formatElem.isNull() )
1499 format = formatElem.firstChild().nodeValue();
1503 if ( graphicChildElem.localName() ==
"ExternalGraphic" && format !=
"image/svg+xml" )
1508 if ( graphicChildElem.localName() ==
"Mark" && format !=
"ttf" )
1512 QDomElement onlineResourceElem = graphicChildElem.firstChildElement(
"OnlineResource" );
1513 QDomElement inlineContentElem = graphicChildElem.firstChildElement(
"InlineContent" );
1515 if ( !onlineResourceElem.isNull() )
1517 name = onlineResourceElem.attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
1519 if ( graphicChildElem.localName() ==
"Mark" && format ==
"ttf" )
1522 if ( name.startsWith(
"ttf://" ) )
1523 name = name.mid( 6 );
1526 QDomElement markIndexElem = graphicChildElem.firstChildElement(
"MarkIndex" );
1527 if ( markIndexElem.isNull() )
1531 int v = markIndexElem.firstChild().nodeValue().toInt( &ok );
1542 else if ( !inlineContentElem.isNull() )
1552 if ( graphicChildElem.localName() ==
"Mark" )
1561 if ( found && graphicChildElem.localName() ==
"Mark" )
1568 Qt::BrushStyle markFillStyle;
1570 QDomElement markFillElem = graphicChildElem.firstChildElement(
"Fill" );
1571 if (
fillFromSld( markFillElem, markFillStyle, fillColor ) )
1576 Qt::PenStyle borderStyle;
1577 double borderWidth = 1.0, dashOffset = 0.0;
1578 QVector<qreal> customDashPattern;
1580 QDomElement markStrokeElem = graphicChildElem.firstChildElement(
"Stroke" );
1581 if (
lineFromSld( markStrokeElem, borderStyle, borderColor, borderWidth,
1582 0, 0, &customDashPattern, &dashOffset ) )
1589 QDomElement opacityElem = graphicElem.firstChildElement(
"Opacity" );
1590 if ( !opacityElem.isNull() )
1591 fillColor.setAlpha(
decodeSldAlpha( opacityElem.firstChild().nodeValue() ) );
1593 QDomElement sizeElem = graphicElem.firstChildElement(
"Size" );
1594 if ( !sizeElem.isNull() )
1597 double v = sizeElem.firstChild().nodeValue().toDouble( &ok );
1606 double v = angleFunc.toDouble( &ok );
1616 if ( validFill || validBorder )
1618 if ( format ==
"image/svg+xml" )
1622 map[
"fill"] = fillColor.name();
1623 map[
"outline"] = borderColor.name();
1624 map[
"outline-width"] = QString::number( borderWidth );
1626 map[
"size"] = QString::number(
size );
1628 map[
"angle"] = QString::number(
angle );
1629 if ( !offset.isNull() )
1633 else if ( format ==
"ttf" )
1637 map[
"chr"] = markIndex;
1638 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1640 map[
"size"] = QString::number(
size );
1642 map[
"angle"] = QString::number(
angle );
1643 if ( !offset.isNull() )
1650 if ( layers.isEmpty() )
1653 layerList << layers;
1660 QString patternName;
1661 switch ( brushStyle )
1666 case Qt::SolidPattern:
1667 if ( color.isValid() )
1670 if ( color.alpha() < 255 )
1675 case Qt::CrossPattern:
1676 case Qt::DiagCrossPattern:
1677 case Qt::HorPattern:
1678 case Qt::VerPattern:
1679 case Qt::BDiagPattern:
1680 case Qt::FDiagPattern:
1681 case Qt::Dense1Pattern:
1682 case Qt::Dense2Pattern:
1683 case Qt::Dense3Pattern:
1684 case Qt::Dense4Pattern:
1685 case Qt::Dense5Pattern:
1686 case Qt::Dense6Pattern:
1687 case Qt::Dense7Pattern:
1692 element.appendChild( doc.createComment( QString(
"Qt::BrushStyle '%1'' not supported yet" ).arg( brushStyle ) ) );
1696 QDomElement graphicFillElem = doc.createElement(
"se:GraphicFill" );
1697 element.appendChild( graphicFillElem );
1699 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1700 graphicFillElem.appendChild( graphicElem );
1702 QColor fillColor = patternName.startsWith(
"brush://" ) ? color : QColor();
1703 QColor borderColor = !patternName.startsWith(
"brush://" ) ? color : QColor();
1706 wellKnownMarkerToSld( doc, graphicElem, patternName, fillColor, borderColor, Qt::SolidLine, -1, -1 );
1713 brushStyle = Qt::SolidPattern;
1714 color = QColor(
"#808080" );
1716 if ( element.isNull() )
1718 brushStyle = Qt::NoBrush;
1723 QDomElement graphicFillElem = element.firstChildElement(
"GraphicFill" );
1725 if ( graphicFillElem.isNull() )
1728 for ( QgsStringMap::iterator it = svgParams.begin(); it != svgParams.end(); ++it )
1730 QgsDebugMsg( QString(
"found SvgParameter %1: %2" ).arg( it.key() ).arg( it.value() ) );
1732 if ( it.key() ==
"fill" )
1733 color = QColor( it.value() );
1734 else if ( it.key() ==
"fill-opacity" )
1740 QDomElement graphicElem = graphicFillElem.firstChildElement(
"Graphic" );
1741 if ( graphicElem.isNull() )
1744 QString patternName =
"square";
1745 QColor fillColor, borderColor;
1746 double borderWidth,
size;
1747 Qt::PenStyle borderStyle;
1748 if ( !
wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderStyle, borderWidth, size ) )
1752 if ( brushStyle == Qt::NoBrush )
1755 QColor c = patternName.startsWith(
"brush://" ) ? fillColor : borderColor;
1764 Qt::PenStyle penStyle, QColor color,
double width,
1765 const Qt::PenJoinStyle *penJoinStyle,
const Qt::PenCapStyle *penCapStyle,
1766 const QVector<qreal> *customDashPattern,
double dashOffset )
1768 QVector<qreal> dashPattern;
1769 const QVector<qreal> *pattern = &dashPattern;
1771 if ( penStyle == Qt::CustomDashLine && !customDashPattern )
1773 element.appendChild( doc.createComment(
"WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) );
1774 penStyle = Qt::DashLine;
1786 dashPattern.push_back( 4.0 );
1787 dashPattern.push_back( 2.0 );
1790 dashPattern.push_back( 1.0 );
1791 dashPattern.push_back( 2.0 );
1793 case Qt::DashDotLine:
1794 dashPattern.push_back( 4.0 );
1795 dashPattern.push_back( 2.0 );
1796 dashPattern.push_back( 1.0 );
1797 dashPattern.push_back( 2.0 );
1799 case Qt::DashDotDotLine:
1800 dashPattern.push_back( 4.0 );
1801 dashPattern.push_back( 2.0 );
1802 dashPattern.push_back( 1.0 );
1803 dashPattern.push_back( 2.0 );
1804 dashPattern.push_back( 1.0 );
1805 dashPattern.push_back( 2.0 );
1808 case Qt::CustomDashLine:
1809 Q_ASSERT( customDashPattern );
1810 pattern = customDashPattern;
1814 element.appendChild( doc.createComment( QString(
"Qt::BrushStyle '%1'' not supported yet" ).arg( penStyle ) ) );
1818 if ( color.isValid() )
1821 if ( color.alpha() < 255 )
1831 if ( pattern->size() > 0 )
1841 Qt::PenStyle &penStyle, QColor &color,
double &width,
1842 Qt::PenJoinStyle *penJoinStyle, Qt::PenCapStyle *penCapStyle,
1843 QVector<qreal> *customDashPattern,
double *dashOffset )
1847 penStyle = Qt::SolidLine;
1848 color = QColor(
"#000000" );
1851 *penJoinStyle = Qt::BevelJoin;
1853 *penCapStyle = Qt::SquareCap;
1854 if ( customDashPattern )
1855 customDashPattern->clear();
1859 if ( element.isNull() )
1861 penStyle = Qt::NoPen;
1867 for ( QgsStringMap::iterator it = svgParams.begin(); it != svgParams.end(); ++it )
1869 QgsDebugMsg( QString(
"found SvgParameter %1: %2" ).arg( it.key() ).arg( it.value() ) );
1871 if ( it.key() ==
"stroke" )
1873 color = QColor( it.value() );
1875 else if ( it.key() ==
"stroke-opacity" )
1879 else if ( it.key() ==
"stroke-width" )
1882 double w = it.value().toDouble( &ok );
1886 else if ( it.key() ==
"stroke-linejoin" && penJoinStyle )
1890 else if ( it.key() ==
"stroke-linecap" && penCapStyle )
1894 else if ( it.key() ==
"stroke-dasharray" )
1897 if ( dashPattern.size() > 0 )
1901 bool dashPatternFound =
false;
1903 if ( dashPattern.count() == 2 )
1905 if ( dashPattern.at( 0 ) == 4.0 &&
1906 dashPattern.at( 1 ) == 2.0 )
1908 penStyle = Qt::DashLine;
1909 dashPatternFound =
true;
1911 else if ( dashPattern.at( 0 ) == 1.0 &&
1912 dashPattern.at( 1 ) == 2.0 )
1914 penStyle = Qt::DotLine;
1915 dashPatternFound =
true;
1918 else if ( dashPattern.count() == 4 )
1920 if ( dashPattern.at( 0 ) == 4.0 &&
1921 dashPattern.at( 1 ) == 2.0 &&
1922 dashPattern.at( 2 ) == 1.0 &&
1923 dashPattern.at( 3 ) == 2.0 )
1925 penStyle = Qt::DashDotLine;
1926 dashPatternFound =
true;
1929 else if ( dashPattern.count() == 6 )
1931 if ( dashPattern.at( 0 ) == 4.0 &&
1932 dashPattern.at( 1 ) == 2.0 &&
1933 dashPattern.at( 2 ) == 1.0 &&
1934 dashPattern.at( 3 ) == 2.0 &&
1935 dashPattern.at( 4 ) == 1.0 &&
1936 dashPattern.at( 5 ) == 2.0 )
1938 penStyle = Qt::DashDotDotLine;
1939 dashPatternFound =
true;
1944 if ( !dashPatternFound )
1946 if ( customDashPattern )
1948 penStyle = Qt::CustomDashLine;
1949 *customDashPattern = dashPattern;
1953 QgsDebugMsg(
"custom dash pattern required but not provided. Using default dash pattern." );
1954 penStyle = Qt::DashLine;
1959 else if ( it.key() ==
"stroke-dashoffset" && dashOffset )
1962 double d = it.value().toDouble( &ok );
1972 QString path, QString mime,
1973 QColor color,
double size )
1975 QDomElement externalGraphicElem = doc.createElement(
"se:ExternalGraphic" );
1976 element.appendChild( externalGraphicElem );
1985 QDomElement sizeElem = doc.createElement(
"se:Size" );
1986 sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
1987 element.appendChild( sizeElem );
1992 QString &path, QString &mime,
1993 QColor &color,
double &
size )
1998 QDomElement externalGraphicElem = element.firstChildElement(
"ExternalGraphic" );
1999 if ( externalGraphicElem.isNull() )
2004 QDomElement sizeElem = element.firstChildElement(
"Size" );
2005 if ( !sizeElem.isNull() )
2008 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2017 QString path, QString format,
int *markIndex,
2018 QColor color,
double size )
2020 QDomElement markElem = doc.createElement(
"se:Mark" );
2021 element.appendChild( markElem );
2027 QDomElement markIndexElem = doc.createElement(
"se:MarkIndex" );
2028 markIndexElem.appendChild( doc.createTextNode( QString::number( *markIndex ) ) );
2029 markElem.appendChild( markIndexElem );
2033 QDomElement fillElem = doc.createElement(
"se:Fill" );
2034 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2035 markElem.appendChild( fillElem );
2040 QDomElement sizeElem = doc.createElement(
"se:Size" );
2041 sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
2042 element.appendChild( sizeElem );
2047 QString &path, QString &format,
int &markIndex,
2048 QColor &color,
double &
size )
2056 QDomElement markElem = element.firstChildElement(
"Mark" );
2057 if ( markElem.isNull() )
2062 QDomElement markIndexElem = markElem.firstChildElement(
"MarkIndex" );
2063 if ( !markIndexElem.isNull() )
2066 int i = markIndexElem.firstChild().nodeValue().toInt( &ok );
2072 QDomElement fillElem = markElem.firstChildElement(
"Fill" );
2073 Qt::BrushStyle b = Qt::SolidPattern;
2078 QDomElement sizeElem = element.firstChildElement(
"Size" );
2079 if ( !sizeElem.isNull() )
2082 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2091 QString name, QColor color, QColor borderColor,
2092 double borderWidth,
double size )
2094 wellKnownMarkerToSld( doc, element, name, color, borderColor, Qt::SolidLine, borderWidth, size );
2098 QString name, QColor color, QColor borderColor, Qt::PenStyle borderStyle,
2099 double borderWidth,
double size )
2101 QDomElement markElem = doc.createElement(
"se:Mark" );
2102 element.appendChild( markElem );
2104 QDomElement wellKnownNameElem = doc.createElement(
"se:WellKnownName" );
2105 wellKnownNameElem.appendChild( doc.createTextNode( name ) );
2106 markElem.appendChild( wellKnownNameElem );
2109 if ( color.isValid() )
2111 QDomElement fillElem = doc.createElement(
"se:Fill" );
2112 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2113 markElem.appendChild( fillElem );
2117 if ( borderColor.isValid() )
2119 QDomElement strokeElem = doc.createElement(
"se:Stroke" );
2120 lineToSld( doc, strokeElem, borderStyle, borderColor, borderWidth );
2121 markElem.appendChild( strokeElem );
2127 QDomElement sizeElem = doc.createElement(
"se:Size" );
2128 sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
2129 element.appendChild( sizeElem );
2134 QString &name, QColor &color, QColor &borderColor,
2135 double &borderWidth,
double &
size )
2137 Qt::PenStyle borderStyle;
2142 QString &name, QColor &color, QColor &borderColor, Qt::PenStyle &borderStyle,
2143 double &borderWidth,
double &
size )
2149 borderColor = QColor(
"#000000" );
2153 QDomElement markElem = element.firstChildElement(
"Mark" );
2154 if ( markElem.isNull() )
2157 QDomElement wellKnownNameElem = markElem.firstChildElement(
"WellKnownName" );
2158 if ( !wellKnownNameElem.isNull() )
2160 name = wellKnownNameElem.firstChild().nodeValue();
2161 QgsDebugMsg(
"found Mark with well known name: " + name );
2165 QDomElement fillElem = markElem.firstChildElement(
"Fill" );
2166 Qt::BrushStyle b = Qt::SolidPattern;
2171 QDomElement strokeElem = markElem.firstChildElement(
"Stroke" );
2172 lineFromSld( strokeElem, borderStyle, borderColor, borderWidth );
2176 QDomElement sizeElem = element.firstChildElement(
"Size" );
2177 if ( !sizeElem.isNull() )
2180 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2190 if ( !rotationFunc.isEmpty() )
2192 QDomElement rotationElem = doc.createElement(
"se:Rotation" );
2194 element.appendChild( rotationElem );
2200 QDomElement rotationElem = element.firstChildElement(
"Rotation" );
2201 if ( !rotationElem.isNull() )
2211 if ( !alphaFunc.isEmpty() )
2213 QDomElement opacityElem = doc.createElement(
"se:Opacity" );
2215 element.appendChild( opacityElem );
2221 QDomElement opacityElem = element.firstChildElement(
"Opacity" );
2222 if ( !opacityElem.isNull() )
2231 if ( offset.isNull() )
2234 QDomElement displacementElem = doc.createElement(
"se:Displacement" );
2235 element.appendChild( displacementElem );
2237 QDomElement dispXElem = doc.createElement(
"se:DisplacementX" );
2238 dispXElem.appendChild( doc.createTextNode( QString::number( offset.x() ) ) );
2240 QDomElement dispYElem = doc.createElement(
"se:DisplacementY" );
2241 dispYElem.appendChild( doc.createTextNode( QString::number( offset.y() ) ) );
2243 displacementElem.appendChild( dispXElem );
2244 displacementElem.appendChild( dispYElem );
2249 offset = QPointF( 0, 0 );
2251 QDomElement displacementElem = element.firstChildElement(
"Displacement" );
2252 if ( displacementElem.isNull() )
2255 QDomElement dispXElem = displacementElem.firstChildElement(
"DisplacementX" );
2256 if ( !dispXElem.isNull() )
2259 double offsetX = dispXElem.firstChild().nodeValue().toDouble( &ok );
2261 offset.setX( offsetX );
2264 QDomElement dispYElem = displacementElem.firstChildElement(
"DisplacementY" );
2265 if ( !dispYElem.isNull() )
2268 double offsetY = dispYElem.firstChild().nodeValue().toDouble( &ok );
2270 offset.setY( offsetY );
2277 QString label, QFont font,
2278 QColor color,
double size )
2280 QDomElement labelElem = doc.createElement(
"se:Label" );
2281 labelElem.appendChild( doc.createTextNode( label ) );
2282 element.appendChild( labelElem );
2284 QDomElement fontElem = doc.createElement(
"se:Font" );
2285 element.appendChild( fontElem );
2289 fontElem.appendChild( createSldParameterElement( doc,
"font-style",
encodeSldFontStyle( font.style() ) ) );
2290 fontElem.appendChild( createSldParameterElement( doc,
"font-weight",
encodeSldFontWeight( font.weight() ) ) );
2295 if ( color.isValid() )
2297 QDomElement fillElem = doc.createElement(
"Fill" );
2298 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2299 element.appendChild( fillElem );
2304 Qt::PenJoinStyle joinStyle,
2305 Qt::PenCapStyle capStyle,
2307 const QVector<qreal>* dashPattern )
2310 penStyle.append(
"PEN(" );
2311 penStyle.append(
"c:" );
2312 penStyle.append( c.name() );
2313 penStyle.append(
",w:" );
2315 penStyle.append( QString::number( width * mmScaleFactor ) );
2316 penStyle.append(
"mm" );
2319 if ( dashPattern && dashPattern->size() > 0 )
2321 penStyle.append(
",p:\"" );
2322 QVector<qreal>::const_iterator pIt = dashPattern->constBegin();
2323 for ( ; pIt != dashPattern->constEnd(); ++pIt )
2325 if ( pIt != dashPattern->constBegin() )
2327 penStyle.append(
" " );
2329 penStyle.append( QString::number( *pIt * mapUnitScaleFactor ) );
2330 penStyle.append(
"g" );
2332 penStyle.append(
"\"" );
2336 penStyle.append(
",cap:" );
2340 penStyle.append(
"p" );
2343 penStyle.append(
"r" );
2347 penStyle.append(
"b" );
2351 penStyle.append(
",j:" );
2352 switch ( joinStyle )
2355 penStyle.append(
"b" );
2358 penStyle.append(
"r" );
2362 penStyle.append(
"m" );
2368 penStyle.append(
",dp:" );
2369 penStyle.append( QString::number( offset * mapUnitScaleFactor ) );
2370 penStyle.append(
"g" );
2373 penStyle.append(
")" );
2380 brushStyle.append(
"BRUSH(" );
2381 brushStyle.append(
"fc:" );
2382 brushStyle.append( fillColor.name() );
2383 brushStyle.append(
")" );
2389 if ( geomFunc.isEmpty() )
2392 QDomElement geometryElem = doc.createElement(
"Geometry" );
2393 element.appendChild( geometryElem );
2423 QDomElement geometryElem = element.firstChildElement(
"Geometry" );
2424 if ( geometryElem.isNull() )
2436 element.appendChild( doc.createComment(
"Parser Error: " + expr.
parserErrorString() +
" - Expression was: " + function ) );
2440 if ( !filterElem.isNull() )
2441 element.appendChild( filterElem );
2447 QDomElement elem = element;
2448 if ( element.tagName() !=
"Filter" )
2450 QDomNodeList filterNodes = element.elementsByTagName(
"Filter" );
2451 if ( filterNodes.size() > 0 )
2453 elem = filterNodes.at( 0 ).toElement();
2457 if ( elem.isNull() )
2482 QString path, QString format )
2486 QDomElement onlineResourceElem = doc.createElement(
"se:OnlineResource" );
2487 onlineResourceElem.setAttribute(
"xlink:type",
"simple" );
2488 onlineResourceElem.setAttribute(
"xlink:href", url );
2489 element.appendChild( onlineResourceElem );
2491 QDomElement formatElem = doc.createElement(
"se:Format" );
2492 formatElem.appendChild( doc.createTextNode( format ) );
2493 element.appendChild( formatElem );
2500 QDomElement onlineResourceElem = element.firstChildElement(
"OnlineResource" );
2501 if ( onlineResourceElem.isNull() )
2504 path = onlineResourceElem.attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
2506 QDomElement formatElem = element.firstChildElement(
"Format" );
2507 if ( formatElem.isNull() )
2510 format = formatElem.firstChild().nodeValue();
2517 QDomElement nodeElem = doc.createElement(
"se:SvgParameter" );
2518 nodeElem.setAttribute(
"name", name );
2519 nodeElem.appendChild( doc.createTextNode( value ) );
2527 QDomElement paramElem = element.firstChildElement();
2528 while ( !paramElem.isNull() )
2530 if ( paramElem.localName() ==
"SvgParameter" || paramElem.localName() ==
"CssParameter" )
2532 QString name = paramElem.attribute(
"name" );
2533 QString value = paramElem.firstChild().nodeValue();
2535 if ( !name.isEmpty() && !value.isEmpty() )
2536 params[ name ] = value;
2539 paramElem = paramElem.nextSiblingElement();
2547 QDomElement nodeElem = doc.createElement(
"VendorOption" );
2548 nodeElem.setAttribute(
"name", name );
2549 nodeElem.appendChild( doc.createTextNode( value ) );
2557 QDomElement paramElem = element.firstChildElement(
"VendorOption" );
2558 while ( !paramElem.isNull() )
2560 QString name = paramElem.attribute(
"name" );
2561 QString value = paramElem.firstChild().nodeValue();
2563 if ( !name.isEmpty() && !value.isEmpty() )
2564 params[ name ] = value;
2566 paramElem = paramElem.nextSiblingElement(
"VendorOption" );
2576 QDomElement e = element.firstChildElement();
2577 while ( !e.isNull() )
2579 if ( e.tagName() !=
"prop" )
2585 QString propKey = e.attribute(
"k" );
2586 QString propValue = e.attribute(
"v" );
2587 props[propKey] = propValue;
2589 e = e.nextSiblingElement();
2597 for ( QgsStringMap::iterator it = props.begin(); it != props.end(); ++it )
2599 QDomElement propEl = doc.createElement(
"prop" );
2600 propEl.setAttribute(
"k", it.key() );
2601 propEl.setAttribute(
"v", it.value() );
2602 element.appendChild( propEl );
2611 QDomElement e = element.firstChildElement();
2613 while ( !e.isNull() )
2615 if ( e.tagName() ==
"symbol" )
2618 if ( symbol != NULL )
2619 symbols.insert( e.attribute(
"name" ), symbol );
2625 e = e.nextSiblingElement();
2632 QStringList subsymbols;
2634 for ( QMap<QString, QgsSymbolV2*>::iterator it = symbols.begin(); it != symbols.end(); ++it )
2636 if ( it.key()[0] !=
'@' )
2640 subsymbols.append( it.key() );
2642 QStringList parts = it.key().split(
"@" );
2643 if ( parts.count() < 3 )
2645 QgsDebugMsg(
"found subsymbol with invalid name: " + it.key() );
2649 QString symname = parts[1];
2650 int symlayer = parts[2].toInt();
2652 if ( !symbols.contains( symname ) )
2654 QgsDebugMsg(
"subsymbol references invalid symbol: " + symname );
2662 QgsDebugMsg(
"subsymbol references invalid symbol layer: " + QString::number( symlayer ) );
2671 QgsDebugMsg(
"symbol layer refused subsymbol: " + it.key() );
2678 for (
int i = 0; i < subsymbols.count(); i++ )
2679 symbols.take( subsymbols[i] );
2686 QDomElement symbolsElem = doc.createElement( tagName );
2689 for ( QMap<QString, QgsSymbolV2*>::iterator its = symbols.begin(); its != symbols.end(); ++its )
2691 QDomElement symEl =
saveSymbol( its.key(), its.value(), doc );
2692 symbolsElem.appendChild( symEl );
2700 foreach ( QString name, symbols.keys() )
2702 delete symbols.value( name );
2710 QString rampType = element.attribute(
"type" );
2715 if ( rampType ==
"gradient" )
2717 else if ( rampType ==
"random" )
2719 else if ( rampType ==
"colorbrewer" )
2721 else if ( rampType ==
"cpt-city" )
2725 QgsDebugMsg(
"unknown colorramp type " + rampType );
2733 QDomElement rampEl = doc.createElement(
"colorramp" );
2734 rampEl.setAttribute(
"type", ramp->
type() );
2735 rampEl.setAttribute(
"name", name );
2743 if ( !color.isValid() )
2750 return color.name();
2755 QList<QColor> colors;
2758 QStringList components = colorStr.simplified().split( QRegExp(
"(,|\\s)" ) );
2759 QStringList::iterator it = components.begin();
2760 for ( ; it != components.end(); ++it )
2763 if ( result.isValid() )
2768 if ( colors.length() > 0 )
2774 components = colorStr.split( QRegExp(
"(,|\n)" ) );
2775 it = components.begin();
2776 for ( ; it != components.end(); ++it )
2779 if ( result.isValid() )
2784 if ( colors.length() > 0 )
2790 components = colorStr.simplified().split( QString(
" " ) );
2791 it = components.begin();
2792 for ( ; it != components.end(); ++it )
2795 if ( result.isValid() )
2800 if ( colors.length() > 0 )
2806 components = colorStr.split( QString(
"\n" ) );
2807 it = components.begin();
2808 for ( ; it != components.end(); ++it )
2811 if ( result.isValid() )
2824 QMimeData *mimeData =
new QMimeData;
2825 mimeData->setColorData( QVariant( color ) );
2826 mimeData->setText( color.name() );
2833 QColor mimeColor = mimeData->colorData().value<QColor>();
2834 if ( mimeColor.isValid() )
2843 if ( textColor.isValid() )
2857 if ( data->hasFormat(
"text/xml" ) )
2860 QByteArray encodedData = data->data(
"text/xml" );
2861 QDomDocument xmlDoc;
2862 xmlDoc.setContent( encodedData );
2864 QDomElement dragDataElem = xmlDoc.documentElement();
2865 if ( dragDataElem.tagName() ==
"ColorSchemeModelDragData" )
2867 QDomNodeList nodeList = dragDataElem.childNodes();
2868 int nChildNodes = nodeList.size();
2869 QDomElement currentElem;
2871 for (
int i = 0; i < nChildNodes; ++i )
2873 currentElem = nodeList.at( i ).toElement();
2874 if ( currentElem.isNull() )
2879 QPair< QColor, QString> namedColor;
2881 namedColor.second = currentElem.attribute(
"label",
"" );
2883 mimeColors << namedColor;
2888 if ( mimeColors.length() == 0 && data->hasFormat(
"application/x-colorobject-list" ) )
2891 QByteArray encodedData = data->data(
"application/x-colorobject-list" );
2892 QDomDocument xmlDoc;
2893 xmlDoc.setContent( encodedData );
2895 QDomNodeList colorsNodes = xmlDoc.elementsByTagName( QString(
"colors" ) );
2896 if ( colorsNodes.length() > 0 )
2898 QDomElement colorsElem = colorsNodes.at( 0 ).toElement();
2899 QDomNodeList colorNodeList = colorsElem.childNodes();
2900 int nChildNodes = colorNodeList.size();
2901 QDomElement currentElem;
2903 for (
int i = 0; i < nChildNodes; ++i )
2906 currentElem = colorNodeList.at( i ).toElement();
2907 if ( currentElem.isNull() )
2912 QDomNodeList colorNodes = currentElem.elementsByTagName( QString(
"color" ) );
2913 QDomNodeList nameNodes = currentElem.elementsByTagName( QString(
"name" ) );
2915 if ( colorNodes.length() > 0 )
2917 QDomElement colorElem = colorNodes.at( 0 ).toElement();
2919 QStringList colorParts = colorElem.text().simplified().split(
" " );
2920 if ( colorParts.length() < 3 )
2925 int red = colorParts.at( 0 ).toDouble() * 255;
2926 int green = colorParts.at( 1 ).toDouble() * 255;
2927 int blue = colorParts.at( 2 ).toDouble() * 255;
2928 QPair< QColor, QString> namedColor;
2929 namedColor.first = QColor( red, green, blue );
2930 if ( nameNodes.length() > 0 )
2932 QDomElement nameElem = nameNodes.at( 0 ).toElement();
2933 namedColor.second = nameElem.text();
2935 mimeColors << namedColor;
2941 if ( mimeColors.length() == 0 && data->hasText() )
2945 QList< QColor >::iterator it = parsedColors.begin();
2946 for ( ; it != parsedColors.end(); ++it )
2948 mimeColors << qMakePair( *it, QString() );
2952 if ( mimeColors.length() == 0 && data->hasColor() )
2955 QColor mimeColor = data->colorData().value<QColor>();
2956 if ( mimeColor.isValid() )
2958 mimeColors << qMakePair( mimeColor, QString() );
2968 QMimeData* mimeData =
new QMimeData();
2969 QDomDocument xmlDoc;
2970 QDomElement xmlRootElement = xmlDoc.createElement(
"ColorSchemeModelDragData" );
2971 xmlDoc.appendChild( xmlRootElement );
2973 QgsNamedColorList::const_iterator colorIt = colorList.constBegin();
2974 for ( ; colorIt != colorList.constEnd(); ++colorIt )
2976 QDomElement namedColor = xmlDoc.createElement(
"NamedColor" );
2978 namedColor.setAttribute(
"label", ( *colorIt ).second );
2979 xmlRootElement.appendChild( namedColor );
2981 mimeData->setData(
"text/xml", xmlDoc.toByteArray() );
2989 colorIt = colorList.constBegin();
2990 QStringList colorListString;
2991 for ( ; colorIt != colorList.constEnd(); ++colorIt )
2993 colorListString << ( *colorIt ).first.name();
2995 mimeData->setText( colorListString.join(
"\n" ) );
2998 if ( colorList.length() > 0 )
3000 mimeData->setColorData( QVariant( colorList.at( 0 ).first ) );
3008 if ( !file.open( QIODevice::ReadWrite ) )
3013 QTextStream stream( &file );
3014 stream <<
"GIMP Palette" << endl;
3015 if ( paletteName.isEmpty() )
3017 stream <<
"Name: QGIS Palette" << endl;
3021 stream <<
"Name: " << paletteName << endl;
3023 stream <<
"Columns: 4" << endl;
3024 stream <<
"#" << endl;
3026 for ( QgsNamedColorList::ConstIterator colorIt = colors.constBegin(); colorIt != colors.constEnd(); ++colorIt )
3028 QColor color = ( *colorIt ).first;
3029 if ( !color.isValid() )
3033 stream << QString(
"%1 %2 %3" ).arg( color.red(), 3 ).arg( color.green(), 3 ).arg( color.blue(), 3 );
3034 stream <<
"\t" << (( *colorIt ).second.isEmpty() ? color.name() : ( *colorIt ).second ) << endl;
3045 if ( !file.open( QIODevice::ReadOnly ) )
3048 return importedColors;
3051 QTextStream in( &file );
3053 QString line = in.readLine();
3054 if ( !line.startsWith(
"GIMP Palette" ) )
3057 return importedColors;
3061 while ( !in.atEnd() && !line.startsWith(
"Name:" ) && !line.startsWith(
"#" ) )
3063 line = in.readLine();
3065 if ( line.startsWith(
"Name:" ) )
3067 QRegExp nameRx(
"Name:\\s*(\\S.*)$" );
3068 if ( nameRx.indexIn( line ) != -1 )
3070 name = nameRx.cap( 1 );
3075 while ( !in.atEnd() && !line.startsWith(
"#" ) )
3077 line = in.readLine();
3082 return importedColors;
3086 QRegExp rx(
"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)(\\s.*)?$" );
3087 while ( !in.atEnd() )
3089 line = in.readLine();
3090 if ( rx.indexIn( line ) == -1 )
3094 int red = rx.cap( 1 ).toInt();
3095 int green = rx.cap( 2 ).toInt();
3096 int blue = rx.cap( 3 ).toInt();
3097 QColor color = QColor( red, green, blue );
3098 if ( !color.isValid() )
3105 if ( rx.captureCount() > 3 )
3107 label = rx.cap( 4 ).simplified();
3114 importedColors << qMakePair( color, label );
3119 return importedColors;
3133 if ( QColor::isValidColor( colorStr ) )
3136 parsedColor.setNamedColor( colorStr );
3137 if ( parsedColor.isValid() )
3139 containsAlpha =
false;
3145 QRegExp hexColorAlphaRx(
"^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
3146 if ( hexColorAlphaRx.indexIn( colorStr ) != -1 )
3148 QString hexColor = hexColorAlphaRx.cap( 1 );
3149 parsedColor.setNamedColor( QString(
"#" ) + hexColor );
3151 int alphaHex = hexColorAlphaRx.cap( 2 ).toInt( &alphaOk, 16 );
3153 if ( parsedColor.isValid() && alphaOk )
3155 parsedColor.setAlpha( alphaHex );
3156 containsAlpha =
true;
3164 QRegExp hexColorRx2(
"^\\s*(?:[0-9a-fA-F]{3}){1,2}\\s*$" );
3165 if ( hexColorRx2.indexIn( colorStr ) != -1 )
3168 parsedColor.setNamedColor( QString(
"#" ) + colorStr );
3169 if ( parsedColor.isValid() )
3171 containsAlpha =
false;
3178 QRegExp rgbFormatRx(
"^\\s*(?:rgb)?\\(?\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*\\)?\\s*;?\\s*$" );
3179 if ( rgbFormatRx.indexIn( colorStr ) != -1 )
3181 int r = rgbFormatRx.cap( 1 ).toInt();
3182 int g = rgbFormatRx.cap( 2 ).toInt();
3183 int b = rgbFormatRx.cap( 3 ).toInt();
3184 parsedColor.setRgb( r, g, b );
3185 if ( parsedColor.isValid() )
3187 containsAlpha =
false;
3193 QRegExp rgbPercentFormatRx(
"^\\s*(?:rgb)?\\(?\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*\\)?\\s*;?\\s*$" );
3194 if ( rgbPercentFormatRx.indexIn( colorStr ) != -1 )
3196 int r = qRound( rgbPercentFormatRx.cap( 1 ).toDouble() * 2.55 );
3197 int g = qRound( rgbPercentFormatRx.cap( 2 ).toDouble() * 2.55 );
3198 int b = qRound( rgbPercentFormatRx.cap( 3 ).toDouble() * 2.55 );
3199 parsedColor.setRgb( r, g, b );
3200 if ( parsedColor.isValid() )
3202 containsAlpha =
false;
3208 QRegExp rgbaFormatRx(
"^\\s*(?:rgba)?\\(?\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*(0|0?\\.\\d*|1(?:\\.0*)?)\\s*\\)?\\s*;?\\s*$" );
3209 if ( rgbaFormatRx.indexIn( colorStr ) != -1 )
3211 int r = rgbaFormatRx.cap( 1 ).toInt();
3212 int g = rgbaFormatRx.cap( 2 ).toInt();
3213 int b = rgbaFormatRx.cap( 3 ).toInt();
3214 int a = qRound( rgbaFormatRx.cap( 4 ).toDouble() * 255.0 );
3215 parsedColor.setRgb( r, g, b, a );
3216 if ( parsedColor.isValid() )
3218 containsAlpha =
true;
3224 QRegExp rgbaPercentFormatRx(
"^\\s*(?:rgba)?\\(?\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(0|0?\\.\\d*|1(?:\\.0*)?)\\s*\\)?\\s*;?\\s*$" );
3225 if ( rgbaPercentFormatRx.indexIn( colorStr ) != -1 )
3227 int r = qRound( rgbaPercentFormatRx.cap( 1 ).toDouble() * 2.55 );
3228 int g = qRound( rgbaPercentFormatRx.cap( 2 ).toDouble() * 2.55 );
3229 int b = qRound( rgbaPercentFormatRx.cap( 3 ).toDouble() * 2.55 );
3230 int a = qRound( rgbaPercentFormatRx.cap( 4 ).toDouble() * 255.0 );
3231 parsedColor.setRgb( r, g, b, a );
3232 if ( parsedColor.isValid() )
3234 containsAlpha =
true;
3293 if ( p && p->device() )
3312 QImage::Format format = image->format();
3313 if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
3320 for (
int heightIndex = 0; heightIndex < image->height(); ++heightIndex )
3322 QRgb* scanLine = ( QRgb* )image->scanLine( heightIndex );
3323 for (
int widthIndex = 0; widthIndex < image->width(); ++widthIndex )
3325 myRgb = scanLine[widthIndex];
3326 if ( format == QImage::Format_ARGB32_Premultiplied )
3327 scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3329 scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3337 int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
3338 int alpha = ( radius < 1 ) ? 16 : ( radius > 17 ) ? 1 : tab[radius-1];
3340 if ( image.format() != QImage::Format_ARGB32_Premultiplied
3341 && image.format() != QImage::Format_RGB32 )
3343 image = image.convertToFormat( QImage::Format_ARGB32_Premultiplied );
3346 int r1 = rect.top();
3347 int r2 = rect.bottom();
3348 int c1 = rect.left();
3349 int c2 = rect.right();
3351 int bpl = image.bytesPerLine();
3359 i1 = i2 = ( QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3 );
3361 for (
int col = c1; col <= c2; col++ )
3363 p = image.scanLine( r1 ) + col * 4;
3364 for (
int i = i1; i <= i2; i++ )
3365 rgba[i] = p[i] << 4;
3368 for (
int j = r1; j < r2; j++, p += bpl )
3369 for (
int i = i1; i <= i2; i++ )
3370 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3373 for (
int row = r1; row <= r2; row++ )
3375 p = image.scanLine( row ) + c1 * 4;
3376 for (
int i = i1; i <= i2; i++ )
3377 rgba[i] = p[i] << 4;
3380 for (
int j = c1; j < c2; j++, p += 4 )
3381 for (
int i = i1; i <= i2; i++ )
3382 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3385 for (
int col = c1; col <= c2; col++ )
3387 p = image.scanLine( r2 ) + col * 4;
3388 for (
int i = i1; i <= i2; i++ )
3389 rgba[i] = p[i] << 4;
3392 for (
int j = r1; j < r2; j++, p -= bpl )
3393 for (
int i = i1; i <= i2; i++ )
3394 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3397 for (
int row = r1; row <= r2; row++ )
3399 p = image.scanLine( row ) + c2 * 4;
3400 for (
int i = i1; i <= i2; i++ )
3401 rgba[i] = p[i] << 4;
3404 for (
int j = c1; j < c2; j++, p -= 4 )
3405 for (
int i = i1; i <= i2; i++ )
3406 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3412 if ( alpha != 255 && alpha > 0 )
3416 double alphaFactor = alpha / 255.;
3417 int r = 0, g = 0, b = 0;
3418 rgb.getRgb( &r, &g, &b );
3423 rgb.setRgb( r, g, b, alpha );
3425 else if ( alpha == 0 )
3427 rgb.setRgb( 0, 0, 0, 0 );
3432 static bool _QVariantLessThan(
const QVariant& lhs,
const QVariant& rhs )
3434 switch ( lhs.type() )
3437 return lhs.toInt() < rhs.toInt();
3438 case QVariant::UInt:
3439 return lhs.toUInt() < rhs.toUInt();
3440 case QVariant::LongLong:
3441 return lhs.toLongLong() < rhs.toLongLong();
3442 case QVariant::ULongLong:
3443 return lhs.toULongLong() < rhs.toULongLong();
3444 case QVariant::Double:
3445 return lhs.toDouble() < rhs.toDouble();
3446 case QVariant::Char:
3447 return lhs.toChar() < rhs.toChar();
3448 case QVariant::Date:
3449 return lhs.toDate() < rhs.toDate();
3450 case QVariant::Time:
3451 return lhs.toTime() < rhs.toTime();
3452 case QVariant::DateTime:
3453 return lhs.toDateTime() < rhs.toDateTime();
3455 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
3459 static bool _QVariantGreaterThan(
const QVariant& lhs,
const QVariant& rhs )
3461 return ! _QVariantLessThan( lhs, rhs );
3467 if ( order == Qt::AscendingOrder )
3481 double dx = directionPoint.x() - startPoint.x();
3482 double dy = directionPoint.y() - startPoint.y();
3483 double length = sqrt( dx * dx + dy * dy );
3484 double scaleFactor = distance / length;
3485 return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
3495 for (
int i = 0; i < svgPaths.size(); i++ )
3497 QDir dir( svgPaths[i] );
3498 foreach ( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3500 svgPaths.insert( i + 1, dir.path() +
"/" + item );
3503 foreach ( QString item, dir.entryList( QStringList(
"*.svg" ), QDir::Files ) )
3506 list.append( dir.path() +
"/" + item );
3518 QStringList svgPaths;
3519 svgPaths.append( directory );
3521 for (
int i = 0; i < svgPaths.size(); i++ )
3523 QDir dir( svgPaths[i] );
3524 foreach ( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3526 svgPaths.insert( i + 1, dir.path() +
"/" + item );
3529 foreach ( QString item, dir.entryList( QStringList(
"*.svg" ), QDir::Files ) )
3531 list.append( dir.path() +
"/" + item );
3543 if ( QFile( name ).exists() )
3544 return QFileInfo( name ).canonicalFilePath();
3547 if ( name.contains(
"://" ) )
3550 if ( url.isValid() && !url.scheme().isEmpty() )
3552 if ( url.scheme().compare(
"file", Qt::CaseInsensitive ) == 0 )
3555 name = url.toLocalFile();
3556 if ( QFile( name ).exists() )
3558 return QFileInfo( name ).canonicalFilePath();
3572 for (
int i = 0; i < svgPaths.size(); i++ )
3574 QString svgPath = svgPaths[i];
3575 if ( svgPath.endsWith( QString(
"/" ) ) )
3586 QString myLocalPath = svgPath + QDir::separator() + name;
3588 QgsDebugMsg(
"Alternative svg path: " + myLocalPath );
3589 if ( QFile( myLocalPath ).exists() )
3592 return QFileInfo( myLocalPath ).canonicalFilePath();
3597 QString alternatePath = pfi.canonicalPath() + QDir::separator() + name;
3598 if ( pfi.exists() && QFile( alternatePath ).exists() )
3601 return QFileInfo( alternatePath ).canonicalFilePath();
3608 QgsDebugMsg(
"Computed alternate path but no svg there either" );
3617 QFileInfo fi( path );
3621 path = fi.canonicalFilePath();
3625 bool isInSvgPathes =
false;
3626 for (
int i = 0; i < svgPaths.size(); i++ )
3628 QString dir = QFileInfo( svgPaths[i] ).canonicalFilePath();
3630 if ( !dir.isEmpty() && path.startsWith( dir ) )
3632 path = path.mid( dir.size() + 1 );
3633 isInSvgPathes =
true;
3638 if ( isInSvgPathes )
3647 double cx = 0, cy = 0;
3648 double area, sum = 0;
3649 for (
int i = points.count() - 1, j = 0; j < points.count(); i = j++ )
3651 const QPointF& p1 = points[i];
3652 const QPointF& p2 = points[j];
3653 area = p1.x() * p2.y() - p1.y() * p2.x();
3655 cx += ( p1.x() + p2.x() ) * area;
3656 cy += ( p1.y() + p2.y() ) * area;
3663 if ( points.count() >= 2 )
3664 return QPointF(( points[0].x() + points[1].x() ) / 2, ( points[0].y() + points[1].y() ) / 2 );
3665 else if ( points.count() == 1 )
3673 return QPointF( cx, cy );
3683 unsigned int i, pointCount = points.count();
3686 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPoint( points[i].x(), points[i].y() );
3693 if ( pointOnSurfaceGeom )
3696 delete pointOnSurfaceGeom;
3699 return QPointF( point.
x(), point.
y() );
3709 bool inside =
false;
3711 double x = point.x();
3712 double y = point.y();
3714 for (
int i = 0, j = points.count() - 1; i < points.count(); i++ )
3716 const QPointF& p1 = points[i];
3717 const QPointF& p2 = points[j];
3719 if ( p1.x() == x && p1.y() == y )
3722 if (( p1.y() < y && p2.y() >= y ) || ( p2.y() < y && p1.y() >= y ) )
3724 if ( p1.x() + ( y - p1.y() ) / ( p2.y() - p1.y() )*( p2.x() - p1.x() ) <= x )
3735 if ( fieldOrExpression.isEmpty() )
3754 return static_cast<const QgsExpression::NodeColumnRef*>( n )->name();