本文整理汇总了C#中IGeometry.GetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.GetBoundingBox方法的具体用法?C# IGeometry.GetBoundingBox怎么用?C# IGeometry.GetBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.GetBoundingBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public static void Render(Graphics graphics, IGeometry feature, IStyle style, IViewport viewport)
{
var stream = ((IRaster)feature).Data;
stream.Position = 0;
var bitmap = new Bitmap(stream);
Geometries.Point min = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MinX, feature.GetBoundingBox().MinY));
Geometries.Point max = viewport.WorldToScreen(new Geometries.Point(feature.GetBoundingBox().MaxX, feature.GetBoundingBox().MaxY));
Rectangle destination = RoundToPixel(new RectangleF((float)min.X, (float)max.Y, (float)(max.X - min.X), (float)(min.Y - max.Y)));
graphics.DrawImage(bitmap,
destination,
0, 0, bitmap.Width, bitmap.Height,
GraphicsUnit.Pixel,
new ImageAttributes());
if (DeveloperTools.DeveloperMode)
{
var font = new System.Drawing.Font("Arial", 12);
var message = (GC.GetTotalMemory(true) / 1000).ToString(CultureInfo.InvariantCulture) + " KB";
graphics.DrawString(message, font, new SolidBrush(Color.Black), 10f, 10f);
}
bitmap.Dispose();
}
示例2: CreateLabel
private static Label CreateLabel(IGeometry feature, string text, float rotation, int priority, LabelStyle style, IViewport viewport,
Graphics g)
{
var gdiSize = g.MeasureString(text, style.Font.ToGdi());
var size = new Styles.Size { Width = gdiSize.Width, Height = gdiSize.Height };
var position = viewport.WorldToScreen(feature.GetBoundingBox().GetCentroid());
position.X = position.X - size.Width * (short)style.HorizontalAlignment * 0.5f;
position.Y = position.Y - size.Height * (short)style.VerticalAlignment * 0.5f;
if (position.X - size.Width > viewport.Width || position.X + size.Width < 0 ||
position.Y - size.Height > viewport.Height || position.Y + size.Height < 0)
return null;
Label label;
if (!style.CollisionDetection)
label = new Label(text, position, rotation, priority, null, style);
else
{
//Collision detection is enabled so we need to measure the size of the string
label = new Label(text, position, rotation, priority,
new LabelBox(position.X - size.Width * 0.5f - style.CollisionBuffer.Width,
position.Y + size.Height * 0.5f + style.CollisionBuffer.Height,
size.Width + 2f * style.CollisionBuffer.Width,
size.Height + style.CollisionBuffer.Height * 2f), style);
}
if (!(feature is LineString)) return label;
var line = feature as LineString;
if (line.Length / viewport.Resolution > size.Width) //Only label feature if it is long enough
CalculateLabelOnLinestring(line, ref label, viewport);
else
return null;
return label;
}
示例3: Union
public BoundingBox Union(IGeometry geometry)
{
var bbox = geometry.GetBoundingBox();
return Union(bbox);
}