/// <summary> /// Returns integral from nodes[0] to nodes[last] of function f. /// </summary> /// <param name="f"></param> /// <param name="nodes"></param> /// <param name="formulaType"></param> /// <returns></returns> public static double Rectangular(Func <double, double> f, double[] nodes, RectType formulaType) { double sum = 0; double a, b; switch (formulaType) { case RectType.Left: a = 1; b = 0; break; case RectType.Right: a = 0; b = 1; break; case RectType.Center: a = b = 0.5; break; default: throw new ArgumentOutOfRangeException(nameof(formulaType), formulaType, null); } for (int i = 0; i < nodes.Length - 1; i++) { sum += f(a * nodes[i] + b * nodes[i + 1]) * (nodes[i + 1] - nodes[i]); } return(sum); }
////////////////////////////////////////////////////////////////////////// public RectangleResizer(WUIWindow Window, RectType Type) { this.Window = Window; this.Type = Type; _OrigRect = GetRect(); }
public Frame(Frame other) { mCharImage = other.mCharImage; mBoxAnchor = other.mBoxAnchor; mBoxSize = other.mBoxSize; mText = other.mText; mFocusRect = other.mFocusRect; mRectType = other.mRectType; mNextButton = other.mNextButton; mContextualHelp = other.mContextualHelp; mAction = other.mAction; }
/// <summary> /// Calculates integral on (a,b) using nodes (nodes[i] that not in [a,b] are not taken into account) /// </summary> /// <param name="f"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="nodes">Sorted array of nodes</param> /// <param name="formulaType"></param> /// <returns></returns> public static double Rectangular(Func <double, double> f, double a, double b, double[] nodes, RectType formulaType) { //var nodesInSegment = nodes.SkipWhile(x => x < a).TakeWhile(x => x < b).ToList(); //var i = 0; //while (nodes[i] < a && i < nodes.Length) ++i; //for (int i = 0; i < nodesInSegment.Length; i++) //{ //} throw new NotImplementedException(); }
private static Azul.Rect GetRect(RectType typeIn) { int cordX = bx[0]; int cordY = by[0]; const int width = 240; const int height = 130; switch (typeIn) { case RectType.Octopus1: break; case RectType.Octopus2: cordY = by[1]; break; case RectType.Crab1: cordX = bx[1]; break; case RectType.Crab2: cordX = bx[1]; cordY = by[1]; break; case RectType.Squid1: cordX = bx[2]; break; case RectType.Squid2: cordX = bx[2]; cordY = by[1]; break; case RectType.CoreCannon1: cordY = by[2]; break; default: break; } Azul.Rect returnRect = new Azul.Rect(cordX, cordY, width, height); return(returnRect); }
/// <summary> /// 创建VRT文件 /// </summary> /// <param name="file_list">遍历文件夹得到的瓦片地图列表</param> /// <param name="dstPath">保存路径</param> /// <param name="maptype">0为百度地图,1为高德地图</param> /// <param name="Request"></param> void BuildVRT(FileInfo[] file_list, string dstPath, int maptype, BuildVRTByTileRequest Request) { int z = 19; //获取瓦片地图的范围 List <Point> TilePoints = GetTileCoor(file_list); Tuple <int, int, int, int> TileBoundary = GetBoundary(TilePoints); //计算VRT的宽度和高度 int VRTWidth = (TileBoundary.Item3 - TileBoundary.Item1 + 1) * 256; int VRTHeight = (TileBoundary.Item4 - TileBoundary.Item2 + 1) * 256; //计算瓦片地图左上角墨卡托坐标 int mcx = (int)(TileBoundary.Item1 * 256 * Math.Pow(2, (18 - z))); int mcy = (int)((TileBoundary.Item4 + 1) * 256 * Math.Pow(2, (18 - z))); //PointF startpoint = new PointF(mcx, mcy); //基于VRT生成类构建VRT文件 VRTDataset wuhan_vrt = new VRTDataset(); //设置VRTDataset属性 wuhan_vrt.rasterXSize = VRTWidth.ToString(); wuhan_vrt.rasterYSize = VRTHeight.ToString(); //设置VRTDataset子节点 wuhan_vrt.ItemsElementName = new ItemsChoiceType5[5] { ItemsChoiceType5.SRS, ItemsChoiceType5.GeoTransform, ItemsChoiceType5.VRTRasterBand, ItemsChoiceType5.VRTRasterBand, ItemsChoiceType5.VRTRasterBand }; wuhan_vrt.Items = new object[5]; wuhan_vrt.Items[0] = "PROJCS[\"WGS_1984_Pseudo_Mercator\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator\"],PARAMETER[\"false_easting\",0.0],PARAMETER[\"false_northing\",0.0],PARAMETER[\"central_meridian\",0.0],PARAMETER[\"standard_parallel_1\",0.0],UNIT[\"Meter\",1.0]]"; wuhan_vrt.Items[1] = mcx.ToString() + ", " + Math.Pow(2, (18 - z)).ToString() + ", 0, " + mcy.ToString() + ", 0, -" + Math.Pow(2, (18 - z)).ToString(); //红色波段 VRTRasterBandType VRTRasterBand_Red = new VRTRasterBandType(); VRTRasterBand_Red.dataType = DataTypeType.Byte; VRTRasterBand_Red.band = 1; VRTRasterBand_Red.ItemsElementName = new ItemsChoiceType4[file_list.Length + 1]; VRTRasterBand_Red.ItemsElementName[0] = ItemsChoiceType4.ColorInterp; VRTRasterBand_Red.Items = new object[file_list.Length + 1]; VRTRasterBand_Red.Items[0] = ColorInterpType.Red; //绿色波段 VRTRasterBandType VRTRasterBand_Green = new VRTRasterBandType(); VRTRasterBand_Green.dataType = DataTypeType.Byte; VRTRasterBand_Green.band = 2; VRTRasterBand_Green.ItemsElementName = new ItemsChoiceType4[file_list.Length + 1]; VRTRasterBand_Green.ItemsElementName[0] = ItemsChoiceType4.ColorInterp; VRTRasterBand_Green.Items = new object[file_list.Length + 1]; VRTRasterBand_Green.Items[0] = ColorInterpType.Green; //蓝色波段 VRTRasterBandType VRTRasterBand_Blue = new VRTRasterBandType(); VRTRasterBand_Blue.dataType = DataTypeType.Byte; VRTRasterBand_Blue.band = 3; VRTRasterBand_Blue.ItemsElementName = new ItemsChoiceType4[file_list.Length + 1]; VRTRasterBand_Blue.ItemsElementName[0] = ItemsChoiceType4.ColorInterp; VRTRasterBand_Blue.Items = new object[file_list.Length + 1]; VRTRasterBand_Blue.Items[0] = ColorInterpType.Blue; //循环遍历瓦片地图列表,获取瓦片地图信息写入VRT for (int i = 0; i < file_list.Length; i++) { //红色波段 SimpleSourceType SimpleSource_Red = new SimpleSourceType(); SimpleSource_Red.ItemsElementName = new ItemsChoiceType1[5] { ItemsChoiceType1.SourceFilename, ItemsChoiceType1.SourceBand, ItemsChoiceType1.SourceProperties, ItemsChoiceType1.SrcRect, ItemsChoiceType1.DstRect }; SimpleSource_Red.Items = new object[5]; SimpleSource_Red.Items[1] = "1"; //绿色波段 SimpleSourceType SimpleSource_Green = new SimpleSourceType(); SimpleSource_Green.ItemsElementName = new ItemsChoiceType1[5] { ItemsChoiceType1.SourceFilename, ItemsChoiceType1.SourceBand, ItemsChoiceType1.SourceProperties, ItemsChoiceType1.SrcRect, ItemsChoiceType1.DstRect }; SimpleSource_Green.Items = new object[5]; SimpleSource_Green.Items[1] = "2"; //蓝色波段 SimpleSourceType SimpleSource_Blue = new SimpleSourceType(); SimpleSource_Blue.ItemsElementName = new ItemsChoiceType1[5] { ItemsChoiceType1.SourceFilename, ItemsChoiceType1.SourceBand, ItemsChoiceType1.SourceProperties, ItemsChoiceType1.SrcRect, ItemsChoiceType1.DstRect }; SimpleSource_Blue.Items = new object[5]; SimpleSource_Blue.Items[1] = "3"; //SimpleSource共同属性构建 //1. SourceFilename SourceFilenameType SourceFilename = new SourceFilenameType(); SourceFilename.relativeToVRT = ZeroOrOne.Item1; SourceFilename.Value = file_list[i].FullName.Replace(Request.defaultfolderpath + "\\", "").Replace("\\", "/"); SimpleSource_Red.Items[0] = SourceFilename; SimpleSource_Green.Items[0] = SourceFilename; SimpleSource_Blue.Items[0] = SourceFilename; //3. SourceProperties SourcePropertiesType SourceProperties = new SourcePropertiesType(); SourceProperties.RasterXSize = "256"; SourceProperties.RasterYSize = "256"; SourceProperties.DataType = DataTypeType.Byte; SourceProperties.BlockXSize = "128"; SourceProperties.BlockYSize = "128"; SimpleSource_Red.Items[2] = SourceProperties; SimpleSource_Green.Items[2] = SourceProperties; SimpleSource_Blue.Items[2] = SourceProperties; //4. SrcRect RectType SrcRect = new RectType(); SrcRect.xOff = 0.0; SrcRect.yOff = 0.0; SrcRect.xSize = 256.0; SrcRect.ySize = 256.0; SimpleSource_Red.Items[3] = SrcRect; SimpleSource_Green.Items[3] = SrcRect; SimpleSource_Blue.Items[3] = SrcRect; //5. DstRect RectType DstRect = new RectType(); ////根据maptype类型计算瓦片地图的偏移坐标 int xOff = -9999, yOff = -9999; if (maptype == 0) { xOff = (TilePoints[i].X - TileBoundary.Item1) * 256; yOff = (TileBoundary.Item4 - TilePoints[i].Y) * 256; } else if (maptype == 1) { xOff = (TilePoints[i].X - TileBoundary.Item1) * 256; yOff = (TilePoints[i].Y - TileBoundary.Item2) * 256; } if (xOff == -9999 || yOff == -9999) { return; } //// DstRect.xOff = (double)xOff; DstRect.yOff = (double)yOff; DstRect.xSize = 256.0; DstRect.ySize = 256.0; SimpleSource_Red.Items[4] = DstRect; SimpleSource_Green.Items[4] = DstRect; SimpleSource_Blue.Items[4] = DstRect; VRTRasterBand_Red.ItemsElementName[i + 1] = ItemsChoiceType4.SimpleSource; VRTRasterBand_Green.ItemsElementName[i + 1] = ItemsChoiceType4.SimpleSource; VRTRasterBand_Blue.ItemsElementName[i + 1] = ItemsChoiceType4.SimpleSource; VRTRasterBand_Red.Items[i + 1] = SimpleSource_Red; VRTRasterBand_Green.Items[i + 1] = SimpleSource_Green; VRTRasterBand_Blue.Items[i + 1] = SimpleSource_Blue; } wuhan_vrt.Items[2] = VRTRasterBand_Red; wuhan_vrt.Items[3] = VRTRasterBand_Green; wuhan_vrt.Items[4] = VRTRasterBand_Blue; //VRT文件输出保存 var serializer = new XmlSerializer(typeof(VRTDataset)); using (var stream = new StreamWriter(dstPath)) { try { serializer.Serialize(stream, wuhan_vrt); } catch (Exception ex) { throw ex; } } }
/// <summary> /// If upper bound of integral is infinite then for numerically calculation we should set some finite upper bound. /// </summary> /// <param name="integral"></param> /// <param name="nodesCount"></param> /// <param name="upperBound"></param> /// <param name="formulaType"></param> /// <returns></returns> public static double RectangularInfinite(Integral integral, int nodesCount, double upperBound, RectType formulaType = RectType.Left) { return(Rectangular(integral.Function, integral.LowerBound, upperBound, nodesCount, formulaType)); }
public static double Rectangular(Func <double, double> f, double a, double b, int nodesCount, RectType formulaType = RectType.Left) { var nodes = Enumerable.Range(0, nodesCount).Select(j => a + j * (b - a) / (nodesCount - 1)).ToArray(); return(Rectangular(f, nodes, formulaType)); }
public static extern int GetWindowRect(int hwnd, ref RectType lpRect);
public Rect GetRect(float left, float top, float width, float height, RectType rectType = RectType.Default) { float ratio = this.GetGuiRatio(); float finalLeft = left * ratio; float finalTop = top * ratio; float finalWidth = width * ratio; float finalHeight = height * ratio; if (rectType == RectType.Centered) { finalLeft = (Screen.width / 2f) - (finalWidth / 2f); finalTop = (Screen.height / 2f) - (finalHeight / 2f); } if (rectType == RectType.Absolute) { finalLeft = left; finalTop = top; } return new Rect(finalLeft, finalTop, finalWidth, finalHeight); }