Beispiel #1
0
        protected override MultiPointZ ReadElement()
        {
            int shapeType = shpReader.ReadInt32();

            if ((ShapeType)shapeType != ShapeType.MultiPointZ)
            {
                throw new NotImplementedException();
            }

            IRI.Ham.SpatialBase.BoundingBox boundingBox = this.ReadBoundingBox();

            int numPoints = shpReader.ReadInt32();

            EsriPoint[] points = this.ReadPoints(numPoints);

            double minZ, maxZ;

            double[] zValues;

            this.ReadZValues(numPoints, out minZ, out maxZ, out zValues);

            double minMeasure = ShapeConstants.NoDataValue, maxMeasure = ShapeConstants.NoDataValue;

            double[] measures = new double[numPoints];

            if (shpReader.BaseStream.Position != shpReader.BaseStream.Length)
            {
                this.ReadMeasures(numPoints, out minMeasure, out maxMeasure, out measures);
            }

            return(new MultiPointZ(boundingBox, points, minZ, maxZ, zValues, minMeasure, maxMeasure, measures));
        }
Beispiel #2
0
        public PolyLineZ(IRI.Ham.SpatialBase.BoundingBox boundingBox,
                         int[] parts,
                         EsriPoint[] points,
                         double minZ,
                         double maxZ,
                         double[] zValues,
                         double minMeasure,
                         double maxMeasure,
                         double[] measures)
        {
            this.boundingBox = boundingBox;

            this.parts = parts;

            this.points = points;

            this.minZ = minZ;

            this.maxZ = maxZ;

            this.zValues = zValues;

            this.minMeasure = minMeasure;

            this.maxMeasure = maxMeasure;

            this.measures = measures;
        }
Beispiel #3
0
        public PolyLineM(EsriPoint[] points, int[] parts, double[] measures)
        {
            if (points.Length != measures.Length)
            {
                throw new NotImplementedException();
            }

            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(points.Cast <IRI.Ham.SpatialBase.IPoint>());

            this.parts = parts;

            this.points = points;

            this.measures = measures;

            if (measures?.Count() > 0)
            {
                this.minMeasure = measures.Min();

                this.maxMeasure = measures.Max();
            }
            else
            {
                this.minMeasure = ShapeConstants.NoDataValue;

                this.maxMeasure = ShapeConstants.NoDataValue;
            }
        }
Beispiel #4
0
        internal MultiPointZ(IRI.Ham.SpatialBase.BoundingBox boundingBox,
                             EsriPoint[] points,
                             double minZ,
                             double maxZ,
                             double[] zValues,
                             double minMeasure,
                             double maxMeasure,
                             double[] measures)
        {
            this.boundingBox = boundingBox;

            this.points = points;

            this.minZ = minZ;

            this.maxZ = maxZ;

            this.zValues = zValues;

            this.minMeasure = minMeasure;

            this.maxMeasure = maxMeasure;

            this.measures = measures;
        }
Beispiel #5
0
        public MultiPointM(EsriPointM[] points)
        {
            //this.boundingBox = new IRI.Ham.SpatialBase.BoundingBox(xMin: MapStatistics.GetMinX(points),
            //                                    yMin: MapStatistics.GetMinY(points),
            //                                    xMax: MapStatistics.GetMaxX(points),
            //                                    yMax: MapStatistics.GetMaxY(points));
            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(points.Cast <IRI.Ham.SpatialBase.IPoint>());


            this.points = new EsriPoint[points.Length];

            this.measures = new double[points.Length];

            this.minMeasure = points[0].Measure;

            this.maxMeasure = points[0].Measure;

            for (int i = 0; i < points.Length; i++)
            {
                this.points[i] = new EsriPoint(points[i].X, points[i].Y);

                this.measures[i] = points[i].Measure;

                if (this.minMeasure > points[i].Measure)
                {
                    this.minMeasure = points[i].Measure;
                }

                if (this.maxMeasure < points[i].Measure)
                {
                    this.maxMeasure = points[i].Measure;
                }
            }
        }
Beispiel #6
0
        protected override PolyLine ReadElement()
        {
            int shapeType = shpReader.ReadInt32();

            if ((ShapeType)shapeType != ShapeType.PolyLine)
            {
                throw new NotImplementedException();
            }

            IRI.Ham.SpatialBase.BoundingBox boundingBox = this.ReadBoundingBox();

            int numParts = shpReader.ReadInt32();

            int numPoints = shpReader.ReadInt32();

            int[] parts = new int[numParts];

            for (int i = 0; i < numParts; i++)
            {
                parts[i] = shpReader.ReadInt32();
            }

            EsriPoint[] points = this.ReadPoints(numPoints);

            return(new PolyLine(boundingBox, parts, points));
        }
Beispiel #7
0
        protected override PolygonM ReadElement()
        {
            int shapeType = shpReader.ReadInt32();

            if ((ShapeType)this.MainHeader.ShapeType != ShapeType.PolygonM)
            {
                throw new NotImplementedException();
            }

            IRI.Ham.SpatialBase.BoundingBox boundingBox = this.ReadBoundingBox();

            int numParts = shpReader.ReadInt32();

            int numPoints = shpReader.ReadInt32();

            int[] parts = new int[numParts];

            for (int i = 0; i < numParts; i++)
            {
                parts[i] = shpReader.ReadInt32();
            }

            EsriPoint[] points = this.ReadPoints(numPoints);

            double minMeasure, maxMeasure;

            double[] measures;

            this.ReadMeasures(numPoints, out minMeasure, out maxMeasure, out measures);

            return(new PolygonM(boundingBox, parts, points, minMeasure, maxMeasure, measures));
        }
Beispiel #8
0
        internal PolyLine(IRI.Ham.SpatialBase.BoundingBox boundingBox, int[] parts, EsriPoint[] points)
        {
            this.boundingBox = boundingBox;

            this.parts = parts;

            this.points = points;
        }
Beispiel #9
0
        public PolyLine(EsriPoint[] points, int[] parts)
        {
            //this.boundingBox = new IRI.Ham.SpatialBase.BoundingBox(xMin: MapStatistics.GetMinX(points),
            //                                 yMin: MapStatistics.GetMinY(points),
            //                                 xMax: MapStatistics.GetMaxX(points),
            //                                 yMax: MapStatistics.GetMaxY(points));
            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(points.Cast <IRI.Ham.SpatialBase.IPoint>());

            this.points = points;

            this.parts = parts;
        }
Beispiel #10
0
        public Polygon(EsriPoint[] points, int[] parts)
        {
            //this.boundingBox = new IRI.Ham.SpatialBase.BoundingBox(
            //                                    xMin: points.Min(i => i.X),
            //                                    yMin: points.Min(i => i.Y),
            //                                    xMax: points.Max(i => i.X),
            //                                    yMax: points.Max(i => i.Y));
            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(points.Cast <IRI.Ham.SpatialBase.IPoint>());

            this.parts = parts;

            this.points = points;
        }
Beispiel #11
0
        internal PolyLineM(IRI.Ham.SpatialBase.BoundingBox boundingBox, int[] parts, EsriPoint[] points, double minMeasure, double maxMeasure, double[] measures)
        {
            this.boundingBox = boundingBox;

            this.parts = parts;

            this.points = points;

            this.minMeasure = minMeasure;

            this.maxMeasure = maxMeasure;

            this.measures = measures;
        }
Beispiel #12
0
        public static async Task <IShapeCollection> Read(string shpFileName, IRI.Ham.SpatialBase.BoundingBox boundingBox)
        {
            var indexFileName = GetIndexFileName(shpFileName);

            if (!CheckAllNeededFilesExists(shpFileName) || !System.IO.File.Exists(indexFileName))
            {
                throw new NotImplementedException();
            }

            var shpIndexes = await Indexing.IndexIO.Read(indexFileName);

            var filtered = shpIndexes.Where(i => i.MinimumBoundingBox.Intersects(boundingBox)).ToList();

            var shxFile = new ShxReader(GetShxFileName(shpFileName));

            using (System.IO.FileStream shpStream = new System.IO.FileStream(shpFileName, System.IO.FileMode.Open))
            {
                using (var shpReader = new System.IO.BinaryReader(shpStream))
                {
                    switch (shxFile.MainHeader.ShapeType)
                    {
                    case ShapeType.Point:
                    case ShapeType.PointZ:
                    case ShapeType.PointM:
                        return(ExtractPoints(shpReader, shxFile, filtered));

                    case ShapeType.MultiPoint:
                    case ShapeType.MultiPointZ:
                    case ShapeType.MultiPointM:
                        return(ExtractMultiPoints(shpReader, shxFile, filtered));

                    case ShapeType.PolyLine:
                    case ShapeType.PolyLineZ:
                    case ShapeType.PolyLineM:
                        return(ExtractPolyLines(shpReader, shxFile, filtered));

                    case ShapeType.Polygon:
                    case ShapeType.PolygonZ:
                    case ShapeType.PolygonM:
                        return(ExtractPolygons(shpReader, shxFile, filtered));

                    case ShapeType.NullShape:
                    case ShapeType.MultiPatch:
                    default:
                        throw new NotImplementedException();
                    }
                }
            }
        }
Beispiel #13
0
        public PolyLine(EsriPoint[][] points)
        {
            this.points = points.Where(i => i.Length > 1).SelectMany(i => i).ToArray();

            this.parts = new int[points.Length];

            for (int i = 1; i < points.Length; i++)
            {
                parts[i] = points.Where((array, index) => index < i).Sum(array => array.Length);
            }

            var boundingBoxes = points.Select(i => IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(i.Cast <IRI.Ham.SpatialBase.IPoint>()));

            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.GetMergedBoundingBox(boundingBoxes);
        }
        protected override MultiPoint ReadElement()
        {
            int shapeType = shpReader.ReadInt32();

            if ((ShapeType)shapeType != ShapeType.MultiPoint)
            {
                throw new NotImplementedException();
            }

            IRI.Ham.SpatialBase.BoundingBox boundingBox = this.ReadBoundingBox();

            int numPoints = shpReader.ReadInt32();

            EsriPoint[] points = this.ReadPoints(numPoints);

            return(new MultiPoint(boundingBox, points));
        }
Beispiel #15
0
        protected override MultiPointM ReadElement()
        {
            int shapeType = shpReader.ReadInt32();

            if ((ShapeType)shapeType != ShapeType.MultiPointM)
            {
                throw new NotImplementedException();
            }

            IRI.Ham.SpatialBase.BoundingBox boundingBox = this.ReadBoundingBox();

            int numPoints = shpReader.ReadInt32();

            EsriPoint[] points = this.ReadPoints(numPoints);

            double minMeasure, maxMeasure;

            double[] measures;

            this.ReadMeasures(numPoints, out minMeasure, out maxMeasure, out measures);

            return(new MultiPointM(boundingBox, points, minMeasure, maxMeasure, measures));
        }
Beispiel #16
0
        internal MainFileHeader(int fileLength, ShapeType type, IRI.Ham.SpatialBase.BoundingBox minimumnBoundingBox)
        {
            this.m_Version = 9994;

            this.m_FileLength = fileLength;

            this.m_ShapeType = (int)type;

            this.m_XMin = minimumnBoundingBox.XMin;

            this.m_YMin = minimumnBoundingBox.YMin;

            this.m_XMax = minimumnBoundingBox.XMax;

            this.m_YMax = minimumnBoundingBox.YMax;

            this.m_ZMax = 0;

            this.m_ZMin = 0;

            this.m_MMax = 0;

            this.m_MMin = 0;
        }