本文整理汇总了C++中OGRFeature::SetStyleString方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::SetStyleString方法的具体用法?C++ OGRFeature::SetStyleString怎么用?C++ OGRFeature::SetStyleString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::SetStyleString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
oLine.setPoint( 1,
dfArrowX2 - dfVec2X*3 - dfVec1X,
dfArrowY2 - dfVec2Y*3 - dfVec1Y );
poMLS->addGeometry( &oLine );
poFeature->SetGeometryDirectly( poMLS );
PrepareLineStyle( poFeature );
/* -------------------------------------------------------------------- */
/* Is the layer disabled/hidden/frozen/off? */
/* -------------------------------------------------------------------- */
CPLString osLayer = poFeature->GetFieldAsString("Layer");
int bHidden =
EQUAL(poDS->LookupLayerProperty( osLayer, "Hidden" ), "1");
/* -------------------------------------------------------------------- */
/* Work out the color for this feature. */
/* -------------------------------------------------------------------- */
int nColor = 256;
if( oStyleProperties.count("Color") > 0 )
nColor = atoi(oStyleProperties["Color"]);
// Use layer color?
if( nColor < 1 || nColor > 255 )
{
const char *pszValue = poDS->LookupLayerProperty( osLayer, "Color" );
if( pszValue != NULL )
nColor = atoi(pszValue);
}
if( nColor < 1 || nColor > 255 )
nColor = 8;
/* -------------------------------------------------------------------- */
/* Prepare a new feature to serve as the dimension text label */
/* feature. We will push it onto the layer as a pending */
/* feature for the next feature read. */
/* -------------------------------------------------------------------- */
// a single space suppresses labeling.
if( osText == " " )
return poFeature;
OGRFeature *poLabelFeature = poFeature->Clone();
poLabelFeature->SetGeometryDirectly( new OGRPoint( oTextPos.x, oTextPos.y ) );
// Do we need to compute the dimension value?
if( osText.empty() )
{
FormatDimension( osText, POINT_DIST( oArrow1.x, oArrow1.y,
dfArrowX2, dfArrowY2 ) );
}
CPLString osStyle;
char szBuffer[64];
char* pszComma = NULL;
osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\",p:5",osText.c_str());
if( dfAngle != 0.0 )
{
CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfAngle);
pszComma = strchr(szBuffer, ',');
if (pszComma)
*pszComma = '.';
osStyle += CPLString().Printf(",a:%s", szBuffer);
}
if( dfHeight != 0.0 )
{
CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfHeight);
pszComma = strchr(szBuffer, ',');
if (pszComma)
*pszComma = '.';
osStyle += CPLString().Printf(",s:%sg", szBuffer);
}
const unsigned char *pabyDWGColors = ACGetColorTable();
snprintf( szBuffer, sizeof(szBuffer), ",c:#%02x%02x%02x",
pabyDWGColors[nColor*3+0],
pabyDWGColors[nColor*3+1],
pabyDWGColors[nColor*3+2] );
osStyle += szBuffer;
if( bHidden )
osStyle += "00";
osStyle += ")";
poLabelFeature->SetStyleString( osStyle );
apoPendingFeatures.push( poLabelFeature );
return poFeature;
}
示例2: if
OGRFeature *OGROpenAirLabelLayer::GetNextRawFeature()
{
const char* pszLine;
double dfLat = 0, dfLon = 0;
int bHasCoord = FALSE;
while(TRUE)
{
pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);
if (pszLine == NULL)
return NULL;
if (pszLine[0] == '*' || pszLine[0] == '\0')
continue;
if (EQUALN(pszLine, "AC ", 3))
{
if (osCLASS.size() != 0)
{
osNAME = "";
osCEILING = "";
osFLOOR = "";
}
osCLASS = pszLine + 3;
}
else if (EQUALN(pszLine, "AN ", 3))
osNAME = pszLine + 3;
else if (EQUALN(pszLine, "AH ", 3))
osCEILING = pszLine + 3;
else if (EQUALN(pszLine, "AL ", 3))
osFLOOR = pszLine + 3;
else if (EQUALN(pszLine, "AT ", 3))
{
bHasCoord = OGROpenAirGetLatLon(pszLine + 3, dfLat, dfLon);
break;
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetField(0, osCLASS.c_str());
poFeature->SetField(1, osNAME.c_str());
poFeature->SetField(2, osFLOOR.c_str());
poFeature->SetField(3, osCEILING.c_str());
CPLString osStyle;
osStyle.Printf("LABEL(t:\"%s\")", osNAME.c_str());
poFeature->SetStyleString(osStyle.c_str());
if (bHasCoord)
{
OGRPoint* poPoint = new OGRPoint(dfLon, dfLat);
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
poFeature->SetFID(nNextFID++);
return poFeature;
}
示例3: if
//.........这里部分代码省略.........
oLR.addPoint(dfSecondLon, dfSecondLat);
/* dfLastLat = oLR.getY(oLR.getNumPoints() - 1); */
/* dfLastLon = oLR.getX(oLR.getNumPoints() - 1); */
}
CSLDestroy(papszTokens);
}
else if ((EQUALN(pszLine, "DC ", 3) || EQUALN(pszLine, "DC=", 3)) &&
(bHasCenter || strstr(pszLine, "V X=") != NULL))
{
if (!bHasCenter)
{
const char* pszVX = strstr(pszLine, "V X=");
bHasCenter = OGROpenAirGetLatLon(pszVX, dfCenterLat, dfCenterLon);
}
if (bHasCenter)
{
pszLine += 3;
double dfRADIUS = CPLAtof(pszLine) * 1852;
double dfAngle;
double dfLat, dfLon;
for(dfAngle = 0; dfAngle < 360; dfAngle += 1)
{
OGRXPlane_ExtendPosition(dfCenterLat, dfCenterLon,
dfRADIUS, dfAngle, &dfLat, &dfLon);
oLR.addPoint(dfLon, dfLat);
}
OGRXPlane_ExtendPosition(dfCenterLat, dfCenterLon,
dfRADIUS, 0, &dfLat, &dfLon);
oLR.addPoint(dfLon, dfLat);
/* dfLastLat = oLR.getY(oLR.getNumPoints() - 1); */
/* dfLastLon = oLR.getX(oLR.getNumPoints() - 1); */
}
}
else if (EQUALN(pszLine, "V X=", 4))
{
bHasCenter =
OGROpenAirGetLatLon(pszLine + 4, dfCenterLat, dfCenterLon);
}
else if (EQUALN(pszLine, "V D=-", 5))
{
bClockWise = FALSE;
}
else if (EQUALN(pszLine, "V D=+", 5))
{
bClockWise = TRUE;
}
else
{
//CPLDebug("OpenAir", "Unexpected content : %s", pszLine);
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetField(0, osCLASS.c_str());
poFeature->SetField(1, osNAME.c_str());
poFeature->SetField(2, osFLOOR.c_str());
poFeature->SetField(3, osCEILING.c_str());
if (sStyle.penStyle != -1 || sStyle.fillR != -1)
{
CPLString osStyle;
if (sStyle.penStyle != -1)
{
osStyle += CPLString().Printf("PEN(c:#%02X%02X%02X,w:%dpt",
sStyle.penR, sStyle.penG, sStyle.penB,
sStyle.penWidth);
if (sStyle.penStyle == 1)
osStyle += ",p:\"5px 5px\"";
osStyle += ")";
}
if (sStyle.fillR != -1)
{
if (osStyle.size() != 0)
osStyle += ";";
osStyle += CPLString().Printf("BRUSH(fc:#%02X%02X%02X)",
sStyle.fillR, sStyle.fillG, sStyle.fillB);
}
else
{
if (osStyle.size() != 0)
osStyle += ";";
osStyle += "BRUSH(fc:#00000000,id:\"ogr-brush-1\")";
}
if (osStyle.size() != 0)
poFeature->SetStyleString(osStyle);
}
OGRPolygon* poPoly = new OGRPolygon();
oLR.closeRings();
poPoly->addRing(&oLR);
poPoly->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoly);
poFeature->SetFID(nNextFID++);
return poFeature;
}
示例4: OGRFeature
OGRFeature *OGRDWGLayer::TranslateHATCH( OdDbEntityPtr poEntity )
{
OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
OdDbHatchPtr poHatch = OdDbHatch::cast( poEntity );
OGRGeometryCollection oGC;
TranslateGenericProperties( poFeature, poEntity );
poFeature->SetField( "Text",
(const char *) poHatch->patternName() );
/* -------------------------------------------------------------------- */
/* Collect the loops. */
/* -------------------------------------------------------------------- */
for( int i = 0; i < poHatch->numLoops(); i++ )
{
DWGCollectBoundaryLoop( poHatch, i, &oGC );
}
/* -------------------------------------------------------------------- */
/* Try to turn the set of lines into something useful. */
/* -------------------------------------------------------------------- */
OGRErr eErr;
OGRGeometryH hFinalGeom =
OGRBuildPolygonFromEdges( (OGRGeometryH) &oGC,
TRUE, TRUE, 0.0000001, &eErr );
poFeature->SetGeometryDirectly( (OGRGeometry *) hFinalGeom );
/* -------------------------------------------------------------------- */
/* Work out the color for this feature. For now we just assume */
/* solid fill. We cannot trivially translate the various sorts */
/* of hatching. */
/* -------------------------------------------------------------------- */
CPLString osLayer = poFeature->GetFieldAsString("Layer");
int nColor = 256;
if( oStyleProperties.count("Color") > 0 )
nColor = atoi(oStyleProperties["Color"]);
// Use layer color?
if( nColor < 1 || nColor > 255 )
{
const char *pszValue = poDS->LookupLayerProperty( osLayer, "Color" );
if( pszValue != NULL )
nColor = atoi(pszValue);
}
/* -------------------------------------------------------------------- */
/* Setup the style string. */
/* -------------------------------------------------------------------- */
if( nColor >= 1 && nColor <= 255 )
{
CPLString osStyle;
const unsigned char *pabyDWGColors = ACGetColorTable();
osStyle.Printf( "BRUSH(fc:#%02x%02x%02x)",
pabyDWGColors[nColor*3+0],
pabyDWGColors[nColor*3+1],
pabyDWGColors[nColor*3+2] );
poFeature->SetStyleString( osStyle );
}
return poFeature;
}
示例5: OGRFeature
OGRFeature *OGRDXFLayer::TranslateHATCH()
{
char szLineBuf[257];
int nCode;
OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
CPLString osHatchPattern;
int nFillFlag = 0;
OGRGeometryCollection oGC;
while( (nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf))) > 0 )
{
switch( nCode )
{
case 70:
nFillFlag = atoi(szLineBuf);
break;
case 2:
osHatchPattern = szLineBuf;
poFeature->SetField( "Text", osHatchPattern.c_str() );
break;
case 91:
{
int nBoundaryPathCount = atoi(szLineBuf);
int iBoundary;
for( iBoundary = 0; iBoundary < nBoundaryPathCount; iBoundary++ )
{
if (CollectBoundaryPath( &oGC ) != OGRERR_NONE)
break;
}
}
break;
default:
TranslateGenericProperty( poFeature, nCode, szLineBuf );
break;
}
}
if( nCode == 0 )
poDS->UnreadValue();
/* -------------------------------------------------------------------- */
/* Try to turn the set of lines into something useful. */
/* -------------------------------------------------------------------- */
OGRErr eErr;
OGRGeometry* poFinalGeom = (OGRGeometry *)
OGRBuildPolygonFromEdges( (OGRGeometryH) &oGC,
TRUE, TRUE, 0.0000001, &eErr );
if( eErr != OGRERR_NONE )
{
delete poFinalGeom;
OGRMultiLineString* poMLS = new OGRMultiLineString();
for(int i=0;i<oGC.getNumGeometries();i++)
poMLS->addGeometry(oGC.getGeometryRef(i));
poFinalGeom = poMLS;
}
ApplyOCSTransformer( poFinalGeom );
poFeature->SetGeometryDirectly( poFinalGeom );
/* -------------------------------------------------------------------- */
/* Work out the color for this feature. For now we just assume */
/* solid fill. We cannot trivially translate the various sorts */
/* of hatching. */
/* -------------------------------------------------------------------- */
CPLString osLayer = poFeature->GetFieldAsString("Layer");
int nColor = 256;
if( oStyleProperties.count("Color") > 0 )
nColor = atoi(oStyleProperties["Color"]);
// Use layer color?
if( nColor < 1 || nColor > 255 )
{
const char *pszValue = poDS->LookupLayerProperty( osLayer, "Color" );
if( pszValue != NULL )
nColor = atoi(pszValue);
}
/* -------------------------------------------------------------------- */
/* Setup the style string. */
/* -------------------------------------------------------------------- */
if( nColor >= 1 && nColor <= 255 )
{
CPLString osStyle;
const unsigned char *pabyDXFColors = ACGetColorTable();
osStyle.Printf( "BRUSH(fc:#%02x%02x%02x)",
pabyDXFColors[nColor*3+0],
pabyDXFColors[nColor*3+1],
pabyDXFColors[nColor*3+2] );
poFeature->SetStyleString( osStyle );
//.........这里部分代码省略.........
示例6: if
//.........这里部分代码省略.........
psEMP->vertices[i].z );
}
poPolygon->addRingDirectly( poLine );
poFeature->SetGeometryDirectly( poPolygon );
ConsiderBrush( psElement, szPen, poFeature );
}
else if( psElement->type == DGNT_CURVE )
{
DGNElemMultiPoint *psEMP = (DGNElemMultiPoint *) psElement;
OGRLineString *poLine = new OGRLineString();
DGNPoint *pasPoints;
int nPoints;
nPoints = 5 * psEMP->num_vertices;
pasPoints = (DGNPoint *) CPLMalloc(sizeof(DGNPoint) * nPoints);
DGNStrokeCurve( hDGN, psEMP, nPoints, pasPoints );
poLine->setNumPoints( nPoints );
for( int i = 0; i < nPoints; i++ )
{
poLine->setPoint( i,
pasPoints[i].x,
pasPoints[i].y,
pasPoints[i].z );
}
poFeature->SetGeometryDirectly( poLine );
CPLFree( pasPoints );
poFeature->SetStyleString( szPen );
}
else
{
OGRLineString *poLine = new OGRLineString();
DGNElemMultiPoint *psEMP = (DGNElemMultiPoint *) psElement;
if( psEMP->num_vertices > 0 )
{
poLine->setNumPoints( psEMP->num_vertices );
for( int i = 0; i < psEMP->num_vertices; i++ )
{
poLine->setPoint( i,
psEMP->vertices[i].x,
psEMP->vertices[i].y,
psEMP->vertices[i].z );
}
poFeature->SetGeometryDirectly( poLine );
}
poFeature->SetStyleString( szPen );
}
break;
case DGNST_ARC:
{
OGRLineString *poLine = new OGRLineString();
DGNElemArc *psArc = (DGNElemArc *) psElement;
DGNPoint asPoints[90];
int nPoints;
nPoints = (int) (MAX(1,ABS(psArc->sweepang) / 5) + 1);
示例7: OGRPoint
OGRFeature *OGRCADLayer::GetFeature( GIntBig nFID )
{
if( poCADLayer.getGeometryCount() <= static_cast<size_t>(nFID)
|| nFID < 0 )
{
return nullptr;
}
OGRFeature *poFeature = nullptr;
CADGeometry *poCADGeometry = poCADLayer.getGeometry( static_cast<size_t>(nFID) );
if( nullptr == poCADGeometry || GetLastErrorCode() != CADErrorCodes::SUCCESS )
{
CPLError( CE_Failure, CPLE_NotSupported,
"Failed to get geometry with ID = " CPL_FRMT_GIB " from layer \"%s\". Libopencad errorcode: %d",
nFID, poCADLayer.getName().c_str(), GetLastErrorCode() );
return nullptr;
}
poFeature = new OGRFeature( poFeatureDefn );
poFeature->SetFID( nFID );
poFeature->SetField( FIELD_NAME_THICKNESS, poCADGeometry->getThickness() );
if( !poCADGeometry->getEED().empty() )
{
std::vector<std::string> asGeometryEED = poCADGeometry->getEED();
std::string sEEDAsOneString = "";
for ( std::vector<std::string>::const_iterator
iter = asGeometryEED.cbegin();
iter != asGeometryEED.cend(); ++iter )
{
sEEDAsOneString += *iter;
sEEDAsOneString += ' ';
}
poFeature->SetField( FIELD_NAME_EXT_DATA, sEEDAsOneString.c_str() );
}
RGBColor stRGB = poCADGeometry->getColor();
CPLString sHexColor;
sHexColor.Printf("#%02X%02X%02X%02X", stRGB.R, stRGB.G, stRGB.B, 255);
poFeature->SetField( FIELD_NAME_COLOR, sHexColor );
CPLString sStyle;
sStyle.Printf("PEN(c:%s,w:5px)", sHexColor.c_str());
poFeature->SetStyleString( sStyle );
std::vector< CADAttrib > oBlockAttrs = poCADGeometry->getBlockAttributes();
for( const CADAttrib& oAttrib : oBlockAttrs )
{
CPLString osTag = oAttrib.getTag();
auto featureAttrIt = asFeaturesAttributes.find( osTag );
if( featureAttrIt != asFeaturesAttributes.end())
{
poFeature->SetField(*featureAttrIt, oAttrib.getTextValue().c_str());
}
}
switch( poCADGeometry->getType() )
{
case CADGeometry::POINT:
{
CADPoint3D * const poCADPoint = ( CADPoint3D* ) poCADGeometry;
CADVector stPositionVector = poCADPoint->getPosition();
poFeature->SetGeometryDirectly( new OGRPoint( stPositionVector.getX(),
stPositionVector.getY(),
stPositionVector.getZ() ) );
poFeature->SetField( FIELD_NAME_GEOMTYPE, "CADPoint" );
break;
}
case CADGeometry::LINE:
{
CADLine * const poCADLine = ( CADLine* ) poCADGeometry;
OGRLineString *poLS = new OGRLineString();
poLS->addPoint( poCADLine->getStart().getPosition().getX(),
poCADLine->getStart().getPosition().getY(),
poCADLine->getStart().getPosition().getZ() );
poLS->addPoint( poCADLine->getEnd().getPosition().getX(),
poCADLine->getEnd().getPosition().getY(),
poCADLine->getEnd().getPosition().getZ() );
poFeature->SetGeometryDirectly( poLS );
poFeature->SetField( FIELD_NAME_GEOMTYPE, "CADLine" );
break;
}
case CADGeometry::SOLID:
{
CADSolid * const poCADSolid = ( CADSolid* ) poCADGeometry;
OGRPolygon * poPoly = new OGRPolygon();
OGRLinearRing * poLR = new OGRLinearRing();
std::vector<CADVector> astSolidCorners = poCADSolid->getCorners();
for( size_t i = 0; i < astSolidCorners.size(); ++i )
{
poLR->addPoint( astSolidCorners[i].getX(),
astSolidCorners[i].getY(),
astSolidCorners[i].getZ());
//.........这里部分代码省略.........