本文整理汇总了C#中Envelope.Intersection方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.Intersection方法的具体用法?C# Envelope.Intersection怎么用?C# Envelope.Intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Envelope
的用法示例。
在下文中一共展示了Envelope.Intersection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPreview
protected virtual void GetPreview(Dataset dataset, Size size, Graphics g,
Envelope displayBbox, ProjectionInfo mapProjection, Map map)
#endif
{
if (!NeedRotation(dataset))
{
GetNonRotatedPreview(dataset, size, g, displayBbox, mapProjection);
return;
}
var geoTransform = new GeoTransform(dataset);
Bitmap bitmap = null;
var bitmapTL = new Point();
//Coordinate imageTL = new Coordinate(), imageBR = new Coordinate();
//int bitmapWidth, bitmapHeight;
var bitmapSize = new Size();
const int pixelSize = 3; //Format24bppRgb = byte[b,g,r]
if (dataset != null)
{
//check if image is in bounding box
if ((displayBbox.MinX > _envelope.MaxX) || (displayBbox.MaxX < _envelope.MinX)
|| (displayBbox.MaxY < _envelope.MinY) || (displayBbox.MinY > _envelope.MaxY))
return;
// init histo
Histogram = new List<int[]>();
for (int i = 0; i < Bands + 1; i++)
Histogram.Add(new int[256]);
// bounds of section of image to be displayed
//var left = Math.Max(displayBbox.MinX, _envelope.MinX);
//var top = Math.Min(displayBbox.MaxY, _envelope.MaxY);
//var right = Math.Min(displayBbox.MaxX, _envelope.MaxX);
//var bottom = Math.Max(displayBbox.MinY, _envelope.MinY);
var trueImageBbox = displayBbox.Intersection(_envelope);
// put display bounds into current projection
Envelope shownImageBbox;
if (Transform != null)
{
#if !DotSpatialProjections
Transform.MathTransform.Invert();
shownImageBbox = GeometryTransform.TransformBox(trueImageBbox, Transform.MathTransform);
Transform.MathTransform.Invert();
#else
shownImageBbox = GeometryTransform.TransformBox(trueImageBbox, _transform.Source, _transform.Target);
#endif
}
else
{
shownImageBbox = trueImageBbox;
}
// find min/max x and y pixels needed from image
var g2i = geoTransform.GroundToImage(shownImageBbox).Intersection(new Envelope(0, _imageSize.Width, 0, _imageSize.Height));
var gdalImageRect = ToRectangle(g2i);
var displayImageSize = gdalImageRect.Size;
//// find ground coordinates of image pixels
//var groundBR = geoTransform.ImageToGround(imageBR);
//var groundTL = geoTransform.ImageToGround(imageTL);
// convert ground coordinates to map coordinates to figure out where to place the bitmap
var bitmapBR = new Point((int)map.WorldToImage(trueImageBbox.BottomRight()).X + 1,
(int)map.WorldToImage(trueImageBbox.BottomRight()).Y + 1);
bitmapTL = new Point((int)map.WorldToImage(trueImageBbox.TopLeft()).X,
(int)map.WorldToImage(trueImageBbox.TopLeft()).Y);
bitmapSize.Width = bitmapBR.X - bitmapTL.X;
bitmapSize.Height = bitmapBR.Y - bitmapTL.Y;
// check to see if image is on its side
if (bitmapSize.Width > bitmapSize.Height && displayImageSize.Width < displayImageSize.Height)
{
displayImageSize.Width = bitmapSize.Height;
displayImageSize.Height = bitmapSize.Width;
}
else
{
displayImageSize.Width = bitmapSize.Width;
displayImageSize.Height = bitmapSize.Height;
}
// scale
var bitScalar = GetBitScalar();
// 0 pixels in length or height, nothing to display
if (bitmapSize.Width < 1 || bitmapSize.Height < 1)
return;
//initialize bitmap
BitmapData bitmapData;
bitmap = InitializeBitmap(bitmapSize, PixelFormat.Format24bppRgb, out bitmapData);
//.........这里部分代码省略.........
示例2: GetPreview
protected virtual void GetPreview(Dataset dataset, Size size, Graphics g,
Envelope displayBbox, ProjectionInfo mapProjection, Map map)
#endif
{
DateTime drawStart = DateTime.Now;
double totalReadDataTime = 0;
double totalTimeSetPixel = 0;
if (!NeedRotation(dataset))
{
GetNonRotatedPreview(dataset, size, g, displayBbox, mapProjection);
return;
}
var geoTransform = new GeoTransform(dataset);
Bitmap bitmap = null;
var bitmapTl = new Point();
var bitmapSize = new Size();
const int pixelSize = 3; //Format24bppRgb = byte[b,g,r]
if (dataset != null)
{
//check if image is in bounding box
if ((displayBbox.MinX > _envelope.MaxX) || (displayBbox.MaxX < _envelope.MinX)
|| (displayBbox.MaxY < _envelope.MinY) || (displayBbox.MinY > _envelope.MaxY))
return;
// init histo
Histogram = new List<int[]>();
for (int i = 0; i < Bands + 1; i++)
Histogram.Add(new int[256]);
var trueImageBbox = displayBbox.Intersection(_envelope);
// put display bounds into current projection
Envelope shownImageBbox = trueImageBbox;
#if !DotSpatialProjections
if (ReverseCoordinateTransformation != null)
{
shownImageBbox = GeometryTransform.TransformBox(trueImageBbox, ReverseCoordinateTransformation.MathTransform);
}
#else
if (CoordinateTransformation != null)
{
shownImageBbox = GeometryTransform.TransformBox(trueImageBbox,
CoordinateTransformation.Target, CoordinateTransformation.Source);
}
#endif
// find min/max x and y pixels needed from image
var g2I = geoTransform.GroundToImage(shownImageBbox).Intersection(new Envelope(0, _imageSize.Width, 0, _imageSize.Height));
var gdalImageRect = ToRectangle(g2I);
var displayImageSize = gdalImageRect.Size;
// convert ground coordinates to map coordinates to figure out where to place the bitmap
var bitmapBr = new Point((int)map.WorldToImage(trueImageBbox.BottomRight()).X + 1,
(int)map.WorldToImage(trueImageBbox.BottomRight()).Y + 1);
bitmapTl = new Point((int)map.WorldToImage(trueImageBbox.TopLeft()).X,
(int)map.WorldToImage(trueImageBbox.TopLeft()).Y);
bitmapSize.Width = bitmapBr.X - bitmapTl.X;
bitmapSize.Height = bitmapBr.Y - bitmapTl.Y;
// check to see if image is on its side
if (bitmapSize.Width > bitmapSize.Height && displayImageSize.Width < displayImageSize.Height)
{
displayImageSize.Width = bitmapSize.Height;
displayImageSize.Height = bitmapSize.Width;
}
else
{
displayImageSize.Width = bitmapSize.Width;
displayImageSize.Height = bitmapSize.Height;
}
// scale
var bitScalar = GetBitScalar();
// 0 pixels in length or height, nothing to display
if (bitmapSize.Width < 1 || bitmapSize.Height < 1)
return;
//initialize bitmap
BitmapData bitmapData;
bitmap = InitializeBitmap(bitmapSize, PixelFormat.Format24bppRgb, out bitmapData);
try
{
unsafe
{
var cr = _noDataInitColor.R;
var cg = _noDataInitColor.G;
var cb = _noDataInitColor.B;
// create 3 dimensional buffer [band][x pixel][y pixel]
var buffer = new double[Bands][][];
for (int i = 0; i < Bands; i++)
//.........这里部分代码省略.........