public IEnumerable<IFeature> FetchTiles(BoundingBox boundingBox, double resolution) { var extent = new Extent(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Max.X, boundingBox.Max.Y); var levelId = BruTile.Utilities.GetNearestLevel(_source.Schema.Resolutions, resolution); var infos = _source.Schema.GetTileInfos(extent, levelId).ToList(); ICollection<WaitHandle> waitHandles = new List<WaitHandle>(); foreach (TileInfo info in infos) { if (_bitmaps.Find(info.Index) != null) continue; if (_queue.Contains(info.Index)) continue; var waitHandle = new AutoResetEvent(false); waitHandles.Add(waitHandle); _queue.Add(info.Index); ThreadPool.QueueUserWorkItem(GetTileOnThread, new object[] { _source, info, _bitmaps, waitHandle }); } WaitHandle.WaitAll(waitHandles.ToArray()); IFeatures features = new Features(); foreach (TileInfo info in infos) { byte[] bitmap = _bitmaps.Find(info.Index); if (bitmap == null) continue; IRaster raster = new Raster(new MemoryStream(bitmap), new BoundingBox(info.Extent.MinX, info.Extent.MinY, info.Extent.MaxX, info.Extent.MaxY)); IFeature feature = features.New(); feature.Geometry = raster; features.Add(feature); } return features; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometry">Geometry to be in this datasource</param> public MemoryProvider(Geometry geometry) { SRID = -1; Features = new Features(); IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="features">Features to be included in this datasource</param> public MemoryProvider(IEnumerable <IFeature> features) { CRS = ""; Features = new Features(); foreach (var feature in features) { Features.Add(feature); } }
private static Features CreateFeatures(IEnumerable<IGeometry> randomPoints) { var features = new Features(); var counter = 0; foreach (var point in randomPoints) { features.Add(new Feature { Geometry = point, ["Label"] = counter++.ToString() }); } return features; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometry">Geometry to be in this datasource</param> public MemoryProvider(Geometry geometry) { CRS = ""; Features = new Features(); IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); SymbolSize = 64; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="features">Features to be included in this datasource</param> public MemoryProvider(IEnumerable <IFeature> features) { CRS = ""; var localFeatures = new Features(); foreach (var feature in features) { localFeatures.Add(feature); } _features = localFeatures; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometries">Set of geometries that this datasource should contain</param> public MemoryProvider(IEnumerable <IGeometry> geometries) { CRS = ""; Features = new Features(); foreach (IGeometry geometry in geometries) { IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); } }
public void DeleteFeatureReferenceType() { // Arrange const string keyField = "thekeyfield"; var features = new Features(keyField); var feature1 = new Feature(); feature1[keyField] = "a"; features.Add(feature1); var feature2 = new Feature(); feature2[keyField] = "b"; features.Add(feature2); // Act var first = features.First(f => f[keyField].Equals("a")); features.Delete(first[keyField]); // Assert Assert.IsFalse(features.Any(f => f[keyField].Equals("a"))); }
private static MemoryProvider CreateRandomPointsProvider(BoundingBox box) { var randomPoints = PointLayerSample.GenerateRandomPoints(box, 200); var features = new Features(); var count = 0; foreach (var point in randomPoints) { var feature = new Feature { Geometry = point }; feature["Label"] = count.ToString(CultureInfo.InvariantCulture); features.Add(feature); count++; } return new MemoryProvider(features); }
public System.Collections.Generic.IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution) { var features = new Features(); IRaster raster = null; var view = new Viewport { Resolution = resolution, Center = box.GetCentroid(), Width = (box.Width / resolution), Height = (box.Height / resolution) }; if (TryGetMap(view, ref raster)) { IFeature feature = features.New(); feature.Styles.Add(new VectorStyle()); // this is not my fault feature.Geometry = raster; features.Add(feature); } return features; }
private static MemoryProvider CreateRandomPointsProvider(IEnumerable<IGeometry> randomPoints) { var features = new Features(); var count = 0; foreach (var point in randomPoints) { var feature = new Feature { Geometry = point, [LabelColumn] = count.ToString(CultureInfo.InvariantCulture) }; features.Add(feature); count++; } return new MemoryProvider(features); }
public IEnumerable <IFeature> FetchTiles(BoundingBox boundingBox, double resolution) { var extent = new Extent(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Max.X, boundingBox.Max.Y); int level = BruTile.Utilities.GetNearestLevel(source.Schema.Resolutions, resolution); var infos = source.Schema.GetTilesInView(extent, level).ToList(); ICollection <WaitHandle> waitHandles = new List <WaitHandle>(); foreach (TileInfo info in infos) { if (bitmaps.Find(info.Index) != null) { continue; } if (queue.Contains(info.Index)) { continue; } var waitHandle = new AutoResetEvent(false); waitHandles.Add(waitHandle); queue.Add(info.Index); ThreadPool.QueueUserWorkItem(GetTileOnThread, new object[] { source.Provider, info, bitmaps, waitHandle }); } foreach (WaitHandle handle in waitHandles) { handle.WaitOne(); } IFeatures features = new Features(); foreach (TileInfo info in infos) { byte[] bitmap = bitmaps.Find(info.Index); if (bitmap == null) { continue; } IRaster raster = new Raster(new MemoryStream(bitmap), new BoundingBox(info.Extent.MinX, info.Extent.MinY, info.Extent.MaxX, info.Extent.MaxY)); IFeature feature = features.New(); feature.Geometry = raster; features.Add(feature); } return(features); }
public static IEnumerable<IFeature> DataSetToFeatures(FeatureDataSet dataSet) { var features = new Features(); foreach (FeatureDataTable table in dataSet.Tables) { foreach (FeatureDataRow row in table) { IFeature feature = features.New(); feature.Geometry = row.Geometry; foreach (DataColumn column in table.Columns) feature[column.ColumnName] = row[column.ColumnName]; features.Add(feature); } } return features; }
public IEnumerable <IFeature> FetchTiles(BoundingBox boundingBox, double resolution) { var extent = new Extent(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Max.X, boundingBox.Max.Y); var levelId = BruTile.Utilities.GetNearestLevel(_source.Schema.Resolutions, resolution); var infos = _source.Schema.GetTileInfos(extent, levelId).ToList(); ICollection <WaitHandle> waitHandles = new List <WaitHandle>(); foreach (TileInfo info in infos) { if (_bitmaps.Find(info.Index) != null) { continue; } if (_queue.Contains(info.Index)) { continue; } var waitHandle = new AutoResetEvent(false); waitHandles.Add(waitHandle); _queue.Add(info.Index); Task.Run(() => GetTileOnThread(new object[] { _source, info, _bitmaps, waitHandle })); } WaitHandle.WaitAll(waitHandles.ToArray()); IFeatures features = new Features(); foreach (TileInfo info in infos) { byte[] bitmap = _bitmaps.Find(info.Index); if (bitmap == null) { continue; } IRaster raster = new Raster(new MemoryStream(bitmap), new BoundingBox(info.Extent.MinX, info.Extent.MinY, info.Extent.MaxX, info.Extent.MaxY)); IFeature feature = features.New(); feature.Geometry = raster; features.Add(feature); } return(features); }
public static IEnumerable <IFeature> DataSetToFeatures(FeatureDataSet dataSet) { var features = new Features(); foreach (FeatureDataTable table in dataSet.Tables) { foreach (FeatureDataRow row in table) { IFeature feature = features.New(); feature.Geometry = row.Geometry; foreach (DataColumn column in table.Columns) { feature[column.ColumnName] = row[column.ColumnName]; } features.Add(feature); } } return(features); }
private static ILayer CreateMutatingTriangleLayer(BoundingBox envelope) { var layer = new MemoryLayer(); var polygon = new Polygon(new LinearRing(GenerateRandomPoints(envelope, 3))); var feature = new Feature() { Geometry = polygon }; var features = new Features(); features.Add(feature); layer.DataSource = new MemoryProvider(features); PeriodicTask.Run(() => { polygon.ExteriorRing = new LinearRing(GenerateRandomPoints(envelope, 3)); // Clear cache for change to show feature.RenderedGeometry.Clear(); // Trigger DataChanged notification layer.ViewChanged(true, layer.Envelope, 1); }, TimeSpan.FromMilliseconds(1000)); return layer; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometries">Set of geometries that this datasource should contain</param> public MemoryProvider(IEnumerable<IGeometry> geometries) { CRS = ""; Features = new Features(); foreach (IGeometry geometry in geometries) { IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); } }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometry">Geometry to be in this datasource</param> public MemoryProvider(Geometry geometry) { CRS = ""; Features = new Features(); IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); SymbolSize = 64; }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="features">Features to be included in this datasource</param> public MemoryProvider(IEnumerable<IFeature> features) { CRS = ""; Features = new Features(); foreach (var feature in features) Features.Add(feature); }
private MemoryProvider CreateRandomPointsProvider() { var randomPoints = PointLayerSample.GenerateRandomPoints(MapControl.Map.Envelope, 100); var features = new Features(); var count = 0; foreach (var point in randomPoints) { var feature = new Feature { Geometry = point }; feature["Label"] = count.ToString(CultureInfo.InvariantCulture); features.Add(feature); count++; } return new MemoryProvider(features); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="feature">Feature to be in this datasource</param> public MemoryProvider(IFeature feature) { SRID = -1; Features = new Features(); Features.Add(feature); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="geometry">Geometry to be in this datasource</param> public MemoryProvider(Geometry geometry) { SRID = -1; Features = new Features(); IFeature feature = Features.New(); feature.Geometry = geometry; Features.Add(feature); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryProvider"/> /// </summary> /// <param name="feature">Feature to be in this datasource</param> public MemoryProvider(IFeature feature) { SRID = -1; Features = new Features(); Features.Add(feature); }
public IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution) { lock (_syncRoot) { Open(); try { //Use the spatial index to get a list of features whose boundingbox intersects bbox var objectlist = GetObjectIDsInView(box); var features = new Features(); foreach (var index in objectlist) { var feature = _dbaseFile != null ? _dbaseFile.GetFeature(index, features) : new Feature(); feature.Geometry = ReadGeometry(index); if (feature.Geometry == null) continue; if (!feature.Geometry.GetBoundingBox().Intersects(box)) continue; if (FilterDelegate != null && !FilterDelegate(feature)) continue; features.Add(feature); } return features; } finally { Close(); } } }
public IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution) { //Use the spatial index to get a list of features whose boundingbox intersects bbox Collection<uint> objectlist = GetObjectIDsInView(box); IFeatures features = new Features(); foreach (uint index in objectlist) { IFeature feature = dbaseFile.GetFeature(index, features); feature.Geometry = ReadGeometry(index); if (feature.Geometry != null) if (feature.Geometry.GetBoundingBox().Intersects(box)) if (FilterDelegate == null || FilterDelegate(feature)) features.Add(feature); } return features; }