Пример #1
0
        private void TryExportIceLine(Feature[] features, string iceLineShpFileName)
        {
            double geoX, geoY = 0;

            GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform;
            List <Feature> fets = new List <Feature>();
            int            oid  = 0;

            foreach (Feature fet in features)
            {
                ShapePolyline          line           = fet.Geometry as ShapePolyline;
                List <ShapeLineString> newLineStrings = new List <ShapeLineString>();
                ShapeLineString        newpart        = null;
                ShapePoint             newPt          = null;
                ShapeLineString        part           = null;;
                List <ShapePoint>      newpts         = new List <ShapePoint>();
                for (int m = 0; m < line.Parts.Length; m++)
                {
                    part = line.Parts[m];
                    for (int j = 0; j < part.Points.Length; j++)
                    {
                        ShapePoint sp = part.Points[j];
                        if (line.IsProjected)
                        {
                            tran.Prj2Geo(sp.X, sp.Y, out geoX, out geoY);
                            newPt = new ShapePoint(geoX, geoY);
                        }
                        else
                        {
                            newPt = new ShapePoint(sp.X, sp.Y);
                        }
                        newpts.Add(newPt);
                    }
                    newpart = new ShapeLineString(newpts.ToArray());
                    newLineStrings.Add(newpart);
                }
                ShapePolyline sply       = new ShapePolyline(newLineStrings.ToArray());
                string[]      fieldvalue = new string[] { fet.FieldValues[0] };
                Feature       outFet     = new Feature(oid, sply, new string[] { _fieldName }, fieldvalue, null);
                oid++;
                fets.Add(outFet);
            }
            TryExport2ShapeFile(fets.ToArray(), iceLineShpFileName, enumShapeType.Polyline);
        }
Пример #2
0
        private Feature GetIceLineFeature(ref int oid, GeometryOfDrawed geo)
        {
            if (geo.ControlRasterPoints == null || geo.ControlRasterPoints.Length == 0)
            {
                return(null);
            }
            Feature           fet    = null;
            List <ShapePoint> points = new List <ShapePoint>();

            foreach (PointF rasterPoint in geo.RasterPoints)
            {
                double geoX, geoY;
                _canvas.CoordTransform.Raster2Geo((int)rasterPoint.Y, (int)rasterPoint.X, out geoX, out geoY);
                points.Add(new ShapePoint(geoX, geoY));
            }
            ShapeLineString shapeLine  = new ShapeLineString(points.ToArray());
            string          fieldValue = "冰缘线" + (oid + 1).ToString();

            fet = new Feature(oid, new ShapePolyline(new ShapeLineString[] { shapeLine }), new string[] { _fieldName }, new string[] { fieldValue }, new LabelLocation[] { new LabelLocation() });
            oid++;
            return(fet);
        }
Пример #3
0
        private unsafe Feature GetFeature(ContourLine cntLine, ICanvas canvas, int OID)
        {
            int ptCount = cntLine.Count;

            ShapePoint[] pts = new ShapePoint[ptCount];
            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < ptCount; i++, ptr++)
                {
                    double geoX, geoY;
                    canvas.CoordTransform.Prj2Geo(ptr->X, ptr->Y, out geoX, out geoY);
                    pts[i] = new ShapePoint(geoX, geoY);
                }
            }

            ShapeLineString ring = new ShapeLineString(pts);
            ShapePolyline   ply  = new ShapePolyline(new ShapeLineString[] { ring });
            Feature         fet  = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null);

            return(fet);
        }
Пример #4
0
        private unsafe Feature GetFeature(ContourLine cntLine, double resX, double resY,
                                          double minX, double maxY, int OID)
        {
            int ptCount = cntLine.Count;

            ShapePoint[] pts = new ShapePoint[ptCount];
            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < ptCount; i++, ptr++)
                {
                    ptr->X = (float)(ptr->X * resX + minX);
                    ptr->Y = (float)(maxY - ptr->Y * resY);
                    pts[i] = new ShapePoint(ptr->X, ptr->Y);
                }
            }

            ShapeLineString ring = new ShapeLineString(pts);
            ShapePolyline   ply  = new ShapePolyline(new ShapeLineString[] { ring });
            Feature         fet  = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null);

            return(fet);
        }
Пример #5
0
        private Feature[] ConstructPoint(float[] lats, float[] lons)
        {
            List <Feature> features = new List <Feature>();
            ShapePoint     pt;

            string[] fieldValues = null;
            string[] fieldNames  = null;
            //除去经度、纬度属性
            //int fieldCount = _fields.Length;
            int pointCount        = lats.Length;
            List <ShapePoint> sps = new List <ShapePoint>();

            for (int oid = 0; oid < pointCount; oid++)
            {
                pt = new ShapePoint(lons[oid], lats[oid]);
                sps.Add(pt);
            }
            ShapeLineString[] parts = new ShapeLineString[] { new ShapeLineString(sps.ToArray()) };
            ShapePolyline     spl   = new ShapePolyline(parts);
            Feature           f     = new Feature(0, spl, fieldNames, fieldValues, null);

            features.Add(f);
            return(features.ToArray());
        }