コード例 #1
0
 /// <summary>
 /// Initializes an orhtonormal transformation from the Src and Dest
 /// rectangles.
 /// </summary>
 /// <remarks>
 /// Initializes an orhtonormal transformation from the Src and Dest
 /// rectangles.
 /// The result transformation proportionally fits the Src into the Dest. The
 /// center of the Src will be in the center of the Dest.
 /// </remarks>
 internal void InitializeFromRectIsotropic(com.epl.geometry.Envelope2D src, com.epl.geometry.Envelope2D dest)
 {
     if (src.IsEmpty() || dest.IsEmpty() || 0 == src.GetWidth() || 0 == src.GetHeight())
     {
         SetZero();
     }
     else
     {
         yx = 0;
         xy = 0;
         xx = dest.GetWidth() / src.GetWidth();
         yy = dest.GetHeight() / src.GetHeight();
         if (xx > yy)
         {
             xx = yy;
         }
         else
         {
             yy = xx;
         }
         com.epl.geometry.Point2D destCenter = dest.GetCenter();
         com.epl.geometry.Point2D srcCenter  = src.GetCenter();
         xd = destCenter.x - srcCenter.x * xx;
         yd = destCenter.y - srcCenter.y * yy;
     }
 }
コード例 #2
0
 /// <summary>Initialize transformation from two rectangles.</summary>
 internal void InitializeFromRect(com.epl.geometry.Envelope2D src, com.epl.geometry.Envelope2D dest)
 {
     if (src.IsEmpty() || dest.IsEmpty() || 0 == src.GetWidth() || 0 == src.GetHeight())
     {
         SetZero();
     }
     else
     {
         xy = yx = 0;
         xx = dest.GetWidth() / src.GetWidth();
         yy = dest.GetHeight() / src.GetHeight();
         xd = dest.xmin - src.xmin * xx;
         yd = dest.ymin - src.ymin * yy;
     }
 }
コード例 #3
0
        //dbgSaveToBitmap("c:/temp/_dbg.bmp");
        internal bool TryRenderAsSmallEnvelope_(com.epl.geometry.Envelope2D env)
        {
            if (!env.IsIntersecting(m_geomEnv))
            {
                return(true);
            }
            com.epl.geometry.Envelope2D envPix = new com.epl.geometry.Envelope2D();
            envPix.SetCoords(env);
            m_transform.Transform(env);
            double strokeHalfWidthPixX = m_stroke_half_widthX_pix;
            double strokeHalfWidthPixY = m_stroke_half_widthY_pix;

            if (envPix.GetWidth() > 2 * strokeHalfWidthPixX + 1 || envPix.GetHeight() > 2 * strokeHalfWidthPixY + 1)
            {
                return(false);
            }
            // This envelope is too narrow/small, so that it can be just drawn as a
            // rectangle using only boundary color.
            envPix.Inflate(strokeHalfWidthPixX, strokeHalfWidthPixY);
            envPix.xmax += 1.0;
            envPix.ymax += 1.0;
            // take into account that it does not draw right and
            // bottom edges.
            m_callback.SetColor(m_rasterizer, 2);
            FillEnvelope(m_rasterizer, envPix);
            return(true);
        }
コード例 #4
0
        private com.epl.geometry.Geometry DensifyEnvelope(com.epl.geometry.Envelope geom)
        {
            com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(geom.GetDescription());
            polygon.AddEnvelope(geom, false);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            geom.QueryEnvelope2D(env2D);
            double w = env2D.GetWidth();
            double h = env2D.GetHeight();

            if (w <= m_maxLength && h <= m_maxLength)
            {
                return((com.epl.geometry.Geometry)polygon);
            }
            return(DensifyMultiPath((com.epl.geometry.MultiPath)polygon));
        }
コード例 #5
0
        public virtual void TestBufferEnvelope()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Envelope         inputGeom = new com.epl.geometry.Envelope(1, 0, 200, 400);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.Geometry         result    = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (80 + 199)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (80 + 400)) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 104.0) < 10);
            com.epl.geometry.NonSimpleResult nsr = new com.epl.geometry.NonSimpleResult();
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, true, nsr, null));
            {
                result = buffer.Execute(inputGeom, sr, -200.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -200.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -199 / 2.0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -50.0, null);
                poly   = (com.epl.geometry.Polygon)(result);
                result.QueryEnvelope2D(env2D);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - (199 - 100)) < 0.001 && System.Math.Abs(env2D.GetHeight() - (400 - 100)) < 0.001);
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 201.0 / 2) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 400 / 2.0) < 0.001);
                pathCount = poly.GetPathCount();
                NUnit.Framework.Assert.IsTrue(pathCount == 1);
                pointCount = poly.GetPointCount();
                NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 4.0) < 10);
                NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            }
        }
コード例 #6
0
 public virtual void TestBufferPolygon()
 {
     com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
     com.epl.geometry.Polygon          inputGeom = new com.epl.geometry.Polygon();
     com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
     com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
     inputGeom.StartPath(0, 0);
     inputGeom.LineTo(50, 50);
     inputGeom.LineTo(50, 0);
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result == inputGeom);
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 10, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 20 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 20 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 104.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.epl.geometry.SpatialReference.Create(4326);
         inputGeom = new com.epl.geometry.Polygon();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(50, 50);
         inputGeom.LineTo(50, 0);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -10, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 15.85) < 0.1 && System.Math.Abs(env2D.GetHeight() - 15.85) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 32.07) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 17.93) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(pointCount == 3);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.epl.geometry.SpatialReference.Create(4326);
         inputGeom = new com.epl.geometry.Polygon();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(0, 50);
         inputGeom.LineTo(50, 50);
         inputGeom.LineTo(50, 0);
         inputGeom.StartPath(10, 10);
         inputGeom.LineTo(40, 10);
         inputGeom.LineTo(40, 40);
         inputGeom.LineTo(10, 40);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -2, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() + 4 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() + 4 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 2);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 108) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
 }
コード例 #7
0
 public virtual void TestBufferPolyline()
 {
     com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
     com.epl.geometry.Polyline         inputGeom = new com.epl.geometry.Polyline();
     com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
     com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
     inputGeom.StartPath(0, 0);
     inputGeom.LineTo(50, 50);
     inputGeom.LineTo(50, 0);
     inputGeom.LineTo(0, 50);
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result.IsEmpty());
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, -1, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         NUnit.Framework.Assert.IsTrue(result.IsEmpty());
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 80 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 171.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 2);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 186.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         inputGeom = new com.epl.geometry.Polyline();
         inputGeom.StartPath(0, 0);
         inputGeom.LineTo(50, 50);
         inputGeom.StartPath(50, 0);
         inputGeom.LineTo(0, 50);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null);
         NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
         com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
         com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
         result.QueryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1);
         int pathCount = poly.GetPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.GetPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 208.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
     {
         inputGeom = new com.epl.geometry.Polyline();
         inputGeom.StartPath(1.762614, 0.607368);
         inputGeom.LineTo(1.762414, 0.606655);
         inputGeom.LineTo(1.763006, 0.607034);
         inputGeom.LineTo(1.762548, 0.607135);
         com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0.005, null);
         NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
     }
 }
コード例 #8
0
        public virtual void TestBufferMultiPoint()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.MultiPoint       inputGeom = new com.epl.geometry.MultiPoint();
            inputGeom.Add(12, 120);
            inputGeom.Add(20, 120);
            com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 8) < 0.001 && System.Math.Abs(env2D.GetHeight() - 80) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 16) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 120) < 0.001);
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 108.0) < 10);
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            {
                result = buffer.Execute(inputGeom, sr, 0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -1, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
        }
コード例 #9
0
        internal void Init(com.epl.geometry.MultiVertexGeometryImpl geom, double toleranceXY, int rasterSizeBytes)
        {
            // _ASSERT(CanUseAccelerator(geom));
            m_width        = System.Math.Max((int)(System.Math.Sqrt(rasterSizeBytes) * 2 + 0.5), 64);
            m_scanLineSize = (m_width * 2 + 31) / 32;
            // 2 bits per pixel
            m_geomEnv     = new com.epl.geometry.Envelope2D();
            m_toleranceXY = toleranceXY;
            // calculate bitmap size
            int size         = 0;
            int width        = m_width;
            int scanLineSize = m_scanLineSize;

            while (width >= 8)
            {
                size        += width * scanLineSize;
                width       /= 2;
                scanLineSize = (width * 2 + 31) / 32;
            }
            // allocate the bitmap, that contains the base and the mip-levels
            m_bitmap = new int[size];
            for (int i = 0; i < size; i++)
            {
                m_bitmap[i] = 0;
            }
            m_rasterizer = new com.epl.geometry.SimpleRasterizer();
            com.epl.geometry.RasterizedGeometry2DImpl.ScanCallbackImpl callback = new com.epl.geometry.RasterizedGeometry2DImpl.ScanCallbackImpl(this, m_bitmap, m_scanLineSize);
            m_callback = callback;
            m_rasterizer.Setup(m_width, m_width, callback);
            geom.QueryEnvelope2D(m_geomEnv);
            if (m_geomEnv.GetWidth() > m_width * m_geomEnv.GetHeight() || m_geomEnv.GetHeight() > m_geomEnv.GetWidth() * m_width)
            {
            }
            // the geometry is thin and the rasterizer is not needed.
            m_geomEnv.Inflate(toleranceXY, toleranceXY);
            com.epl.geometry.Envelope2D worldEnv = new com.epl.geometry.Envelope2D();
            com.epl.geometry.Envelope2D pixEnv   = com.epl.geometry.Envelope2D.Construct(1, 1, m_width - 2, m_width - 2);
            double minWidth = toleranceXY * pixEnv.GetWidth();
            // min width is such
            // that the size of
            // one pixel is
            // equal to the
            // tolerance
            double minHeight = toleranceXY * pixEnv.GetHeight();

            worldEnv.SetCoords(m_geomEnv.GetCenter(), System.Math.Max(minWidth, m_geomEnv.GetWidth()), System.Math.Max(minHeight, m_geomEnv.GetHeight()));
            m_stroke_half_widthX_pix = worldEnv.GetWidth() / pixEnv.GetWidth();
            m_stroke_half_widthY_pix = worldEnv.GetHeight() / pixEnv.GetHeight();
            // The stroke half width. Later it will be inflated to account for
            // pixels size.
            m_stroke_half_width = m_toleranceXY;
            m_transform         = new com.epl.geometry.Transformation2D();
            m_transform.InitializeFromRect(worldEnv, pixEnv);
            // geom to pixels
            com.epl.geometry.Transformation2D identityTransform = new com.epl.geometry.Transformation2D();
            switch (geom.GetType().Value())
            {
            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            {
                callback.SetColor(m_rasterizer, 2);
                FillPoints(m_rasterizer, (com.epl.geometry.MultiPointImpl)geom, m_stroke_half_width);
                break;
            }

            case com.epl.geometry.Geometry.GeometryType.Polyline:
            {
                callback.SetColor(m_rasterizer, 2);
                StrokeDrawPolyPath(m_rasterizer, (com.epl.geometry.MultiPathImpl)geom._getImpl(), m_stroke_half_width);
                break;
            }

            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                bool isWinding = false;
                // NOTE: change when winding is supported
                callback.SetColor(m_rasterizer, 1);
                FillMultiPath(m_rasterizer, m_transform, (com.epl.geometry.MultiPathImpl)geom, isWinding);
                callback.SetColor(m_rasterizer, 2);
                StrokeDrawPolyPath(m_rasterizer, (com.epl.geometry.MultiPathImpl)geom._getImpl(), m_stroke_half_width);
                break;
            }
            }
            m_dx = m_transform.xx;
            m_dy = m_transform.yy;
            m_x0 = m_transform.xd;
            m_y0 = m_transform.yd;
            BuildLevels();
        }
コード例 #10
0
        internal bool ClusterNonReciprocal_()
        {
            int point_count = m_shape.GetTotalPointCount();

            com.epl.geometry.Envelope2D env = m_shape.GetEnvelope2D();
            m_origin = env.GetLowerLeft();
            double dim     = System.Math.Max(env.GetHeight(), env.GetWidth());
            double mincell = dim / (com.epl.geometry.NumberUtils.IntMax() - 1);

            if (m_cell_size < mincell)
            {
                m_cell_size     = mincell;
                m_inv_cell_size = 1.0 / m_cell_size;
            }
            // This holds clusters.
            m_clusters = new com.epl.geometry.IndexMultiList();
            m_clusters.ReserveLists(m_shape.GetTotalPointCount() / 3 + 1);
            m_clusters.ReserveNodes(m_shape.GetTotalPointCount() / 3 + 1);
            m_hash_values  = m_shape.CreateUserIndex();
            m_new_clusters = m_shape.CreateUserIndex();
            // Make the hash table. It serves a purpose of fine grain grid.
            // Make it 25% larger than the 4 times point count to reduce the chance
            // of collision.
            // The 4 times comes from the fact that we check four neighbouring cells
            // in the grid for each point.
            m_hash_function = new com.epl.geometry.Clusterer.ClusterHashFunction(this, m_shape, m_origin, m_sqr_tolerance, m_inv_cell_size, m_hash_values);
            m_hash_table    = new com.epl.geometry.IndexHashTable(4 * point_count / 3, m_hash_function);
            m_hash_table.ReserveElements(m_shape.GetTotalPointCount());
            bool b_clustered = false;

            // Go through all vertices stored in the m_shape and put the handles of
            // the vertices into the clusters and the hash table.
            for (int geometry = m_shape.GetFirstGeometry(); geometry != -1; geometry = m_shape.GetNextGeometry(geometry))
            {
                for (int path = m_shape.GetFirstPath(geometry); path != -1; path = m_shape.GetNextPath(path))
                {
                    int vertex = m_shape.GetFirstVertex(path);
                    for (int index = 0, nindex = m_shape.GetPathSize(path); index < nindex; index++)
                    {
                        System.Diagnostics.Debug.Assert((vertex != -1));
                        int hash = m_hash_function.Calculate_hash_from_vertex(vertex);
                        m_shape.SetUserIndex(vertex, m_hash_values, hash);
                        m_hash_table.AddElement(vertex, hash);
                        // add cluster to the
                        // hash table
                        System.Diagnostics.Debug.Assert((m_shape.GetUserIndex(vertex, m_new_clusters) == -1));
                        vertex = m_shape.GetNextVertex(vertex);
                    }
                }
            }
            {
                // m_hash_table->dbg_print_bucket_histogram_();
                // scope for candidates array
                com.epl.geometry.AttributeStreamOfInt32 candidates = new com.epl.geometry.AttributeStreamOfInt32(0);
                candidates.Reserve(10);
                for (int geometry_1 = m_shape.GetFirstGeometry(); geometry_1 != -1; geometry_1 = m_shape.GetNextGeometry(geometry_1))
                {
                    for (int path = m_shape.GetFirstPath(geometry_1); path != -1; path = m_shape.GetNextPath(path))
                    {
                        int vertex = m_shape.GetFirstVertex(path);
                        for (int index = 0, nindex = m_shape.GetPathSize(path); index < nindex; index++)
                        {
                            if (m_shape.GetUserIndex(vertex, m_new_clusters) == com.epl.geometry.StridedIndexTypeCollection.ImpossibleIndex2())
                            {
                                vertex = m_shape.GetNextVertex(vertex);
                                continue;
                            }
                            // this vertex was merged with another
                            // cluster. It also was removed from the
                            // hash table.
                            int hash = m_shape.GetUserIndex(vertex, m_hash_values);
                            m_hash_table.DeleteElement(vertex, hash);
                            while (true)
                            {
                                CollectClusterCandidates_(vertex, candidates);
                                if (candidates.Size() == 0)
                                {
                                    // no candidate for
                                    // clustering has
                                    // been found for
                                    // the cluster_1.
                                    break;
                                }
                                bool clustered = false;
                                for (int candidate_index = 0, ncandidates = candidates.Size(); candidate_index < ncandidates; candidate_index++)
                                {
                                    int cluster_node = candidates.Get(candidate_index);
                                    int other_vertex = m_hash_table.GetElement(cluster_node);
                                    m_hash_table.DeleteNode(cluster_node);
                                    clustered |= MergeClusters_(vertex, other_vertex, candidate_index + 1 == ncandidates);
                                }
                                b_clustered |= clustered;
                                candidates.Clear(false);
                                // repeat search for the cluster candidates for
                                // cluster_1
                                if (!clustered)
                                {
                                    break;
                                }
                            }
                            // positions did not change
                            // m_shape->set_user_index(vertex, m_new_clusters,
                            // Strided_index_type_collection::impossible_index_2());
                            vertex = m_shape.GetNextVertex(vertex);
                        }
                    }
                }
            }
            if (b_clustered)
            {
                ApplyClusterPositions_();
            }
            m_hash_table    = null;
            m_hash_function = null;
            m_shape.RemoveUserIndex(m_hash_values);
            m_shape.RemoveUserIndex(m_new_clusters);
            // output_debug_printf("total: %d\n",m_shape->get_total_point_count());
            // output_debug_printf("clustered: %d\n",m_dbg_candidate_check_count);
            return(b_clustered);
        }
コード例 #11
0
 /// <summary>The height of the envelope.</summary>
 /// <returns>The height of the envelope.</returns>
 public virtual double GetHeight()
 {
     return(m_envelope.GetHeight());
 }