Skip to content
This repository
  • 3 commits
  • 5 files changed
  • 0 comments
  • 1 contributor
6  include/mapnik/metawriter_renderer.hpp
@@ -59,12 +59,10 @@ class MAPNIK_DECL metawriter_renderer : public feature_style_processor<metawrite
59 59
 
60 60
     void start_style_processing(feature_type_style const& st);
61 61
     void end_style_processing(feature_type_style const& st);
62  
-    
63  
-    /*
  62
+       
64 63
     void process(point_symbolizer const& sym,
65 64
                  mapnik::feature_ptr const& feature,
66  
-                 proj_transform const& prj_trans);
67  
-    */
  65
+                 proj_transform const& prj_trans);    
68 66
     void process(line_symbolizer const& sym,
69 67
                  mapnik::feature_ptr const& feature,
70 68
                  proj_transform const& prj_trans);
1  src/build.py
@@ -279,6 +279,7 @@ def ldconfig(*args,**kwargs):
279 279
     """
280 280
     metawriter/metawriter_renderer.cpp
281 281
     metawriter/process_line_symbolizer.cpp
  282
+    metawriter/process_point_symbolizer.cpp
282 283
     """)
283 284
 
284 285
 if env['SVG_RENDERER']: # svg backend
70  src/feature_style_processor.cpp
@@ -98,35 +98,35 @@ struct feature_style_processor<Processor>::symbol_dispatch : public boost::stati
98 98
         : output_(output),
99 99
           f_(f),
100 100
           prj_trans_(prj_trans)  {}
101  
-    
  101
+
102 102
     template <typename T>
103 103
     void operator () (T const& sym) const
104 104
     {
105 105
         process_impl<has_process<Processor,T>::value>::process(output_,sym,f_,prj_trans_);
106 106
     }
107  
-    
  107
+
108 108
     Processor & output_;
109 109
     mapnik::feature_ptr const& f_;
110 110
     proj_transform const& prj_trans_;
111 111
 };
112 112
 
113  
-typedef char (&no_tag)[1]; 
114  
-typedef char (&yes_tag)[2]; 
  113
+typedef char (&no_tag)[1];
  114
+typedef char (&yes_tag)[2];
  115
+
  116
+template <typename T0, typename T1, void (T0::*)(T1 const&, mapnik::feature_ptr const&, proj_transform const&) >
  117
+struct process_memfun_helper {};
115 118
 
116  
-template <typename T0, typename T1, void (T0::*)(T1 const&, mapnik::feature_ptr const&, proj_transform const&) > 
117  
-struct process_memfun_helper {}; 
118  
-    
119  
-template <typename T0, typename T1> no_tag  has_process_helper(...); 
  119
+template <typename T0, typename T1> no_tag  has_process_helper(...);
120 120
 template <typename T0, typename T1> yes_tag has_process_helper(process_memfun_helper<T0, T1, &T0::process>* p);
121  
-    
122  
-template<typename T0,typename T1> 
  121
+
  122
+template<typename T0,typename T1>
123 123
 struct has_process
124  
-{      
  124
+{
125 125
     typedef typename T0::processor_impl_type processor_impl_type;
126  
-    BOOST_STATIC_CONSTANT(bool 
127  
-                          , value = sizeof(has_process_helper<processor_impl_type,T1>(0)) == sizeof(yes_tag) 
128  
-        ); 
129  
-}; 
  126
+    BOOST_STATIC_CONSTANT(bool
  127
+                          , value = sizeof(has_process_helper<processor_impl_type,T1>(0)) == sizeof(yes_tag)
  128
+        );
  129
+};
130 130
 
131 131
 
132 132
 template <typename Processor>
@@ -149,9 +149,6 @@ void feature_style_processor<Processor>::apply()
149 149
     try
150 150
     {
151 151
         projection proj(m_.srs());
152  
-
153  
-        //start_metawriters(m_,proj);
154  
-
155 152
         double scale_denom = mapnik::scale_denominator(m_,proj.is_geographic());
156 153
         scale_denom *= scale_factor_;
157 154
 
@@ -163,8 +160,6 @@ void feature_style_processor<Processor>::apply()
163 160
                 apply_to_layer(lyr, p, proj, scale_denom, names);
164 161
             }
165 162
         }
166  
-
167  
-        //stop_metawriters(m_);
168 163
     }
169 164
     catch (proj_init_error& ex)
170 165
     {
@@ -492,7 +487,7 @@ void feature_style_processor<Processor>::render_style(
492 487
 {
493 488
 
494 489
     p.start_style_processing(*style);
495  
-    
  490
+
496 491
 #if defined(RENDERING_STATS)
497 492
     std::ostringstream s1;
498 493
     s1 << "rendering style for layer: '" << lay.name()
@@ -528,18 +523,13 @@ void feature_style_processor<Processor>::render_style(
528 523
 
529 524
                 do_else=false;
530 525
                 do_also=true;
531  
-                rule::symbolizers const& symbols = r->get_symbolizers();
532 526
 
533  
-                // if the underlying renderer is not able to process the complete set of symbolizers,
534  
-                // process one by one.
535  
-                // if(!p.process(symbols,feature,prj_trans))
  527
+                rule::symbolizers const& symbols = r->get_symbolizers();
  528
+                BOOST_FOREACH (symbolizer const& sym, symbols)
536 529
                 {
537  
-
538  
-                    BOOST_FOREACH (symbolizer const& sym, symbols)
539  
-                    {
540  
-                        boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
541  
-                    }
  530
+                    boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
542 531
                 }
  532
+
543 533
                 if (style->get_filter_mode() == FILTER_FIRST)
544 534
                 {
545 535
                     // Stop iterating over rules and proceed with next feature.
@@ -558,14 +548,9 @@ void feature_style_processor<Processor>::render_style(
558 548
                 p.painted(true);
559 549
 
560 550
                 rule::symbolizers const& symbols = r->get_symbolizers();
561  
-                // if the underlying renderer is not able to process the complete set of symbolizers,
562  
-                // process one by one.
563  
-                //if(!p.process(symbols,feature,prj_trans))
  551
+                BOOST_FOREACH (symbolizer const& sym, symbols)
564 552
                 {
565  
-                    BOOST_FOREACH (symbolizer const& sym, symbols)
566  
-                    {
567  
-                        boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
568  
-                    }
  553
+                    boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
569 554
                 }
570 555
             }
571 556
         }
@@ -580,14 +565,10 @@ void feature_style_processor<Processor>::render_style(
580 565
                 p.painted(true);
581 566
 
582 567
                 rule::symbolizers const& symbols = r->get_symbolizers();
583  
-                // if the underlying renderer is not able to process the complete set of symbolizers,
584  
-                // process one by one.
585  
-                //if(!p.process(symbols,feature,prj_trans))
  568
+
  569
+                BOOST_FOREACH (symbolizer const& sym, symbols)
586 570
                 {
587  
-                    BOOST_FOREACH (symbolizer const& sym, symbols)
588  
-                    {
589  
-                        boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
590  
-                    }
  571
+                    boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym);
591 572
                 }
592 573
             }
593 574
         }
@@ -635,4 +616,3 @@ template class feature_style_processor<agg_renderer<image_32> >;
635 616
 template class feature_style_processor<metawriter_renderer>;
636 617
 
637 618
 }
638  
-
3  src/metawriter.cpp
@@ -170,7 +170,8 @@ void metawriter_json_stream::add_box(box2d<double> const &box, Feature const& fe
170 170
         minx << ", " << miny << "], [" <<
171 171
         maxx << ", " << miny << "], [" <<
172 172
         maxx << ", " << maxy << "], [" <<
173  
-        minx << ", " << maxy << "] ] ]";
  173
+        minx << ", " << maxy << "], [" <<
  174
+        minx << ", " << miny << "] ] ]";
174 175
 
175 176
     write_properties(feature, properties);
176 177
 
95  src/metawriter/process_point_symbolizer.cpp
... ...
@@ -0,0 +1,95 @@
  1
+/*****************************************************************************
  2
+ *
  3
+ * This file is part of Mapnik (c++ mapping toolkit)
  4
+ *
  5
+ * Copyright (C) 2011 Artem Pavlenko
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ *****************************************************************************/
  22
+
  23
+// mapnik
  24
+#include <mapnik/image_util.hpp>
  25
+#include <mapnik/marker.hpp>
  26
+#include <mapnik/marker_cache.hpp>
  27
+#include <mapnik/point_symbolizer.hpp>
  28
+#include <mapnik/metawriter_renderer.hpp>
  29
+#include <mapnik/metawriter_factory.hpp>
  30
+
  31
+// stl
  32
+#include <string>
  33
+
  34
+// boost
  35
+#include <boost/make_shared.hpp>
  36
+
  37
+namespace mapnik {
  38
+
  39
+void metawriter_renderer::process(point_symbolizer const& sym,
  40
+                              mapnik::feature_ptr const& feature,
  41
+                              proj_transform const& prj_trans)
  42
+{
  43
+    std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature);
  44
+
  45
+    boost::optional<mapnik::marker_ptr> marker;
  46
+    if ( !filename.empty() )
  47
+    {
  48
+        marker = marker_cache::instance()->find(filename, true);
  49
+    }
  50
+    else
  51
+    {
  52
+        marker.reset(boost::make_shared<mapnik::marker>());
  53
+    }
  54
+
  55
+    if (marker)
  56
+    {
  57
+        box2d<double> const& bbox = (*marker)->bounding_box();
  58
+        coord2d const center = bbox.center();
  59
+
  60
+        agg::trans_affine tr;
  61
+        evaluate_transform(tr, *feature, sym.get_image_transform());
  62
+
  63
+        agg::trans_affine_translation const recenter(-center.x, -center.y);
  64
+        agg::trans_affine const recenter_tr = recenter * tr;
  65
+        box2d<double> label_ext = bbox * recenter_tr;
  66
+
  67
+        for (unsigned i=0; i<feature->num_geometries(); ++i)
  68
+        {
  69
+            geometry_type const& geom = feature->get_geometry(i);
  70
+            double x;
  71
+            double y;
  72
+            double z=0;
  73
+            if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
  74
+                geom.label_position(&x, &y);
  75
+            else
  76
+                geom.label_interior_position(&x, &y);
  77
+
  78
+            prj_trans.backward(x,y,z);
  79
+            t_.forward(&x,&y);
  80
+            label_ext.re_center(x,y);
  81
+
  82
+            if (sym.get_allow_overlap() ||
  83
+                detector_->has_placement(label_ext))
  84
+            {                
  85
+                if (!sym.get_ignore_placement())
  86
+                    detector_->insert(label_ext);
  87
+                metawriter_with_properties writer = sym.get_metawriter();
  88
+                add_box(writer.first, label_ext,*feature, t_, writer.second);
  89
+            }
  90
+        }
  91
+    }
  92
+}
  93
+}
  94
+
  95
+

No commit comments for this range

Something went wrong with that request. Please try again.