public unsafe Bitmap Draw(GeoCalcBound bound, List<GeoRasterStyle> styles, int transparency, GeoTransformation transfor, HeightStyle heightStyle) { Bitmap bitmap; int key = this.DrawContextGetHashCode(bound, styles, transparency, heightStyle); if (!this.m_Cache.TryGetBitmap(key, out bitmap)) { bitmap = new Bitmap(bound.RectColumns, bound.RectRows, PixelFormat.Format8bppIndexed); this.SetPalette(bitmap, styles, transparency, heightStyle); short[] valueByCalcBound = this.m_HeightData.GetValueByCalcBound<short>(bound, true); Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat); byte* numPtr = (byte*) bitmapdata.Scan0.ToPointer(); int num2 = bitmapdata.Stride - bitmap.Width; List<MaxMinValue> heightIntervals = this.GetHeightIntervals(styles); for (int i = 0; i < bound.RectRows; i++) { for (int j = 0; j < bound.RectColumns; j++) { short heightValue = valueByCalcBound[(bound.RectColumns * i) + j]; numPtr++; numPtr[0] = (byte) ColorArray<short>.GetHeightIndexOfPalette(heightIntervals, heightValue, heightStyle); } numPtr += num2; } bitmap.UnlockBits(bitmapdata); this.GrayBitmap(bitmap, styles, heightStyle); this.m_Cache.UpdateCache(key, bitmap); } return bitmap; }
public override LayerImagePara GetImage(GeoXYRect bound, Rectangle clientRect, GeoTransformation trans) { if (this.m_Transparency == 0) { return null; } GeoXYRect joinGeoXYRect = this.m_RasterData.Bound.GetJoinGeoXYRect(bound); if (joinGeoXYRect == null) { return null; } System.Drawing.Point bmpLocation = trans.PlaneToScreen(joinGeoXYRect.Left, joinGeoXYRect.Top); bmpLocation.X -= clientRect.X; bmpLocation.Y -= clientRect.Y; int num = trans.PlaneDistanceToScreenDistance(joinGeoXYRect.Right - joinGeoXYRect.Left); int num2 = trans.PlaneDistanceToScreenDistance(joinGeoXYRect.Top - joinGeoXYRect.Bottom); if ((num < 1) || (num2 < 1)) { return null; } GeoCalcBound bound2 = new GeoCalcBound(joinGeoXYRect, 1.0 / trans.TempValue); Bitmap bitmap = this.m_Render.Draw(bound2, this.m_Styles, this.m_Transparency, trans, this.m_HeightRenderStyle); this.m_LayerImage = (Bitmap) bitmap.Clone(); return new LayerImagePara(bmpLocation, bitmap); }
private int DrawContextGetHashCode(GeoCalcBound bound, List<GeoRasterStyle> styles, int transparency, HeightStyle heightStyle) { int num = (bound.GetHashCode() ^ transparency) ^ heightStyle.GetHashCode(); foreach (GeoRasterStyle style in styles) { num ^= style.GetHashCode(); } return num; }
private short BoundParaCheck(int indexOfRect, GeoCalcBound geoCalcBound, DemDataType demDataType, int layerIndex, ref bool flag) { flag = this.CheckBoundIndex(indexOfRect, geoCalcBound, demDataType, layerIndex); if (flag) { return -32768; } if (this.GetRasterData(demDataType).Count == 0) { flag = true; return 0; } flag = false; return 0; }
private GeoInfo() { this.m_CurrentReadStyle = ReadStyle.ClosestResolution; this.m_ClutterlayerIndex = 0; this.m_geoClutterCalcBound = null; this.m_HeightlayerIndex = 0; this.m_geoHeightCalcBound = null; this.m_BuildinglayerIndex = 0; this.m_geoBuildingCalcBound = null; this.pointThreadTag = new object(); this.lineThreadTag = new object(); this.boundThreadTag = new object(); this.m_IsGeoXYLinePointCalc = false; this.m_ClutterIDInLine = null; this.m_PointListOfClutterID = null; }
private void CalcOneLineXDatas(GeoCalcBound geoCalcBound, double tempX, double tempY, GeoPolygonRegion polygonRegion, short[] valueArray) { for (int i = 0; i < geoCalcBound.RectColumns; i++) { tempX = geoCalcBound.Left + (geoCalcBound.CalcWidth * i); if (this.m_CaculateFullMap || polygonRegion.IsPointInRegion(new GeoXYPoint(tempX, tempY))) { int indexOffsetIsCalcWidthMulti = geoCalcBound.GetIndexOffsetIsCalcWidthMulti(tempX, tempY); short key = valueArray[indexOffsetIsCalcWidthMulti]; if (this.m_ClutterIDCountDict.ContainsKey(key)) { Dictionary<short, int> dictionary; short num4; (dictionary = this.m_ClutterIDCountDict)[num4 = key] = dictionary[num4] + 1; } } } }
public GeoInfo(IGeoDataMgr IGeoDataMgr) { this.m_CurrentReadStyle = ReadStyle.ClosestResolution; this.m_ClutterlayerIndex = 0; this.m_geoClutterCalcBound = null; this.m_HeightlayerIndex = 0; this.m_geoHeightCalcBound = null; this.m_BuildinglayerIndex = 0; this.m_geoBuildingCalcBound = null; this.pointThreadTag = new object(); this.lineThreadTag = new object(); this.boundThreadTag = new object(); this.m_IsGeoXYLinePointCalc = false; this.m_ClutterIDInLine = null; this.m_PointListOfClutterID = null; this.m_GeoDataMgr = IGeoDataMgr; this.m_DemDataColletion = new Dictionary<DemDataType, List<IGeoRasterData>>(); this.m_DemDataColletion.Add(DemDataType.Clutter, this.m_GeoDataMgr.ClutterRasterData); this.m_DemDataColletion.Add(DemDataType.Height, this.m_GeoDataMgr.HeightRasterData); this.m_DemDataColletion.Add(DemDataType.Building, this.m_GeoDataMgr.BuildingRasterData); this.InitGetValueByPointDelegate(); }
public Dictionary<GeoXYPoint, short> GetGeoNodeByGeoCalcBound(GeoCalcBound geoCalcBound) { short valueByGeoXYPoint = -32768; double x = 0.0; double y = 0.0; Dictionary<GeoXYPoint, short> dictionary = new Dictionary<GeoXYPoint, short>(); x = geoCalcBound.Left; y = geoCalcBound.Top; int rectRows = geoCalcBound.RectRows; int rectColumns = geoCalcBound.RectColumns; for (int i = 0; i < rectRows; i++) { x = geoCalcBound.Left; y = geoCalcBound.Top - (i * geoCalcBound.CalcWidth); for (int j = 0; j < rectColumns; j++) { x = geoCalcBound.Left + (geoCalcBound.CalcWidth * j); valueByGeoXYPoint = this.GetValueByGeoXYPoint(x, y); dictionary.Add(new GeoXYPoint(x, y), valueByGeoXYPoint); } } return dictionary; }
private short GetValueByPoint(int indexInRect, GeoCalcBound geoCalcBound, DemDataType demDataType, int layerIndex) { if (this.m_GetValueByPointDelegateDict.ContainsKey(demDataType)) { return this.m_GetValueByPointDelegateDict[demDataType](indexInRect, geoCalcBound, demDataType, layerIndex); } return 0; }
public short[] GetValueByGeoCalcBound(GeoCalcBound geoCalcBound, DemDataType demDataType) { short[] numArray; try { bool flag = false; short[] numArray2 = this.DemDataTypeCheckByGeoCalcBound(geoCalcBound, demDataType, ref flag); if (flag) { return numArray2; } List<short> list = this.RunReadGridThread(geoCalcBound, demDataType); if (list.Count == 0) { int num = geoCalcBound.RectColumns * geoCalcBound.RectRows; for (int i = 0; i < num; i++) { list.Add(-32768); } } return list.ToArray(); } catch { int rectRows = geoCalcBound.RectRows; int rectColumns = geoCalcBound.RectColumns; numArray = new short[rectRows * rectColumns]; } return numArray; }
private short GetHeightByRectBoundAssist(int indexInRect, GeoCalcBound geoCalcBound, DemDataType demDataType, int layerIndex) { if ((!geoCalcBound.Equals(this.m_geoHeightCalcBound) || (this.m_HeightlayerIndex != layerIndex)) || (this.m_HeightValueArray == null)) { this.m_HeightlayerIndex = layerIndex; this.m_geoHeightCalcBound = geoCalcBound; this.m_HeightValueArray = this.GetValueByGeoCalcBound(geoCalcBound, demDataType); } return this.m_HeightValueArray[indexInRect]; }
public List<GeoXYPoint> GetClutterPointDict(GeoPolygonRegion polygonRegion, short clutterID, List<int> clutterIDIndexList, bool isRandomPt) { if (this.GetDemData(DemDataType.Clutter) == null) { return null; } GeoCalcBound geoCalcBound = new GeoCalcBound(polygonRegion.GetMiniEnclosingRect(), this.GetDemData(0)[0].Resolution); return this.GetClutterPointInBound(clutterID, clutterIDIndexList, geoCalcBound, isRandomPt); }
private short[] GetDatas(GeoXYRect geoXYRect, IGeoRasterData rasterData) { if (rasterData == null) { return null; } GeoCalcBound geoCalcBound = new GeoCalcBound(geoXYRect, rasterData.Resolution); return rasterData.GetValueByCalcBound<short>(geoCalcBound); }
private List<short> RunReadGridThread(GeoCalcBound geoCalcBound, DemDataType demDataType) { Dictionary<double, List<short>> gridValueByPointDict = new Dictionary<double, List<short>>(); List<IGeoRasterData> rasterDataList = new List<IGeoRasterData>(); rasterDataList = this.GetRasterData(demDataType); rasterDataList = this.CheckRasterData(rasterDataList, new GeoXYRect(geoCalcBound.Left, geoCalcBound.Right, geoCalcBound.Bottom, geoCalcBound.Top), geoCalcBound.CalcWidth); foreach (IGeoRasterData data in rasterDataList) { this.ReadGridDataByGeoCalcBound(geoCalcBound, data, gridValueByPointDict); } return GetGridData(gridValueByPointDict); }
private short[] GetDatas(Huawei.UNet.GIS.GeoInterface.GeoPolygon geoPolygon, IGeoRasterData geoRasterData) { if (geoRasterData == null) { return null; } GeoXYRect miniEnclosingRect = geoPolygon.GetMiniEnclosingRect(); GeoCalcBound geoCalcBound = new GeoCalcBound(miniEnclosingRect, geoRasterData.Resolution); short[] datas = this.GetDatas(miniEnclosingRect, geoRasterData); if (datas.Length == 0) { return null; } List<short> valueInPolygon = new List<short>(); double tempX = 0.0; double tempY = 0.0; tempX = geoCalcBound.Left; tempY = geoCalcBound.Top; for (int i = 0; i < geoCalcBound.RectRows; i++) { tempX = geoCalcBound.Left; tempY = geoCalcBound.Top - (i * geoCalcBound.CalcWidth); this.GetOneLineXDatas(geoCalcBound, tempX, tempY, geoPolygon, ref datas, ref valueInPolygon); } return valueInPolygon.ToArray(); }
private void GetOneLineXDatas(GeoCalcBound geoCalcBound, double tempX, double tempY, GeoPolygonRegion polygonRegion, ref short[] valueArray, bool isSetPointDict, double random) { if (isSetPointDict) { this.CalcOneLineXDatas(geoCalcBound, tempX, tempY, polygonRegion, valueArray, random); } else { this.CalcOneLineXDatas(geoCalcBound, tempX, tempY, polygonRegion, valueArray); } }
private void GetOneLineXDatas(GeoCalcBound geoCalcBound, double tempX, double tempY, Huawei.UNet.GIS.GeoInterface.GeoPolygon geoPolygon, ref short[] valueArray, ref List<short> valueInPolygon) { for (int i = 0; i < geoCalcBound.RectColumns; i++) { tempX = geoCalcBound.Left + (geoCalcBound.CalcWidth * i); if (geoPolygon.IsPointInPolygon(new GeoXYPoint(tempX, tempY))) { int indexOffsetIsCalcWidthMulti = geoCalcBound.GetIndexOffsetIsCalcWidthMulti(tempX, tempY); short item = valueArray[indexOffsetIsCalcWidthMulti]; valueInPolygon.Add(item); } } }
private Dictionary<GeoXYPoint, short> GetNodeDatas(GeoXYRect geoXYRect, List<IGeoRasterData> rasterDataList) { if ((rasterDataList == null) || (rasterDataList.Count < 1)) { return null; } rasterDataList = this.SortRasterDataList(rasterDataList); GeoCalcBound geoCalcBound = new GeoCalcBound(geoXYRect, rasterDataList[0].Resolution); Dictionary<double, List<short>> valueDict = new Dictionary<double, List<short>>(); foreach (IGeoRasterData data in rasterDataList) { short[] valueByCalcBound = data.GetValueByCalcBound<short>(geoCalcBound); valueDict.Add(data.Resolution, new List<short>(valueByCalcBound)); } List<short> gridData = GeoInfo.GetGridData(valueDict); Dictionary<GeoXYPoint, short> dictionary2 = new Dictionary<GeoXYPoint, short>(); int rectRows = geoCalcBound.RectRows; int rectColumns = geoCalcBound.RectColumns; for (int i = 0; i < rectRows; i++) { double y = geoCalcBound.Top - (i * geoCalcBound.CalcWidth); for (int j = 0; j < rectColumns; j++) { double x = geoCalcBound.Left + (geoCalcBound.CalcWidth * j); dictionary2.Add(new GeoXYPoint(x, y), gridData[(i * rectColumns) + j]); } } return dictionary2; }
private void GetDatasCore(GeoPolygonRegion polygonRegion, List<IGeoRasterData> rasterDataList, bool isSetPointDict, bool isRandomPt, GeoXYRect resPolyRegion) { GeoCalcBound geoCalcBound = new GeoCalcBound(resPolyRegion, rasterDataList[0].Resolution); short[] datas = this.GetDatas(resPolyRegion, rasterDataList); if (datas.Length != 0) { List<short> list = new List<short>(); double tempX = 0.0; double tempY = 0.0; tempX = geoCalcBound.Left; tempY = geoCalcBound.Top; this.InitialCLutterIDIndexDict(); GC.Collect(); int step = 0; if (this.m_IsNeedReportProgress) { step = (int) Math.Ceiling((double) (((double) geoCalcBound.RectRows) / ((double) (this.m_ProgressEnd - this.m_ProgressStart)))); } lock (this.m_ClutterIDIndexDict) { double random = 0.0; if (isRandomPt) { random = new Random().Next(0, 9); } for (int i = 0; i < geoCalcBound.RectRows; i++) { tempX = geoCalcBound.Left; tempY = geoCalcBound.Top - (i * geoCalcBound.CalcWidth); this.GetOneLineXDatas(geoCalcBound, tempX, tempY, polygonRegion, ref datas, isSetPointDict, random); this.ReportProgress(step, i); } } } }
private void ReadGridDataByGeoCalcBound(GeoCalcBound geoCalcBound, IGeoRasterData geoDemData, Dictionary<double, List<short>> gridValueByPointDict) { short[] valueByCalcBound = geoDemData.GetValueByCalcBound<short>(geoCalcBound); lock (this.boundThreadTag) { List<short> list = new List<short>(); list.AddRange(valueByCalcBound); double resolution = geoDemData.Resolution; while (gridValueByPointDict.ContainsKey(resolution)) { resolution += 0.0001; } if (!gridValueByPointDict.ContainsKey(resolution)) { gridValueByPointDict.Add(resolution, list); } } }
private List<GeoXYPoint> GetClutterPointInBound(short clutterID, List<int> clutterIDIndexList, GeoCalcBound geoCalcBound, bool isRandomPt) { double num; double num2; double num3; double num4; int num11; List<GeoXYPoint> list = new List<GeoXYPoint>(); GetMapBound(this.m_IGeoDataMgr.ClutterRasterData, out num, out num2, out num3, out num4); GeoXYRect rect = new GeoXYRect(num, num2, num3, num4); GeoXYRect rect2 = new GeoXYRect(geoCalcBound.Left, geoCalcBound.Right, geoCalcBound.Bottom, geoCalcBound.Top); GeoCalcBound bound = new GeoCalcBound(rect.GetJoinGeoXYRect(rect2), geoCalcBound.CalcWidth); double left = bound.Left; double top = bound.Top; int rectColumns = bound.RectColumns; int rectRows = bound.RectRows; double calcWidth = geoCalcBound.CalcWidth; if (isRandomPt) { Random random = new Random(); foreach (int num10 in clutterIDIndexList) { num11 = this.m_ClutterIDIndexDict[clutterID][num10 / 10]; list.Add(this.GetRadomPoint(num11, left, top, rectColumns, rectRows, calcWidth, random)); } return list; } foreach (int num10 in clutterIDIndexList) { num11 = this.m_ClutterIDIndexDict[clutterID][num10 / 10]; list.Add(this.GetFixPoint(num11, left, top, rectColumns, calcWidth)); } return list; }
public short[] GetValueByGeoCalcBound(GeoCalcBound geoCalcBound, DemDataType demDataType) { throw new NotImplementedException(); }
private short[] GetDatas(GeoXYRect geoXYRect, List<IGeoRasterData> rasterDataList) { if (rasterDataList == null) { return null; } rasterDataList = this.SortRasterDataList(rasterDataList); GeoCalcBound geoCalcBound = new GeoCalcBound(geoXYRect, rasterDataList[0].Resolution); Dictionary<double, List<short>> valueDict = new Dictionary<double, List<short>>(); foreach (IGeoRasterData data in rasterDataList) { short[] valueByCalcBound = data.GetValueByCalcBound<short>(geoCalcBound); valueDict.Add(data.Resolution, new List<short>(valueByCalcBound)); } return GeoInfo.GetGridData(valueDict).ToArray(); }
private bool CheckBoundIndex(int indexOfRect, GeoCalcBound geoCalcBound, DemDataType demDataType, int layerIndex) { return (((indexOfRect < 0) || (indexOfRect > (geoCalcBound.ArrayLength - 1))) || ((this.GetRasterData(demDataType).Count - 1) < layerIndex)); }
private short[] DemDataTypeCheckByGeoCalcBound(GeoCalcBound geoCalcBound, DemDataType demDataType, ref bool Flag) { if (this.GetRasterData(demDataType).Count == 0) { Flag = true; int rectRows = geoCalcBound.RectRows; int rectColumns = geoCalcBound.RectColumns; short[] numArray = new short[rectRows * rectColumns]; if (demDataType == DemDataType.Clutter) { for (int i = 0; i < numArray.Length; i++) { numArray[i] = -1; } } return numArray; } Flag = false; return null; }
public short[] GetValueByGeoCalcBound(GeoCalcBound geoCalcBound) { int num11; int rectRows = geoCalcBound.RectRows; int rectColumns = geoCalcBound.RectColumns; short[] destinationArray = new short[rectRows * rectColumns]; short temp = 0; if (this.m_OptimizeReading) { FileStream input = new FileStream(this.m_GeoDemData.FilePath, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(input); int num3 = (int) ((this.m_GeoDemData.RightOfBound - this.m_GeoDemData.LeftOfBound) / this.m_GeoDemData.Resolution); int num4 = (int) ((geoCalcBound.Top - geoCalcBound.Bottom) / this.m_GeoDemData.Resolution); int num5 = (int) ((geoCalcBound.Right - geoCalcBound.Left) / this.m_GeoDemData.Resolution); double num6 = ((double) num5) / ((double) rectColumns); double num7 = ((double) num4) / ((double) rectRows); for (int j = 0; j < rectRows; j++) { short[] sourceArray = new short[rectColumns]; int num9 = (int) ((geoCalcBound.Left - this.m_GeoDemData.LeftOfBound) / this.m_GeoDemData.Resolution); int num10 = (int) ((j * num7) + ((this.m_GeoDemData.TopOfBound - geoCalcBound.Top) / this.m_GeoDemData.Resolution)); input.Seek((long) (((num10 * num3) + num9) * 2), SeekOrigin.Begin); byte[] buffer = reader.ReadBytes(num5 * 2); if (buffer.Length == 0) { num11 = 0; while (num11 < sourceArray.Length) { sourceArray[num11] = temp; num11++; } } else { num11 = 0; while (num11 < sourceArray.Length) { int index = ((int)(num11 * num6)) * 2; sourceArray[num11] = (short)((buffer[index] << 8) + buffer[index + 1]); num11++; } } Array.Copy(sourceArray, 0, destinationArray, j * sourceArray.Length, sourceArray.Length); sourceArray = null; } input.Close(); input.Dispose(); input = null; reader.Close(); reader = null; return destinationArray; } double x = 0.0; double y = 0.0; x = geoCalcBound.Left; y = geoCalcBound.Top; for (int i = 0; i < rectRows; i++) { x = geoCalcBound.Left; y = geoCalcBound.Top - (i * geoCalcBound.CalcWidth); for (num11 = 0; num11 < rectColumns; num11++) { x = geoCalcBound.Left + (geoCalcBound.CalcWidth * num11); destinationArray[num11 + (rectColumns * i)] = this.GetValueByGeoXYPointCore(x, y); } } return destinationArray; }
private void GeoBoundParaException(GeoCalcBound geoCalcBound, DemDataType demDataType) { if (geoCalcBound.CalcWidth < 0.10000000149011612) { throw new GeoParamIllegalException(); } if (this.GetRasterData(demDataType) == null) { throw new GeoNullException(); } }
public short[] GetValueByGeoCalcBound(GeoCalcBound geoCalcBound, DemDataType demDataType) { //hrow new NotImplementedException(); //short[] short[] count = new short[1] {0 }; return count; }
public void CalcPolygonClutterPercent(GeoPolygonRegion polygonRegion, GeoXYRect resPolyRegion, List<IGeoRasterData> rasterDataList) { rasterDataList = this.SortRasterDataList(rasterDataList); GeoCalcBound bound = new GeoCalcBound(resPolyRegion, rasterDataList[0].Resolution); double x = 0.0; double y = 0.0; x = bound.Left; y = bound.Top; short key = -1; int num4 = 0; num4 = (int) Math.Ceiling((double) (((double) bound.RectRows) / ((double) (this.m_ProgressEnd - this.m_ProgressStart)))); for (int i = 0; i < bound.RectRows; i++) { if (((i % num4) == 0) && (this.m_ProgressStart < this.m_ProgressEnd)) { this.m_ProgressStart++; this.m_SimulationProgressEvent("", this.m_ProgressStart, ""); } y = bound.Top - (i * bound.CalcWidth); for (int j = 0; j < bound.RectColumns; j++) { x = bound.Left + (bound.CalcWidth * j); GeoXYPoint geoXYPoint = new GeoXYPoint(x, y); if (this.m_CaculateFullMap || polygonRegion.IsPointInRegion(geoXYPoint)) { key = this.GetValueByPoint(geoXYPoint, rasterDataList); if (this.m_ClutterIDCountDict.ContainsKey(key)) { Dictionary<short, int> dictionary; short num7; (dictionary = this.m_ClutterIDCountDict)[num7 = key] = dictionary[num7] + 1; } } } } if (this.m_ProgressStart != this.m_ProgressEnd) { this.m_SimulationProgressEvent("", this.m_ProgressEnd, ""); } }