Beispiel #1
0
        public Text()
        {
            _symbol = new SimpleTextSymbol();
            _symbol.Font = Current.Engine.CreateFont("Arial", 20);
            _symbol.Text = _text;
            _symbol.TextSymbolAlignment = TextSymbolAlignment.leftAlignOver;
            //this.Symbol = _symbol;

            AggregateGeometry aGeometry = new AggregateGeometry();
            Polygon polygon = new Polygon();
            Ring ring = new Ring();
            ring.AddPoint(new Point(0, 0));
            ring.AddPoint(new Point(1, 0));
            ring.AddPoint(new Point(1, 1));
            ring.AddPoint(new Point(0, 1));
            polygon.AddRing(ring);

            aGeometry.AddGeometry(polygon);
            aGeometry.AddGeometry(new Point(0, 0));

            this.Template = aGeometry;

            RemoveAllGrabbers();
            AddGrabber(GrabberIDs.rotation);
            AddGrabber(GrabberIDs.move);
        }
Beispiel #2
0
        private void writeFDB_FC_Index_nodes(DualTreeNode dnode, List <SpatialIndexNode> nodes, int NID, int PID)
        {
            SpatialIndexNode node = new SpatialIndexNode();
            Polygon          p    = new Polygon();
            Ring             ring = new Ring();

            ring.AddPoint(new Point(dnode.Bounds.minx, dnode.Bounds.miny));
            //ring.AddPoint(new Point(node.Bounds.maxx,node.Bounds.miny));
            ring.AddPoint(new Point(dnode.Bounds.maxx, dnode.Bounds.maxy));
            //ring.AddPoint(new Point(node.Bounds.minx,node.Bounds.maxy));
            //ring.AddPoint(new Point(node.Bounds.minx,node.Bounds.miny));
            p.AddRing(ring);
            node.Rectangle = p;

            node.NID  = NID;
            node.PID  = PID;
            node.Page = dnode.page;
            node.IDs  = dnode.ShapeIds;
            nodes.Add(node);

            foreach (DualTreeNode subNode in dnode.SubNodes)
            {
                writeFDB_FC_Index_nodes(subNode, nodes, _NID++, NID);
            }
        }
Beispiel #3
0
        public GeomPolygon(IEnvelope envelope)
        {
            Polygon polygon = new Polygon();
            Ring    ring    = new Ring();

            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.miny));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.maxy));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.maxx, envelope.maxy));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.maxx, envelope.miny));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.miny));

            polygon.AddRing(ring);

            NofContours = polygon.RingCount;

            ContourIsHole = new bool[NofContours];
            Contour       = new GeomVertexList[NofContours];
            for (int i = 0; i < NofContours; i++)
            {
                ContourIsHole[i] = (i != 0);
            }

            for (int i = 0; i < polygon.RingCount; i++)
            {
                Contour[i] = new GeomVertexList(polygon[i]);
            }
        }
Beispiel #4
0
        private bool calcPolygon()
        {
            if (!InitReader())
            {
                return(false);
            }

            TFWFile tfw = this.GeoCoord as TFWFile;

            if (tfw == null)
            {
                return(false);
            }

            int iWidth  = _geoCoord.iWidth;
            int iHeight = _geoCoord.iHeight;

            _polygon = new Polygon();
            Ring ring = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                tfw.X - tfw.dx_X / 2.0 - tfw.dy_X / 2.0,
                tfw.Y - tfw.dx_Y / 2.0 - tfw.dy_Y / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dx_X * iWidth, p1.Y + tfw.dx_Y * iWidth));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dx_X * iWidth + tfw.dy_X * iHeight, p1.Y + tfw.dx_Y * iWidth + tfw.dy_Y * iHeight));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dy_X * iHeight, p1.Y + tfw.dy_Y * iHeight));
            _polygon.AddRing(ring);

            return(true);
        }
        private void calcPolygon(IEnvelope env)
        {
            if (env == null)
            {
                return;
            }
            _polygon = new Polygon();
            Ring ring = new Ring();

            ring.AddPoint(new Point(env.minx, env.miny));
            ring.AddPoint(new Point(env.maxx, env.miny));
            ring.AddPoint(new Point(env.maxx, env.maxy));
            ring.AddPoint(new Point(env.minx, env.maxy));
            _polygon.AddRing(ring);
        }
Beispiel #6
0
        private void calcPolygon()
        {
            _polygon = new Polygon();
            Ring ring = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0,
                _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight));
            _polygon.AddRing(ring);
        }
Beispiel #7
0
        static public Polygon ToPolygon(this GeoJSON.Net.Geometry.MultiPolygon geoJsonMultiPolygon)
        {
            var polygon = new Polygon();

            if (geoJsonMultiPolygon?.Coordinates != null)
            {
                foreach (var geoJsonPolygon in geoJsonMultiPolygon.Coordinates)
                {
                    if (geoJsonPolygon?.Coordinates != null)
                    {
                        foreach (var geoJsonLineString in geoJsonPolygon.Coordinates)
                        {
                            if (geoJsonLineString?.Coordinates != null)
                            {
                                var ring = new Ring();
                                polygon.AddRing(ring);

                                foreach (var position in geoJsonLineString.Coordinates)
                                {
                                    ring.AddPoint(new Point(position.Longitude, position.Latitude));
                                }
                            }
                        }
                    }
                }
            }

            return(polygon);
        }
Beispiel #8
0
        public Rectangle()
        {
            SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
            fillSymbol.Color = ArgbColor.FromArgb(40, 255, 255, 100);
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol();
            fillSymbol.OutlineSymbol = lineSymbol;
            this.Symbol = fillSymbol;

            Polygon polygon = new Polygon();
            Ring ring = new Ring();
            ring.AddPoint(new Point(0, 0));
            ring.AddPoint(new Point(1, 0));
            ring.AddPoint(new Point(1, 1));
            ring.AddPoint(new Point(0, 1));
            polygon.AddRing(ring);
            this.Template = polygon;
        }
Beispiel #9
0
        public Polygon CreatePolygon()
        {
            Polygon polygon = new Polygon();
            Ring    ring    = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                X - dx1 / 2.0 - dy1 / 2.0,
                Y - dx2 / 2.0 - dy2 / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dx1 * iWidth, p1.Y + dx2 * iWidth));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dx1 * iWidth + dy1 * iHeight, p1.Y + dx2 * iWidth + dy2 * iHeight));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dy1 * iHeight, p1.Y + dy2 * iHeight));
            polygon.AddRing(ring);

            return(polygon);
        }
Beispiel #10
0
        public Polygon CreatePolygon(int width, int height)
        {
            Polygon polygon = new Polygon();
            Ring    ring    = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                X - dx_X / 2.0 - dy_X / 2.0,
                Y - dx_Y / 2.0 - dy_Y / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dx_X * width, p1.Y + dx_Y * width));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dx_X * width + dy_X * height, p1.Y + dx_Y * width + dy_Y * height));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + dy_X * height, p1.Y + dy_Y * height));
            polygon.AddRing(ring);

            return(polygon);
        }
Beispiel #11
0
        private static IGeometry GeometryFromSymbol(ISymbol symbol, IEnvelope env)
        {
            IGeometry geometry = null;

            if (symbol is ISymbolCollection)
            {
                if (((ISymbolCollection)symbol).Symbols.Count > 0)
                {
                    geometry = GeometryFromSymbol(((ISymbolCollection)symbol).Symbols[0].Symbol, env);
                }
            }
            else if (symbol is IPointSymbol || symbol is ITextSymbol)
            {
                geometry = new gView.Framework.Geometry.Point((env.minx + env.maxx) / 2, Math.Abs(env.miny - env.maxy) / 2);
            }
            else if (symbol is ILineSymbol)
            {
                IPoint p1   = new gView.Framework.Geometry.Point(env.minx + 5, Math.Abs(env.miny - env.maxy) / 2);
                IPoint p2   = new gView.Framework.Geometry.Point(env.maxx - 5, Math.Abs(env.miny - env.maxy) / 2);
                IPath  path = new Path();
                path.AddPoint(p1);
                path.AddPoint(p2);
                IPolyline line = new Polyline();
                line.AddPath(path);
                geometry = line;
            }
            else if (symbol is IFillSymbol)
            {
                IPoint p1   = new gView.Framework.Geometry.Point(env.minx + 5, 5);
                IPoint p2   = new gView.Framework.Geometry.Point(env.maxx - 5, 5);
                IPoint p3   = new gView.Framework.Geometry.Point(env.maxx - 5, Math.Abs(env.miny - env.maxy) - 5);
                IPoint p4   = new gView.Framework.Geometry.Point(env.minx + 5, Math.Abs(env.miny - env.maxy) - 5);
                IRing  ring = new Ring();
                ring.AddPoint(p1);
                ring.AddPoint(p2);
                ring.AddPoint(p3);
                ring.AddPoint(p4);
                IPolygon polygon = new Polygon();
                polygon.AddRing(ring);
                geometry = polygon;
            }

            return(geometry);
        }
Beispiel #12
0
        public IRing ToRing()
        {
            Ring ring = new Ring();

            for (int i = 0; i < NofVertices; i++)
            {
                ring.AddPoint(new gView.Framework.Geometry.Point(Vertex[i].X, Vertex[i].Y));
            }
            return(ring);
        }
Beispiel #13
0
        private void SetBounds(GraphicsEngine.Abstraction.IBitmap bitmap)
        {
            if (bitmap != null)
            {
                _iWidth  = bitmap.Width;
                _iHeight = bitmap.Height;
            }
            _polygon = new Polygon();
            Ring ring = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0,
                _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight));
            _polygon.AddRing(ring);
        }
Beispiel #14
0
        private void setBounds(Image image)
        {
            if (image != null)
            {
                _iWidth  = image.Width;
                _iHeight = image.Height;
            }
            _polygon = new Polygon();
            Ring ring = new Ring();

            gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point(
                _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0,
                _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0);

            ring.AddPoint(p1);
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight));
            ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight));
            _polygon.AddRing(ring);
        }
Beispiel #15
0
        static public IRing ToRing <T>(this GeoJsonLinearRingCoordinates <T> linearRing) where T : GeoJsonCoordinates
        {
            var ring = new Ring();

            foreach (var position in linearRing.Positions)
            {
                var values = position.Values;
                ring.AddPoint(new Point(values[0], values[1]));
            }

            return(ring);
        }
Beispiel #16
0
        public void TristripToPolyons(ref List <IPolygon> polygons)
        {
            if (polygons == null)
            {
                return;
            }

            for (int i = 0; i < NofVertices - 2; i++)
            {
                Polygon poly = new Polygon();
                Ring    ring = new Ring();

                ring.AddPoint(new gView.Framework.Geometry.Point(
                                  Vertex[i].X, Vertex[i].Y));
                ring.AddPoint(new gView.Framework.Geometry.Point(
                                  Vertex[i + 1].X, Vertex[i + 1].Y));
                ring.AddPoint(new gView.Framework.Geometry.Point(
                                  Vertex[i + 2].X, Vertex[i + 2].Y));

                poly.AddRing(ring);
                polygons.Add(poly);
            }
        }
Beispiel #17
0
        public void AddPoint(IPoint point)
        {
            if (point == null)
            {
                return;
            }

            if (_geometry is IPoint && _actPartNr == 0)
            {
                ((IPoint)_geometry).X = point.X;
                ((IPoint)_geometry).Y = point.Y;
                ((IPoint)_geometry).Z = point.Z;
            }
            else if (_geometry is IMultiPoint)
            {
                IMultiPoint mPoint = (IMultiPoint)_geometry;
                mPoint.AddPoint(point);
            }
            else if (_geometry is IPolyline)
            {
                IPolyline pLine = (IPolyline)_geometry;
                if (_actPartNr >= pLine.PathCount)
                {
                    gView.Framework.Geometry.Path path = new gView.Framework.Geometry.Path();
                    path.AddPoint(point);
                    pLine.AddPath(path);
                    _actPartNr = pLine.PathCount - 1;
                }
                else
                {
                    pLine[_actPartNr].AddPoint(point);
                }
            }
            else if (_geometry is IPolygon)
            {
                IPolygon poly = (IPolygon)_geometry;
                if (_actPartNr >= poly.RingCount)
                {
                    Ring ring = new Ring();
                    ring.AddPoint(point);
                    poly.AddRing(ring);
                    _actPartNr = poly.RingCount - 1;
                }
                else
                {
                    poly[_actPartNr].AddPoint(point);
                }
            }
        }
Beispiel #18
0
        public Ellipse()
        {
            SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
            fillSymbol.Color = ArgbColor.FromArgb(60, 255, 255, 100);
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol();
            fillSymbol.OutlineSymbol = lineSymbol;
            this.Symbol = fillSymbol;

            Polygon polygon = new Polygon();
            Ring ring = new Ring();
            for (double w = 0; w < 2.0 * Math.PI; w += 2.0 * Math.PI / 50)
            {
                ring.AddPoint(new Point(0.5 + 0.5 * Math.Cos(w), 0.5 + 0.5 * Math.Sin(w)));
            }
            polygon.AddRing(ring);
            this.Template = polygon;
        }
Beispiel #19
0
        static public Polygon ToPolygon(this ClipperPolygons clipperPolygons)
        {
            Polygon result = new Polygon();

            foreach (var clipperRing in clipperPolygons)
            {
                var ring = new Ring();

                foreach (var clipperPoint in clipperRing)
                {
                    ring.AddPoint(clipperPoint.ToPoint());
                }
                result.AddRing(ring);
            }

            return result;
        }
Beispiel #20
0
        static public IGeometry ToGeometry(this JObject jObject)
        {
            if (jObject != null)
            {
                var type = jObject["type"].Value <string>()?.ToLower();
                if (type == "point")
                {
                    var coordinates = (JArray)jObject["coordinates"];
                    return(new Point(
                               coordinates[0].Value <double>(),
                               coordinates[1].Value <double>()));
                }
                if (type == "polygon")
                {
                    var polygon = new Polygon();

                    var jsonRings = (JArray)jObject["coordinates"];
                    foreach (JArray jsonRing in jsonRings)
                    {
                        var ring = new Ring();
                        foreach (JArray jsonPoint in jsonRing)
                        {
                            ring.AddPoint(new Point(
                                              jsonPoint[0].Value <double>(),
                                              jsonPoint[1].Value <double>()));
                        }
                        if (ring.PointCount > 0)
                        {
                            polygon.AddRing(ring);
                        }
                    }

                    return(polygon);
                }
            }
            return(null);
        }
Beispiel #21
0
        public Arrow()
        {
            SimpleFillSymbol fillSymbol = new SimpleFillSymbol();

            fillSymbol.Color = System.Drawing.Color.FromArgb(60, 255, 255, 100);
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol();

            fillSymbol.OutlineSymbol = lineSymbol;
            this.Symbol = fillSymbol;

            Polygon polygon = new Polygon();
            Ring    ring    = new Ring();

            ring.AddPoint(new Point(0, 0.33));
            ring.AddPoint(new Point(0.66, 0.33));
            ring.AddPoint(new Point(0.66, 0));
            ring.AddPoint(new Point(1, 0.5));
            ring.AddPoint(new Point(0.66, 1));
            ring.AddPoint(new Point(0.66, 0.66));
            ring.AddPoint(new Point(0, 0.66));
            polygon.AddRing(ring);
            this.Template = polygon;
        }
    void LoadPointCloud()
    {
        try
        {
            var file = new StreamReader(tunnelPath);

            string line;
            rings = new List <Ring>();
            int  ringID = 0;
            Ring ring   = new Ring(ringID);
            while ((line = file.ReadLine()) != null)
            {
                string[] elements = line.Split(',');

                int   id    = Convert.ToInt32(elements[0]);
                float angle = (float)Convert.ToDouble(elements[1]); //Not necessary given that angle is same each time. Steps aren't linear though, so I at least need to think
                float range = (float)Convert.ToDouble(elements[2]);

                ring.AddPoint(range, angle);
                numPoints++;

                if (id == 1080)
                {
                    rings.Add(ring);
                    ring = new Ring(++ringID);
                }
            }

            file.Close();

            LoadAdjustments();

            points  = new Vector3[numPoints];
            colours = new Color[numPoints];

            int pointNum = 0;

            int threadCount    = Environment.ProcessorCount;
            var threads        = new List <Thread>();
            int ringsPerThread = rings.Count / threadCount;

            for (int i = 0; i < 11; i++)
            {
                int    temp = i; //Must be done because of "closures" and "captured variables" https://stackoverflow.com/questions/26631939/captured-variables-in-a-thread-in-a-loop-in-c-what-is-the-solution
                Thread t    = new Thread(() => ThreadedDistanceCalculation(ringsPerThread * temp, ringsPerThread * (temp + 1)));
                t.Start();
                threads.Add(t);
            }
            Thread t12 = new Thread(() => ThreadedDistanceCalculation(ringsPerThread * 11, rings.Count));
            t12.Start();
            threads.Add(t12);

            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Join();
            }

            //Colour the points and fill the position array
            pointNum = 0;
            for (int i = 0; i < rings.Count; i++)
            {
                for (int j = 0; j < rings[i].points.Count; j++)
                {
                    if (rings[i].points[j].valid)
                    {
                        float distanceWithDeadZone = Mathf.Abs(rings[i].points[j].distance) - 60;
                        if (distanceWithDeadZone < 0)
                        {
                            distanceWithDeadZone = 0;
                        }
                        float s;
                        float h;
                        if (rings[i].points[j].distance > 0) //Positive distance indicates the point is bulging out
                        {
                            h = 0.65f;                       //blue
                            s = distanceWithDeadZone / maxDistanceOuter;
                        }
                        else
                        {
                            h = 1;  //red
                            s = distanceWithDeadZone / maxDistanceInner;
                        }

                        colours[pointNum] = Color.HSVToRGB(h, s, 1);

                        Vector2 pt = rings[i].GetPointAligned(j);
                        points[pointNum] = new Vector3(pt.x, pt.y, i * zSpacing);
                        pointNum++;
                    }
                }
            }

            //Instantiate Point Groups
            int numPointGroups = Mathf.CeilToInt(numPoints * 1.0f / pointLimit * 1.0f);

            pointCloud = new GameObject("Point cloud");

            for (int i = 0; i < numPointGroups - 1; i++)
            {
                InstantiateMesh(i, pointLimit);
            }
            InstantiateMesh(numPointGroups - 1, numPoints - (numPointGroups - 1) * pointLimit);

            MenuControl.mc.CloudReady();
            lm.PlotLines(lineMat, rings.Count);
            lm.ToggleVisibility();
            loaded = true;
        }
        catch
        {
            DestroyEverything();
        }
    }
Beispiel #23
0
        private IGeometry FetchShape(System.Int16 index)
        {
            unsafe
            {
                System.Int32 err_no    = 0;
                SE_SHAPE     shape_val = new SE_SHAPE();

                System.Int32 *part_offsets = null;
                System.Int32 *subp_offsets = null;
                SE_POINT *    points       = null;
                try
                {
                    err_no = Wrapper10.SE_shape_create(new SE_COORDREF(), ref shape_val);
                    if (err_no != 0)
                    {
                        return(null);
                    }

                    err_no = Wrapper10.SE_stream_get_shape(_stream.SeStream, index, shape_val);
                    if (err_no != 0)
                    {
                        return(null);
                    }

                    Int32 shapeType = 0, numPoints = 0, numParts = 0, numSubparts = 0;

                    err_no = Wrapper10.SE_shape_get_type(shape_val, ref shapeType);
                    if (err_no != 0 || shapeType == CONST.SG_NIL_SHAPE)
                    {
                        return(null);
                    }
                    err_no = Wrapper10.SE_shape_get_num_points(shape_val, 0, 0, ref numPoints);
                    if (err_no != 0)
                    {
                        return(null);
                    }
                    err_no = Wrapper10.SE_shape_get_num_parts(shape_val, ref numParts, ref numSubparts);
                    if (err_no != 0)
                    {
                        return(null);
                    }

                    part_offsets = (System.Int32 *)Marshal.AllocHGlobal(((int)numParts + 1) * sizeof(System.Int32));
                    subp_offsets = (System.Int32 *)Marshal.AllocHGlobal(((int)numSubparts + 1) * sizeof(System.Int32));
                    points       = (SE_POINT *)Marshal.AllocHGlobal((int)numPoints * sizeof(SE_POINT));

                    part_offsets[numParts]    = (int)numSubparts;
                    subp_offsets[numSubparts] = (int)numPoints;

                    err_no = Wrapper10.SE_shape_get_all_points(
                        shape_val,
                        SE_ROTATION_TYPE.SE_DEFAULT_ROTATION,
                        (IntPtr)part_offsets,
                        (IntPtr)subp_offsets,
                        (IntPtr)points,
                        (IntPtr)null,
                        (IntPtr)null);
                    if (err_no != 0)
                    {
                        return(null);
                    }

                    IGeometry ret = null;
                    switch (shapeType)
                    {
                    case CONST.SG_POINT_SHAPE:
                        if (numPoints == 1)
                        {
                            ret = new Point(points[0].x, points[0].y);
                        }
                        else if (numPoints > 1)
                        {
                            MultiPoint mPoint_ = new MultiPoint();
                            for (int i = 0; i < numPoints; i++)
                            {
                                mPoint_.AddPoint(new Point(points[i].x, points[i].y));
                            }
                            ret = mPoint_;
                        }
                        break;

                    case CONST.SG_MULTI_POINT_SHAPE:
                        MultiPoint mPoint = new MultiPoint();
                        for (int i = 0; i < numPoints; i++)
                        {
                            mPoint.AddPoint(new Point(points[i].x, points[i].y));
                        }
                        ret = mPoint;
                        break;

                    case CONST.SG_LINE_SHAPE:
                    case CONST.SG_SIMPLE_LINE_SHAPE:
                    case CONST.SG_MULTI_LINE_SHAPE:
                    case CONST.SG_MULTI_SIMPLE_LINE_SHAPE:
                        Polyline polyline = new Polyline();
                        for (int s = 0; s < numSubparts; s++)
                        {
                            Path path = new Path();
                            int  to   = subp_offsets[s + 1];
                            for (int i = subp_offsets[s]; i < to; i++)
                            {
                                path.AddPoint(new Point(points[i].x, points[i].y));
                            }
                            polyline.AddPath(path);
                        }
                        ret = polyline;
                        break;

                    case CONST.SG_AREA_SHAPE:
                    case CONST.SG_MULTI_AREA_SHAPE:
                        Polygon polygon = new Polygon();
                        for (int s = 0; s < numSubparts; s++)
                        {
                            Ring ring = new Ring();
                            int  to   = subp_offsets[s + 1];
                            for (int i = subp_offsets[s]; i < to; i++)
                            {
                                ring.AddPoint(new Point(points[i].x, points[i].y));
                            }
                            polygon.AddRing(ring);
                        }
                        ret = polygon;
                        break;
                    }
                    return(ret);
                }
                catch
                {
                    return(null);
                }
                finally
                {
                    if (part_offsets != null)
                    {
                        Marshal.FreeHGlobal((System.IntPtr)part_offsets);
                    }
                    if (subp_offsets != null)
                    {
                        Marshal.FreeHGlobal((System.IntPtr)subp_offsets);
                    }
                    if (points != null)
                    {
                        Marshal.FreeHGlobal((System.IntPtr)points);
                    }

                    if (shape_val.handle != IntPtr.Zero)
                    {
                        Wrapper10.SE_shape_free(shape_val);
                    }
                }
            }
        }
Beispiel #24
0
        public static IGroupElement CreateFacadesFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = null;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope         envelope         = geometry.Envelope;
                double            num              = envelope.ZMin;
                ISpatialReference spatialReference = BuildingProperty.Scene.SpatialReference;
                geometry.Project(spatialReference);
                string a = num.ToString();
                if (a.Equals("非数字"))
                {
                    num = 0.0;
                }
                double num2 = 0.0;
                if (ifeature3DProperties_0 != null)
                {
                    I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                    if (i3DProperties.OffsetExpressionString.Length > 0)
                    {
                        try
                        {
                            num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                        }
                        catch
                        {
                        }
                    }
                    if (geometry is IPolygon)
                    {
                        num += num2;
                    }
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight < 1.0)
                {
                    modFacades.m_extrusionHeight = 1.0;
                }
                IPoint point = null;
                double num4  = 0.0;
                double num5  = 0.0;
                double num6  = 0.0;
                object value = Missing.Value;
                for (int i = num3; i < geometryCount; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPointCollection pointCollection = geometry2 as IPointCollection;
                        int pointCount = pointCollection.PointCount;
                        if (pointCount >= 2)
                        {
                            int                 num7 = 0;
                            int                 num8 = 1;
                            bool                flag = false;
                            IPointCollection    pointCollection2;
                            double              m;
                            IMultiPatch         multiPatch;
                            IGeometryCollection geometryCollection2;
                            IZAware             iZAware;
                            IMAware             iMAware;
                            IElement            element;
                            while (!flag)
                            {
                                bool flag2 = false;
                                while (num8 < pointCount && !flag2)
                                {
                                    if (num8 - num7 == 1)
                                    {
                                        IPoint point2 = pointCollection.get_Point(num7);
                                        point = pointCollection.get_Point(num8);
                                        num5  = point.X - point2.X;
                                        num6  = point.Y - point2.Y;
                                        num4  = Math.Sqrt(num5 * num5 + num6 * num6);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                    }
                                    else
                                    {
                                        IPoint point2 = point;
                                        double num9   = num5;
                                        double num10  = num6;
                                        point = pointCollection.get_Point(num8);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                        num5 = point.X - point2.X;
                                        num6 = point.Y - point2.Y;
                                        double num11 = Math.Sqrt(num9 * num9 + num10 * num10);
                                        double num12 = Math.Sqrt(num5 * num5 + num6 * num6);
                                        double num13 = (num9 * num5 + num10 * num6) / (num11 * num12);
                                        if (num13 < Math.Cos(modFacades.m_limitAngle))
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                        num4 += num12;
                                    }
                                    num8++;
                                }
                                if (flag2)
                                {
                                    num8--;
                                }
                                else
                                {
                                    num8--;
                                }
                                pointCollection2 = new TriangleStrip();
                                double num14 = 0.0;
                                for (int j = num7; j <= num8; j++)
                                {
                                    if (j > 0)
                                    {
                                        IPoint point2 = point;
                                        point  = pointCollection.get_Point(j);
                                        num5   = point.X - point2.Y;
                                        num6   = point.Y - point2.Y;
                                        num14 += Math.Sqrt(num5 * num5 + num6 * num6);
                                    }
                                    else
                                    {
                                        point = pointCollection.get_Point(j);
                                    }
                                    point.Z = num;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, 0.0, out m);
                                    point.M = m;
                                    IClone clone = point as IClone;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                    point.Z = num + modFacades.m_extrusionHeight;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, -1.0, out m);
                                    point.M = m;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                }
                                multiPatch          = new MultiPatch() as IMultiPatch;
                                geometryCollection2 = (multiPatch as IGeometryCollection);
                                iZAware             = (multiPatch as IZAware);
                                iZAware.ZAware      = true;
                                iMAware             = (multiPatch as IMAware);
                                iMAware.MAware      = true;
                                geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                                if (clsTextureGroup_0 != null)
                                {
                                    int index = modFacades.FindTextureByAspect(clsTextureGroup_0, num4 / modFacades.m_extrusionHeight);
                                    element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.Symbols[index], string_0);
                                }
                                else
                                {
                                    element = modFacades.CreateElement(multiPatch, null, string_0);
                                }
                                if (element != null)
                                {
                                    groupElement2.AddElement(element);
                                }
                                num7 = num8;
                                num8 = num7 + 1;
                                if (num7 >= pointCount - 1)
                                {
                                    flag = true;
                                }
                            }
                            IVector3D vector3D = new Vector3D() as IVector3D;
                            vector3D.XComponent = 0.0;
                            vector3D.YComponent = 0.0;
                            vector3D.ZComponent = 1.0;
                            m = 0.0;
                            encode3DProperties.PackNormal(vector3D, out m);
                            pointCollection2 = new Ring();
                            for (int j = 0; j <= pointCount - 1; j++)
                            {
                                IPoint point3 = pointCollection.get_Point(j);
                                point3.Z = num + modFacades.m_extrusionHeight;
                                point3.M = 0.0;
                                IClone clone = point3 as IClone;
                                pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                            }
                            IRing ring = pointCollection2 as IRing;
                            ring.Close();
                            multiPatch          = new MultiPatch() as IMultiPatch;
                            geometryCollection2 = (multiPatch as IGeometryCollection);
                            iZAware             = (multiPatch as IZAware);
                            iZAware.ZAware      = true;
                            iMAware             = (multiPatch as IMAware);
                            iMAware.MAware      = true;
                            geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                            multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                            if (clsTextureGroup_0 != null)
                            {
                                element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                            }
                            else
                            {
                                element = modFacades.CreateElement(multiPatch, null, string_0 + ";ROOFCOLOR=1");
                            }
                            if (element != null)
                            {
                                groupElement2.AddElement(element);
                            }
                        }
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
Beispiel #25
0
        public static void CreateVerticalLOSPatches(bool bool_0, IPoint ipoint_0, IPoint ipoint_1, IPolyline ipolyline_0,
                                                    IPolyline ipolyline_1, IGeometryCollection igeometryCollection_0, IGeometryCollection igeometryCollection_1,
                                                    out double double_0)
        {
            int i;
            IPointCollection    geometry;
            IClone              point;
            IPointCollection    triangleFanClass;
            IVector3D           vector3DClass;
            IPoint              point1;
            IPoint              point2;
            object              value                = Missing.Value;
            IGeometryCollection ipolyline0           = ipolyline_0 as IGeometryCollection;
            IMultiPatch         igeometryCollection1 = igeometryCollection_1 as IMultiPatch;

            double_0 = ipoint_1.Z;
            double magnitude = 0;
            IPoint point3    = null;

            for (i = 0; i < ipolyline0.GeometryCount; i++)
            {
                geometry = ipolyline0.Geometry[i] as IPointCollection;
                if (i == 0)
                {
                    point = geometry.Point[0] as IClone;
                    IPoint point4 = point.Clone() as IPoint;
                }
                point            = geometry as IClone;
                triangleFanClass = new TriangleFan();
                point            = ipoint_0 as IClone;
                triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                point = geometry as IClone;
                triangleFanClass.AddPointCollection(point.Clone() as IPointCollection);
                if (i == ipolyline0.GeometryCount - 1)
                {
                    vector3DClass = new Vector3D() as IVector3D;
                    point         = ipoint_0 as IClone;
                    point1        = point.Clone() as IPoint;
                    point1.Z      = 0;
                    point         = geometry.Point[geometry.PointCount - 1] as IClone;
                    point2        = point.Clone() as IPoint;
                    point2.Z      = 0;
                    vector3DClass.ConstructDifference(point1, point2);
                    magnitude = vector3DClass.Magnitude;
                    point3    = point.Clone() as IPoint;
                    if (ipolyline_1 == null && ipoint_1.Z > geometry.Point[geometry.PointCount - 1].Z)
                    {
                        point = ipoint_1 as IClone;
                        triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                    }
                }
                igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value);
            }
            if (ipolyline_1 != null)
            {
                ipolyline0 = ipolyline_1 as IGeometryCollection;
                for (i = 0; i < ipolyline0.GeometryCount; i++)
                {
                    geometry = ipolyline0.Geometry[i] as IPointCollection;
                    point    = geometry as IClone;
                    IPointCollection ringClass = new Ring();
                    point = geometry as IClone;
                    ringClass.AddPointCollection(point.Clone() as IPointCollection);
                    if (i == ipolyline0.GeometryCount - 1)
                    {
                        vector3DClass = new Vector3D() as IVector3D;
                        point         = ipoint_0 as IClone;
                        point1        = point.Clone() as IPoint;
                        point1.Z      = 0;
                        point         = geometry.Point[geometry.PointCount - 1] as IClone;
                        point2        = point.Clone() as IPoint;
                        point2.Z      = 0;
                        vector3DClass.ConstructDifference(point1, point2);
                        if (magnitude < vector3DClass.Magnitude)
                        {
                            point    = ipoint_0 as IClone;
                            point1   = point.Clone() as IPoint;
                            point1.Z = 0;
                            point    = geometry.Point[0] as IClone;
                            point2   = point.Clone() as IPoint;
                            point2.Z = 0;
                            vector3DClass.ConstructDifference(point1, point2);
                            double num = vector3DClass.Magnitude;
                            double z   = (ipoint_0.Z - geometry.Point[0].Z) / num;
                            point = geometry.Point[geometry.PointCount - 1] as IClone;
                            IPoint z1 = point.Clone() as IPoint;
                            point2   = point.Clone() as IPoint;
                            point2.Z = 0;
                            vector3DClass.ConstructDifference(point1, point2);
                            double magnitude1 = vector3DClass.Magnitude;
                            z1.Z  = ipoint_0.Z - magnitude1 * z;
                            point = z1 as IClone;
                            ringClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                            if (!bool_0)
                            {
                                double_0 = z1.Z;
                            }
                            else
                            {
                                triangleFanClass = new TriangleFan();
                                point            = ipoint_0 as IClone;
                                triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                                point = ipoint_1 as IClone;
                                triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                                point = z1 as IClone;
                                triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                                igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value);
                            }
                        }
                        else if (bool_0 && ipoint_1.Z > point3.Z)
                        {
                            triangleFanClass = new TriangleFan();
                            point            = ipoint_0 as IClone;
                            triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                            point = ipoint_1 as IClone;
                            triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                            point = point3 as IClone;
                            triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                            igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value);
                        }
                    }
                    point = ringClass.Point[0] as IClone;
                    ringClass.AddPoint(point.Clone() as IPoint, ref value, ref value);
                    igeometryCollection_1.AddGeometry(ringClass as IGeometry, ref value, ref value);
                    igeometryCollection1.PutRingType(ringClass as IRing, esriMultiPatchRingType.esriMultiPatchRing);
                }
            }
        }
        private void Run()
        {
            if (_targetDataset == null || _fdb == null || _sourceDataset == null)
            {
                return;
            }

            //if (_targetDataset[_name] != null)
            //{
            //    MessageBox.Show("Featureclass '" + _name + "' already exists!");
            //    return;
            //}
            bool succeeded = false;

            try
            {
                Envelope bounds  = new Envelope(_spatialIndexDef.SpatialIndexBounds);
                Envelope iBounds = new Envelope(bounds.minx - _tileSizeX, bounds.miny - _tileSizeY,
                                                bounds.maxx + _tileSizeX, bounds.maxy + _tileSizeY);

                _cacheDirectory += @"\" + _name;
                if (!String.IsNullOrEmpty(_cacheDirectory))
                {
                    DirectoryInfo di = new DirectoryInfo(_cacheDirectory);
                    if (!di.Exists)
                    {
                        di.Create();
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append("<TileCacheDefinition>\r\n");
                    sb.Append(" <General levels='" + _levels + "' origin='lowerleft' />\r\n");
                    sb.Append(" <Envelope minx='" + bounds.minx.ToString(_nhi) + "' miny='" + bounds.miny.ToString(_nhi) + "' maxx='" + bounds.maxx.ToString(_nhi) + "' maxy='" + bounds.maxy.ToString(_nhi) + "' />\r\n");
                    sb.Append(" <TileSize x='" + _tileSizeX.ToString(_nhi) + "' y='" + _tileSizeY.ToString(_nhi) + "' />\r\n");
                    sb.Append(" <TileResolution x='" + _resX.ToString(_nhi) + "' y='" + _resY.ToString(_nhi) + "' />\r\n");
                    sb.Append("</TileCacheDefinition>");

                    StreamWriter sw = new StreamWriter(di.FullName + @"\tilecache.xml");
                    sw.WriteLine(sb.ToString());
                    sw.Close();
                }
                ProgressReport report = new ProgressReport();

                int datasetId = _fdb.DatasetID(_targetDataset.DatasetName);
                if (datasetId == -1)
                {
                    return;
                }

                IClass cls = null;
                try
                {
                    cls = _sourceDataset.Elements[0].Class;
                }
                catch { cls = null; }
                IMultiGridIdentify gridClass = cls as IMultiGridIdentify;
                if (_gridType == TileGridType.binary_float && gridClass == null)
                {
                    return;
                }
                IFeatureClass sourceFc = cls as IFeatureClass;

                Map map = null;
                if (_gridType == TileGridType.image_jpg || _gridType == TileGridType.image_png)
                {
                    map = new Map();
                    ILayer layer = LayerFactory.Create(cls);
                    map.AddLayer(layer);
                    //map.iWidth = (int)(_tileSizeX / _resX);
                    //map.iHeight = (int)(_tileSizeY / _resY);
                }


                #region Create Featureclass
                IFeatureClass   fc      = null;
                IDatasetElement element = _targetDataset[_name];
                if (element != null && element.Class is IFeatureClass)
                {
                    fc = (IFeatureClass)element.Class;
                    if (fc.GeometryType == geometryType.Polygon &&
                        fc.FindField("GRID_LEVEL") != null &&
                        fc.FindField("GRID_ROW") != null &&
                        fc.FindField("GRID_COLUMN") != null &&
                        fc.FindField("FILE") != null)
                    {
                        if (MessageBox.Show("TileGridClass already exists. Do you wan't to append to this Grid?",
                                            "Warning",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                    else
                    {
                        _fdb.DeleteFeatureClass(_name);
                        fc = null;
                    }
                }
                if (fc == null)
                {
                    Fields fields = new Fields();

                    fields.Add(new Field("GRID_LEVEL", FieldType.integer));
                    fields.Add(new Field("GRID_ROW", FieldType.integer));
                    fields.Add(new Field("GRID_COLUMN", FieldType.integer));
                    fields.Add(new Field("FILE", FieldType.String, 512));

                    _fdb.CreateFeatureClass(_targetDataset.DatasetName, _name,
                                            new GeometryDef(geometryType.Polygon),
                                            fields);
                    element = _targetDataset[_name];
                    if (element == null || !(element.Class is IFeatureClass))
                    {
                        return;
                    }
                    _fdb.SetSpatialIndexBounds(_name, "BinaryTree2", iBounds, _spatialIndexDef.SplitRatio, _spatialIndexDef.MaxPerNode, _spatialIndexDef.Levels);
                    fc = (IFeatureClass)element.Class;
                }
                #endregion

                #region Create Tiles

                #region Report
                double tx = _tileSizeX, ty = _tileSizeY;
                if (ReportProgress != null)
                {
                    report.featureMax = 0;
                    for (int i = 0; i < _levels; i++)
                    {
                        if (_createLevels.Contains(i))
                        {
                            for (double y = bounds.miny; y < bounds.maxy; y += ty)
                            {
                                for (double x = bounds.minx; x < bounds.maxx; x += tx)
                                {
                                    report.featureMax++;
                                }
                            }
                        }
                        if (_levelType == TileLevelType.ConstantImagesize)
                        {
                            tx *= 2;
                            ty *= 2;
                        }
                    }
                    report.Message    = "Create Tiles";
                    report.featurePos = 0;
                    ReportProgress(report);
                }
                int reportInterval = (_createTiles ? 10 : 1000);
                #endregion

                List <IFeature> features = new List <IFeature>();
                for (int level = 0; level < _levels; level++)
                {
                    if (map != null)
                    {
                        map.iWidth  = (int)(_tileSizeX / _resX);
                        map.iHeight = (int)(_tileSizeY / _resY);
                    }
                    if (_createLevels.Contains(level))
                    {
                        int row = 0;
                        for (double y = bounds.miny; y < bounds.maxy; y += _tileSizeY)
                        {
                            DirectoryInfo di = new DirectoryInfo(_cacheDirectory + @"\" + level + @"\" + row);
                            if (!di.Exists)
                            {
                                di.Create();
                            }

                            int column = 0;
                            for (double x = bounds.minx; x < bounds.maxx; x += _tileSizeX)
                            {
                                #region Polygon
                                Polygon polygon = new Polygon();
                                Ring    ring    = new Ring();
                                ring.AddPoint(new Point(x, y));
                                ring.AddPoint(new Point(Math.Min(x + _tileSizeX, bounds.maxx), y));
                                ring.AddPoint(new Point(Math.Min(x + _tileSizeX, bounds.maxx), Math.Min(y + _tileSizeY, bounds.maxy)));
                                ring.AddPoint(new Point(x, Math.Min(y + _tileSizeY, bounds.maxy)));
                                ring.Close();
                                polygon.AddRing(ring);
                                #endregion

                                if (sourceFc != null)
                                {
                                    SpatialFilter filter = new SpatialFilter();
                                    filter.AddField(sourceFc.IDFieldName);
                                    filter.Geometry = polygon;
                                    filter.FilterSpatialReference = fc.SpatialReference;
                                    using (IFeatureCursor cursor = sourceFc.GetFeatures(filter))
                                    {
                                        if (cursor.NextFeature == null)
                                        {
                                            column++;
                                            report.featurePos++;
                                            if (ReportProgress != null && report.featurePos % reportInterval == 0)
                                            {
                                                ReportProgress(report);
                                            }
                                            continue;
                                        }
                                    }
                                }

                                string relFilename = level + "/" + row + "/" + column + ".bin";

                                if (_createTiles)
                                {
                                    string filename = di.FullName + @"\" + column;
                                    if (_gridType == TileGridType.binary_float)
                                    {
                                        float[] vals = gridClass.MultiGridQuery(
                                            null,
                                            new IPoint[] { ring[0], ring[1], ring[3] },
                                            _resX, _resY,
                                            fc.SpatialReference, null);
                                        if (!HasFloatArrayData(vals))
                                        {
                                            column++;
                                            report.featurePos++;
                                            if (ReportProgress != null && report.featurePos % reportInterval == 0)
                                            {
                                                ReportProgress(report);
                                            }
                                            continue;
                                        }
                                        StoreFloatArray(filename + ".bin", x, y, _resX, _resY, vals);
                                    }
                                    else if (map != null)
                                    {
                                        map.ZoomTo(new Envelope(x, y, x + _tileSizeX, y + _tileSizeY));
                                        map.RefreshMap(DrawPhase.All, _cancelTracker);
                                        if (_gridType == TileGridType.image_png)
                                        {
                                            map.Bitmap.Save(filename + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                        }
                                        else if (_gridType == TileGridType.image_jpg)
                                        {
                                            map.Bitmap.Save(filename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                                        }
                                    }
                                }

                                Feature feature = new Feature();
                                feature.Shape = polygon;
                                feature.Fields.Add(new FieldValue("GRID_LEVEL", level));
                                feature.Fields.Add(new FieldValue("GRID_ROW", row));
                                feature.Fields.Add(new FieldValue("GRID_COLUMN", column));
                                feature.Fields.Add(new FieldValue("FILE", relFilename));

                                features.Add(feature);
                                column++;
                                report.featurePos++;
                                if (features.Count >= reportInterval)
                                {
                                    if (ReportProgress != null)
                                    {
                                        ReportProgress(report);
                                    }
                                    if (!_fdb.Insert(fc, features))
                                    {
                                        MessageBox.Show(_fdb.lastErrorMsg, "DB Insert Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                    features.Clear();

                                    if (!_cancelTracker.Continue)
                                    {
                                        succeeded = true;
                                        return;
                                    }
                                }
                            }
                            row++;
                        }
                    }
                    if (_levelType == TileLevelType.ConstantImagesize)
                    {
                        _tileSizeX *= 2;
                        _tileSizeY *= 2;
                    }
                    _resX *= 2;
                    _resY *= 2;
                }
                if (features.Count > 0)
                {
                    if (ReportProgress != null)
                    {
                        ReportProgress(report);
                    }
                    _fdb.Insert(fc, features);
                }
                _fdb.CalculateExtent(fc);
                #endregion

                succeeded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (!succeeded)
                {
                    _fdb.DeleteFeatureClass(_name);
                }
            }
        }
Beispiel #27
0
        public static IGroupElement CreateRoadSurfaceFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                        modFacades.g_bFeaturePropertiesApplied = true;
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                        modFacades.g_bFeaturePropertiesApplied = false;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = groupElement;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope envelope = geometry.Envelope;
                double    num      = envelope.ZMin;
                if (modFacades.IsNaN(num))
                {
                    num = 0.0;
                }
                double        num2          = 0.0;
                I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                if (i3DProperties.OffsetExpressionString.Length > 0)
                {
                    num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                }
                if (geometry is IPolygon)
                {
                    num += num2;
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight >= 1.0)
                {
                }
                for (int i = num3; i <= geometryCount - 1; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                    }
                    IPointCollection pointCollection = geometry2 as IPointCollection;
                    int pointCount = pointCollection.PointCount;
                    if (pointCount >= 2)
                    {
                    }
                    IVector3D vector3D = new Vector3D() as IVector3D;
                    vector3D.XComponent = 0.0;
                    vector3D.YComponent = 0.0;
                    vector3D.ZComponent = 1.0;
                    double m = 0.0;
                    encode3DProperties.PackNormal(vector3D, out m);
                    IPointCollection pointCollection2 = new Ring();
                    object           value            = Missing.Value;
                    short            num4             = 0;
                    while ((int)num4 <= pointCount - 1)
                    {
                        IPoint point = pointCollection.get_Point((int)num4);
                        point.Z = num;
                        point.M = m;
                        IClone clone = point as IClone;
                        pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                        num4 += 1;
                    }
                    IRing ring = pointCollection2 as IRing;
                    ring.Close();
                    IMultiPatch         multiPatch          = new MultiPatch() as IMultiPatch;
                    IGeometryCollection geometryCollection2 = multiPatch as IGeometryCollection;
                    IZAware             iZAware             = multiPatch as IZAware;
                    iZAware.ZAware = true;
                    IMAware iMAware = multiPatch as IMAware;
                    iMAware.MAware = true;
                    geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                    multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                    IElement element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                    if (element != null)
                    {
                        groupElement2.AddElement(element);
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
Beispiel #28
0
        static public IGeometry ToGeometry(this JsonGeometry geometry)
        {
            if (geometry == null)
            {
                return(null);
            }

            if (geometry.X.HasValue && geometry.Y.HasValue)
            {
                return(new Point(geometry.X.Value, geometry.Y.Value));
            }
            if (geometry.XMin.HasValue && geometry.YMin.HasValue && geometry.XMax.HasValue && geometry.YMax.HasValue)
            {
                return(new Envelope(geometry.XMin.Value, geometry.YMin.Value, geometry.XMax.Value, geometry.YMax.Value));
            }
            if (geometry.Paths != null && geometry.Paths.Length > 0)
            {
                var polyline = new Polyline();

                for (int p = 0, pathCount = geometry.Paths.Length; p < pathCount; p++)
                {
                    var jsonPath = geometry.Paths[p];
                    if (jsonPath.Length < 1)
                    {
                        continue;
                    }

                    var path = new Path();
                    for (int i = 0, pointCount = jsonPath.GetLength(0); i < pointCount; i++)
                    {
                        path.AddPoint(new Point(jsonPath[i, 0], jsonPath[i, 1]));
                    }
                    polyline.AddPath(path);
                }

                return(polyline);
            }
            if (geometry.Rings != null && geometry.Rings.Length > 0)
            {
                var polygon = new Polygon();

                for (int p = 0, ringCount = geometry.Rings.Length; p < ringCount; p++)
                {
                    var jsonRing = geometry.Rings[p];
                    if (jsonRing.Length < 1)
                    {
                        continue;
                    }

                    var ring = new Ring();
                    for (int i = 0, pointCount = jsonRing.GetLength(0); i < pointCount; i++)
                    {
                        ring.AddPoint(new Point(jsonRing[i, 0], jsonRing[i, 1]));
                    }
                    polygon.AddRing(ring);
                }

                return(polygon);
            }

            return(null);
        }
        virtual public void DrawGrabbers(IDisplay display)
        {
            IMultiPoint grabbers = Grabbers(display, true);

            if (grabbers == null)
            {
                return;
            }

            System.Drawing.Drawing2D.SmoothingMode smode = display.GraphicsContext.SmoothingMode;
            display.GraphicsContext.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            SimplePointSymbol pointSymbol = new SimplePointSymbol();

            pointSymbol.Color        = System.Drawing.Color.White;
            pointSymbol.OutlineColor = System.Drawing.Color.Black;
            pointSymbol.OutlineWidth = 1;
            pointSymbol.Size         = 8;

            if (display.GraphicsContainer.EditMode == GrabberMode.Pointer)
            {
                Ring ring = new Ring();
                for (int i = 0; i < Math.Min(grabbers.PointCount, 4); i++)
                {
                    ring.AddPoint(grabbers[i]);
                }
                Polygon polygon = new Polygon();
                polygon.AddRing(ring);

                SimpleLineSymbol lSymbol = new SimpleLineSymbol();
                lSymbol.Color     = System.Drawing.Color.Gray;
                lSymbol.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                display.Draw(lSymbol, polygon);
                lSymbol.Release();

                for (int i = 0; i < grabbers.PointCount; i++)
                {
                    if (!UseGrabber((GrabberIDs)i))
                    {
                        continue;
                    }

                    if (i > 7 && pointSymbol.Color == System.Drawing.Color.White)
                    {
                        pointSymbol.Color = System.Drawing.Color.Yellow;
                        DrawRotationGrabberline(display);
                    }
                    display.Draw(pointSymbol, grabbers[i]);
                }
            }
            else if (display.GraphicsContainer.EditMode == GrabberMode.Vertex)
            {
                pointSymbol.Marker = SimplePointSymbol.MarkerType.Square;
                pointSymbol.Size   = 5;

                for (int i = 0; i < grabbers.PointCount; i++)
                {
                    display.Draw(pointSymbol, grabbers[i]);
                }
            }

            display.GraphicsContext.SmoothingMode = smode;
        }
Beispiel #30
0
        private void DrawChart(IDisplay disp, IPoint point, double[] values, double valSum, double valMin, double valMax)
        {
            if (!(disp is Display) || disp.LabelEngine.LabelGraphicsContext == null)
            {
                return;
            }

            System.Drawing.Graphics original = disp.GraphicsContext;
            try
            {
                ((Display)disp).GraphicsContext = disp.LabelEngine.LabelGraphicsContext;

                if (_symbolTable.Keys.Count == 0)
                {
                    return;
                }

                int i = 0;
                if (_type == chartType.Pie)
                {
                    #region Draw Pie

                    if (valSum == 0.0)
                    {
                        return;
                    }

                    double r = disp.mapScale / disp.dpm * _size / 2D;
                    switch (_sizeType)
                    {
                    case sizeType.ValueOfEquatesToSize:
                        double a = r * r * Math.PI * valSum / _valueEquatesToSize;
                        r = Math.Sqrt(a / Math.PI);
                        break;
                    }

                    i = 0;
                    double startAngle = 0.0;

                    Path outerPath = new Path();
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double angle = (Math.PI * 2.0) * Math.Abs(values[i++]) / valSum;

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(point);

                        for (double a = startAngle, to = startAngle + angle; a < to; a += 0.01745)
                        {
                            IPoint piePoint = new Point(point.X + r * Math.Cos(a), point.Y + r * Math.Sin(a));
                            ring.AddPoint(piePoint);
                            outerPath.AddPoint(piePoint);
                        }
                        ring.AddPoint(new Point(point.X + r * Math.Cos(startAngle + angle), point.Y + r * Math.Sin(startAngle + angle)));

                        symbol.Draw(disp, poly);

                        //if (_outlineSymbol != null && ring.PointCount > 0)
                        //    outerPath.AddPoints(ring);

                        startAngle += angle;
                    }
                    if (outerPath.PointCount > 0 && _outlineSymbol != null)
                    {
                        outerPath.AddPoint(outerPath[0]);
                        _outlineSymbol.Draw(disp, new Polyline(outerPath));
                    }

                    #endregion
                }
                else if (_type == chartType.Bars)
                {
                    #region Draw Bars

                    double height    = disp.mapScale / disp.dpm * _size;
                    double width     = disp.mapScale / disp.dpm * _size / 4D;
                    double heightVal = _valueEquatesToSize;

                    switch (_sizeType)
                    {
                    case sizeType.ConstantSize:
                        if (valSum == 0.0)
                        {
                            return;
                        }
                        height *= _valueEquatesToSize / valSum;
                        break;
                    }

                    i = 0;
                    double left = -(_symbolTable.Keys.Count * width / 2.0) - (_symbolTable.Keys.Count - 1) * (disp.mapScale / disp.dpm) / 2.0;
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double h = height * (values[i++] / heightVal);
                        if (Math.Abs(h) < disp.mapScale / disp.dpm)
                        {
                            h = disp.mapScale / disp.dpm;
                        }

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(new Point(point.X + left, point.Y));
                        ring.AddPoint(new Point(point.X + left, point.Y + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y));

                        symbol.Draw(disp, poly);

                        if (_outlineSymbol != null && ring.PointCount > 0)
                        {
                            ring.AddPoint(new Point(point.X + left, point.Y));
                            _outlineSymbol.Draw(disp, new Polyline(ring));
                        }
                        left += width + (disp.mapScale / disp.dpm);
                    }

                    #endregion
                }
                else if (_type == chartType.Stack)
                {
                    #region Draw Stack
                    double height    = disp.mapScale / disp.dpm * _size;
                    double width     = disp.mapScale / disp.dpm * _size / 4D;
                    double heightVal = _valueEquatesToSize;

                    Path outerPath = new Path();

                    switch (_sizeType)
                    {
                    case sizeType.ConstantSize:
                        if (valSum == 0.0)
                        {
                            return;
                        }
                        height *= _valueEquatesToSize / valSum;
                        break;
                    }

                    i = 0;
                    double left = -width / 2.0, bottom = 0D;
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double h = height * (values[i++] / heightVal);
                        if (Math.Abs(h) < disp.mapScale / disp.dpm)
                        {
                            h = disp.mapScale / disp.dpm;
                        }

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(new Point(point.X + left, point.Y + bottom));
                        ring.AddPoint(new Point(point.X + left, point.Y + bottom + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + bottom + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + bottom));

                        if (_outlineSymbol != null)
                        {
                            if (i == 1)
                            {
                                outerPath.AddPoint(new Point(point.X + left, point.Y + bottom));
                            }
                            if (i == _symbolTable.Keys.Count)
                            {
                                outerPath.AddPoint(new Point(point.X + left, point.Y + bottom + h));
                                outerPath.AddPoint(new Point(point.X + left + width, point.Y + bottom + h));
                                outerPath.AddPoint(new Point(point.X + left + width, point.Y));
                                outerPath.AddPoint(outerPath[0]);
                            }
                        }

                        symbol.Draw(disp, poly);
                        bottom += h;
                    }
                    if (_outlineSymbol != null && outerPath.PointCount > 0)
                    {
                        _outlineSymbol.Draw(disp, new Polyline(outerPath));
                    }
                    #endregion
                }
            }
            finally
            {
                ((Display)disp).GraphicsContext = original;
            }
        }