PyObject* Python::WritePhase(const Phase &phase) {
  return Py_BuildValue("{s:N,s:N,s:s,s:i,s:s,s:i,s:i,s:d,s:d,s:d}",
    "start_time", BrokenDateTimeToPy(phase.start_datetime),
    "end_time", BrokenDateTimeToPy(phase.end_datetime),
    "type", FormatPhaseType(phase.phase_type),
    "duration", (long)phase.duration,
    "circling_direction", FormatCirclingDirection(phase.circling_direction),
    "alt_diff", (long)phase.alt_diff,
    "distance", (long)phase.alt_diff,
    "speed", phase.GetSpeed(),
    "vario", phase.GetVario(),
    "glide_rate", phase.GetGlideRate());
}
Esempio n. 2
0
static void
WritePhase(TextWriter &writer, Phase &phase)
{
  JSON::ObjectWriter object(writer);
  NarrowString<64> buffer;

  FormatISO8601(buffer.buffer(), phase.start_datetime);
  object.WriteElement("start_time", JSON::WriteString, buffer);

  FormatISO8601(buffer.buffer(), phase.end_datetime);
  object.WriteElement("end_time", JSON::WriteString, buffer);

  object.WriteElement("type", JSON::WriteString,
                      FormatPhaseType(phase.phase_type));
  object.WriteElement("duration", JSON::WriteInteger, (int)phase.duration);
  object.WriteElement("circling_direction", JSON::WriteString,
                      FormatCirclingDirection(phase.circling_direction));
  object.WriteElement("alt_diff", JSON::WriteInteger, (int)phase.alt_diff);
  object.WriteElement("distance", JSON::WriteInteger, (int)phase.distance);
  object.WriteElement("speed", JSON::WriteFixed, phase.GetSpeed());
  object.WriteElement("vario", JSON::WriteFixed, phase.GetVario());
  object.WriteElement("glide_rate", JSON::WriteFixed, phase.GetGlideRate());
}