From: <hb...@us...> - 2012-05-19 10:04:23
|
Revision: 2605 http://gpsdrive.svn.sourceforge.net/gpsdrive/?rev=2605&view=rev Author: hbowman Date: 2012-05-19 10:04:16 +0000 (Sat, 19 May 2012) Log Message: ----------- deal with new Mapnik 2.0 API Modified Paths: -------------- trunk/src/mapnik.cpp Modified: trunk/src/mapnik.cpp =================================================================== --- trunk/src/mapnik.cpp 2012-05-19 05:03:17 UTC (rev 2604) +++ trunk/src/mapnik.cpp 2012-05-19 10:04:16 UTC (rev 2605) @@ -22,6 +22,7 @@ #include <mapnik/font_engine_freetype.hpp> #include <mapnik/config_error.hpp> #include <mapnik/image_util.hpp> +#include <mapnik/version.hpp> #include <fstream> #include <sys/stat.h> @@ -29,10 +30,17 @@ #include "config.h" #include "gpsdrive_config.h" + +#if MAPNIK_VERSION < 200000 using mapnik::Image32; -using mapnik::Map; using mapnik::Layer; using mapnik::Envelope; +#else +using mapnik::image_32; +using mapnik::layer; +using mapnik::box2d; +#endif +using mapnik::Map; using mapnik::coord2d; using mapnik::feature_ptr; using mapnik::geometry_ptr; @@ -491,7 +499,7 @@ double res = scale_denom * 0.00028; /* render image */ - +#if MAPNIK_VERSION < 200000 Envelope<double> box = Envelope<double>(MapnikMap.NewCenterPt.x - 0.5 * MapnikMap.WidthInt * res, MapnikMap.NewCenterPt.y - 0.5 * MapnikMap.HeightInt * res, MapnikMap.NewCenterPt.x + 0.5 * MapnikMap.WidthInt * res, @@ -504,16 +512,36 @@ ren.apply(); if (mydebug > 0) std::cout << MapnikMap.MapPtr->getCurrentExtent() << "\n"; +#else + box2d<double> box = box2d<double>(MapnikMap.NewCenterPt.x - 0.5 * MapnikMap.WidthInt * res, + MapnikMap.NewCenterPt.y - 0.5 * MapnikMap.HeightInt * res, + MapnikMap.NewCenterPt.x + 0.5 * MapnikMap.WidthInt * res, + MapnikMap.NewCenterPt.y + 0.5 * MapnikMap.HeightInt * res); + MapnikMap.MapPtr->zoom_to_box(box); + + image_32 buf(MapnikMap.WidthInt, MapnikMap.HeightInt); + mapnik::agg_renderer<image_32> ren(*MapnikMap.MapPtr,buf); + ren.apply(); + + if (mydebug > 0) std::cout << MapnikMap.MapPtr->get_current_extent() << "\n"; +#endif /* get raw data for gpsdrives pixbuf */ convert_argb32_to_gdkpixbuf_data(buf.raw_data(), MapnikMap.ImageRawDataPtr); /* create pixbuf data before check to unref */ - if (MapnikMap.GdkPixbufPtr) gdk_pixbuf_unref(MapnikMap.GdkPixbufPtr); - MapnikMap.GdkPixbufPtr = gdk_pixbuf_new_from_data(MapnikMap.ImageRawDataPtr, GDK_COLORSPACE_RGB, FALSE, 8, 1280, 1024, 1280 * 3, NULL, NULL); + if (MapnikMap.GdkPixbufPtr) + gdk_pixbuf_unref(MapnikMap.GdkPixbufPtr); + MapnikMap.GdkPixbufPtr = gdk_pixbuf_new_from_data(MapnikMap.ImageRawDataPtr, + GDK_COLORSPACE_RGB, FALSE, 8, 1280, 1024, 1280 * 3, NULL, NULL); + /* ok we have a map set default values */ +#if MAPNIK_VERSION < 200000 mapnik::Envelope<double> ext = MapnikMap.MapPtr->getCurrentExtent(); +#else + mapnik::box2d<double> ext = MapnikMap.MapPtr->get_current_extent(); +#endif mapnik::coord2d pt = ext.center(); MapnikMap.CenterPt.x = pt.x; MapnikMap.CenterPt.y = pt.y; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |