00001 // Copyright (C) 2005 Pablo Mejia 00002 00003 00004 #ifndef CAJUN_GRID_PUBLISHER_H 00005 #define CAJUN_GRID_PUBLISHER_H 00006 00007 00008 #include "data_queue.H" 00009 #include "data_logger.H" 00010 #include "grid_tile_data.H" 00011 00012 00013 namespace cajun 00014 { 00015 class grid_publisher_t 00016 { 00017 public: 00018 grid_publisher_t (unsigned qid_, double cell_size_); 00019 00020 void transform (double orient_, 00021 double base_x_, double base_y_); 00022 00023 // Called by grid walk 00024 void init () { m_tile.cell_size = m_cell_size; } 00025 void init_tile (int x_, int y_) 00026 { 00027 m_publish_tile = false; 00028 m_tile.orientation = m_orient; 00029 m_tile.min_x = m_base_x + 00030 m_cell_size * (x_ * m_x_dx + y_ * m_x_dy); 00031 m_tile.min_y = m_base_y + 00032 m_cell_size * (x_ * m_y_dx + y_ * m_y_dy); 00033 } 00034 void fini_tile () 00035 { 00036 if (m_publish_tile) 00037 { 00038 m_dq->push (m_tile); 00039 m_logger.log (m_tile); 00040 } 00041 } 00042 00043 protected: 00044 double m_base_x; 00045 double m_base_y; 00046 double m_orient; 00047 double m_x_dx; 00048 double m_y_dx; 00049 double m_x_dy; 00050 double m_y_dy; 00051 double m_cell_size; 00052 00053 data_logger_t<grid_tile_data_t> m_logger; 00054 data_queue_writer_t<grid_tile_data_t> *m_dq; 00055 00056 bool m_publish_tile; 00057 grid_tile_data_t m_tile; 00058 }; 00059 }; 00060 00061 00062 #endif