00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MAP_HPP
00025 #define MAP_HPP
00026
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031 #include <mapnik/feature_type_style.hpp>
00032 #include <mapnik/datasource.hpp>
00033 #include <mapnik/layer.hpp>
00034 #include <boost/optional/optional.hpp>
00035
00036 namespace mapnik
00037 {
00038 class MAPNIK_DECL Map
00039 {
00040 public:
00041
00042 enum aspect_fix_mode
00043 {
00044
00045 GROW_BBOX,
00046
00047 GROW_CANVAS,
00048
00049 SHRINK_BBOX,
00050
00051 SHRINK_CANVAS,
00052
00053 ADJUST_BBOX_WIDTH,
00054
00055 ADJUST_BBOX_HEIGHT,
00056
00057 ADJUST_CANVAS_WIDTH,
00058
00059 ADJUST_CANVAS_HEIGHT
00060 };
00061 private:
00062 static const unsigned MIN_MAPSIZE=16;
00063 static const unsigned MAX_MAPSIZE=MIN_MAPSIZE<<10;
00064 unsigned width_;
00065 unsigned height_;
00066 std::string srs_;
00067 int buffer_size_;
00068 boost::optional<Color> background_;
00069 std::map<std::string,feature_type_style> styles_;
00070 std::map<std::string,FontSet> fontsets_;
00071 std::vector<Layer> layers_;
00072 aspect_fix_mode aspectFixMode_;
00073 Envelope<double> currentExtent_;
00074
00075 public:
00076
00077 typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
00078 typedef std::map<std::string,feature_type_style>::iterator style_iterator;
00079
00087 Map();
00088
00094 Map(int width, int height, std::string const& srs="+proj=latlong +datum=WGS84");
00095
00100 Map(const Map& rhs);
00101
00107 Map& operator=(const Map& rhs);
00108
00112 std::map<std::string,feature_type_style> const& styles() const;
00113
00117 std::map<std::string,feature_type_style> & styles();
00118
00122 const_style_iterator begin_styles() const;
00123
00127 const_style_iterator end_styles() const;
00128
00132 style_iterator begin_styles();
00133
00137 style_iterator end_styles();
00138
00145 bool insert_style(std::string const& name,feature_type_style const& style);
00146
00150 void remove_style(const std::string& name);
00151
00156 feature_type_style const& find_style(std::string const& name) const;
00157
00164 bool insert_fontset(std::string const& name, FontSet const& fontset);
00165
00170 FontSet const& find_fontset(std::string const& name) const;
00171
00174 size_t layerCount() const;
00175
00179 void addLayer(const Layer& l);
00180
00185 const Layer& getLayer(size_t index) const;
00186
00191 Layer& getLayer(size_t index);
00192
00196 void removeLayer(size_t index);
00197
00201 std::vector<Layer> const& layers() const;
00202
00206 std::vector<Layer> & layers();
00207
00210 void remove_all();
00211
00214 unsigned getWidth() const;
00215
00218 unsigned getHeight() const;
00219
00222 void setWidth(unsigned width);
00223
00226 void setHeight(unsigned height);
00227
00230 void resize(unsigned width,unsigned height);
00231
00235 std::string const& srs() const;
00236
00240 void set_srs(std::string const& srs);
00241
00245 void set_background(const Color& c);
00246
00251 boost::optional<Color> const& background() const;
00252
00257 void set_buffer_size(int buffer_size);
00258
00262 int buffer_size() const;
00263
00267 void zoom(double factor);
00268
00274 void zoomToBox(const Envelope<double>& box);
00275
00278 void zoom_all();
00279
00280 void pan(int x,int y);
00281
00282 void pan_and_zoom(int x,int y,double zoom);
00283
00287 const Envelope<double>& getCurrentExtent() const;
00288
00289 double scale() const;
00290
00291 CoordTransform view_transform() const;
00292
00293 featureset_ptr query_point(unsigned index, double x, double y) const;
00294
00295 featureset_ptr query_map_point(unsigned index, double x, double y) const;
00296 ~Map();
00297
00298 void setAspectFixMode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
00299 bool getAspectFixMode() { return aspectFixMode_; }
00300
00301 private:
00302 void fixAspectRatio();
00303 };
00304 }
00305
00306 #endif //MAP_HPP