Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <string>
  4. #include <functional>
  5. #include <set>
  6.  
  7. #include "descriptions.h"
  8. #include "json.h"
  9. #include "svg.h"
  10.  
  11. struct RenderingSettings {
  12.   double width;
  13.   double height;
  14.   double padding;
  15.   double stop_radius;
  16.   double line_width;
  17.   int stop_label_font_size;
  18.   Svg::Point stop_label_offset;
  19.   Svg::Color underlayer_color;
  20.   double underlayer_width;
  21.   std::vector<Svg::Color> color_palette;
  22.   int bus_label_font_size;
  23.   Svg::Point bus_label_offset;
  24.   std::vector<std::string> layers;
  25. };
  26.  
  27. struct double_compare {
  28.   bool operator() (double lhs, double rhs) const {
  29.     return lhs + std::numeric_limits<double>::epsilon() < rhs;
  30.   }
  31. };
  32.  
  33. class PackInfo : public std::pair<double, double> {
  34. public:
  35.   using std::pair<double, double>::pair;
  36.  
  37.   std::set<std::pair<std::string, std::string>> buss_and_stop;
  38.   std::set<std::pair<std::string, std::string>> black_listed_buss_and_stop;
  39. };
  40.  
  41. class MapRenderer {
  42. public:
  43.   MapRenderer(Descriptions::StopsDict stops_dict,
  44.               Descriptions::BusesDict buses_dict,
  45.               const Json::Dict& rendering_settings_json);
  46.  
  47.   std::string RenderMap() const;
  48.  
  49.   enum class RenderLayer {
  50.     BusWay,
  51.     StopLabel,
  52.     StopCircle,
  53.     BusId
  54.   };
  55.  
  56. private:
  57.   using Drawer = std::function<void(Svg::Document&)>;
  58.  
  59.   void InitMap();
  60.   void MakeRenderingSettings(const Json::Dict& rendering_settings_json);
  61.   Svg::Point FromSpherePoint(const Sphere::Point& point) const;
  62.   Svg::Point TransformPoint(const Sphere::Point& point) const;
  63.   double min_lat, min_lon, max_lat, max_lon;
  64.   std::vector<PackInfo> sorted_coords[2];
  65.   std::function<Svg::Point(const Sphere::Point&)> transformer_;
  66.  
  67.   std::string resultMap;
  68.  
  69.   Descriptions::StopsDict stops_dict_;
  70.   Descriptions::BusesDict buses_dict_;
  71.   RenderingSettings settings_;
  72.   std::map<RenderLayer, Drawer> renderers_;
  73. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement