~ubuntu-branches/ubuntu/trusty/mapnik/trusty

« back to all changes in this revision

Viewing changes to include/mapnik/geometry.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-03-18 01:07:40 UTC
  • mfrom: (1.1.4 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100318010740-u01iy3n0ux9xzzir
Tags: 0.7.0-2ubuntu1
* Merge from debian testing (LP: #526070), remaining changes:
  - Bump boost build-dep and libmapnik-dev depends to boost1.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
namespace mapnik {
39
39
    enum GeomType {
40
 
        Point = 1,
41
 
        LineString = 2,
42
 
        Polygon = 3
 
40
      Point = 1,
 
41
      LineString = 2,
 
42
      Polygon = 3
43
43
    };
44
44
    
45
45
    template <typename T>
49
49
        typedef T vertex_type;
50
50
        typedef typename vertex_type::type value_type;
51
51
    public:
52
 
        geometry () {}  
53
 
        
 
52
        geometry () {}  
 
53
  
54
54
        Envelope<double> envelope() const
55
55
        {
56
 
            Envelope<double> result;            
 
56
            Envelope<double> result;    
57
57
            double x,y;
58
 
            rewind(0);
 
58
            rewind(0);
59
59
            for (unsigned i=0;i<num_points();++i)
60
60
            {
61
61
                vertex(&x,&y);
72
72
        }
73
73
        
74
74
        virtual int type() const=0;
75
 
        virtual bool hit_test(value_type x,value_type y, double tol) const=0;   
 
75
        virtual bool hit_test(value_type x,value_type y, double tol) const=0;  
76
76
        virtual void label_position(double *x, double *y) const=0;
77
77
        virtual void move_to(value_type x,value_type y)=0;
78
78
        virtual void line_to(value_type x,value_type y)=0;
176
176
            double y1 =0;
177
177
            double ox =0;
178
178
            double oy =0;
179
 
            
 
179
      
180
180
            unsigned i;
181
181
 
182
182
            // Use first point as origin to improve numerical accuracy
194
194
               atmp += ai;
195
195
               xtmp += (x1 + x0) * ai;
196
196
               ytmp += (y1 + y0) * ai;
197
 
            }     
 
197
            }    
198
198
            if (atmp != 0)
199
199
            {
200
200
               *x = (xtmp/(3*atmp)) + ox;
202
202
               return;
203
203
            }
204
204
            *x=x0;
205
 
            *y=y0;                  
 
205
            *y=y0;            
206
206
         }
207
207
         
208
208
         void line_to(value_type x,value_type y)
231
231
         }
232
232
         
233
233
         bool hit_test(value_type x,value_type y, double) const
234
 
         {          
 
234
         {      
235
235
            return point_inside_path(x,y,cont_.begin(),cont_.end());
236
236
         } 
237
237
         
269
269
            double y0=0;
270
270
            double x1=0;
271
271
            double y1=0;
272
 
            
 
272
      
273
273
            unsigned size = cont_.size();
274
274
            if (size == 1)
275
275
            {
277
277
            }
278
278
            else if (size == 2)
279
279
            {
280
 
 
281
280
               cont_.get_vertex(0,&x0,&y0);
282
281
               cont_.get_vertex(1,&x1,&y1);
283
282
               *x = 0.5 * (x1 + x0);
284
 
               *y = 0.5 * (y1 + y0);            
 
283
               *y = 0.5 * (y1 + y0);    
285
284
            }
286
285
            else
287
286
            {
340
339
         }
341
340
         
342
341
         bool hit_test(value_type x,value_type y, double tol) const
343
 
         {          
 
342
         {      
344
343
            return point_on_path(x,y,cont_.begin(),cont_.end(),tol);
345
344
         } 
346
345