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 boost::optional<Color> background_;
00068 std::map<std::string,feature_type_style> styles_;
00069 std::map<std::string,FontSet> fontsets_;
00070 std::vector<Layer> layers_;
00071 aspect_fix_mode aspectFixMode_;
00072 Envelope<double> currentExtent_;
00073
00074 public:
00075
00076 typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
00077 typedef std::map<std::string,feature_type_style>::iterator style_iterator;
00078
00086 Map();
00087
00093 Map(int width, int height, std::string const& srs="+proj=latlong +datum=WGS84");
00094
00099 Map(const Map& rhs);
00100
00106 Map& operator=(const Map& rhs);
00107
00111 std::map<std::string,feature_type_style> const& styles() const;
00112
00116 std::map<std::string,feature_type_style> & styles();
00117
00121 const_style_iterator begin_styles() const;
00122
00126 const_style_iterator end_styles() const;
00127
00131 style_iterator begin_styles();
00132
00136 style_iterator end_styles();
00137
00144 bool insert_style(std::string const& name,feature_type_style const& style);
00145
00149 void remove_style(const std::string& name);
00150
00155 feature_type_style const& find_style(std::string const& name) const;
00156
00163 bool insert_fontset(std::string const& name, FontSet const& fontset);
00164
00169 FontSet const& find_fontset(std::string const& name) const;
00170
00173 size_t layerCount() const;
00174
00178 void addLayer(const Layer& l);
00179
00184 const Layer& getLayer(size_t index) const;
00185
00190 Layer& getLayer(size_t index);
00191
00195 void removeLayer(size_t index);
00196
00200 std::vector<Layer> const& layers() const;
00201
00205 std::vector<Layer> & layers();
00206
00209 void remove_all();
00210
00213 unsigned getWidth() const;
00214
00217 unsigned getHeight() const;
00218
00221 void setWidth(unsigned width);
00222
00225 void setHeight(unsigned height);
00226
00229 void resize(unsigned width,unsigned height);
00230
00234 std::string const& srs() const;
00235
00239 void set_srs(std::string const& srs);
00240
00244 void set_background(const Color& c);
00245
00250 boost::optional<Color> const& background() const;
00251
00255 void zoom(double factor);
00256
00262 void zoomToBox(const Envelope<double>& box);
00263
00266 void zoom_all();
00267
00268 void pan(int x,int y);
00269
00270 void pan_and_zoom(int x,int y,double zoom);
00271
00275 const Envelope<double>& getCurrentExtent() const;
00276
00277 double scale() const;
00278
00279 CoordTransform view_transform() const;
00280
00281 featureset_ptr query_point(unsigned index, double x, double y) const;
00282
00283 featureset_ptr query_map_point(unsigned index, double x, double y) const;
00284 ~Map();
00285
00286 void setAspectFixMode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
00287 bool getAspectFixMode() { return aspectFixMode_; }
00288
00289 private:
00290 void fixAspectRatio();
00291 };
00292 }
00293
00294 #endif //MAP_HPP