| 94 | | class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >( |
| 95 | | "Create a Map with a width and height as integers and, optionally,\n" |
| 96 | | "an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n" |
| 97 | | "or with a Proj.4 literal ('+proj=<literal>').\n" |
| 98 | | "If no srs is specified the map will default to '+proj=latlong +datum=WGS84'\n" |
| 99 | | "\n" |
| 100 | | "Usage:\n" |
| 101 | | ">>> from mapnik import Map\n" |
| 102 | | ">>> m = Map(600,400)\n" |
| 103 | | ">>> m\n" |
| 104 | | "<mapnik._mapnik.Map object at 0x6a240>\n" |
| 105 | | ">>> m.srs\n" |
| 106 | | "'+proj=latlong +datum=WGS84'\n" |
| 107 | | )) |
| 108 | | |
| 109 | | .def_pickle(map_pickle_suite() |
| 110 | | ) |
| 111 | | |
| 112 | | .def("append_style",&Map::insert_style, |
| 113 | | "Insert a Mapnik Style onto the map by appending it.\n" |
| 114 | | "\n" |
| 115 | | "Usage:\n" |
| 116 | | ">>> sty\n" |
| 117 | | "<mapnik._mapnik.Style object at 0x6a330>\n" |
| 118 | | ">>> m.append_style('Style Name', sty)\n" |
| 119 | | "True # style object added to map by name\n" |
| 120 | | ">>> m.append_style('Style Name', sty)\n" |
| 121 | | "False # you can only append styles with unique names\n" |
| 122 | | ) |
| 123 | | |
| 124 | | .def("envelope", |
| 125 | | make_function(&Map::getCurrentExtent, |
| 126 | | return_value_policy<copy_const_reference>()), |
| 127 | | "Return the Map Envelope object\n" |
| 128 | | "and print the string representation\n" |
| 129 | | "of the current extent of the map.\n" |
| 130 | | "\n" |
| 131 | | "Usage:\n" |
| 132 | | ">>> m.envelope()\n" |
| 133 | | "Envelope(-0.185833333333,-0.96,0.189166666667,-0.71)\n" |
| 134 | | ">>> dir(m.envelope())\n" |
| 135 | | "...'center', 'contains', 'expand_to_include', 'forward',\n" |
| 136 | | "...'height', 'intersect', 'intersects', 'inverse', 'maxx',\n" |
| 137 | | "...'maxy', 'minx', 'miny', 'width'\n" |
| 138 | | ) |
| 139 | | |
| 140 | | .def("find_style", |
| 141 | | &Map::find_style, |
| 142 | | return_value_policy<copy_const_reference>(), |
| 143 | | "Query the Map for a style by name and return\n" |
| 144 | | "a style object if found and the default map\n" |
| 145 | | "style if not found.\n" |
| 146 | | "\n" |
| 147 | | "Usage:\n" |
| 148 | | ">>> m.find_style('Style Name')\n" |
| 149 | | "<mapnik._mapnik.Style object at 0x654f0>\n" |
| 150 | | ) |
| 151 | | |
| 152 | | .def("pan",&Map::pan, |
| 153 | | "Set the Map center at a given x,y location\n" |
| 154 | | "as integers in the coordinates of the pixmap or map surface.\n" |
| 155 | | "\n" |
| 156 | | "Usage:\n" |
| 157 | | ">>> m = Map(600,400)\n" |
| 158 | | ">>> m.envelope().center()\n" |
| 159 | | "Coord(-0.5,-0.5) # default Map center\n" |
| 160 | | ">>> m.pan(-1,-1)\n" |
| 161 | | ">>> m.envelope().center()\n" |
| 162 | | "Coord(0.00166666666667,-0.835)\n" |
| 163 | | ) |
| 164 | | |
| 165 | | .def("pan_and_zoom",&Map::pan_and_zoom, |
| 166 | | "Set the Map center at a given x,y location\n" |
| 167 | | "and zoom factor as a float.\n" |
| 168 | | "\n" |
| 169 | | "Usage:\n" |
| 170 | | ">>> m = Map(600,400)\n" |
| 171 | | ">>> m.envelope().center()\n" |
| 172 | | "Coord(-0.5,-0.5) # default Map center\n" |
| 173 | | ">>> m.scale()\n" |
| 174 | | "-0.0016666666666666668\n" |
| 175 | | ">>> m.pan_and_zoom(-1,-1,0.25)\n" |
| 176 | | ">>> m.scale()\n" |
| 177 | | "0.00062500000000000001\n" |
| 178 | | ) |
| 179 | | |
| 180 | | .def("query_map_point",&Map::query_map_point, |
| 181 | | "Query a Map Layer (by layer index) for features \n" |
| 182 | | "intersecting the given x,y location in the coordinates\n" |
| 183 | | "of the pixmap or map surface.\n" |
| 184 | | "Will return a Mapnik Featureset if successful\n" |
| 185 | | "otherwise will return None.\n" |
| 186 | | "\n" |
| 187 | | "Usage:\n" |
| 188 | | ">>> feat = m.query_map_point(0,200,200)\n" |
| 189 | | ">>> feat\n" |
| 190 | | ">>> <mapnik._mapnik.Featureset object at 0x5fe1f0>\n" |
| 191 | | ">>> feat.next()\n" |
| 192 | | ">>> <mapnik._mapnik.Feature object at 0x5fe230>\n" |
| 193 | | ) |
| 194 | | |
| 195 | | .def("query_point",&Map::query_point, |
| 196 | | "Query a Map Layer (by layer index) for features \n" |
| 197 | | "intersecting the given x,y location in the coordinates\n" |
| 198 | | "of map projection.\n" |
| 199 | | "Will return a Mapnik Featureset if successful\n" |
| 200 | | "otherwise will return None.\n" |
| 201 | | "\n" |
| 202 | | "Usage:\n" |
| 203 | | ">>> feat = m.query_point(0,-122,48)\n" |
| 204 | | ">>> feat\n" |
| 205 | | ">>> <mapnik._mapnik.Featureset object at 0x5fe130>\n" |
| 206 | | ">>> feat.next()\n" |
| 207 | | ">>> <mapnik._mapnik.Feature object at 0x5fe1b0>\n" |
| 208 | | ) |
| 209 | | |
| 210 | | .def("remove_style",&Map::remove_style, |
| 211 | | "Remove a Mapnik Style from the map.\n" |
| 212 | | "\n" |
| 213 | | "Usage:\n" |
| 214 | | ">>> m.remove_style('Style Name')\n" |
| 215 | | ) |
| 216 | | |
| 217 | | .def("scale", &Map::scale, |
| 218 | | "Return the Map Scale.\n" |
| 219 | | "Usage:\n" |
| 220 | | "\n" |
| 221 | | ">>> m.scale()\n" |
| 222 | | ) |
| 223 | | |
| 224 | | .def("zoom",&Map::zoom, |
| 225 | | "Zoom in by a given factor.\n" |
| 226 | | "Usage:\n" |
| 227 | | "\n" |
| 228 | | ">>> m.zoom(0.25)\n" |
| 229 | | ) |
| 230 | | |
| 231 | | .def("zoom_all",&Map::zoom_all, |
| 232 | | "Set the geographical extent of the map\n" |
| 233 | | "to the combined extents of all active layers.\n" |
| 234 | | "\n" |
| 235 | | "Usage:\n" |
| 236 | | ">>> m.zoom_all()\n" |
| 237 | | ) |
| 238 | | |
| 239 | | .def("zoom_to_box",&Map::zoomToBox, |
| 240 | | "Set the geographical extent of the map\n" |
| 241 | | "by specifying a Mapnik Envelope.\n" |
| 242 | | "\n" |
| 243 | | "Usage:\n" |
| 244 | | ">>> extext = Envelope(-180.0, -90.0, 180.0, 90.0)\n" |
| 245 | | ">>> m.zoom_to_box(extent)\n" |
| 246 | | ) |
| 247 | | |
| 248 | | .add_property("background",make_function |
| 249 | | (&Map::background,return_value_policy<copy_const_reference>()), |
| 250 | | &Map::set_background, |
| 251 | | "The background color of the map.\n" |
| 252 | | "\n" |
| 253 | | "Usage:\n" |
| 254 | | ">>> m.background = Color('steelblue')\n" |
| 255 | | ) |
| 256 | | |
| 257 | | .add_property("buffer_size", |
| 258 | | &Map::buffer_size, |
| 259 | | &Map::set_buffer_size, |
| 260 | | "Get/Set the size of buffer around map in pixels.\n" |
| 261 | | "\n" |
| 262 | | "Usage:\n" |
| 263 | | ">>> m.buffer_size\n" |
| 264 | | "0 # zero by default\n" |
| 265 | | ">>> m.buffer_size = 2\n" |
| 266 | | ">>> m.buffer_size\n" |
| 267 | | "2\n" |
| 268 | | ) |
| 269 | | |
| 270 | | .add_property("height", |
| 271 | | &Map::getHeight, |
| 272 | | &Map::setHeight, |
| 273 | | "Get/Set the height of the map in pixels.\n" |
| 274 | | "Minimum settable size is 16 pixels.\n" |
| 275 | | "\n" |
| 276 | | "Usage:\n" |
| 277 | | ">>> m.height\n" |
| 278 | | "400\n" |
| 279 | | ">>> m.height = 600\n" |
| 280 | | ">>> m.height\n" |
| 281 | | "600\n" |
| 282 | | ) |
| 283 | | |
| 284 | | .add_property("layers",make_function |
| 285 | | (layers_nonconst,return_value_policy<reference_existing_object>()), |
| 286 | | "The list of map layers.\n" |
| 287 | | "\n" |
| 288 | | "Usage:\n" |
| 289 | | ">>> m.layers\n" |
| 290 | | "<mapnik._mapnik.Layers object at 0x6d458>" |
| 291 | | ">>> m.layers[0]\n" |
| 292 | | "<mapnik._mapnik.Layer object at 0x5fe130>\n" |
| 293 | | ) |
| 294 | | |
| 295 | | .add_property("srs", |
| 296 | | make_function(&Map::srs,return_value_policy<copy_const_reference>()), |
| 297 | | &Map::set_srs, |
| 298 | | "Spatial reference in Proj.4 format.\n" |
| 299 | | "Either an epsg code or proj literal.\n" |
| 300 | | "For example, a proj literal:\n" |
| 301 | | "\t'+proj=latlong +datum=WGS84'\n" |
| 302 | | "and a proj epsg code:\n" |
| 303 | | "\t'+init=epsg:4326'\n" |
| 304 | | "\n" |
| 305 | | "Note: using epsg codes requires the installation of\n" |
| 306 | | "the Proj.4 'epsg' data file normally found in '/usr/local/share/proj'\n" |
| 307 | | "\n" |
| 308 | | "Usage:\n" |
| 309 | | ">>> m.srs\n" |
| 310 | | "'+proj=latlong +datum=WGS84' # The default srs if not initialized with custom srs\n" |
| 311 | | ">>> # set to google mercator with Proj.4 literal\n" |
| 312 | | "... \n" |
| 313 | | ">>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'\n" |
| 314 | | ) |
| 315 | | |
| 316 | | .add_property("width", |
| 317 | | &Map::getWidth, |
| 318 | | &Map::setWidth, |
| 319 | | "Get/Set the width of the map in pixels.\n" |
| 320 | | "Minimum settable size is 16 pixels.\n" |
| 321 | | "\n" |
| 322 | | "Usage:\n" |
| 323 | | ">>> m.width\n" |
| 324 | | "600\n" |
| 325 | | ">>> m.width = 800\n" |
| 326 | | ">>> m.width\n" |
| 327 | | "800\n" |
| 328 | | ) |
| 329 | | ; |
| | 106 | class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >( |
| | 107 | "Create a Map with a width and height as integers and, optionally,\n" |
| | 108 | "an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n" |
| | 109 | "or with a Proj.4 literal ('+proj=<literal>').\n" |
| | 110 | "If no srs is specified the map will default to '+proj=latlong +datum=WGS84'\n" |
| | 111 | "\n" |
| | 112 | "Usage:\n" |
| | 113 | ">>> from mapnik import Map\n" |
| | 114 | ">>> m = Map(600,400)\n" |
| | 115 | ">>> m\n" |
| | 116 | "<mapnik._mapnik.Map object at 0x6a240>\n" |
| | 117 | ">>> m.srs\n" |
| | 118 | "'+proj=latlong +datum=WGS84'\n" |
| | 119 | )) |
| | 120 | |
| | 121 | .def_pickle(map_pickle_suite() |
| | 122 | ) |
| | 123 | |
| | 124 | .def("append_style",&Map::insert_style, |
| | 125 | "Insert a Mapnik Style onto the map by appending it.\n" |
| | 126 | "\n" |
| | 127 | "Usage:\n" |
| | 128 | ">>> sty\n" |
| | 129 | "<mapnik._mapnik.Style object at 0x6a330>\n" |
| | 130 | ">>> m.append_style('Style Name', sty)\n" |
| | 131 | "True # style object added to map by name\n" |
| | 132 | ">>> m.append_style('Style Name', sty)\n" |
| | 133 | "False # you can only append styles with unique names\n" |
| | 134 | ) |
| | 135 | |
| | 136 | .def("envelope", |
| | 137 | make_function(&Map::getCurrentExtent, |
| | 138 | return_value_policy<copy_const_reference>()), |
| | 139 | "Return the Map Envelope object\n" |
| | 140 | "and print the string representation\n" |
| | 141 | "of the current extent of the map.\n" |
| | 142 | "\n" |
| | 143 | "Usage:\n" |
| | 144 | ">>> m.envelope()\n" |
| | 145 | "Envelope(-0.185833333333,-0.96,0.189166666667,-0.71)\n" |
| | 146 | ">>> dir(m.envelope())\n" |
| | 147 | "...'center', 'contains', 'expand_to_include', 'forward',\n" |
| | 148 | "...'height', 'intersect', 'intersects', 'inverse', 'maxx',\n" |
| | 149 | "...'maxy', 'minx', 'miny', 'width'\n" |
| | 150 | ) |
| | 151 | |
| | 152 | .def("find_style", |
| | 153 | find_style, |
| | 154 | |
| | 155 | "Query the Map for a style by name and return\n" |
| | 156 | "a style object if found or raise KeyError\n" |
| | 157 | "style if not found.\n" |
| | 158 | "\n" |
| | 159 | "Usage:\n" |
| | 160 | ">>> m.find_style('Style Name')\n" |
| | 161 | "<mapnik._mapnik.Style object at 0x654f0>\n" |
| | 162 | ) |
| | 163 | |
| | 164 | .def("pan",&Map::pan, |
| | 165 | "Set the Map center at a given x,y location\n" |
| | 166 | "as integers in the coordinates of the pixmap or map surface.\n" |
| | 167 | "\n" |
| | 168 | "Usage:\n" |
| | 169 | ">>> m = Map(600,400)\n" |
| | 170 | ">>> m.envelope().center()\n" |
| | 171 | "Coord(-0.5,-0.5) # default Map center\n" |
| | 172 | ">>> m.pan(-1,-1)\n" |
| | 173 | ">>> m.envelope().center()\n" |
| | 174 | "Coord(0.00166666666667,-0.835)\n" |
| | 175 | ) |
| | 176 | |
| | 177 | .def("pan_and_zoom",&Map::pan_and_zoom, |
| | 178 | "Set the Map center at a given x,y location\n" |
| | 179 | "and zoom factor as a float.\n" |
| | 180 | "\n" |
| | 181 | "Usage:\n" |
| | 182 | ">>> m = Map(600,400)\n" |
| | 183 | ">>> m.envelope().center()\n" |
| | 184 | "Coord(-0.5,-0.5) # default Map center\n" |
| | 185 | ">>> m.scale()\n" |
| | 186 | "-0.0016666666666666668\n" |
| | 187 | ">>> m.pan_and_zoom(-1,-1,0.25)\n" |
| | 188 | ">>> m.scale()\n" |
| | 189 | "0.00062500000000000001\n" |
| | 190 | ) |
| | 191 | |
| | 192 | .def("query_map_point",&Map::query_map_point, |
| | 193 | "Query a Map Layer (by layer index) for features \n" |
| | 194 | "intersecting the given x,y location in the coordinates\n" |
| | 195 | "of the pixmap or map surface.\n" |
| | 196 | "Will return a Mapnik Featureset if successful\n" |
| | 197 | "otherwise will return None.\n" |
| | 198 | "\n" |
| | 199 | "Usage:\n" |
| | 200 | ">>> feat = m.query_map_point(0,200,200)\n" |
| | 201 | ">>> feat\n" |
| | 202 | ">>> <mapnik._mapnik.Featureset object at 0x5fe1f0>\n" |
| | 203 | ">>> feat.next()\n" |
| | 204 | ">>> <mapnik._mapnik.Feature object at 0x5fe230>\n" |
| | 205 | ) |
| | 206 | |
| | 207 | .def("query_point",&Map::query_point, |
| | 208 | "Query a Map Layer (by layer index) for features \n" |
| | 209 | "intersecting the given x,y location in the coordinates\n" |
| | 210 | "of map projection.\n" |
| | 211 | "Will return a Mapnik Featureset if successful\n" |
| | 212 | "otherwise will return None.\n" |
| | 213 | "\n" |
| | 214 | "Usage:\n" |
| | 215 | ">>> feat = m.query_point(0,-122,48)\n" |
| | 216 | ">>> feat\n" |
| | 217 | ">>> <mapnik._mapnik.Featureset object at 0x5fe130>\n" |
| | 218 | ">>> feat.next()\n" |
| | 219 | ">>> <mapnik._mapnik.Feature object at 0x5fe1b0>\n" |
| | 220 | ) |
| | 221 | |
| | 222 | .def("remove_style",&Map::remove_style, |
| | 223 | "Remove a Mapnik Style from the map.\n" |
| | 224 | "\n" |
| | 225 | "Usage:\n" |
| | 226 | ">>> m.remove_style('Style Name')\n" |
| | 227 | ) |
| | 228 | |
| | 229 | .def("scale", &Map::scale, |
| | 230 | "Return the Map Scale.\n" |
| | 231 | "Usage:\n" |
| | 232 | "\n" |
| | 233 | ">>> m.scale()\n" |
| | 234 | ) |
| | 235 | |
| | 236 | .def("zoom",&Map::zoom, |
| | 237 | "Zoom in by a given factor.\n" |
| | 238 | "Usage:\n" |
| | 239 | "\n" |
| | 240 | ">>> m.zoom(0.25)\n" |
| | 241 | ) |
| | 242 | |
| | 243 | .def("zoom_all",&Map::zoom_all, |
| | 244 | "Set the geographical extent of the map\n" |
| | 245 | "to the combined extents of all active layers.\n" |
| | 246 | "\n" |
| | 247 | "Usage:\n" |
| | 248 | ">>> m.zoom_all()\n" |
| | 249 | ) |
| | 250 | |
| | 251 | .def("zoom_to_box",&Map::zoomToBox, |
| | 252 | "Set the geographical extent of the map\n" |
| | 253 | "by specifying a Mapnik Envelope.\n" |
| | 254 | "\n" |
| | 255 | "Usage:\n" |
| | 256 | ">>> extext = Envelope(-180.0, -90.0, 180.0, 90.0)\n" |
| | 257 | ">>> m.zoom_to_box(extent)\n" |
| | 258 | ) |
| | 259 | |
| | 260 | .add_property("background",make_function |
| | 261 | (&Map::background,return_value_policy<copy_const_reference>()), |
| | 262 | &Map::set_background, |
| | 263 | "The background color of the map.\n" |
| | 264 | "\n" |
| | 265 | "Usage:\n" |
| | 266 | ">>> m.background = Color('steelblue')\n" |
| | 267 | ) |
| | 268 | |
| | 269 | .add_property("buffer_size", |
| | 270 | &Map::buffer_size, |
| | 271 | &Map::set_buffer_size, |
| | 272 | "Get/Set the size of buffer around map in pixels.\n" |
| | 273 | "\n" |
| | 274 | "Usage:\n" |
| | 275 | ">>> m.buffer_size\n" |
| | 276 | "0 # zero by default\n" |
| | 277 | ">>> m.buffer_size = 2\n" |
| | 278 | ">>> m.buffer_size\n" |
| | 279 | "2\n" |
| | 280 | ) |
| | 281 | |
| | 282 | .add_property("height", |
| | 283 | &Map::getHeight, |
| | 284 | &Map::setHeight, |
| | 285 | "Get/Set the height of the map in pixels.\n" |
| | 286 | "Minimum settable size is 16 pixels.\n" |
| | 287 | "\n" |
| | 288 | "Usage:\n" |
| | 289 | ">>> m.height\n" |
| | 290 | "400\n" |
| | 291 | ">>> m.height = 600\n" |
| | 292 | ">>> m.height\n" |
| | 293 | "600\n" |
| | 294 | ) |
| | 295 | |
| | 296 | .add_property("layers",make_function |
| | 297 | (layers_nonconst,return_value_policy<reference_existing_object>()), |
| | 298 | "The list of map layers.\n" |
| | 299 | "\n" |
| | 300 | "Usage:\n" |
| | 301 | ">>> m.layers\n" |
| | 302 | "<mapnik._mapnik.Layers object at 0x6d458>" |
| | 303 | ">>> m.layers[0]\n" |
| | 304 | "<mapnik._mapnik.Layer object at 0x5fe130>\n" |
| | 305 | ) |
| | 306 | |
| | 307 | .add_property("srs", |
| | 308 | make_function(&Map::srs,return_value_policy<copy_const_reference>()), |
| | 309 | &Map::set_srs, |
| | 310 | "Spatial reference in Proj.4 format.\n" |
| | 311 | "Either an epsg code or proj literal.\n" |
| | 312 | "For example, a proj literal:\n" |
| | 313 | "\t'+proj=latlong +datum=WGS84'\n" |
| | 314 | "and a proj epsg code:\n" |
| | 315 | "\t'+init=epsg:4326'\n" |
| | 316 | "\n" |
| | 317 | "Note: using epsg codes requires the installation of\n" |
| | 318 | "the Proj.4 'epsg' data file normally found in '/usr/local/share/proj'\n" |
| | 319 | "\n" |
| | 320 | "Usage:\n" |
| | 321 | ">>> m.srs\n" |
| | 322 | "'+proj=latlong +datum=WGS84' # The default srs if not initialized with custom srs\n" |
| | 323 | ">>> # set to google mercator with Proj.4 literal\n" |
| | 324 | "... \n" |
| | 325 | ">>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'\n" |
| | 326 | ) |
| | 327 | |
| | 328 | .add_property("width", |
| | 329 | &Map::getWidth, |
| | 330 | &Map::setWidth, |
| | 331 | "Get/Set the width of the map in pixels.\n" |
| | 332 | "Minimum settable size is 16 pixels.\n" |
| | 333 | "\n" |
| | 334 | "Usage:\n" |
| | 335 | ">>> m.width\n" |
| | 336 | "600\n" |
| | 337 | ">>> m.width = 800\n" |
| | 338 | ">>> m.width\n" |
| | 339 | "800\n" |
| | 340 | ) |
| | 341 | ; |