コード例 #1
0
ファイル: CachedVectorData.cs プロジェクト: configare/hispeed
        private void ProjectFeature(Feature fet)
        {
            Shape geometry = fet.Geometry;

            double[] xs = new double[1];
            double[] ys = new double[1];
            if (geometry is ShapePolygon)
            {
                ShapePolygon plygon = geometry as ShapePolygon;
                foreach (ShapeRing ring in plygon.Rings)
                {
                    foreach (ShapePoint pt in ring.Points)
                    {
                        xs[0] = pt.X;
                        ys[0] = pt.Y;
                        _coordTransform.Transform(xs, ys);
                        pt.X = xs[0];
                        pt.Y = ys[0];
                    }
                    ring.UpdateCentroid();
                    ring.UpdateEnvelope();
                }
                plygon.UpdateCentroid();
                plygon.UpdateEnvelope();
            }
            else if (geometry is ShapePolyline)
            {
                ShapePolyline plyline = geometry as ShapePolyline;
                foreach (ShapeLineString line in plyline.Parts)
                {
                    foreach (ShapePoint pt in line.Points)
                    {
                        xs[0] = pt.X;
                        ys[0] = pt.Y;
                        _coordTransform.Transform(xs, ys);
                        pt.X = xs[0];
                        pt.Y = ys[0];
                    }
                    line.UpdateCentroid();
                    line.UpdateEnvelope();
                }
                plyline.UpdateCentroid();
                plyline.UpdateEnvelope();
            }
            else if (geometry is ShapePoint)
            {
                ShapePoint pt = geometry as ShapePoint;
                xs[0] = pt.X;
                ys[0] = pt.Y;
                _coordTransform.Transform(xs, ys);
                pt.X = xs[0];
                pt.Y = ys[0];
                pt.UpdateCentroid();
                pt.UpdateEnvelope();
            }
            fet.Geometry.UpdateCentroid();
            fet.Geometry.UpdateEnvelope();
            fet.Projected = true;
        }
コード例 #2
0
ファイル: CachedVectorData.cs プロジェクト: configare/hispeed
        private void ProjectFeature(Feature fet)
        {
            Shape geometry = fet.Geometry;

            double[] xs = new double[1];
            double[] ys = new double[1];
            if (geometry is ShapePolygon)
            {
                ShapePolygon plygon = geometry as ShapePolygon;
                foreach (ShapeRing ring in plygon.Rings)
                {
                    foreach (ShapePoint pt in ring.Points)
                    {
                        xs[0] = pt.X;
                        ys[0] = pt.Y;
                        _coordTransform.Transform(xs, ys);
                        pt.X = xs[0];
                        pt.Y = ys[0];
                    }
                    ring.UpdateCentroid();
                    ring.UpdateEnvelope();
                }
                plygon.UpdateCentroid();
                plygon.UpdateEnvelope();
            }
            else if (geometry is ShapePolyline)
            {
                ShapePolyline plyline = geometry as ShapePolyline;
                foreach (ShapeLineString line in plyline.Parts)
                {
                    foreach (ShapePoint pt in line.Points)
                    {
                        xs[0] = pt.X;
                        ys[0] = pt.Y;
                        _coordTransform.Transform(xs, ys);
                        pt.X = xs[0];
                        pt.Y = ys[0];
                    }
                    line.UpdateCentroid();
                    line.UpdateEnvelope();
                }
                plyline.UpdateCentroid();
                plyline.UpdateEnvelope();
            }
            else if (geometry is ShapePoint)
            {
                ShapePoint pt = geometry as ShapePoint;
                xs[0] = pt.X;
                ys[0] = pt.Y;
                _coordTransform.Transform(xs, ys);
                pt.X = xs[0];
                pt.Y = ys[0];
                pt.UpdateCentroid();
                pt.UpdateEnvelope();
            }
            fet.Geometry.UpdateCentroid();
            fet.Geometry.UpdateEnvelope();
            //
            if (fet.Annotations != null && fet.Annotations.Length > 0)
            {
                foreach (LabelLocation loc in fet.Annotations)
                {
                    xs[0] = loc.Location.X;
                    ys[0] = loc.Location.Y;
                    _coordTransform.Transform(xs, ys);
                    loc.Location = new ShapePoint(xs[0], ys[0]);
                }
            }
            //
            fet.Projected = true;
        }