Exemplo n.º 1
0
        public static MultipointN FromCommon(IMultiPoint commonMultiPoint)
        {
            MultipointN agsMultiPoint = new MultipointN();

            agsMultiPoint.PointArray = commonMultiPoint.Select(o => PointN.FromCommon(o)).Cast <Point>().ToArray();
            return(agsMultiPoint);
        }
Exemplo n.º 2
0
        public static MultipointN FromCommon(IPoint commonPoint)
        {
            MultipointN agsMultiPoint = new MultipointN();

            agsMultiPoint.PointArray    = new Point[1];
            agsMultiPoint.PointArray[0] = PointN.FromCommon(commonPoint);
            return(agsMultiPoint);
        }
Exemplo n.º 3
0
        public static PointN FromCoordinate(Coordinate coordinate)
        {
            PointN agsPoint = new PointN();

            agsPoint.X = coordinate.X;
            agsPoint.Y = coordinate.Y;

            return(agsPoint);
        }
Exemplo n.º 4
0
        public override List <Coordinate> ToCommonCoordinates(bool includeEndPoint)
        {
            // create a coordinate array containing the from-point, all the control points, and the to-point

            Coordinate[] c = new Coordinate[ControlPointArray.Length + 2];
            PointN       p = FromPoint as PointN;

            c[0] = new Coordinate(p.X, p.Y);

            ControlPointArray.Cast <PointN>().Select(o => o.ToCoordinate()).ToArray().CopyTo(c, 1);

            p = ToPoint as PointN;
            c[c.Length - 1] = new Coordinate(p.X, p.Y);

            // determine the number of points to interpolate

            int interpolateCount = 0;

            for (int i = 1; i < c.Length - 1; ++i)
            {
                double ax = c[i - 1].X - c[i].X;
                double ay = c[i - 1].Y - c[i].Y;
                double bx = c[i + 1].X - c[i].X;
                double by = c[i + 1].Y - c[i].Y;

                double dot = ax * bx + ay * by;
                double ad  = Math.Sqrt(ax * ax + ay * ay);
                double bd  = Math.Sqrt(bx * bx + by * by);

                double angle = Math.PI - Math.Abs(Math.Acos(dot / (ad * bd)));
                interpolateCount += Convert.ToInt32(Math.Floor(angle / SweepAngle));
            }

            // add the from-point to the output coordinates

            List <Coordinate> coords = new List <Coordinate>();

            coords.Add(c[0]);

            // add interpolated points along the Bezier curve to the output coordinates

            for (int i = 1; i < interpolateCount; ++i)
            {
                coords.Add(Interpolate(c, (double)i / interpolateCount));
            }

            // add the to-point to the output coordinates

            if (includeEndPoint)
            {
                coords.Add(c[c.Length - 1]);
            }

            return(coords);
        }
Exemplo n.º 5
0
        public override List <Coordinate> ToCommonCoordinates(bool includeEndPoint)
        {
            List <Coordinate> coords = new List <Coordinate>();

            PointN p = FromPoint as PointN;

            coords.Add(new Coordinate(p.X, p.Y));

            if (includeEndPoint)
            {
                p = ToPoint as PointN;
                coords.Add(new Coordinate(p.X, p.Y));
            }

            return(coords);
        }
Exemplo n.º 6
0
        public static Geometry FromCommon(IGeometry commonGeometry)
        {
            switch (commonGeometry.OgcGeometryType)
            {
            case OgcGeometryType.Point: return(PointN.FromCommon((IPoint)commonGeometry));

            case OgcGeometryType.MultiPoint: return(MultipointN.FromCommon((IMultiPoint)commonGeometry));

            case OgcGeometryType.LineString: return(PolylineN.FromCommon((ILineString)commonGeometry));

            case OgcGeometryType.MultiLineString: return(PolylineN.FromCommon((IMultiLineString)commonGeometry));

            case OgcGeometryType.Polygon: return(PolygonN.FromCommon((IPolygon)commonGeometry));

            case OgcGeometryType.MultiPolygon: return(PolygonN.FromCommon((IMultiPolygon)commonGeometry));

            default:
                throw new NotSupportedException("Conversion from an IGeometryCollection to an AppGeo.Ags.Geometry is not supported.");
            }
        }
Exemplo n.º 7
0
        public override List <Coordinate> ToCommonCoordinates(bool includeEndPoint)
        {
            List <Coordinate> coords = new List <Coordinate>();

            PointN     p  = FromPoint as PointN;
            Coordinate fc = new Coordinate(p.X, p.Y);

            p = ToPoint as PointN;
            Coordinate tc = new Coordinate(p.X, p.Y);

            coords.Add(fc);

            if (!IsLine)
            {
                p = CenterPoint as PointN;
                Coordinate cc = new Coordinate(p.X, p.Y);

                double angle = 0;
                double twoPI = Math.PI * 2;

                if (fc == tc)
                {
                    angle = twoPI;
                }
                else
                {
                    angle = ((Math.Atan2(tc.Y - cc.Y, tc.X - cc.X) - Math.Atan2(fc.Y - cc.Y, fc.X - cc.X)) + twoPI) % twoPI;

                    if (!IsCounterClockwise)
                    {
                        angle = twoPI - angle;
                    }
                }

                int pointCount = Convert.ToInt32(Math.Floor(angle / SweepAngle)) - (angle % SweepAngle < 0.000001 ? 1 : 0);

                double radius = fc.Distance(cc);

                double cosSweep = Math.Cos(SweepAngle);
                double sinSweep = (IsCounterClockwise ? -1 : 1) * Math.Sin(SweepAngle);

                Coordinate sc = fc;

                for (int n = 0; n < pointCount; ++n)
                {
                    double dx = sc.X - cc.X;
                    double dy = sc.Y - cc.Y;
                    double x  = cc.X + (dx * cosSweep) + (dy * sinSweep);
                    double y  = cc.Y + (dy * cosSweep) - (dx * sinSweep);

                    sc = new Coordinate(x, y);

                    if (sc != cc)
                    {
                        coords.Add(sc);
                    }
                }
            }

            if (includeEndPoint)
            {
                coords.Add(tc);
            }

            return(coords);
        }
Exemplo n.º 8
0
        public override List <Coordinate> ToCommonCoordinates(bool includeEndPoint)
        {
            List <Coordinate> coords = new List <Coordinate>();

            PointN     p  = FromPoint as PointN;
            Coordinate fc = new Coordinate(p.X, p.Y);

            p = ToPoint as PointN;
            Coordinate tc = new Coordinate(p.X, p.Y);

            coords.Add(fc);

            if (CenterPoint != null)
            {
                p = CenterPoint as PointN;
                Coordinate        cc        = new Coordinate(p.X, p.Y);
                EllipticTransform transform = new EllipticTransform(cc, Rotation);

                Coordinate cc0 = new Coordinate(0, 0);
                Coordinate fc0 = EllipseStd ? fc : transform.ToStandard(fc);
                Coordinate tc0 = EllipseStd ? tc : transform.ToStandard(tc);

                Coordinate fcMaj = new Coordinate(fc0.X, fc0.Y / MinorMajorRatio);
                Coordinate tcMaj = new Coordinate(tc0.X, tc0.Y / MinorMajorRatio);

                double majRadius = Math.Sqrt(fcMaj.X * fcMaj.X + fcMaj.Y * fcMaj.Y);
                double cosSweep  = Math.Cos(SweepAngle);
                double sinSweep  = (IsCounterClockWise ? -1 : 1) * Math.Sin(SweepAngle);

                double dCos    = (1 - cosSweep) * majRadius;
                double dSin    = sinSweep * majRadius;
                double d2Sweep = (dCos * dCos) + (dSin * dSin);

                Coordinate scMaj = fcMaj;
                Coordinate scMin = new Coordinate(fc0.X * MinorMajorRatio, fc0.Y);

                while (scMaj.Distance2(tcMaj) > d2Sweep)
                {
                    double dx = scMaj.X - cc.X;
                    double dy = scMaj.Y - cc.Y;
                    double x  = cc.X + (dx * cosSweep) + (dy * sinSweep);
                    double y  = cc.Y + (dy * cosSweep) - (dx * sinSweep);

                    scMaj = new Coordinate(x, y);

                    dx = scMin.X - cc.X;
                    dy = scMin.Y - cc.Y;
                    x  = cc.X + (dx * cosSweep) + (dy * sinSweep);
                    y  = cc.Y + (dy * cosSweep) - (dx * sinSweep);

                    scMin = new Coordinate(x, y);

                    if (!(scMin.X == 0 && scMin.Y == 0))
                    {
                        coords.Add(transform.ToBase(new Coordinate(scMaj.X, scMin.Y)));
                    }
                }
            }

            if (includeEndPoint)
            {
                coords.Add(tc);
            }

            return(coords);
        }