Hi,
I'm sorry because I can't be more helpful. I still don't know how to create a 
patch, so here is the file: /include/mapnik/label_collision_detector.hpp the 
changes are in lines 169 and 186.

Pablo Torres Carreira




Subject: Re: [Mapnik-users] TextSymbolizer allow labels to overlap - one 
solution found
From: [email protected]
Date: Thu, 23 Dec 2010 12:36:27 -0800
CC: [email protected]
To: [email protected]



Great, thanks for the follow through Pablo. Good stuff.
I see you updated http://trac.mapnik.org/ticket/678 as well with the images. 
Can you also attach your patch?
Dane
On Dec 23, 2010, at 5:33 AM, Pablo Carreira wrote:Hi,
After a nice time looking at mapnik's code,  I managed to totally disable 
collision detection for line_placed labels.Since I don't know nothing about 
C++, I made it in a "ugly" way changing the label_collision_detector.hpp making 
has_placement aways return true. Maybe it could become an option in the 
future.More details in tiket #678.
Look at the before and after images. It's a another steep heading toward nice 
'on-the-fly' typographic maps made from OSM data. lol

Regards,
Pablo Torres Carreira 



From: [email protected]
CC: [email protected]
Subject: RE: [Mapnik-users] TextSymbolizer allow labels to overlap
Date: Mon, 20 Dec 2010 09:20:31 -0200

Hi Dane,
>So, sounds like you are doing all that you can - could you please comment 
>further on the original ticket you created with some sample data/xml?

I'm running mores test here and soon I will provide more information.

Regards,
Pablo.




On Dec 17, 2010, at 1:46 PM, Pablo Carreira wrote:Hi Lennard,

> 
> > Is there any way (even if it's dirty) to disable collisionsdetections or
> > anything like that so the line_placed labels could overlap each other in
> > the same layer?
> 
> Use allow_overlap="yes" with TextSymbolizer.

Bothallow_overlap="yes"
and in the layer levelclear_label_cache="on" 
But I still don't get the desired effect.

Pablo.


_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

<before.jpg><after.jpg>_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

                                          
/*****************************************************************************
 * 
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 Artem Pavlenko
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

//$Id$

#if !defined LABEL_COLLISION_DETECTOR
#define LABEL_COLLISION_DETECTOR
// mapnik
#include <mapnik/quad_tree.hpp>
#include <mapnik/value.hpp>
// stl
#include <vector>
#include <unicode/unistr.h>

namespace mapnik
{
   //this needs to be tree structure 
   //as a proof of a concept _only_ we use sequential scan 

   struct label_collision_detector
   {
      typedef std::vector<Envelope<double> > label_placements;

      bool has_plasement(Envelope<double> const& box)
      {
         label_placements::const_iterator itr=labels_.begin();
         for( ; itr !=labels_.end();++itr)
         {
            if (itr->intersects(box))
            {
               return false;
            }
         }
         labels_.push_back(box);
         return true;
      }
      void clear()
      {
         labels_.clear();
      }
          
   private:

      label_placements labels_;
   };

   // quad_tree based label collision detector
   class label_collision_detector2 : boost::noncopyable
   {
      typedef quad_tree<Envelope<double> > tree_t;
      tree_t tree_;
   public:
         
      explicit label_collision_detector2(Envelope<double> const& extent)
         : tree_(extent) {}
	
      bool has_placement(Envelope<double> const& box)
      {
         tree_t::query_iterator itr = tree_.query_in_box(box);
         tree_t::query_iterator end = tree_.query_end();
	    
         for ( ;itr != end; ++itr)
         {
            if (itr->intersects(box))
            {
               return false;
            }
         }
	    
         tree_.insert(box,box);
         return true;
      }
         
      void clear()
      {
         tree_.clear();
      } 
         
   };
    
   // quad_tree based label collision detector with seperate check/insert
   class label_collision_detector3 : boost::noncopyable
   {
      typedef quad_tree< Envelope<double> > tree_t;
      tree_t tree_;
   public:
	
      explicit label_collision_detector3(Envelope<double> const& extent)
         : tree_(extent) {}
	
      bool has_placement(Envelope<double> const& box)
      {
         tree_t::query_iterator itr = tree_.query_in_box(box);
         tree_t::query_iterator end = tree_.query_end();
          
         for ( ;itr != end; ++itr)
         {
            if (itr->intersects(box))
            {
               return false;
            }
         }
          
         return true;
      }

      void insert(Envelope<double> const& box)
      {
         tree_.insert(box, box);
      }
         
      void clear()
      {
         tree_.clear();
      }
   };

    
   //quad tree based label collission detector so labels dont appear within a given distance
   class label_collision_detector4 : boost::noncopyable
   {
      struct label
      {
         label(Envelope<double> const& b) : box(b) {}
         label(Envelope<double> const& b, UnicodeString const& t) : box(b), text(t) {}
               
         Envelope<double> box;
         UnicodeString text;
      };
         
      typedef quad_tree< label > tree_t;
      Envelope<double> extent_;
      tree_t tree_;
         
   public:
	
      explicit label_collision_detector4(Envelope<double> const& extent)
         : extent_(extent),
           tree_(extent) {}
	
      bool has_placement(Envelope<double> const& box)
      {
         tree_t::query_iterator itr = tree_.query_in_box(box);
         tree_t::query_iterator end = tree_.query_end();
          
         for ( ;itr != end; ++itr)
         {
            if (itr->box.intersects(box))
            {
            	return true;                //return false;
            }
         }
          
         return true;
      }	

      bool has_placement(Envelope<double> const& box, UnicodeString const& text, double distance)
      {
         Envelope<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance);
         tree_t::query_iterator itr = tree_.query_in_box(bigger_box);
         tree_t::query_iterator end = tree_.query_end();
        
         for ( ;itr != end; ++itr)
         {
            if (itr->box.intersects(box) || (text == itr->text && itr->box.intersects(bigger_box)))
            {
            	return true;               //return false;
            }
         }
	    
         return true;
      }	

      bool has_point_placement(Envelope<double> const& box, double distance)
      {
         Envelope<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance);
         tree_t::query_iterator itr = tree_.query_in_box(bigger_box);
         tree_t::query_iterator end = tree_.query_end();
         
         for ( ;itr != end; ++itr)
         {
            if (itr->box.intersects(bigger_box))
            {
               return false;
            }
         }
	 
         return true;
      }	
      
      void insert(Envelope<double> const& box)
      {
         tree_.insert(label(box), box);
      }
         
      void insert(Envelope<double> const& box, UnicodeString const& text)
      {
         tree_.insert(label(box, text), box);
      }
         
      void clear()
      {
         tree_.clear();
      }
      
      Envelope<double> const& extent() const
      {
         return extent_;
      }
   };
}

#endif 
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to