- added ViewFormat for parsing GE queries for Camera and stuff
- Camera now controlled with adjustable alt, tilt, auto roll based on aircraft banking and auto heading based on aircraft heading git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@129 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+66
-13
@@ -12,6 +12,10 @@ Kml::Kml(const char *pDocRoot)
|
||||
, m_docRoot(pDocRoot)
|
||||
, m_altitudeModeString("absolute")
|
||||
, m_pathColorString("0xff00ffff")
|
||||
, m_cameraAlt(1000)
|
||||
, m_cameraTilt(0)
|
||||
, m_cameraAutoHeading(false)
|
||||
, m_cameraAutoRoll(false)
|
||||
{
|
||||
memset(m_path, 0, sizeof(m_path));
|
||||
}
|
||||
@@ -49,6 +53,7 @@ void Kml::create()
|
||||
|
||||
// Create an outer XML element..
|
||||
kml->setAttribute("xmlns", "http://www.opengis.net/kml/2.2");
|
||||
kml->setAttribute("xmlns:gx", "http://www.google.com/kml/ext/2.2");
|
||||
sprintf(m_path, "%s\\flight_%4.4d%2.2d%2.2d_%2.2d%2.2d%2.2d.kml", m_docRoot, 1900+time_now->tm_year, time_now->tm_mon+1, time_now->tm_mday, time_now->tm_hour, time_now->tm_min, time_now->tm_sec);
|
||||
pFile->addTextElement(m_path);
|
||||
pSnippet->setAttribute("maxLines", "2");
|
||||
@@ -57,13 +62,13 @@ void Kml::create()
|
||||
pSnippet->addTextElement(time_str);
|
||||
|
||||
// Camera
|
||||
pCamera->createNewChildElement("longitude")->addTextElement("");
|
||||
pCamera->createNewChildElement("latitude")->addTextElement("");
|
||||
pCamera->createNewChildElement("altitude")->addTextElement("");
|
||||
pCamera->createNewChildElement("heading")->addTextElement("");
|
||||
pCamera->createNewChildElement("tilt")->addTextElement("");
|
||||
pCamera->createNewChildElement("altitudeMode")->addTextElement("");
|
||||
|
||||
pCamera->createNewChildElement("longitude")->addTextElement("0");
|
||||
pCamera->createNewChildElement("latitude")->addTextElement("0");
|
||||
pCamera->createNewChildElement("altitude")->addTextElement("0");
|
||||
pCamera->createNewChildElement("heading")->addTextElement("0");
|
||||
pCamera->createNewChildElement("tilt")->addTextElement("0");
|
||||
pCamera->createNewChildElement("roll")->addTextElement("0");
|
||||
pCamera->createNewChildElement("altitudeMode")->addTextElement(m_altitudeModeString);
|
||||
|
||||
}
|
||||
|
||||
@@ -103,6 +108,16 @@ void Kml::setPathColor(String const &colorString)
|
||||
|
||||
}
|
||||
|
||||
void Kml::setCameraAltitude(float alt_meters)
|
||||
{
|
||||
m_cameraAlt = alt_meters;
|
||||
}
|
||||
|
||||
void Kml::setCameraTilt(float tilt_deg)
|
||||
{
|
||||
m_cameraTilt = tilt_deg;
|
||||
}
|
||||
|
||||
void Kml::update(FlightData const &flightData)
|
||||
{
|
||||
const ScopedLock sl (m_lock);
|
||||
@@ -110,6 +125,16 @@ void Kml::update(FlightData const &flightData)
|
||||
updatePath(flightData);
|
||||
}
|
||||
|
||||
void Kml::setCameraAutoHeading(bool enable)
|
||||
{
|
||||
m_cameraAutoHeading = enable;
|
||||
}
|
||||
|
||||
void Kml::setCameraAutoRoll(bool enable)
|
||||
{
|
||||
m_cameraAutoRoll = enable;
|
||||
}
|
||||
|
||||
void Kml::updatePlane(FlightData const &flightData)
|
||||
{
|
||||
char temp_str[1024];
|
||||
@@ -133,7 +158,6 @@ void Kml::updatePlane(FlightData const &flightData)
|
||||
XmlElement *pCoords;
|
||||
|
||||
XmlElement *pCamera;
|
||||
XmlElement *pLookAt;
|
||||
|
||||
if(pPlacemark == NULL)
|
||||
{
|
||||
@@ -212,13 +236,20 @@ void Kml::updatePlane(FlightData const &flightData)
|
||||
pCoords = pPlacemark->getChildByName("Point")->getChildByName("coordinates");
|
||||
pCoords->getFirstChildElement()->setText(temp_str);
|
||||
|
||||
// Camera
|
||||
pCamera = kml->getChildByName("NetworkLinkControl")->getChildByName("Camera");
|
||||
|
||||
pCamera->getChildByName("longitude")->getFirstChildElement()->setText(String(flightData.lon));
|
||||
pCamera->getChildByName("latitude")->getFirstChildElement()->setText(String(flightData.lat));
|
||||
pCamera->getChildByName("altitude")->getFirstChildElement()->setText(String(flightData.alt_meter));
|
||||
pCamera->getChildByName("heading")->getFirstChildElement()->setText(String(flightData.hdgTrue_deg));
|
||||
pCamera->getChildByName("tilt")->getFirstChildElement()->setText("90");
|
||||
pCamera->getChildByName("altitude")->getFirstChildElement()->setText(String(flightData.alt_meter+m_cameraAlt));
|
||||
|
||||
if (m_cameraAutoHeading)
|
||||
pCamera->getChildByName("heading")->getFirstChildElement()->setText(String(flightData.hdgTrue_deg));
|
||||
|
||||
pCamera->getChildByName("tilt")->getFirstChildElement()->setText(String(m_cameraTilt));
|
||||
|
||||
if (m_cameraAutoRoll)
|
||||
pCamera->getChildByName("roll")->getFirstChildElement()->setText(String(flightData.bank_deg));
|
||||
|
||||
pCamera->getChildByName("altitudeMode")->getFirstChildElement()->setText(m_altitudeModeString);
|
||||
|
||||
}
|
||||
@@ -323,8 +354,30 @@ void Kml::exportKmz(const char *pPath)
|
||||
}
|
||||
}
|
||||
|
||||
void Kml::onUpdate(const char *pPath)
|
||||
void Kml::onUpdate(const char *pPath, ViewFormat const &viewFormat)
|
||||
{
|
||||
if (kml == nullptr)
|
||||
return;
|
||||
|
||||
// LookAt
|
||||
XmlElement *pCamera;
|
||||
|
||||
pCamera = kml->getChildByName("NetworkLinkControl")->getChildByName("Camera");
|
||||
|
||||
if (viewFormat.has_camera)
|
||||
{
|
||||
// pCamera->getChildByName("longitude")->getFirstChildElement()->setText(String(viewFormat.camera.lookatLon));
|
||||
// pCamera->getChildByName("latitude")->getFirstChildElement()->setText(String(viewFormat.camera.lookatLat));
|
||||
// pCamera->getChildByName("altitude")->getFirstChildElement()->setText(String(viewFormat.camera.lookatRange));
|
||||
// pCamera->getChildByName("heading")->getFirstChildElement()->setText(String(viewFormat.camera.lookatHeading));
|
||||
// pCamera->getChildByName("heading")->getFirstChildElement()->setText(String(0));
|
||||
// pCamera->getChildByName("tilt")->getFirstChildElement()->setText(String(viewFormat.camera.lookatTilt));
|
||||
// pCamera->getChildByName("tilt")->getFirstChildElement()->setText(String(0));
|
||||
// pCamera->getChildByName("range")->getFirstChildElement()->setText(String(viewFormat.camera.lookatRange));
|
||||
// pCamera->getChildByName("range")->getFirstChildElement()->setText(String("10000"));
|
||||
// pCamera->getChildByName("altitudeMode")->getFirstChildElement()->setText(m_altitudeModeString);
|
||||
}
|
||||
|
||||
exportKmz(pPath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user