本文整理汇总了C#中DotSpatial.Data.Extent.Intersects方法的典型用法代码示例。如果您正苦于以下问题:C# Extent.Intersects方法的具体用法?C# Extent.Intersects怎么用?C# Extent.Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotSpatial.Data.Extent
的用法示例。
在下文中一共展示了Extent.Intersects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Select
/// <inheritdoc/>
public virtual List<IFeature> Select(Extent region, out Extent affectedRegion)
{
var result = new List<IFeature>();
affectedRegion = new Extent();
if (IndexMode)
{
var aoi = new ShapeRange(region);
var shapes = ShapeIndices;
for (var shp = 0; shp < shapes.Count; shp++)
{
if (!shapes[shp].Intersects(aoi))
{
continue;
}
var feature = GetFeature(shp);
affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
result.Add(feature);
}
}
else
{
foreach (var feature in Features)
{
if (!region.Intersects(feature.Envelope) ||
!feature.Intersects(region.ToEnvelope()))
{
continue;
}
result.Add(feature);
affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
}
}
return result;
}
示例2: Select
/// <inheritdoc/>
public virtual List<IFeature> Select(Extent region, out Extent affectedRegion)
{
List<IFeature> result = new List<IFeature>();
if (IndexMode)
{
ShapeRange aoi = new ShapeRange(region);
Extent affected = new Extent();
List<ShapeRange> shapes = ShapeIndices;
if (shapes != null)
{
//ProgressMeter = new ProgressMeter(ProgressHandler, "Selecting shapes", shapes.Count);
for (int shp = 0; shp < shapes.Count; shp++)
{
//ProgressMeter.Next();
if (!shapes[shp].Intersects(aoi))
{
continue;
}
IFeature f = GetFeature(shp);
affected.ExpandToInclude(shapes[shp].Extent);
result.Add(f);
}
//ProgressMeter.Reset();
}
affectedRegion = affected;
return result;
}
affectedRegion = new Extent();
bool useProgress = (Features.Count > 10000);
//ProgressMeter = new ProgressMeter(ProgressHandler, "Selecting Features", Features.Count);
foreach (IFeature feature in Features)
{
//if (useProgress)
// ProgressMeter.Next();
if (!region.Intersects(feature.Envelope))
{
continue;
}
if (!feature.Intersects(region.ToEnvelope()))
{
continue;
}
result.Add(feature);
affectedRegion.ExpandToInclude(feature.Envelope.ToExtent());
}
//if (useProgress)
// ProgressMeter.Reset();
return result;
}
示例3: GetSeriesListForExtent
private List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart> GetSeriesListForExtent(Extent extent, IEnumerable<string> keywords, double tileWidth, double tileHeight,
DateTime startDate, DateTime endDate, ICollection<WebServiceNode> serviceIDs,
BusinessObjects.Models.IProgressHandler bgWorker, Func<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart, bool> seriesFilter)
{
var servicesToSearch = new List<Tuple<WebServiceNode[], Extent>>();
if (serviceIDs.Count > 0)
{
foreach (var webService in serviceIDs)
{
if (webService.ServiceBoundingBox == null)
{
servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new[] { webService }, extent));
continue;
}
const double eps = 0.05; //tolerance (0.05 deg) used for services whose bounding box is one point
var wsBox = webService.ServiceBoundingBox;
var wsExtent = new Extent(wsBox.XMin - eps, wsBox.YMin - eps, wsBox.XMax + eps, wsBox.YMax + eps);
if (wsExtent.Intersects(extent))
{
servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new[] { webService }, wsExtent.Intersection(extent)));
}
}
}
else
{
servicesToSearch.Add(new Tuple<WebServiceNode[], Extent>(new WebServiceNode[] { }, extent));
}
var servicesWithExtents = new List<Tuple<WebServiceNode[], List<Extent>>>(servicesToSearch.Count);
int totalTilesCount = 0;
foreach (var wsInfo in servicesToSearch)
{
var tiles = SearchHelper.CreateTiles(wsInfo.Item2, tileWidth, tileHeight);
servicesWithExtents.Add(new Tuple<WebServiceNode[], List<Extent>>(wsInfo.Item1, tiles));
totalTilesCount += tiles.Count;
}
var fullSeriesList = new List<List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>>();
long currentTileIndex = 0;
int tilesFinished = 0;
totalSeriesCount = 0;
bgWorker.ReportProgress(0, "0 Series found");
var serviceLoopOptions = new ParallelOptions
{
CancellationToken = bgWorker.CancellationToken,
MaxDegreeOfParallelism = 2,
};
var tileLoopOptions = new ParallelOptions
{
CancellationToken = bgWorker.CancellationToken,
// Note: currently HIS Central returns timeout if many requests are sent in the same time.
// To test set MaxDegreeOfParallelism = -1
MaxDegreeOfParallelism = 4,
};
Parallel.ForEach(servicesWithExtents, serviceLoopOptions, wsInfo =>
{
bgWorker.CheckForCancel();
var ids = wsInfo.Item1.Select(item => item.ServiceID).ToArray();
var tiles = wsInfo.Item2;
Parallel.ForEach(tiles, tileLoopOptions, tile =>
{
var current = Interlocked.Add(ref currentTileIndex, 1);
bgWorker.CheckForCancel();
// Do the web service call
var tileSeriesList = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
if (SearchSettings.AndSearch == true)
{
//CHANGES FOR "AND" SEARCH
var totalTileSeriesList = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
var tileSeriesList2 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
var tileSeriesList3 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
var tileSeriesList4 = new List<BusinessObjects.Models.SeriesDataCartModel.SeriesDataCart>();
SeriesComparer sc = new SeriesComparer();
for (int i = 0; i < keywords.Count(); i++)
{
String keyword = keywords.ElementAt(i);
bgWorker.CheckForCancel();
var series = GetSeriesCatalogForBox(tile.MinX, tile.MaxX, tile.MinY, tile.MaxY, keyword, startDate, endDate, ids, bgWorker, current, totalTilesCount);
totalTileSeriesList.AddRange(series);
if (tileSeriesList.Count() == 0)
{
if (i == 0)
{
tileSeriesList.AddRange(series);
}
else
{
break;
}
}
else
//.........这里部分代码省略.........
示例4: GetShapes
/// <inheritdocs/>
public Dictionary<int, Shape> GetShapes(ref int startIndex, int count, IEnvelope envelope)
{
Dictionary<int, Shape> result = new Dictionary<int, Shape>();
ShapefileIndexFile shx = CacheShapeIndexFile();
// Check to ensure the fileName is not null
if (Filename == null)
{
throw new NullReferenceException(Filename);
}
if (File.Exists(Filename) == false)
{
throw new FileNotFoundException(Filename);
}
// Get the basic header information.
ShapefileHeader header = new ShapefileHeader(Filename);
Extent ext = new Extent(new[] { header.Xmin, header.Ymin, header.Xmax, header.Ymax });
if (envelope != null)
{
if (!ext.Intersects(envelope)) return result;
}
// Check to ensure that the fileName is the correct shape type
if (header.ShapeType != ShapeType &&
header.ShapeType != ShapeTypeM &&
header.ShapeType != ShapeTypeZ)
{
throw new ArgumentException("Wrong feature type.");
}
FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.Read, FileShare.Read);
if (fs.Length == 100)
{
// The shapefile is empty so we can simply return here
fs.Close();
return result;
}
int shapesTested = 0;
int shapesReturned = 0;
// Use spatial index if we have one
if (null != _spatialIndex && null != envelope)
{
IList spatialQueryResults = _spatialIndex.Query(envelope);
// Sort the results from low to high index
var sqra = new int[spatialQueryResults.Count];
spatialQueryResults.CopyTo(sqra, 0);
Array.Sort(sqra);
foreach (int shp in sqra)
{
if (shp >= startIndex)
{
Shape myShape = GetShapeAtIndex(fs, shx, header, shp, envelope);
shapesTested++;
if (null != myShape)
{
shapesReturned++;
result.Add(shp, myShape);
if (shapesReturned >= count) break;
}
}
}
}
else
{
int numShapes = shx.Shapes.Count;
for (int shp = startIndex; shp < numShapes; shp++)
{
Shape myShape = GetShapeAtIndex(fs, shx, header, shp, envelope);
shapesTested++;
if (null != myShape)
{
shapesReturned++;
result.Add(shp, myShape);
if (shapesReturned >= count) break;
}
}
}
startIndex += shapesTested;
fs.Close();
return result;
}