Ejemplo n.º 1
0
        public override void Write(BinaryWriter writer, IMultiPartGeometry <IPointZ> value, WordCount origin)
        {
            Box.Write(writer, value.Box, origin);

            var partCount = value.Parts.Count;

            NumParts.Write(writer, partCount, origin);

            var points = value.Parts.SelectMany(part => part.Points).ToArray();

            NumPoints.Write(writer, points.Length, origin);

            int pointCount = 0;

            for (int i = 0; i < partCount; i++)
            {
                Part(i).Write(writer, pointCount, origin);

                pointCount += value.Parts[i].Points.Count;
            }

            var pointsOffset = OffsetPoints(partCount);

            for (int i = 0; i < points.Length; i++)
            {
                Point(pointsOffset, pointCount, i).Write(writer, points[i], origin);
            }

            MinZ(pointsOffset, pointCount).Write(writer, value.Box.Min.Z, origin);
            MaxZ(pointsOffset, pointCount).Write(writer, value.Box.Max.Z, origin);

            MinM(pointsOffset, pointCount).Write(writer, value.Box.Min.M, origin);
            MaxM(pointsOffset, pointCount).Write(writer, value.Box.Max.M, origin);
        }
Ejemplo n.º 2
0
        public override void Write(BinaryWriter writer, IMultiPatchShape <IPointZ> value, WordCount origin)
        {
            Box.Write(writer, value.Box, origin);

            var numParts = value.Patches.Count;

            NumParts.Write(writer, numParts, origin);

            var points = value.Patches.SelectMany(patch => patch.Points).ToArray();

            NumPoints.Write(writer, points.Length, origin);

            int pointCount = 0;

            for (int i = 0; i < numParts; i++)
            {
                Part(i).Write(writer, pointCount, origin);
                PartType(numParts, i).Write(writer, value.Patches[i].PatchType);

                pointCount += value.Patches[i].Points.Count;
            }

            var pointsOffset = OffsetPoints(numParts);

            for (int i = 0; i < points.Length; i++)
            {
                Point(pointsOffset, pointCount, i).Write(writer, points[i], origin);
            }

            MinZ(pointsOffset, pointCount).Write(writer, value.Box.Min.Z, origin);
            MaxZ(pointsOffset, pointCount).Write(writer, value.Box.Max.Z, origin);

            MinM(pointsOffset, pointCount).Write(writer, value.Box.Min.M, origin);
            MaxM(pointsOffset, pointCount).Write(writer, value.Box.Max.M, origin);
        }
Ejemplo n.º 3
0
        public override void Write(BinaryWriter writer, IMultiPartGeometry <IPoint> value, WordCount origin)
        {
            Box.Write(writer, value.Box, origin);

            var partCount = value.Parts.Count;

            NumParts.Write(writer, partCount, origin);

            var points = value.Parts.SelectMany(part => part.Points).ToArray();

            NumPoints.Write(writer, points.Length, origin);

            int pointCount = 0;

            for (int i = 0; i < partCount; i++)
            {
                Part(i).Write(writer, pointCount, origin);

                pointCount += value.Parts[i].Points.Count;
            }

            for (int i = 0; i < pointCount; i++)
            {
                Point(partCount, i).Write(writer, points[i], origin);
            }
        }
Ejemplo n.º 4
0
        public override IMultiPartGeometry <IPointM> Read(BinaryReader reader, WordCount origin)
        {
            var box       = Box.Read(reader, origin);
            var numParts  = NumParts.Read(reader, origin);
            var numPoints = NumPoints.Read(reader, origin);

            var pointStartIndices = new List <int>();

            for (var i = 0; i < numParts; i++)
            {
                var pointStartIndex = Part(i).Read(reader, origin);

                pointStartIndices.Add(pointStartIndex);
            }

            var parts        = new List <IMultiPointGeometry <IPointM> >();
            var pointsOffset = OffsetPoints(numParts);

            for (var i = 0; i < pointStartIndices.Count; i++)
            {
                var startIndex = pointStartIndices[i];
                var endIndex   = (pointStartIndices.Count > (i + 1) ? pointStartIndices[i + 1] : numPoints) - 1;
                var part       = new MultiPointGeometry <IPointM>();

                for (var iPointIndex = startIndex; iPointIndex <= endIndex; iPointIndex++)
                {
                    var point = Point(pointsOffset, numPoints, iPointIndex).Read(reader, origin);
                    part.Points.Add(point);
                }

                parts.Add(part);
            }

            var minM = MinM(pointsOffset, numPoints).Read(reader, origin);
            var maxM = MaxM(pointsOffset, numPoints).Read(reader, origin);

            var boxM = new BoundingBox <IPointM>()
            {
                Min = new PointM()
                {
                    X = box.Min.X,
                    Y = box.Min.Y,
                    M = minM
                },
                Max = new PointM()
                {
                    X = box.Max.X,
                    Y = box.Max.Y,
                    M = maxM
                }
            };

            return(new MultiPartGeometry <IPointM>()
            {
                Box = boxM,
                Parts = parts
            });
        }
Ejemplo n.º 5
0
        public override IMultiPartGeometry <IPoint> Read(BinaryReader reader, WordCount origin)
        {
            var box       = Box.Read(reader, origin);
            var numParts  = NumParts.Read(reader, origin);
            var numPoints = NumPoints.Read(reader, origin);

            var pointStartIndices = new List <int>();

            for (var i = 0; i < numParts; i++)
            {
                var pointStartIndex = Part(i).Read(reader, origin);

                pointStartIndices.Add(pointStartIndex);
            }

            var parts = new List <IMultiPointGeometry <IPoint> >();

            for (var i = 0; i < pointStartIndices.Count; i++)
            {
                var startIndex = pointStartIndices[i];
                var endIndex   = (pointStartIndices.Count > (i + 1) ? pointStartIndices[i + 1] : numPoints) - 1;
                var part       = new MultiPointGeometry <IPoint>();

                for (var iPointIndex = startIndex; iPointIndex <= endIndex; iPointIndex++)
                {
                    var point = Point(numParts, iPointIndex).Read(reader, origin);
                    part.Points.Add(point);
                }

                parts.Add(part);
            }

            return(new MultiPartGeometry <IPoint>()
            {
                Box = box,
                Parts = parts
            });
        }
Ejemplo n.º 6
0
        public override IMultiPatchShape <IPointZ> Read(BinaryReader reader, WordCount origin)
        {
            var box       = Box.Read(reader, origin);
            var numParts  = NumParts.Read(reader, origin);
            var numPoints = NumPoints.Read(reader, origin);

            var pointStartIndices = new List <int>();

            for (var i = 0; i < numParts; i++)
            {
                var pointStartIndex = Part(i).Read(reader, origin);

                pointStartIndices.Add(pointStartIndex);
            }

            var patches      = new List <IPatch <IPointZ> >();
            var pointsOffset = OffsetPoints(numParts);

            for (var i = 0; i < pointStartIndices.Count; i++)
            {
                var startIndex = pointStartIndices[i];
                var endIndex   = (pointStartIndices.Count > (i + 1) ? pointStartIndices[i + 1] : numPoints) - 1;
                var points     = new List <IPointZ>();

                for (var iPointIndex = startIndex; iPointIndex <= endIndex; iPointIndex++)
                {
                    var pointField = Point(pointsOffset, numPoints, iPointIndex);
                    var point      = pointField.Read(reader, origin);
                    points.Add(point);
                }

                var patch = new PatchZ();

                patch.PatchType = PartType(numParts, i).Read(reader, origin);
                patch.Points    = points;

                patches.Add(patch);
            }

            var minZ = MinZ(pointsOffset, numPoints).Read(reader, origin);
            var maxZ = MaxZ(pointsOffset, numPoints).Read(reader, origin);

            var minM = MinM(pointsOffset, numPoints).Read(reader, origin);
            var maxM = MaxM(pointsOffset, numPoints).Read(reader, origin);

            var boxZ = new BoundingBox <IPointZ>()
            {
                Min = new PointZ()
                {
                    X = box.Min.X,
                    Y = box.Min.Y,
                    Z = minZ,
                    M = minM
                },
                Max = new PointZ()
                {
                    X = box.Max.X,
                    Y = box.Max.Y,
                    Z = maxZ,
                    M = maxM
                }
            };

            return(new MultiPatchShape()
            {
                Box = boxZ,
                Patches = patches
            });
        }
        private void LoadShape(BinaryReader f, DataTable Table, Map Series, string fieldName, string fieldValue, int count)
        {
            Polygon   tmpShape;
            const int MaxNumParts = 10000;

            double[] Box = new double[4];
            int      NumParts, NumPoints;

            int[]  Parts = new int[MaxNumParts - 1];
            int    p;
            string tmpText = "";
            double tmpZ    = 0;

            switch (ShapeType)
            {
            case SHP_POLYLINE:
            case SHP_POLYGON:
                Box[0]    = f.ReadDouble();
                Box[1]    = f.ReadDouble();
                Box[2]    = f.ReadDouble();
                Box[3]    = f.ReadDouble();
                NumParts  = f.ReadInt32();
                NumPoints = f.ReadInt32();

                if (debug != null)
                {
                    AddDebug("NumParts: " + Convert.ToString(NumParts) + " NumPoints: " + Convert.ToString(NumPoints));
                }

                if (NumParts > MaxNumParts)
                {
                    throw new Exception("Maximum number of parts exceeded: " + NumParts.ToString());
                }

                for (p = 0; p < NumParts; ++p)
                {
                    Parts[p] = f.ReadInt32();
                    if (debug != null)
                    {
                        AddDebug(Convert.ToString(Parts[p]));
                    }
                }

                if (Table != null)
                {
                    DataRow row = Table.Rows[count];
                    tmpText = Convert.ToString(row[fieldName]);

                    if (fieldValue != "")
                    {
                        tmpZ = Convert.ToDouble(row[fieldValue]);
                    }
                    else
                    {
                        tmpZ = rnd.NextDouble() * SHPMaxRandom;
                    }
                }
                else
                {
                    tmpText = "";
                    tmpZ    = rnd.NextDouble() * SHPMaxRandom;
                }

                po = 0;

                for (p = 1; p <= NumParts; ++p)
                {
                    Series.Add(0, 0, "");

                    int i = Series.Count - 1;

                    tmpShape = Series.Shapes[i];

                    if (p == NumParts)
                    {
                        ReadPoints(f, ref tmpShape, NumPoints);
                    }
                    else
                    {
                        ReadPoints(f, ref tmpShape, Parts[p]);
                    }

                    Series.Shapes[i].Closed = ShapeType == SHP_POLYGON;
                    Series.Shapes[i].Z      = tmpZ;
                    Series.Shapes[i].Text   = tmpText;
                }
                break;

            default:
                throw new Exception("Invalid ShapeType " + ShapeType.ToString());
            }
        }