point.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "point.h"
  2. Point::Point(Json::Value& v)
  3. {
  4. m_angle= v["angle"].asDouble();
  5. m_field= v["field"].asDouble();
  6. m_radius= v["radius"].asDouble();
  7. m_coord= v["coordinates"];
  8. m_parent= v["parent"].asString();
  9. m_useAngle=v["useAngle"].asBool();
  10. std::cout << "=======" << m_coord.toStyledString() << "\n";
  11. }
  12. Point::Point()
  13. {
  14. m_angle=180;
  15. m_field=90;
  16. m_radius=5;
  17. m_coord= Json::Value(Json::arrayValue);
  18. std::cout << "=======" << m_coord.toStyledString() << "\n";
  19. m_parent="";
  20. }
  21. Point::Point(Node& v)
  22. {
  23. for(int i=0; i<v.m_keys.size(); i++)
  24. {
  25. if(v.m_keys[i]=="angle") m_angle=atof(v.m_values[i].c_str());
  26. if(v.m_keys[i]=="field") m_field=atof(v.m_values[i].c_str());
  27. if(v.m_keys[i]=="radius") m_radius=atof(v.m_values[i].c_str());
  28. }
  29. m_coord = Json::Value(Json::arrayValue);
  30. std::cout << "=======" << m_coord.toStyledString() << "\n";
  31. m_coord[0]=v.m_lon;
  32. m_coord[01]=v.m_lat;
  33. }
  34. const std::string& Point::getParent() {return m_parent;}
  35. Json::Value Point::toJson()
  36. {
  37. Json::Value v(Json::objectValue);
  38. v["angle"]=m_angle;
  39. v["field"]=m_field;
  40. v["radius"]=m_radius;
  41. v["coordinates"]=m_coord;
  42. v["useAngle"]=m_useAngle;
  43. return v;
  44. }
  45. Point::~Point()
  46. {
  47. //dtor
  48. }
  49. int Point::count_child() const
  50. {
  51. return m_coord.size();
  52. }