本文整理汇总了C++中qgsattributemap::const_iterator::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::toString方法的具体用法?C++ const_iterator::toString怎么用?C++ const_iterator::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgsattributemap::const_iterator
的用法示例。
在下文中一共展示了const_iterator::toString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFeatureGeoJSON
QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, QgsCoordinateReferenceSystem &, QMap< int, QgsField > fields, QSet<QString> hiddenAttributes ) /*const*/
{
QString fStr = "{\"type\": \"Feature\",\n";
fStr += " \"id\": ";
fStr += QString::number( feat->id() );
fStr += ",\n";
QgsGeometry* geom = feat->geometry();
if ( geom && mWithGeom )
{
QgsRectangle box = geom->boundingBox();
fStr += " \"bbox\": [ " + QString::number( box.xMinimum(), 'f', 6 ).remove( QRegExp( "[0]{1,5}$" ) ) + ", " + QString::number( box.yMinimum(), 'f', 6 ).remove( QRegExp( "[0]{1,5}$" ) ) + ", " + QString::number( box.xMaximum(), 'f', 6 ).remove( QRegExp( "[0]{1,5}$" ) ) + ", " + QString::number( box.yMaximum(), 'f', 6 ).remove( QRegExp( "[0]{1,5}$" ) ) + "],\n";
fStr += " \"geometry\": ";
fStr += geom->exportToGeoJSON();
fStr += ",\n";
}
//read all attribute values from the feature
fStr += " \"properties\": {\n";
QgsAttributeMap featureAttributes = feat->attributeMap();
int attributeCounter = 0;
for ( QgsAttributeMap::const_iterator it = featureAttributes.begin(); it != featureAttributes.end(); ++it )
{
QString attributeName = fields[it.key()].name();
//skip attribute if it has edit type 'hidden'
if ( hiddenAttributes.contains( attributeName ) )
{
continue;
}
if ( attributeCounter == 0 )
fStr += " \"";
else
fStr += " ,\"";
fStr += attributeName;
fStr += "\": ";
if ( it->type() == 6 || it->type() == 2 )
{
fStr += it->toString();
}
else
{
fStr += "\"";
fStr += it->toString().replace( QString( "\"" ), QString( "\\\"" ) );
fStr += "\"";
}
fStr += "\n";
++attributeCounter;
}
fStr += " }\n";
fStr += " }";
return fStr;
}
示例2: createFeatureElem
QDomElement QgsWFSServer::createFeatureElem( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QMap< int, QgsField > fields, QSet<QString> hiddenAttributes ) /*const*/
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( "gml:featureMember"/*wfs:FeatureMember*/ );
//qgs:%TYPENAME%
QDomElement typeNameElement = doc.createElement( "qgs:" + mTypeName.replace( QString( " " ), QString( "_" ) )/*qgs:%TYPENAME%*/ );
typeNameElement.setAttribute( "fid", QString::number( feat->id() ) );
featureElement.appendChild( typeNameElement );
if ( mWithGeom )
{
//add geometry column (as gml)
QgsGeometry* geom = feat->geometry();
QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = createGeometryElem( geom, doc );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
QDomElement bbElem = doc.createElement( "gml:boundedBy" );
QDomElement boxElem = createBoxElem( &box, doc );
if ( crs.isValid() )
{
boxElem.setAttribute( "srsName", crs.authid() );
gmlElem.setAttribute( "srsName", crs.authid() );
}
bbElem.appendChild( boxElem );
typeNameElement.appendChild( bbElem );
geomElem.appendChild( gmlElem );
typeNameElement.appendChild( geomElem );
}
}
//read all attribute values from the feature
QgsAttributeMap featureAttributes = feat->attributeMap();
for ( QgsAttributeMap::const_iterator it = featureAttributes.begin(); it != featureAttributes.end(); ++it )
{
QString attributeName = fields[it.key()].name();
//skip attribute if it has edit type 'hidden'
if ( hiddenAttributes.contains( attributeName ) )
{
continue;
}
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomText fieldText = doc.createTextNode( it->toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
}
return featureElement;
}
示例3: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
{
// if no symbol found use default one
//return symbolForValue( QVariant( "" ) );
// What is default? Empty string may be a legal value, and features not found
// should not be rendered using empty string value category symbology.
// We also need to get NULL in that case so that willRenderFeature()
// may be used to count features.
return 0;
}
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例4: getLabel
QString QgsPointDisplacementRenderer::getLabel( const QgsFeature& f )
{
QString attribute;
QgsAttributeMap attMap = f.attributeMap();
if ( attMap.size() > 0 )
{
QgsAttributeMap::const_iterator valIt = attMap.find( mLabelIndex );
if ( valIt != attMap.constEnd() )
{
attribute = valIt->toString();
}
}
return attribute;
}
示例5: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
return NULL;
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例6: fieldValue
QString QgsLabel::fieldValue( int attr, QgsFeature &feature )
{
if ( mLabelFieldIdx[attr] == -1 )
{
return QString();
}
const QgsAttributeMap& attrs = feature.attributeMap();
QgsAttributeMap::const_iterator it = attrs.find( mLabelFieldIdx[attr] );
if ( it != attrs.end() )
{
return it->toString();
}
else
{
return QString();
}
}
示例7: addFeature
bool QgsGPXProvider::addFeature( QgsFeature& f )
{
unsigned char* geo = f.geometry()->asWkb();
QGis::WkbType wkbType = f.geometry()->wkbType();
bool success = false;
QgsGPSObject* obj = NULL;
const QgsAttributeMap& attrs( f.attributeMap() );
QgsAttributeMap::const_iterator it;
// is it a waypoint?
if ( mFeatureType == WaypointType && geo != NULL && wkbType == QGis::WKBPoint )
{
// add geometry
QgsWaypoint wpt;
std::memcpy( &wpt.lon, geo + 5, sizeof( double ) );
std::memcpy( &wpt.lat, geo + 13, sizeof( double ) );
// add waypoint-specific attributes
for ( it = attrs.begin(); it != attrs.end(); ++it )
{
if ( it.key() == EleAttr )
{
bool eleIsOK;
double ele = it->toDouble( &eleIsOK );
if ( eleIsOK )
wpt.ele = ele;
}
else if ( it.key() == SymAttr )
{
wpt.sym = it->toString();
}
}
QgsGPSData::WaypointIterator iter = data->addWaypoint( wpt );
success = true;
obj = &( *iter );
}
// is it a route?
if ( mFeatureType == RouteType && geo != NULL && wkbType == QGis::WKBLineString )
{
QgsRoute rte;
// reset bounds
rte.xMin = std::numeric_limits<double>::max();
rte.xMax = -std::numeric_limits<double>::max();
rte.yMin = std::numeric_limits<double>::max();
rte.yMax = -std::numeric_limits<double>::max();
// add geometry
int nPoints;
std::memcpy( &nPoints, geo + 5, 4 );
for ( int i = 0; i < nPoints; ++i )
{
double lat, lon;
std::memcpy( &lon, geo + 9 + 16 * i, sizeof( double ) );
std::memcpy( &lat, geo + 9 + 16 * i + 8, sizeof( double ) );
QgsRoutepoint rtept;
rtept.lat = lat;
rtept.lon = lon;
rte.points.push_back( rtept );
rte.xMin = rte.xMin < lon ? rte.xMin : lon;
rte.xMax = rte.xMax > lon ? rte.xMax : lon;
rte.yMin = rte.yMin < lat ? rte.yMin : lat;
rte.yMax = rte.yMax > lat ? rte.yMax : lat;
}
// add route-specific attributes
for ( it = attrs.begin(); it != attrs.end(); ++it )
{
if ( it.key() == NumAttr )
{
bool numIsOK;
long num = it->toInt( &numIsOK );
if ( numIsOK )
rte.number = num;
}
}
QgsGPSData::RouteIterator iter = data->addRoute( rte );
success = true;
obj = &( *iter );
}
// is it a track?
if ( mFeatureType == TrackType && geo != NULL && wkbType == QGis::WKBLineString )
{
QgsTrack trk;
QgsTrackSegment trkseg;
// reset bounds
trk.xMin = std::numeric_limits<double>::max();
trk.xMax = -std::numeric_limits<double>::max();
trk.yMin = std::numeric_limits<double>::max();
trk.yMax = -std::numeric_limits<double>::max();
// add geometry
//.........这里部分代码省略.........