{"action":"opened","issue":{"number":590,"created_at":"2011-10-11T15:26:47Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Based on discussion here:\r\n\r\nhttp://lists.berlios.de/pipermail/mapnik-devel/2010-January/001044.html\r\n\r\nRelated tickets: #308,#402\r\n\r\nBackground: BoundsClipping\r\n\r\nWorking patch from David:\r\n{{{\r\n#!diff\r\ndiff -NbaurX scripts/from_trunk.exclude_sh.txt mapnik.0.7.1528/include/mapnik/feature_style_processor.hpp mapnik/include/mapnik/feature_style_processor.hpp\r\n--- mapnik.0.7.1528/include/mapnik/feature_style_processor.hpp\t2010-01-09 18:27:34.000000000 -0700\r\n+++ mapnik/include/mapnik/feature_style_processor.hpp\t2010-01-09 18:33:38.000000000 -0700\r\n@@ -121,15 +121,23 @@\r\n             boost::shared_ptr<datasource> ds=lay.datasource();\r\n             if (ds)\r\n             {\r\n-               Envelope<double> ext = m_.get_buffered_extent();\r\n                projection proj1(lay.srs());\r\n                proj_transform prj_trans(proj0,proj1);\r\n                \r\n-               double mx0 = ext.minx();\r\n-               double my0 = ext.miny();\r\n+               Envelope<double> ext = m_.get_buffered_extent();\r\n+               Envelope<double> all = m_.getAllLayersExtent();\r\n+\r\n+               // limit the buffered extents to the extents of all layers\r\n+               if ( ext.minx() > all.maxx() || ext.maxx() < all.minx() || ext.miny() > all.maxy() || ext.maxy() < all.miny() )\r\n+               {\r\n+                  return; // no intersection\r\n+               }\r\n+\r\n+               double mx0 = (all.minx() < ext.minx())? ext.minx(): all.minx();\r\n+               double my0 = (all.miny() < ext.miny())? ext.miny(): all.miny();\r\n                double mz0 = 0.0;\r\n-               double mx1 = ext.maxx();\r\n-               double my1 = ext.maxy();\r\n+               double mx1 = (all.maxx() > ext.maxx())? ext.maxx(): all.maxx();\r\n+               double my1 = (all.maxy() > ext.maxy())? ext.maxy(): all.maxy();\r\n                double mz1 = 0.0;\r\n                \r\n                // project main map projection into layers extent\r\ndiff -NbaurX scripts/from_trunk.exclude_sh.txt mapnik.0.7.1528/include/mapnik/map.hpp mapnik/include/mapnik/map.hpp\r\n--- mapnik.0.7.1528/include/mapnik/map.hpp\t2010-01-09 18:27:34.000000000 -0700\r\n+++ mapnik/include/mapnik/map.hpp\t2010-01-09 18:34:49.000000000 -0700\r\n@@ -78,6 +78,7 @@\r\n         std::vector<Layer> layers_;\r\n         aspect_fix_mode aspectFixMode_;\r\n         Envelope<double> currentExtent_;\r\n+        Envelope<double> allLayersExtent_;\r\n         \r\n     public:\r\n \r\n@@ -300,6 +301,13 @@\r\n \r\n         void pan_and_zoom(int x,int y,double zoom);\r\n \r\n+        void setAllLayersExtent();\r\n+\r\n+        /*! \\brief Get current bounding box encompassinag all layers.\r\n+         *  @return The current bounding box encompassinag all layers.\r\n+         */\r\n+        const Envelope<double>& getAllLayersExtent() const;\r\n+\r\n         /*! \\brief Get current bounding box.\r\n          *  @return The current bounding box.\r\n          */\r\ndiff -NbaurX scripts/from_trunk.exclude_sh.txt mapnik.0.7.1528/src/load_map.cpp mapnik/src/load_map.cpp\r\n--- mapnik.0.7.1528/src/load_map.cpp\t2010-01-09 18:27:40.000000000 -0700\r\n+++ mapnik/src/load_map.cpp\t2010-01-09 18:35:45.000000000 -0700\r\n@@ -120,6 +120,7 @@\r\n #endif\r\n         map_parser parser( strict, filename);\r\n         parser.parse_map(map, pt);\r\n+        map.setAllLayersExtent();\r\n     }\r\n \r\n     void load_map_string(Map & map, std::string const& str, bool strict, std::string const& base_url)\r\n@@ -141,6 +142,7 @@\r\n \r\n         map_parser parser( strict, base_url);\r\n         parser.parse_map(map, pt);\r\n+        map.setAllLayersExtent();\r\n     }\r\n \r\n     void map_parser::parse_map( Map & map, ptree const & pt )\r\ndiff -NbaurX scripts/from_trunk.exclude_sh.txt mapnik.0.7.1528/src/map.cpp mapnik/src/map.cpp\r\n--- mapnik.0.7.1528/src/map.cpp\t2010-01-09 18:27:40.000000000 -0700\r\n+++ mapnik/src/map.cpp\t2010-01-09 18:37:10.000000000 -0700\r\n@@ -280,6 +280,54 @@\r\n         fixAspectRatio();\r\n     }\r\n     \r\n+    void Map::setAllLayersExtent()\r\n+    {\r\n+        try\r\n+        {\r\n+            projection proj0(srs_);\r\n+            bool first = true;\r\n+            std::vector<Layer>::const_iterator itr = layers_.begin();\r\n+            std::vector<Layer>::const_iterator end = layers_.end();\r\n+            while (itr != end)\r\n+            {\r\n+                std::string const& layer_srs = itr->srs();\r\n+                projection proj1(layer_srs);\r\n+                proj_transform prj_trans(proj0,proj1);\r\n+\r\n+                Envelope<double> layerExt = itr->envelope();\r\n+                double x0 = layerExt.minx();\r\n+                double y0 = layerExt.miny();\r\n+                double z0 = 0.0;\r\n+                double x1 = layerExt.maxx();\r\n+                double y1 = layerExt.maxy();\r\n+                double z1 = 0.0;\r\n+                prj_trans.backward(x0,y0,z0);\r\n+                prj_trans.backward(x1,y1,z1);\r\n+\r\n+                Envelope<double> layerExt2(x0,y0,x1,y1);\r\n+#ifdef MAPNIK_DEBUG\r\n+                std::clog << \" layer1 - > \" << layerExt << \"\\n\";\r\n+                std::clog << \" layer2 - > \" << layerExt2 << \"\\n\";\r\n+#endif\r\n+                if (first)\r\n+                {\r\n+                    allLayersExtent_ = layerExt2;\r\n+                    first = false;\r\n+                }\r\n+                else\r\n+                {\r\n+                    allLayersExtent_.expand_to_include(layerExt2);\r\n+                }\r\n+                ++itr;\r\n+            }\r\n+        }\r\n+        catch (proj_init_error & ex)\r\n+        {\r\n+           std::clog << \"proj_init_error:\" << ex.what() << '\\n';\r\n+        }\r\n+    }\r\n+\r\n+\r\n     void Map::zoom_all() \r\n     {\r\n         try \r\n@@ -388,6 +436,12 @@\r\n         }\r\n     }\r\n    \r\n+    const Envelope<double>& Map::getAllLayersExtent() const\r\n+    {\r\n+        return allLayersExtent_;\r\n+    }\r\n+\r\n+\r\n     const Envelope<double>& Map::getCurrentExtent() const\r\n     {\r\n         return currentExtent_;\r\n}}}","comments":1,"title":"Add a Map level custom extent or max_extent to enhance clipping ability","updated_at":"2011-10-11T15:26:49Z","url":"https://api.github.com/repos/artemp/tickets2issues/issues/590","id":1876567,"assignee":null,"milestone":{"number":13,"created_at":"2011-10-11T14:50:06Z","due_on":"1970-01-01T09:21:56Z","title":"Mapnik 2.0","creator":{"avatar_url":"https://secure.gravatar.com/avatar/941f68386168a8a6b60f2529a7830af7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/artemp","id":59056,"login":"artemp"},"url":"https://api.github.com/repos/artemp/tickets2issues/milestones/13","open_issues":0,"closed_issues":62,"description":"Upcoming Mapnik 2 release (first in series)\r\n\r\nMajor new features:\r\n\r\n  * Expressions support ( dynamic/data-driven symbolizers - #359, #70,#352)\r\n  * SVG Symbol support, including Gradients\r\n  * \"!MetaWriters\": Support for outputting GeoJSON of rendered features (see: MetaWriter)\r\n  * Python3 support (wiki:Python3k)\r\n  * Better raster scaling methods like lanczos, cubic, and higher quality bilinear (#656)\r\n  * New RasterColorizer for color ramping data rasters\r\n  * Support for \"interior\" placement of points and labels (aka point_on_surface) #709\r\n  * Performance improvements under high concurrent load (avoidance of proj4 locking)\r\n  * Addition of a 'mapnik-config' program to query mapnik settings\r\n  * Support for XInclude in stylesheets: #567 ([http://trac.mapnik.org/browser/trunk/tests/data/good_maps/xinclude examples])\r\n  * New plugins: Rasterlite, GEOS, templates/hello_world\r\n  * NUmerous improvements to alpha blending in raster support\r\n  * New usage of boost::spirit 2 for parsing (colors, filters, expressions)\r\n    * This means much 'slower' compiles but faster runtime code\r\n  * Addition of Jpeg reader for reading jpeg symbols and jpeg datasources (in raster.input)\r\n  * Advanced MarkersSymbolizer drawing options\r\n  * memory_datasource support in python (dynamic creation of features)\r\n  * Support for the clang++ compiler\r\n  * Fractional text halos using Freetype2 Stroker\r\n  * Ability to align pattern fills globally (#203)\r\n  * Vastly improved builds on Open Solaris\r\n  * Support for .dbf files over 2GB (#595)\r\n  * Support for triggering line breaks with '\\n' character (#584)\r\n  * Symbols are lazily cached instead of being read from filesystem many times\r\n  * Features are cached when used in more than one style consecutively (optional feature)\r\n  * Added ability to pass scale factor to renderer to scale symbols, fonts, line widths\r\n  * OGCServer removed from source tree, now at https://github.com/mapnik/OGCServer with many bugfixes: \r\n  * WKT parser\r\n\r\nFollowing features will be addressed in subsequent releases:\r\n \r\n  * Polygon hatch fills (#642)\r\n  * Map orientation\r\n  ","state":"closed"},"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/941f68386168a8a6b60f2529a7830af7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/artemp","id":59056,"login":"artemp"},"html_url":"https://github.com/artemp/tickets2issues/issues/590","labels":[{"name":"Core_Library","url":"https://api.github.com/repos/artemp/tickets2issues/labels/Core_Library","color":"FFFFFF"}],"state":"open"},"legacy":{"number":590,"action":"opened","issue":1876567}}