示例#1
0
        private double InflateMap2DShapeInBoundaryRectCenter(List <Map2DModel> map2DModelList, Rect rect)
        {
            Point centerPoint = FeaturePointHelper.GetRectCenter(ref rect);

            double zoomFactor = 1000 / Math.Max(rect.Width, rect.Height * 1.78);

            for (int i = 0; i < map2DModelList.Count; i++)
            {
                Map2DModel map2D = map2DModelList[i];
                for (int k = map2D.GeometryPointList.Count - 1; k >= 0; k--)
                {
                    List <Point> pointList = map2D.GeometryPointList[k];
                    for (int j = 0; j < pointList.Count; j++)
                    {
                        Point point = pointList[j];
                        point.X = (point.X - centerPoint.X) * zoomFactor;
                        point.Y = (point.Y - centerPoint.Y) * zoomFactor;

                        pointList[j] = point;
                    }

                    if (pointList.Count < 3)
                    {
                        map2D.GeometryPointList.RemoveAt(k);
                    }
                }
            }

            return(zoomFactor);
        }
示例#2
0
        private List <Map2DModel> ParseMap2DDataFromLatLngString(string latLngStr)
        {
            List <Map2DModel>    map2DModelList = new List <Map2DModel>();
            List <List <Point> > pointListList  = new List <List <Point> >();

            string[] featurePointStrings = latLngStr.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (featurePointStrings != null)
            {
                List <Point> pointList = new List <Point>();
                pointListList.Add(pointList);
                foreach (string lngLatStr in featurePointStrings)
                {
                    string[] lngLatStrArray = lngLatStr.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
                    if (lngLatStrArray == null || lngLatStrArray.Length != 2)
                    {
                        continue;
                    }
                    Point point = new Point()
                    {
                        X = double.Parse(lngLatStrArray[0]), Y = double.Parse(lngLatStrArray[1])
                    };
                    pointList.Add(point);
                }
            }

            Map2DModel map2DModel = MapDataConvertHelper.LngLatPointListToMap2DModel(pointListList);

            map2DModelList.Add(map2DModel);

            return(map2DModelList);
        }
示例#3
0
        public static Map2DModel GeoJsonFeaureToMap2DModel(GeoJsonFeature <GeoJsonGeometry> feature, List <double> minMaxLatLong)
        {
            double longLenth = minMaxLatLong[1] - minMaxLatLong[0];
            double latLength = minMaxLatLong[3] - minMaxLatLong[2];

            Map2DModel map2D = new Map2DModel(); map2D.Id = feature.Id;

            map2D.Name            = feature.Properties == null ? "" : feature.Properties.Name;
            map2D.CapitalLocation = feature.Properties == null ? default(Point) : feature.Properties.CapitalLocationPoint;

            map2D.MinLongitude = minMaxLatLong[0];
            map2D.MaxLongitude = minMaxLatLong[1];
            map2D.MinLatitude  = minMaxLatLong[2];
            map2D.MaxLatitude  = minMaxLatLong[3];

            List <List <Point> > areaList = new List <List <Point> >();

            foreach (List <Point> area in feature.Geometry.PointList)
            {
                List <Point> pointList = new List <Point>();
                areaList.Add(pointList);

                foreach (Point point in area)
                {
                    Point newPoint = LongLatPointToNormalPoint(minMaxLatLong, point);

                    pointList.Add(newPoint);
                }
            }

            map2D.GeometryPointList = areaList;
            return(map2D);
        }
示例#4
0
        public static Map2DModel LngLatPointListToMap2DModel(List <List <Point> > lngLatPointList)
        {
            List <double> minMaxLatLong = GetMinMaxLongLat(lngLatPointList);

            double longLenth = minMaxLatLong[1] - minMaxLatLong[0];
            double latLength = minMaxLatLong[3] - minMaxLatLong[2];

            Map2DModel map2D = new Map2DModel();

            map2D.Id           = "1";
            map2D.MinLongitude = minMaxLatLong[0];
            map2D.MaxLongitude = minMaxLatLong[1];
            map2D.MinLatitude  = minMaxLatLong[2];
            map2D.MaxLatitude  = minMaxLatLong[3];

            List <List <Point> > areaList = new List <List <Point> >();

            foreach (List <Point> area in lngLatPointList)
            {
                List <Point> pointList = new List <Point>();
                areaList.Add(pointList);

                foreach (Point point in area)
                {
                    Point newPoint = LongLatPointToNormalPoint(minMaxLatLong, point);

                    pointList.Add(newPoint);
                }
            }

            map2D.GeometryPointList = areaList;
            return(map2D);
        }
示例#5
0
        private static Rect GetBoundaryRectOfMap2D(Map2DModel map2D)
        {
            List <Point> allFeaturePoints = new List <Point>();

            foreach (List <Point> map2DPathFeaturePoints in map2D.GeometryPointList)
            {
                allFeaturePoints.AddRange(map2DPathFeaturePoints);
            }
            Rect rect = FeaturePointHelper.GetFeaturePointsBoundaryRect(allFeaturePoints);

            return(rect);
        }
示例#6
0
        public static Map3DModel Map2DTo3DModel(Map2DModel map2D, double upperZValue, double lowerZValue)
        {
            Map3DModel map3D = new Map3DModel();

            map3D.Id   = map2D.Id;
            map3D.Name = map2D.Name;

            map3D.MinLongitude = map2D.MinLongitude;
            map3D.MaxLongitude = map2D.MaxLongitude;
            map3D.MinLatitude  = map2D.MinLatitude;
            map3D.MaxLatitude  = map2D.MaxLatitude;

            List <CylinderVisual3DModel> cylinderVisual3DModelList = new List <CylinderVisual3DModel>();

            map3D.Geometries = cylinderVisual3DModelList;

            Rect rect = GetBoundaryRectOfMap2D(map2D);

            foreach (List <Point> map2DPathFeaturePoints in map2D.GeometryPointList)
            {
                List <Point> cleanPointList = CleanPointList(map2DPathFeaturePoints);
                //CylinderVisual3DModel cylinderVisual3DModel = Visual2DTo3DHelper.Closed2DAreaToCylinderVisual3DModel(cleanPointList, upperZValue, lowerZValue);
                CylinderVisual3DModel cylinderVisual3DModel = Visual2DTo3DHelper.Closed2DAreaToCylinderVisual3DModel(cleanPointList, upperZValue, lowerZValue, rect);
                if (cylinderVisual3DModel != null)
                {
                    cylinderVisual3DModelList.Add(cylinderVisual3DModel);
                }
            }

            map3D.Materials = new List <List <Material3DModel> >();
            for (int i = 0; i < map2D.GeometryPointList.Count; i++)
            {
                List <Material3DModel> materialList = new List <Material3DModel>()
                {
                    new Material3DModel()
                    {
                        MaterialType = MaterialType.ColorDiffuse, MaterialData = Color.FromArgb(0x99, 0x00, 0xff, 0xff)
                    },
                    new Material3DModel()
                    {
                        MaterialType = MaterialType.ColorDiffuse, MaterialData = Color.FromArgb(0x99, 0x00, 0xff, 0xff)
                    },
                    new Material3DModel()
                    {
                        MaterialType = MaterialType.ColorDiffuse, MaterialData = Color.FromArgb(0xff, 0x48, 0x3d, 0x88)
                    }
                };

                map3D.Materials.Add(materialList);
            }

            return(map3D);
        }
示例#7
0
        public static List <Map2DModel> GeoJsonModelToMap2DList(GeoJson <GeoJsonGeometry> geoJsonModel)
        {
            List <double> minMaxLongLatList = GetMinMaxLongLatFromGeoJson(geoJsonModel);

            List <Map2DModel> map2DList = new List <Map2DModel>();

            foreach (GeoJsonFeature <GeoJsonGeometry> feature in geoJsonModel.Features)
            {
                Map2DModel map2D = GeoJsonFeaureToMap2DModel(feature, minMaxLongLatList);


                map2DList.Add(map2D);
            }

            return(map2DList);
        }