本文整理汇总了C++中KmlFactory::CreateKml方法的典型用法代码示例。如果您正苦于以下问题:C++ KmlFactory::CreateKml方法的具体用法?C++ KmlFactory::CreateKml怎么用?C++ KmlFactory::CreateKml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KmlFactory
的用法示例。
在下文中一共展示了KmlFactory::CreateKml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportToKMLFile
bool UAVFlightPlan::exportToKMLFile(const std::string &f, int begin_, int end_) const {
bool ret_val = true;
if (end_ < 0 || end_ > size()) {
end_ = size();
}
if (begin_ < 0 || begin_ > size()) {
begin_ = 0;
}
const_iterator it = begin();
// Advance to the first waypoint to save
int i = 0;
for (; i < begin_; i++, it++);
KmlFactory* factory = KmlFactory::GetFactory();
kmldom::DocumentPtr doc = factory->CreateDocument();
for (int j = 1; i < end_ && it != end(); j++,i++, it++) {
ostringstream name_;
name_ << "Waypoint " << j;
// Create a <Point> with <coordinates> from the given Vec3.
kmlbase::Vec3 v(it->getLongitude(), it->getLatitude(), it->getAltitude());
kmldom::PointPtr point = kmlconvenience::CreatePointFromVec3(v);
PlacemarkPtr place = factory->CreatePlacemark();
place->set_geometry(point);
doc->add_feature(place);
}
// Finally create the kml
KmlPtr kml = factory->CreateKml();
kml->set_feature(doc);
// Then the file
KmlFilePtr kmlfile = KmlFile::CreateFromImport(kml);
if (!kmlfile) {
cerr << "error: could not create kml file" << endl;
return false;
}
// And write it
std::string kml_data;
kmlfile->SerializeToString(&kml_data);
if (!kmlbase::File::WriteStringToFile(kml_data, f.c_str())) {
cerr << "error: write of " << f << " failed" << endl;
ret_val = false;
}
return ret_val;
}