@Test public void testDecimationSpansInfinite() throws Exception { MathTransform mt = new AbstractMathTransform() { @Override public void transform( double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException { if (srcPts[0] == -0.5 || srcPts[1] == 0.5) { dstPts[0] = Double.NaN; dstPts[1] = Double.NaN; dstPts[2] = Double.NaN; dstPts[3] = Double.NaN; } else { dstPts[0] = srcPts[0] * 10; dstPts[1] = srcPts[1] * 10; dstPts[2] = srcPts[2] * 10; dstPts[3] = srcPts[3] * 10; } } @Override public int getTargetDimensions() { return 2; } @Override public int getSourceDimensions() { return 2; } }; double[] dx = Decimator.computeGeneralizationDistances(mt, new Rectangle(10, 10), 1); assertEquals(10, dx[0], 0d); assertEquals(10, dx[1], 0d); }
public static double[] computeGeneralizationDistances( MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) throws TransformException { try { double[] spans = getGeneralizationSpans( paintArea.x + paintArea.width / 2, paintArea.y + paintArea.height / 2, screenToWorld); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] ns = getGeneralizationSpans( paintArea.x + paintArea.width * i / 2.0, paintArea.y + paintArea.height * j / 2.0, screenToWorld); if (isFinite(ns[0]) && (ns[0] < spans[0] || !isFinite(spans[0]))) { spans[0] = ns[0]; } if (isFinite(ns[1]) && (ns[1] < spans[1] || !isFinite(spans[1]))) { spans[1] = ns[1]; } } } if (!isFinite(spans[0])) { spans[0] = 0; } if (!isFinite(spans[1])) { spans[1] = 0; } spans[0] *= pixelDistance; spans[1] *= pixelDistance; return spans; } catch (TransformException e) { return new double[] {0, 0}; } }
Decimator { public static double[] computeGeneralizationDistances( MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) throws TransformException { try { double[] spans = getGeneralizationSpans( paintArea.x + paintArea.width / 2, paintArea.y + paintArea.height / 2, screenToWorld); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] ns = getGeneralizationSpans( paintArea.x + paintArea.width * i / 2.0, paintArea.y + paintArea.height * j / 2.0, screenToWorld); if (isFinite(ns[0]) && (ns[0] < spans[0] || !isFinite(spans[0]))) { spans[0] = ns[0]; } if (isFinite(ns[1]) && (ns[1] < spans[1] || !isFinite(spans[1]))) { spans[1] = ns[1]; } } } if (!isFinite(spans[0])) { spans[0] = 0; } if (!isFinite(spans[1])) { spans[1] = 0; } spans[0] *= pixelDistance; spans[1] *= pixelDistance; return spans; } catch (TransformException e) { return new double[] {0, 0}; } } }
Decimator { public static double[] computeGeneralizationDistances( MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) throws TransformException { try { double[] spans = getGeneralizationSpans( paintArea.x + paintArea.width / 2, paintArea.y + paintArea.height / 2, screenToWorld); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] ns = getGeneralizationSpans( paintArea.x + paintArea.width * i / 2.0, paintArea.y + paintArea.height * j / 2.0, screenToWorld); if (isFinite(ns[0]) && (ns[0] < spans[0] || !isFinite(spans[0]))) { spans[0] = ns[0]; } if (isFinite(ns[1]) && (ns[1] < spans[1] || !isFinite(spans[1]))) { spans[1] = ns[1]; } } } if (!isFinite(spans[0])) { spans[0] = 0; } if (!isFinite(spans[1])) { spans[1] = 0; } spans[0] *= pixelDistance; spans[1] *= pixelDistance; return spans; } catch (TransformException e) { return new double[] {0, 0}; } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(double spanx, double spany); }
Decimator { public static double[] computeGeneralizationDistances( MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) throws TransformException { try { double[] spans = getGeneralizationSpans( paintArea.x + paintArea.width / 2, paintArea.y + paintArea.height / 2, screenToWorld); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] ns = getGeneralizationSpans( paintArea.x + paintArea.width * i / 2.0, paintArea.y + paintArea.height * j / 2.0, screenToWorld); if (isFinite(ns[0]) && (ns[0] < spans[0] || !isFinite(spans[0]))) { spans[0] = ns[0]; } if (isFinite(ns[1]) && (ns[1] < spans[1] || !isFinite(spans[1]))) { spans[1] = ns[1]; } } } if (!isFinite(spans[0])) { spans[0] = 0; } if (!isFinite(spans[1])) { spans[1] = 0; } spans[0] *= pixelDistance; spans[1] *= pixelDistance; return spans; } catch (TransformException e) { return new double[] {0, 0}; } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(double spanx, double spany); double getSpanX(); double getSpanY(); static double[] computeGeneralizationDistances(
            MathTransform screenToWorld, Rectangle paintArea, double pixelDistance); final Geometry decimateTransformGeneralize(Geometry geometry, MathTransform transform); final void decimate(Geometry geom); }
Decimator { public static double[] computeGeneralizationDistances( MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) throws TransformException { try { double[] spans = getGeneralizationSpans( paintArea.x + paintArea.width / 2, paintArea.y + paintArea.height / 2, screenToWorld); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] ns = getGeneralizationSpans( paintArea.x + paintArea.width * i / 2.0, paintArea.y + paintArea.height * j / 2.0, screenToWorld); if (isFinite(ns[0]) && (ns[0] < spans[0] || !isFinite(spans[0]))) { spans[0] = ns[0]; } if (isFinite(ns[1]) && (ns[1] < spans[1] || !isFinite(spans[1]))) { spans[1] = ns[1]; } } } if (!isFinite(spans[0])) { spans[0] = 0; } if (!isFinite(spans[1])) { spans[1] = 0; } spans[0] *= pixelDistance; spans[1] *= pixelDistance; return spans; } catch (TransformException e) { return new double[] {0, 0}; } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(double spanx, double spany); double getSpanX(); double getSpanY(); static double[] computeGeneralizationDistances(
            MathTransform screenToWorld, Rectangle paintArea, double pixelDistance); final Geometry decimateTransformGeneralize(Geometry geometry, MathTransform transform); final void decimate(Geometry geom);  }