Class Decimator


  • public final class Decimator
    extends Object
    Accepts geometries and collapses all the vertices that will be rendered to the same pixel. This class works only if the Geometries are based on LiteCoordinateSequence instances.
    Since:
    2.1.x
    Author:
    jeichar
    • Constructor Detail

      • Decimator

        public Decimator​(MathTransform screenToWorld,
                         Rectangle paintArea,
                         double pixelDistance)
        Builds a decimator that will generalize geometries so that two subsequent points will be at least pixelDistance away from each other when painted on the screen. Set pixelDistance to 0 if you don't want any generalization (but just a transformation)
      • Decimator

        public Decimator​(MathTransform screenToWorld,
                         Rectangle paintArea)
        djb - noticed that the old way of finding out the decimation is based on the (0,0) location of the image. This is often wildly unrepresentitive of the scale of the entire map.

        A better thing to do is to decimate this on a per-shape basis (and use the shape's center). Another option would be to sample the image at different locations (say 9) and choose the smallest spanx/spany you find.

        Also, if the xform is an affine Xform, you can be a bit more aggressive in the decimation. If its not an affine xform (ie. its actually doing a CRS xform), you may find this is a bit too aggressive due to any number of mathematical issues.

        This is just a simple method that uses the centre of the given rectangle instead of (0,0).

        NOTE: this could need more work based on CRS, but the rectangle is in pixels so it should be fairly immune to all but crazy projections.

      • Decimator

        public Decimator​(double spanx,
                         double spany)
    • Method Detail

      • getSpanX

        public double getSpanX()
        The generalization step in the x direction
      • getSpanY

        public double getSpanY()
        The generalization step in the y direction
      • computeGeneralizationDistances

        public static double[] computeGeneralizationDistances​(MathTransform screenToWorld,
                                                              Rectangle paintArea,
                                                              double pixelDistance)
                                                       throws TransformException
        Given a full transformation from screen to world and the paint area computes a best guess of the maxium generalization distance that won't make the transformations induced by the generalization visible on screen.

        In other words, it computes how long a pixel is in the native spatial reference system of the data

        Throws:
        TransformException
      • decimate

        public final void decimate​(Geometry geom)
        decimates JTS geometries.