uk.me.parabola.mkgmap.filters
Class SmoothingFilter

java.lang.Object
  extended by uk.me.parabola.mkgmap.filters.SmoothingFilter
All Implemented Interfaces:
MapFilter

public class SmoothingFilter
extends java.lang.Object
implements MapFilter

This is a filter that smooths out lines at low resolutions. If the element has no size at all at the given resolution, then it is not passed on down the chain at all is excluded from the map at that resolution.

Author:
Steve Ratcliffe

Constructor Summary
SmoothingFilter()
           
 
Method Summary
 void doFilter(MapElement element, MapFilterChain next)
          This applies to both lines and polygons.
 void init(FilterConfig config)
          Initialise the filter and pass in parameters that may be needed for the run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmoothingFilter

public SmoothingFilter()
Method Detail

init

public void init(FilterConfig config)
Description copied from interface: MapFilter
Initialise the filter and pass in parameters that may be needed for the run.

Specified by:
init in interface MapFilter
Parameters:
config - Configuration information, giving parameters of the map level that is being produced through this filter.

doFilter

public void doFilter(MapElement element,
                     MapFilterChain next)
This applies to both lines and polygons. We are going to smooth out the points in the line so that you do not get jaggies. We are assuming that there is not an excess of points at the highest resolution.
  1. If there is just one point, the drop it.
  2. Ff the element is too small altogether, then drop it.
  3. If there are just two points the pass it on unchanged. This is probably a pretty common case.
  4. The first point goes in unchanged.
  5. Average points in groups so that they exceed the step size at the shifted resolution.

Specified by:
doFilter in interface MapFilter
Parameters:
element - A map element that will be a line or a polygon.
next - This is used to pass the possibly transformed element onward.