35 #include "locationevent.pb.h" 37 class EMANE::Events::LocationEvent::Implementation
40 Implementation(
const Locations & locations):
41 locations_{locations}{}
57 if(!msg.ParseFromString(serialization))
64 for(
const auto & location : msg.locations())
66 const auto & positionMessage = location.position();
69 Position position{positionMessage.latitudedegrees(),
70 positionMessage.longitudedegrees(),
71 positionMessage.altitudemeters()};
79 if(location.has_velocity())
81 const auto & velocityMessage = location.velocity();
83 velocity =
Velocity{velocityMessage.azimuthdegrees(),
84 velocityMessage.elevationdegrees(),
85 velocityMessage.magnitudemeterspersecond()};
88 if(location.has_orientation())
90 const auto & orientationMessage = location.orientation();
92 orientation =
Orientation{orientationMessage.rolldegrees(),
93 orientationMessage.pitchdegrees(),
94 orientationMessage.yawdegrees()};
97 locations.push_back({nemId,
99 {orientation,location.has_orientation()},
100 {velocity,location.has_velocity()}});
103 pImpl_.reset(
new Implementation{locations});
108 pImpl_{
new Implementation{locations}}{}
112 pImpl_{
new Implementation{rhs.getLocations()}}{}
122 pImpl_{
new Implementation{{}}}
124 rval.pImpl_.swap(pImpl_);
129 rval.pImpl_.swap(pImpl_);
137 return pImpl_->getLocations();
146 for(
auto & location : pImpl_->getLocations())
148 auto pLocationMessage = msg.add_locations();
150 pLocationMessage->set_nemid(location.getNEMId());
152 auto pPositionMessage = pLocationMessage->mutable_position();
154 const auto & position = location.getPosition();
156 pPositionMessage->set_latitudedegrees(position.getLatitudeDegrees());
157 pPositionMessage->set_longitudedegrees(position.getLongitudeDegrees());
158 pPositionMessage->set_altitudemeters(position.getAltitudeMeters());
160 auto optionalVelocity = location.getVelocity();
162 if(optionalVelocity.second)
164 auto pVelocityMessage = pLocationMessage->mutable_velocity();
166 pVelocityMessage->set_azimuthdegrees(optionalVelocity.first.getAzimuthDegrees());
167 pVelocityMessage->set_elevationdegrees(optionalVelocity.first.getElevationDegrees());
168 pVelocityMessage->set_magnitudemeterspersecond(optionalVelocity.first.getMagnitudeMetersPerSecond());
171 auto optionalOrientation = location.getOrientation();
173 if(optionalOrientation.second)
175 auto pOrientationMessage = pLocationMessage->mutable_orientation();
177 pOrientationMessage->set_yawdegrees(optionalOrientation.first.getYawDegrees());
178 pOrientationMessage->set_pitchdegrees(optionalOrientation.first.getPitchDegrees());
179 pOrientationMessage->set_rolldegrees(optionalOrientation.first.getRollDegrees());
183 if(!msg.SerializeToString(&serialization))
188 return serialization;
std::string Serialization
Holds the velocity elements associated with an NEM's location information.
SerializationException is thrown when an exception occurs during serialization or deserialization of ...
Event interface is the base for all events.
A location event is usd to set the position, orientation and velocity information for one or more NEM...
LocationEvent & operator=(const LocationEvent &rhs)
LocationEvent(const Serialization &serialization)
Serialization serialize() const override
std::list< Location > Locations
Holds pitch, yaw and roll.
Holds latitude, longitude and altitude.
const Locations & getLocations() const