本文整理汇总了C++中LineString::getSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ LineString::getSegment方法的具体用法?C++ LineString::getSegment怎么用?C++ LineString::getSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineString
的用法示例。
在下文中一共展示了LineString::getSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
osg::Node* BuildTextOperator::operator()(const FeatureList& features,
const TextSymbol* symbol,
const FilterContext& context)
{
if (!symbol) return 0;
std::set< std::string > labelNames;
bool removeDuplicateLabels = symbol->removeDuplicateLabels().isSet() ? symbol->removeDuplicateLabels().get() : false;
StringExpression contentExpr = *symbol->content();
osg::Geode* result = new osg::Geode;
for (FeatureList::const_iterator itr = features.begin(); itr != features.end(); ++itr)
{
Feature* feature = itr->get();
if (!feature->getGeometry()) continue;
std::string text;
if (symbol->content().isSet())
{
//Get the text from the specified content and referenced attributes
text = feature->eval( contentExpr );
}
if (text.empty()) continue;
//See if there is a duplicate name
if (removeDuplicateLabels && labelNames.find(text) != labelNames.end()) continue;
bool rotateToScreen = symbol->rotateToScreen().isSet() ? symbol->rotateToScreen().value() : false;
// find the centroid
osg::Vec3d position;
osg::Quat orientation;
GeometryIterator gi( feature->getGeometry() );
while( gi.hasMore() )
{
Geometry* geom = gi.next();
TextSymbol::LinePlacement linePlacement = symbol->linePlacement().isSet() ? symbol->linePlacement().get() : TextSymbol::LINEPLACEMENT_ALONG_LINE;
if (geom->getType() == Symbology::Geometry::TYPE_LINESTRING && linePlacement == TextSymbol::LINEPLACEMENT_ALONG_LINE)
{
//Compute the "middle" of the line string
LineString* lineString = static_cast<LineString*>(geom);
double length = lineString->getLength();
double center = length / 2.0;
osg::Vec3d start, end;
if (lineString->getSegment(center, start, end))
{
TextSymbol::LineOrientation lineOrientation = symbol->lineOrientation().isSet() ? symbol->lineOrientation().get() : TextSymbol::LINEORIENTATION_HORIZONTAL;
position = (end + start) / 2.0;
//We don't want to orient the text at all if we are rotating to the screen
if (!rotateToScreen && lineOrientation != TextSymbol::LINEORIENTATION_HORIZONTAL)
{
osg::Vec3d dir = (end-start);
dir.normalize();
if (lineOrientation == TextSymbol::LINEORIENTATION_PERPENDICULAR)
{
osg::Vec3d up(0,0,1);
const SpatialReference* srs = context.profile()->getSRS();
if (srs && context.isGeocentric() && srs->getEllipsoid())
{
osg::Vec3d w = context.toWorld( position );
up = srs->getEllipsoid()->computeLocalUpVector(w.x(), w.y(), w.z());
}
dir = up ^ dir;
}
orientation.makeRotate(osg::Vec3d(1,0,0), dir);
}
}
else
{
//Fall back on using the center
position = lineString->getBounds().center();
}
}
else
{
position = geom->getBounds().center();
}
}
osgText::Text* t = new osgText::Text();
t->setText( text );
std::string font = "fonts/arial.ttf";
if (symbol->font().isSet() && !symbol->font().get().empty())
{
font = symbol->font().value();
}
t->setFont( font );
t->setAutoRotateToScreen( rotateToScreen );
TextSymbol::SizeMode sizeMode = symbol->sizeMode().isSet() ? symbol->sizeMode().get() : TextSymbol::SIZEMODE_SCREEN;
if (sizeMode == TextSymbol::SIZEMODE_SCREEN) {
//.........这里部分代码省略.........