本文整理汇总了C++中Units::convertTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Units::convertTo方法的具体用法?C++ Units::convertTo怎么用?C++ Units::convertTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Units
的用法示例。
在下文中一共展示了Units::convertTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
VerticalDatum::transform(const VerticalDatum* from,
const VerticalDatum* to,
double lat_deg,
double lon_deg,
double& in_out_z)
{
if ( from == to )
return true;
if ( from )
{
in_out_z = from->msl2hae( lat_deg, lon_deg, in_out_z );
}
Units fromUnits = from ? from->getUnits() : Units::METERS;
Units toUnits = to ? to->getUnits() : Units::METERS;
in_out_z = fromUnits.convertTo(toUnits, in_out_z);
if ( to )
{
in_out_z = to->hae2msl( lat_deg, lon_deg, in_out_z );
}
return true;
}
示例2: geopoints
bool
SpatialReference::transformZ(std::vector<osg::Vec3d>& points,
const SpatialReference* outputSRS,
bool pointsAreLatLong) const
{
const VerticalDatum* outVDatum = outputSRS->getVerticalDatum();
// same vdatum, no xformation necessary.
if ( _vdatum.get() == outVDatum )
return true;
Units inUnits = _vdatum.valid() ? _vdatum->getUnits() : Units::METERS;
Units outUnits = outVDatum ? outVDatum->getUnits() : inUnits;
if ( isGeographic() || pointsAreLatLong )
{
for( unsigned i=0; i<points.size(); ++i )
{
if ( _vdatum.valid() )
{
// to HAE:
points[i].z() = _vdatum->msl2hae( points[i].y(), points[i].x(), points[i].z() );
}
// do the units conversion:
points[i].z() = inUnits.convertTo(outUnits, points[i].z());
if ( outVDatum )
{
// to MSL:
points[i].z() = outVDatum->hae2msl( points[i].y(), points[i].x(), points[i].z() );
}
}
}
else // need to xform input points
{
// copy the points and convert them to geographic coordinates (lat/long with the same Z):
std::vector<osg::Vec3d> geopoints(points);
transform( geopoints, getGeographicSRS() );
for( unsigned i=0; i<geopoints.size(); ++i )
{
if ( _vdatum.valid() )
{
// to HAE:
points[i].z() = _vdatum->msl2hae( geopoints[i].y(), geopoints[i].x(), points[i].z() );
}
// do the units conversion:
points[i].z() = inUnits.convertTo(outUnits, points[i].z());
if ( outVDatum )
{
// to MSL:
points[i].z() = outVDatum->hae2msl( geopoints[i].y(), geopoints[i].x(), points[i].z() );
}
}
}
return true;
}