Example #1
0
        internal EsriPolylineM(IRI.Msh.Common.Primitives.BoundingBox boundingBox, int[] parts, EsriPoint[] points, double minMeasure, double maxMeasure, double[] measures)
        {
            if (points == null || points.Length != measures.Length)
            {
                throw new NotImplementedException();
            }

            if (points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = points.First().Srid;
            }

            this.boundingBox = boundingBox;

            this.parts = parts;

            this.points = points;

            this.minMeasure = minMeasure;

            this.maxMeasure = maxMeasure;

            this.measures = measures;
        }
Example #2
0
        public EsriPolygon(EsriPoint[][] points)
        {
            if (points == null)
            {
                throw new NotImplementedException();
            }

            this.points = points.Where(i => i.Length > 3).SelectMany(i => i).ToArray();

            if (this.points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = this.points.First().Srid;
            }

            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 => BoundingBox.CalculateBoundingBox(i /*.Cast<IRI.Msh.Common.Primitives.IPoint>()*/));

            this.boundingBox = BoundingBox.GetMergedBoundingBox(boundingBoxes);

            //this.boundingBox = IRI.Msh.Common.Infrastructure.CalculateBoundingBox(this.points.Cast<IRI.Msh.Common.Primitives.IPoint>());
        }
        public EsriMultiPointZ(EsriPointZ[] points)
        {
            if (points == null || points.Length < 1)
            {
                throw new NotImplementedException();
            }

            this.boundingBox = IRI.Msh.Common.Primitives.BoundingBox.CalculateBoundingBox(points /*.Cast<IRI.Msh.Common.Primitives.IPoint>()*/);

            this.Srid = points.First().Srid;

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

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

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

            this.minMeasure = points[0].Measure;

            this.maxMeasure = points[0].Measure;

            this.minZ = points[0].Z;

            this.maxZ = points[0].Z;

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

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

                this.zValues[i] = points[i].Z;

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

                if (this.maxMeasure < points[i].Measure)
                {
                    this.maxMeasure = points[i].Measure;
                }

                if (this.minZ > points[i].Z)
                {
                    this.minZ = points[i].Z;
                }

                if (this.minZ < points[i].Z)
                {
                    this.minZ = points[i].Z;
                }
            }
        }
        public EsriPolylineZ(EsriPoint[] points, int[] parts, double[] zValues, double[] measures)
        {
            if (points == null || points.Length != zValues?.Length || points.Length != measures?.Length)
            {
                throw new NotImplementedException();
            }

            if (points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = points.First().Srid;
            }

            this.boundingBox = IRI.Msh.Common.Primitives.BoundingBox.CalculateBoundingBox(points /*.Cast<IRI.Msh.Common.Primitives.IPoint>()*/);

            this.parts = parts;

            this.points = points;

            this.measures = measures;

            this.zValues = zValues;

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

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

                this.maxMeasure = ShapeConstants.NoDataValue;
            }

            if (zValues?.Count() > 0)
            {
                this.minZ = zValues.Min();

                this.maxZ = zValues.Max();
            }
            else
            {
                this.minZ = ShapeConstants.NoDataValue;

                this.maxZ = ShapeConstants.NoDataValue;
            }
        }
Example #5
0
        internal EsriMultiPoint(IRI.Msh.Common.Primitives.BoundingBox boundingBox, EsriPoint[] points)
        {
            if (points == null || points.Length < 1)
            {
                throw new NotImplementedException();
            }

            this.boundingBox = boundingBox;

            this.points = points;

            this.Srid = points.First().Srid;
        }
Example #6
0
        public BalancedKdTreeNode(T point, Trees.NodeColor color)
        {
            this.Point = point;

            this.Color = color;

            this.LeftChild  = BalancedKdTree <T> .NilNode;
            this.RightChild = BalancedKdTree <T> .NilNode;

            var pointValue = BalancedKdTree <T> .PointFunc(point);

            this.MinimumBoundingBox = new BoundingBox(pointValue.X, pointValue.Y, pointValue.X, pointValue.Y);
        }
Example #7
0
        public static async Task <IEsriShapeCollection> Read(string shpFileName, IRI.Msh.Common.Primitives.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));

            int srid = TryGetSrid(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 EsriShapeType.EsriPoint:
                    case EsriShapeType.EsriPointZ:
                    case EsriShapeType.EsriPointM:
                        return(ExtractPoints(shpReader, shxFile, filtered, srid));

                    case EsriShapeType.EsriMultiPoint:
                    case EsriShapeType.EsriMultiPointZ:
                    case EsriShapeType.EsriMultiPointM:
                        return(ExtractMultiPoints(shpReader, shxFile, filtered, srid));

                    case EsriShapeType.EsriPolyLine:
                    case EsriShapeType.EsriPolyLineZ:
                    case EsriShapeType.EsriPolyLineM:
                        return(ExtractPolyLines(shpReader, shxFile, filtered, srid));

                    case EsriShapeType.EsriPolygon:
                    case EsriShapeType.EsriPolygonZ:
                    case EsriShapeType.EsriPolygonM:
                        return(ExtractPolygons(shpReader, shxFile, filtered, srid));

                    case EsriShapeType.NullShape:
                    case EsriShapeType.EsriMultiPatch:
                    default:
                        throw new NotImplementedException();
                    }
                }
            }
        }
Example #8
0
        public EsriMultiPoint(EsriPoint[] points)
        {
            if (points == null)
            {
                throw new NotImplementedException();
            }

            if (points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = points.First().Srid;
            }

            this.boundingBox = IRI.Msh.Common.Primitives.BoundingBox.CalculateBoundingBox(points /*.Cast<IRI.Msh.Common.Primitives.IPoint>()*/);

            this.points = points;
        }
        internal EsriPolyline(IRI.Msh.Common.Primitives.BoundingBox boundingBox, int[] parts, EsriPoint[] points)
        {
            if (points == null)
            {
                throw new NotImplementedException();
            }

            if (points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = points.First().Srid;
            }

            this.boundingBox = boundingBox;

            this.parts = parts;

            this.points = points;
        }
        internal EsriMultiPointZ(IRI.Msh.Common.Primitives.BoundingBox boundingBox,
                                 EsriPoint[] points,
                                 double minZ,
                                 double maxZ,
                                 double[] zValues,
                                 double minMeasure,
                                 double maxMeasure,
                                 double[] measures)
        {
            if (points == null || points.Length != zValues?.Length || points.Length != measures?.Length)
            {
                throw new NotImplementedException();
            }

            if (points.Length == 0)
            {
                this.Srid = 0;
            }
            else
            {
                this.Srid = points.First().Srid;
            }

            this.boundingBox = boundingBox;

            this.points = points;

            this.minZ = minZ;

            this.maxZ = maxZ;

            this.zValues = zValues;

            this.minMeasure = minMeasure;

            this.maxMeasure = maxMeasure;

            this.measures = measures;
        }
Example #11
0
        public Path AsBitmapUsingGdiPlus(List <SqlFeature> features, List <string> labels, double mapScale, sb.BoundingBox boundingBox, double width, double height, Func <Point, Point> mapToScreen, RectangleGeometry area)
        {
            if (features == null)
            {
                return(null);
            }

            //var borderBrush = this.VisualParameters.Stroke.AsGdiBrush();

            //var pen = this.VisualParameters.GetGdiPlusPen();

            //var image = SqlSpatialToGdiBitmap.ParseSqlGeometry(
            //    geometries,
            //    width,
            //    height,
            //    mapToScreen,
            //    pen,
            //    this.VisualParameters.Fill.AsGdiBrush(),
            //    this.VisualParameters.PointSymbol);
            var image = SqlFeatureToGdiBitmap.ParseSqlGeometry(
                features,
                width,
                height,
                mapToScreen,
                this.SymbologyRule);


            if (image == null)
            {
                return(null);
            }

            //if (labels != null)
            //{
            //    SqlSpatialToGdiBitmap.DrawLabels(labels, geometries, image, mapToScreen, this.Labels);
            //}

            BitmapImage bitmapImage = Helpers.ImageUtility.AsBitmapImage(image, System.Drawing.Imaging.ImageFormat.Png);

            image.Dispose();

            Path path = new Path()
            {
                Data = area,
                Tag  = new Model.LayerTag(mapScale)
                {
                    Layer = this, Tile = null, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);

            bitmapImage.Freeze();

            return(path);
        }