本文整理汇总了C++中RasterElement::convertPixelsToGeocoords方法的典型用法代码示例。如果您正苦于以下问题:C++ RasterElement::convertPixelsToGeocoords方法的具体用法?C++ RasterElement::convertPixelsToGeocoords怎么用?C++ RasterElement::convertPixelsToGeocoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RasterElement
的用法示例。
在下文中一共展示了RasterElement::convertPixelsToGeocoords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateBoundingBox
void Kml::generateBoundingBox(const Layer* pGeoLayer)
{
VERIFYNRV(pGeoLayer != NULL);
// Translate the view's corner coordinates into layer coordinates
View* pView = pGeoLayer->getView();
VERIFYNRV(pView != NULL);
LocationType worldLowerLeft;
LocationType worldUpperLeft;
LocationType worldUpperRight;
LocationType worldLowerRight;
pView->getVisibleCorners(worldLowerLeft, worldUpperLeft, worldUpperRight, worldLowerRight);
LocationType dataLowerLeft;
LocationType dataUpperLeft;
LocationType dataUpperRight;
LocationType dataLowerRight;
pGeoLayer->translateWorldToData(worldLowerLeft.mX, worldLowerLeft.mY, dataLowerLeft.mX, dataLowerLeft.mY);
pGeoLayer->translateWorldToData(worldUpperLeft.mX, worldUpperLeft.mY, dataUpperLeft.mX, dataUpperLeft.mY);
pGeoLayer->translateWorldToData(worldUpperRight.mX, worldUpperRight.mY, dataUpperRight.mX, dataUpperRight.mY);
pGeoLayer->translateWorldToData(worldLowerRight.mX, worldLowerRight.mY, dataLowerRight.mX, dataLowerRight.mY);
// Translate the layer coordinates into geocoordinates
vector<LocationType> corners;
corners.push_back(dataLowerLeft);
corners.push_back(dataUpperLeft);
corners.push_back(dataUpperRight);
corners.push_back(dataLowerRight);
RasterElement* pGeoElement = dynamic_cast<RasterElement*>(pGeoLayer->getDataElement());
VERIFYNRV(pGeoElement != NULL);
vector<LocationType> geoCorners = pGeoElement->convertPixelsToGeocoords(corners);
// Determine the geo bounding box
double north = -90.0;
double south = 90.0;
double east = -180.0;
double west = 180.0;
for (vector<LocationType>::iterator iter = geoCorners.begin(); iter != geoCorners.end(); ++iter)
{
LocationType geocoord = *iter;
north = std::max(geocoord.mX, north);
south = std::min(geocoord.mX, south);
east = std::max(geocoord.mY, east);
west = std::min(geocoord.mY, west);
}
// Write the info to the file calling StringUtilities first to get higher precision
// instead of calling XmlWriter::addText() and passing in the double value
string northText = StringUtilities::toXmlString(north);
string southText = StringUtilities::toXmlString(south);
string eastText = StringUtilities::toXmlString(east);
string westText = StringUtilities::toXmlString(west);
mXml.pushAddPoint(mXml.addElement("LatLonAltBox"));
mXml.addText(northText, mXml.addElement("north"));
mXml.addText(southText, mXml.addElement("south"));
mXml.addText(eastText, mXml.addElement("east"));
mXml.addText(westText, mXml.addElement("west"));
mXml.popAddPoint();
}