/usr/include/mapnik/map.hpp is in libmapnik-dev 2.2.0+ds1-7+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | /*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_MAP_HPP
#define MAPNIK_MAP_HPP
// mapnik
#include <mapnik/color.hpp>
#include <mapnik/font_set.hpp>
#include <mapnik/enumeration.hpp>
#include <mapnik/datasource.hpp> // for featureset_ptr
#include <mapnik/layer.hpp>
#include <mapnik/params.hpp>
#include <mapnik/well_known_srs.hpp>
// boost
#include <boost/optional/optional.hpp>
namespace mapnik
{
class feature_type_style;
class CoordTransform;
class MAPNIK_DECL Map
{
public:
enum aspect_fix_mode
{
// grow the width or height of the specified geo bbox to fill the map size. default behaviour.
GROW_BBOX,
// grow the width or height of the map to accomodate the specified geo bbox.
GROW_CANVAS,
// shrink the width or height of the specified geo bbox to fill the map size.
SHRINK_BBOX,
// shrink the width or height of the map to accomodate the specified geo bbox.
SHRINK_CANVAS,
// adjust the width of the specified geo bbox, leave height and map size unchanged
ADJUST_BBOX_WIDTH,
// adjust the height of the specified geo bbox, leave width and map size unchanged
ADJUST_BBOX_HEIGHT,
// adjust the width of the map, leave height and geo bbox unchanged
ADJUST_CANVAS_WIDTH,
//adjust the height of the map, leave width and geo bbox unchanged
ADJUST_CANVAS_HEIGHT,
//
aspect_fix_mode_MAX
};
private:
static const unsigned MIN_MAPSIZE=16;
static const unsigned MAX_MAPSIZE=MIN_MAPSIZE<<10;
unsigned width_;
unsigned height_;
std::string srs_;
int buffer_size_;
boost::optional<color> background_;
boost::optional<std::string> background_image_;
std::map<std::string,feature_type_style> styles_;
std::map<std::string,font_set> fontsets_;
std::vector<layer> layers_;
aspect_fix_mode aspectFixMode_;
box2d<double> current_extent_;
boost::optional<box2d<double> > maximum_extent_;
std::string base_path_;
parameters extra_params_;
public:
typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
typedef std::map<std::string,feature_type_style>::iterator style_iterator;
typedef std::map<std::string,font_set>::const_iterator const_fontset_iterator;
typedef std::map<std::string,font_set>::iterator fontset_iterator;
/*! \brief Default constructor.
*
* Creates a map with these parameters:
* - width = 400
* - height = 400
* - projection = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
*/
Map();
/*! \brief Constructor
* @param width Initial map width.
* @param height Initial map height.
* @param srs Initial map projection.
*/
Map(int width, int height, std::string const& srs=MAPNIK_LONGLAT_PROJ);
/*! \brief Copy Constructur.
*
* @param rhs Map to copy from.
*/
Map(Map const& rhs);
/*! \brief Assignment operator
*
* TODO: to be documented
*
*/
Map& operator=(Map const& rhs);
/*! \brief Get all styles
* @return Const reference to styles
*/
std::map<std::string,feature_type_style> const& styles() const;
/*! \brief Get all styles
* @return Non-constant reference to styles
*/
std::map<std::string,feature_type_style> & styles();
/*! \brief Get first iterator in styles.
* @return Constant style iterator.
*/
const_style_iterator begin_styles() const;
/*! \brief Get last iterator in styles.
* @return Constant style iterator.
*/
const_style_iterator end_styles() const;
/*! \brief Get first iterator in styles.
* @return Non-constant style iterator.
*/
style_iterator begin_styles();
/*! \brief Get last iterator in styles.
* @return Non-constant style iterator.
*/
style_iterator end_styles();
/*! \brief Insert a style in the map.
* @param name The name of the style.
* @param style The style to insert.
* @return true If success.
* false If no success.
*/
bool insert_style(std::string const& name,feature_type_style const& style);
/*! \brief Remove a style from the map.
* @param name The name of the style.
*/
void remove_style(std::string const& name);
/*! \brief Find a style.
* @param name The name of the style.
* @return The style if found. If not found return the default map style.
*/
boost::optional<feature_type_style const&> find_style(std::string const& name) const;
/*! \brief Insert a fontset into the map.
* @param name The name of the fontset.
* @param fontset The fontset to insert.
* @return true If success.
* false If failure.
*/
bool insert_fontset(std::string const& name, font_set const& fontset);
/*! \brief Find a fontset.
* @param name The name of the fontset.
* @return The fontset if found. If not found return the default map fontset.
*/
boost::optional<font_set const&> find_fontset(std::string const& name) const;
/*! \brief Get all fontsets
* @return Const reference to fontsets
*/
std::map<std::string,font_set> const& fontsets() const;
/*! \brief Get all fontsets
* @return Non-constant reference to fontsets
*/
std::map<std::string,font_set> & fontsets();
/*! \brief Get number of all layers.
*/
size_t layer_count() const;
/*! \brief Add a layer to the map.
* @param l The layer to add.
*/
void addLayer(layer const& l);
/*! \brief Get a layer.
* @param index layer number.
* @return Constant layer.
*/
layer const& getLayer(size_t index) const;
/*! \brief Get a layer.
* @param index layer number.
* @return Non-constant layer.
*/
layer& getLayer(size_t index);
/*! \brief Remove a layer.
* @param index layer number.
*/
void removeLayer(size_t index);
/*! \brief Get all layers.
* @return Constant layers.
*/
std::vector<layer> const& layers() const;
/*! \brief Get all layers.
* @return Non-constant layers.
*/
std::vector<layer> & layers();
/*! \brief Remove all layers and styles from the map.
*/
void remove_all();
/*! \brief Get map width.
*/
unsigned width() const;
/*! \brief Get map height.
*/
unsigned height() const;
/*! \brief Set map width.
*/
void set_width(unsigned width);
/*! \brief Set map height.
*/
void set_height(unsigned height);
/*! \brief Resize the map.
*/
void resize(unsigned width,unsigned height);
/*! \brief Get the map projection.
* @return Map projection.
*/
std::string const& srs() const;
/*! \brief Set the map projection.
* @param srs Map projection.
*/
void set_srs(std::string const& srs);
/*! \brief Set the map background color.
* @param c Background color.
*/
void set_background(color const& c);
/*! \brief Get the map background color
* @return Background color as boost::optional
* object
*/
boost::optional<color> const& background() const;
/*! \brief Set the map background image filename.
* @param image_filename Background image filename.
*/
void set_background_image(std::string const& image_filename);
/*! \brief Get the map background image
* @return Background image path as std::string
* object
*/
boost::optional<std::string> const& background_image() const;
/*! \brief Set buffer size
* @param buffer_size Buffer size in pixels.
*/
void set_buffer_size(int buffer_size);
/*! \brief Get the map buffer size
* @return Buffer size as int
*/
int buffer_size() const;
/*! \brief Set the map maximum extent.
* @param box The bounding box for the maximum extent.
*/
void set_maximum_extent(box2d<double> const& box);
/*! \brief Get the map maximum extent as box2d<double>
*/
boost::optional<box2d<double> > const& maximum_extent() const;
void reset_maximum_extent();
/*! \brief Get the map base path where paths should be relative to.
*/
std::string const& base_path() const;
/*! \brief Set the map base path where paths should be relative to.
* @param base Map base_path.
*/
void set_base_path(std::string const& base);
/*! \brief Zoom the map at the current position.
* @param factor The factor how much the map is zoomed in or out.
*/
void zoom(double factor);
/*! \brief Zoom the map to a bounding box.
*
* Aspect is handled automatic if not fitting to width/height.
* @param box The bounding box where to zoom.
*/
void zoom_to_box(box2d<double> const& box);
/*! \brief Zoom the map to show all data.
*/
void zoom_all();
void pan(int x,int y);
void pan_and_zoom(int x,int y,double zoom);
/*! \brief Get current bounding box.
* @return The current bounding box.
*/
box2d<double> const& get_current_extent() const;
/*! \brief Get current buffered bounding box.
* @return The current buffered bounding box.
*/
box2d<double> get_buffered_extent() const;
/*!
* @return The Map Scale.
*/
double scale() const;
double scale_denominator() const;
CoordTransform view_transform() const;
/*!
* @brief Query a Map layer (by layer index) for features
*
* Intersecting the given x,y location in the coordinates
* of map projection.
*
* @param index The index of the layer to query from.
* @param x The x coordinate where to query.
* @param y The y coordinate where to query.
* @return A Mapnik Featureset if successful otherwise will return NULL.
*/
featureset_ptr query_point(unsigned index, double x, double y) const;
/*!
* @brief Query a Map layer (by layer index) for features
*
* Intersecting the given x,y location in the coordinates
* of the pixmap or map surface.
*
* @param index The index of the layer to query from.
* @param x The x coordinate where to query.
* @param y The y coordinate where to query.
* @return A Mapnik Featureset if successful otherwise will return NULL.
*/
featureset_ptr query_map_point(unsigned index, double x, double y) const;
~Map();
inline void set_aspect_fix_mode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
inline aspect_fix_mode get_aspect_fix_mode() const { return aspectFixMode_; }
/*!
* @brief Get extra, arbitrary Parameters attached to the Map
*/
parameters const& get_extra_parameters() const;
/*!
* @brief Get non-const extra, arbitrary Parameters attached to the Map
*/
parameters& get_extra_parameters();
/*!
* @brief Set extra, arbitary Parameters of the Map
*/
void set_extra_parameters(parameters& params);
private:
void fixAspectRatio();
};
DEFINE_ENUM(aspect_fix_mode_e,Map::aspect_fix_mode);
}
#endif // MAPNIK_MAP_HPP
|