本文整理汇总了C#中DotSpatial.Topology.Envelope.ExpandToInclude方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.ExpandToInclude方法的具体用法?C# Envelope.ExpandToInclude怎么用?C# Envelope.ExpandToInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotSpatial.Topology.Envelope
的用法示例。
在下文中一共展示了Envelope.ExpandToInclude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveRegion
/// <summary>
/// Tests each member currently in the selected features based on
/// the SelectionMode. If it passes, it will remove the feature from
/// the selection.
/// </summary>
/// <param name="region">The geographic region to remove</param>
/// <param name="affectedArea">A geographic area that was affected by this change.</param>
/// <returns>Boolean, true if the collection was changed</returns>
public bool RemoveRegion(IEnvelope region, out IEnvelope affectedArea)
{
SuspendChanges();
bool removed = false;
affectedArea = new Envelope();
var query = from pair in _filter.DrawnStates
where pair.Value.IsSelected
select pair.Key;
List<IFeature> selectedFeatures = query.ToList();
foreach (IFeature f in selectedFeatures)
{
bool doRemove = false;
if (_selectionMode == SelectionMode.IntersectsExtent)
{
if (region.Intersects(f.Envelope))
{
if (Remove(f))
{
removed = true;
affectedArea.ExpandToInclude(f.Envelope);
}
}
}
else if (_selectionMode == SelectionMode.ContainsExtent)
{
if (region.Contains(f.Envelope))
{
if (Remove(f))
{
removed = true;
affectedArea.ExpandToInclude(f.Envelope);
}
}
}
IPolygon reg = region.ToPolygon();
IGeometry geom = Geometry.FromBasicGeometry(f.BasicGeometry);
switch (_selectionMode)
{
case SelectionMode.Contains:
if (region.Intersects(f.Envelope))
{
if (reg.Contains(geom)) doRemove = true;
}
break;
case SelectionMode.CoveredBy:
if (reg.CoveredBy(geom)) doRemove = true;
break;
case SelectionMode.Covers:
if (reg.Covers(geom)) doRemove = true;
break;
case SelectionMode.Disjoint:
if (reg.Disjoint(geom)) doRemove = true;
break;
case SelectionMode.Intersects:
if (region.Intersects(f.Envelope))
{
if (reg.Intersects(geom)) doRemove = true;
}
break;
case SelectionMode.Overlaps:
if (reg.Overlaps(geom)) doRemove = true;
break;
case SelectionMode.Touches:
if (reg.Touches(geom)) doRemove = true;
break;
case SelectionMode.Within:
if (reg.Within(geom)) doRemove = true;
break;
}
if (doRemove)
{
if (Remove(f))
{
affectedArea.ExpandToInclude(f.Envelope);
removed = true;
}
}
}
ResumeChanges();
return removed;
}
示例2: GetEnvelope
private IEnvelope GetEnvelope()
{
IEnvelope env = new Envelope();
foreach (IFeature f in this)
{
env.ExpandToInclude(f.Envelope);
}
return env;
}
示例3: AddRegion
/// <summary>
/// This uses extent checking (rather than full polygon intersection checking). It will add
/// any members that are either contained by or intersect with the specified region
/// depending on the SelectionMode property. The order of operation is the region
/// acting on the feature, so Contains, for instance, would work with points.
/// </summary>
/// <param name="region"></param>
/// <param name="affectedArea">The affected area of this addition</param>
/// <returns>True if any item was actually added to the collection</returns>
public bool AddRegion(IEnvelope region, out IEnvelope affectedArea)
{
bool added = false;
SuspendChanges();
affectedArea = new Envelope();
Stopwatch sw = new Stopwatch();
Stopwatch total = new Stopwatch();
total.Start();
foreach (IFeature f in FeatureList)
{
bool doAdd = false;
if (_selectionMode == SelectionMode.IntersectsExtent)
{
if (region.Intersects(f.Envelope))
{
Add(f);
affectedArea.ExpandToInclude(f.Envelope);
added = true;
}
}
else if (_selectionMode == SelectionMode.ContainsExtent)
{
if (region.Contains(f.Envelope))
{
Add(f);
affectedArea.ExpandToInclude(f.Envelope);
added = true;
}
}
IGeometry reg;
if (region.Width == 0 && region.Height == 0)
{
reg = new Point(region.X, region.Y);
}
else if (region.Height == 0 || region.Width == 0)
{
Coordinate[] coords = new Coordinate[2];
coords[0] = new Coordinate(region.X, region.Y);
coords[1] = new Coordinate(region.Bottom(), region.Right());
reg = new LineString(coords);
}
else
{
reg = region.ToPolygon();
}
IGeometry geom = Geometry.FromBasicGeometry(f.BasicGeometry);
switch (_selectionMode)
{
case SelectionMode.Contains:
if (region.Contains(f.Envelope))
{
doAdd = true;
}
else if (region.Intersects(f.Envelope))
{
if (reg.Contains(geom)) doAdd = true;
}
break;
case SelectionMode.CoveredBy:
if (reg.CoveredBy(geom)) doAdd = true;
break;
case SelectionMode.Covers:
if (reg.Covers(geom)) doAdd = true;
break;
case SelectionMode.Disjoint:
if (reg.Disjoint(geom)) doAdd = true;
break;
case SelectionMode.Intersects:
if (region.Contains(f.Envelope))
{
doAdd = true;
}
else if (region.Intersects(f.Envelope))
{
if (reg.Intersects(geom)) doAdd = true;
}
break;
case SelectionMode.Overlaps:
if (reg.Overlaps(geom)) doAdd = true;
break;
case SelectionMode.Touches:
if (reg.Touches(geom)) doAdd = true;
break;
case SelectionMode.Within:
if (reg.Within(geom)) doAdd = true;
break;
}
//.........这里部分代码省略.........
示例4: InvertSelection
/// <summary>
/// Inverts the selection based on the current SelectionMode
/// </summary>
/// <param name="region">The geographic region to reverse the selected state</param>
/// <param name="affectedArea">The affected area to invert</param>
public bool InvertSelection(IEnvelope region, out IEnvelope affectedArea)
{
SuspendChanges();
bool flipped = false;
affectedArea = new Envelope();
IDictionary<IFeature, IDrawnState> states = Filter.DrawnStates;
foreach (KeyValuePair<IFeature, IDrawnState> kvp in states)
{
bool doFlip = false;
IFeature f = kvp.Key;
if (SelectionMode == SelectionMode.IntersectsExtent)
{
if (region.Intersects(f.Envelope))
{
kvp.Value.IsSelected = !kvp.Value.IsSelected;
affectedArea.ExpandToInclude(f.Envelope);
}
}
else if (SelectionMode == SelectionMode.ContainsExtent)
{
if (region.Contains(f.Envelope))
{
kvp.Value.IsSelected = !kvp.Value.IsSelected;
affectedArea.ExpandToInclude(f.Envelope);
}
}
IPolygon reg = region.ToPolygon();
IGeometry geom = Geometry.FromBasicGeometry(f.BasicGeometry);
switch (SelectionMode)
{
case SelectionMode.Contains:
if (region.Intersects(f.Envelope))
{
if (reg.Contains(geom)) doFlip = true;
}
break;
case SelectionMode.CoveredBy:
if (reg.CoveredBy(geom)) doFlip = true;
break;
case SelectionMode.Covers:
if (reg.Covers(geom)) doFlip = true;
break;
case SelectionMode.Disjoint:
if (reg.Disjoint(geom)) doFlip = true;
break;
case SelectionMode.Intersects:
if (region.Intersects(f.Envelope))
{
if (reg.Intersects(geom)) doFlip = true;
}
break;
case SelectionMode.Overlaps:
if (reg.Overlaps(geom)) doFlip = true;
break;
case SelectionMode.Touches:
if (reg.Touches(geom)) doFlip = true;
break;
case SelectionMode.Within:
if (reg.Within(geom)) doFlip = true;
break;
}
if (doFlip)
{
flipped = true;
kvp.Value.IsSelected = !kvp.Value.IsSelected;
affectedArea.ExpandToInclude(f.Envelope);
}
}
ResumeChanges();
return flipped;
}
示例5: UnSelect
/// <inheritdoc />
public override bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionMode mode, out IEnvelope affectedArea)
{
affectedArea = new Envelope();
if (!_selectionEnabled) return false;
bool somethingChanged = false;
SuspendEvents();
foreach (ILayer s in GetLayers())
{
IEnvelope layerArea;
if (s.UnSelect(tolerant, strict, mode, out layerArea)) somethingChanged = true;
affectedArea.ExpandToInclude(layerArea);
}
ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
示例6: ComputeEnvelopeInternal
/// <summary>
///
/// </summary>
/// <returns></returns>
protected override IEnvelope ComputeEnvelopeInternal()
{
Envelope envelope = new Envelope();
for (int i = 0; i < _geometries.Length; i++)
envelope.ExpandToInclude(_geometries[i].EnvelopeInternal);
return envelope;
}
示例7: ClearSelection
/// <inheritdoc />
public override bool ClearSelection(out IEnvelope affectedAreas)
{
affectedAreas = new Envelope();
bool changed = false;
if (!_selectionEnabled) return false;
MapFrame.SuspendEvents();
foreach (ILayer layer in GetLayers())
{
IEnvelope layerArea;
if (layer.ClearSelection(out layerArea)) changed = true;
affectedAreas.ExpandToInclude(layerArea);
}
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return changed;
}
示例8: Select
/// <inheritdoc />
public override bool Select(IEnvelope tolerant, IEnvelope strict, SelectionMode mode, out IEnvelope affectedArea)
{
affectedArea = new Envelope();
if (!_selectionEnabled) return false;
bool somethingChanged = false;
MapFrame.SuspendEvents();
List<ILayer> layers = (List<ILayer>)GetLayers();
layers.Reverse();
foreach (ILayer s in layers)
{
if (s.SelectionEnabled == false) continue;
if (s.IsVisible == false) continue;
IEnvelope layerArea;
if (s.Select(tolerant, strict, mode, out layerArea)) somethingChanged = true;
affectedArea.ExpandToInclude(layerArea);
if (somethingChanged == true)
{
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
}
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
示例9: Select
/// <inheritdoc />
public override bool Select(IEnvelope tolerant, IEnvelope strict, SelectionMode mode, out IEnvelope affectedArea)
{
affectedArea = new Envelope();
if (!_selectionEnabled) return false;
bool somethingChanged = false;
MapFrame.SuspendEvents();
foreach (var s in GetLayers()
.Reverse()
.Where(_ => _.SelectionEnabled && _.IsVisible))
{
IEnvelope layerArea;
if (s.Select(tolerant, strict, mode, out layerArea)) somethingChanged = true;
affectedArea.ExpandToInclude(layerArea);
if (somethingChanged)
{
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
}
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
示例10: LoadFeatureFromGeomProperty
private void LoadFeatureFromGeomProperty(DbSet dbSet, PropertyInfo propertyGeom)
{
Envelope env = new Envelope();
IDataService dataService = ServiceLocator.Current.GetInstance<IDataService>();
EntityTableInfo tableInfo = dataService.GetEntityTableInfo(dbSet.ElementType);
this.Lines.DataTable = this.CreateDataTable(dbSet.ElementType);
this.Points.DataTable = this.CreateDataTable(dbSet.ElementType);
this.Polygons.DataTable = this.CreateDataTable(dbSet.ElementType);
PropertyInfo propertyId = dbSet.ElementType.GetProperty("Id");
foreach (Object obj in dbSet)
{
Object data = propertyGeom.GetValue(obj);
if (data != null)
{
String strData = data.ToString();
Geometry geometry = this.CreateGeometryFromWkt(strData);
if (geometry != null)
{
env.ExpandToInclude(geometry.Envelope);
if (geometry is LineString || geometry is MultiLineString)
{
IFeature feature = this.Lines.AddFeature(geometry);
System.Data.DataRow row = this.Lines.DataTable.NewRow();
row.BeginEdit();
row["Id"] = (Int64)propertyId.GetValue(obj);
this.Lines.DataTable.Rows.Add(row);
feature.DataRow = row;
row.EndEdit();
}
else if (geometry is Point)
{
IFeature feature = this.Points.AddFeature(geometry);
System.Data.DataRow row = this.Points.DataTable.NewRow();
row.BeginEdit();
row["Id"] = (Int64)propertyId.GetValue(obj);
this.Points.DataTable.Rows.Add(row);
feature.DataRow = row;
row.EndEdit();
}
else if (geometry is Polygon)
{
IFeature feature = this.Polygons.AddFeature(geometry);
System.Data.DataRow row = this.Polygons.DataTable.NewRow();
row.BeginEdit();
row["Id"] = (Int64)propertyId.GetValue(obj);
this.Polygons.DataTable.Rows.Add(row);
feature.DataRow = row;
row.EndEdit();
}
}
}
}
this.Extent = env.ToExtent();
}
示例11: Select
/// <inheritdoc />
public override bool Select(IEnvelope tolerant, IEnvelope strict, SelectionMode mode, out IEnvelope affectedArea)
{
affectedArea = new Envelope();
if (!_selectionEnabled) return false;
bool somethingChanged = false;
MapFrame.SuspendEvents();
foreach (var s in GetLayers()
.Reverse()
.Where(_ => _.SelectionEnabled && _.IsVisible))
{
IEnvelope layerArea;
if (s.Select(tolerant, strict, mode, out layerArea)) somethingChanged = true;
affectedArea.ExpandToInclude(layerArea);
// removed by jany_: this selected only features of the first layer with features in the selected area, if user wanted to select features of another layer too they get ignored
// added SelectPlugin enables user to choose the layers in which he wants to select features
//if (somethingChanged)
//{
// MapFrame.ResumeEvents();
// OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
// return somethingChanged;
//}
}
MapFrame.ResumeEvents();
OnSelectionChanged(); // fires only AFTER the individual layers have fired their events.
return somethingChanged;
}
示例12: UpdateHeader
/// <summary>
/// Update the header to include the feature extent
/// </summary>
/// <param name="header"></param>
/// <param name="feature"></param>
/// <param name="writeHeaderFiles"> </param>
protected void UpdateHeader(ShapefileHeader header, IBasicGeometry feature, bool writeHeaderFiles)
{
// Update the envelope
IEnvelope newExt;
// First, check to see if there are no features (ShxLength == 50)
if (header.ShxLength <= 50)
{
// This is the lone feature, so just set the extent to the feature extent
newExt = feature.Envelope;
}
else
{
// Other features, so include new feature
newExt = new Envelope(header.Xmin, header.Xmax, header.Ymin, header.Ymax, header.Zmin, header.Zmax);
newExt.ExpandToInclude(feature.Envelope);
}
header.Xmin = newExt.Minimum.X;
header.Ymin = newExt.Minimum.Y;
header.Zmin = newExt.Minimum.Z;
header.Xmax = newExt.Maximum.X;
header.Ymax = newExt.Maximum.Y;
header.Zmax = newExt.Maximum.Z;
header.ShxLength = header.ShxLength + 4;
if (writeHeaderFiles)
{
WriteHeader(header, Filename);
WriteHeader(header, header.ShxFilename);
}
}
示例13: CreateLayers
internal void CreateLayers()
{
Envelope env = new Envelope();
if (this.Model.SigLayer != null)
{
if (this.Model.SigLayer.SigCodeLayer.Code == "Geocodage")
{
FeatureSet featureSetPoint = new FeatureSet(FeatureType.Point);
featureSetPoint.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
PointSymbolizer featureSetPointSymbolizer = new PointSymbolizer(System.Drawing.Color.Red, DotSpatial.Symbology.PointShape.Ellipse, 10);
FeatureSet featureSetLine = new FeatureSet(FeatureType.Line);
featureSetLine.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
IDataService dataService = ServiceLocator.Current.GetInstance<IDataService>();
ICartoService cartoService = ServiceLocator.Current.GetInstance<ICartoService>();
EntityTableInfo tableInfo = dataService.GetEntityTableInfo(this.Model.SigLayer.EntityName);
IQueryable queryable = dataService.GetDbSet(tableInfo.EntityType).AsQueryable();
EntityColumnInfo columnGeom = (from c in tableInfo.ColumnInfos where c.IsLocalisationReferenceGeom select c).FirstOrDefault();
EntityColumnInfo columnRef = (from c in tableInfo.ColumnInfos where c.IsLocalisationReferenceId select c).FirstOrDefault();
EntityColumnInfo columnDeb = (from c in tableInfo.ColumnInfos where c.IsLocalisationDeb select c).FirstOrDefault();
EntityColumnInfo columnFin = (from c in tableInfo.ColumnInfos where c.IsLocalisationFin select c).FirstOrDefault();
foreach (Object item in queryable)
{
Geometry geometry = null;
if (columnGeom != null)
{
Object dataGeom = columnGeom.Property.GetValue(item);
if (dataGeom != null)
{geometry = WktHelper.CreateGeometryFromWkt(dataGeom.ToString());}
}
if (geometry == null && columnRef != null && columnDeb != null)
{
Object objRef = columnRef.Property.GetValue(item);
Object objDeb = columnDeb.Property.GetValue(item);
if (columnFin == null)
{
if (objRef != null && objRef is Int64 && objDeb != null && objDeb is Int64)
{
geometry = cartoService.Geocode((Int64)objRef, (Int64)objDeb );
}
}
else
{
Object objFin = columnFin.Property.GetValue(item);
if (objRef != null && objRef is Int64 && objDeb != null && objDeb is Int64)
{
if (objFin != null && objFin is Int64)
{ geometry = cartoService.Geocode((Int64)objRef, (Int64)objDeb, (Int64)objFin); }
else
{ geometry = cartoService.Geocode((Int64)objRef, (Int64)objDeb); }
}
}
}
if (geometry != null)
{
if (geometry is Point)
{
featureSetPoint.AddFeature(geometry);
env.ExpandToInclude((geometry as Point).Coordinate);
}
else if (geometry is LineString)
{
featureSetLine.AddFeature(geometry);
env.ExpandToInclude(geometry.Envelope);
}
else if (geometry is MultiLineString )
{
featureSetLine.AddFeature(geometry);
env.ExpandToInclude(geometry.Envelope);
}
}
}
this.Layers.Add(new MapLineLayer(featureSetLine));
this.Layers.Add(new MapPointLayer(featureSetPoint));
}
}
this.Envelope = env;
}
示例14: ExpandEnv
private static void ExpandEnv(Envelope env, SqlGeometry geom)
{
for (int i = 0, c = geom.STNumPoints().Value; i < c; i++)
{
SqlGeometry geomPoint = geom.STPointN(i + 1);
env.ExpandToInclude(geomPoint.STX.Value, geomPoint.STY.Value);
}
}
示例15: LoadTemplate
private void LoadTemplate(TemplateViewModel template)
{
template.Nodes.Clear();
this.Map.Layers.Clear();
DbSet<SigNode> nodeSet = this.DataService.GetDbSet<SigNode>();
List<TemplateNodeLayerViewModel> layersNodes = new List<TemplateNodeLayerViewModel>();
this.RecurseLoadTemplate(nodeSet, template, template.Nodes, -1, layersNodes);
Envelope env = new Envelope();
layersNodes = (from ln in layersNodes where ln.Model.SigLayer != null orderby ln.Model.SigLayer.MapOrder select ln).ToList();
foreach (TemplateNodeLayerViewModel layersNode in layersNodes)
{
layersNode.CreateLayers();
if (layersNode.Envelope != null)
{ env.ExpandToInclude(layersNode.Envelope); }
foreach (IMapLayer mapLayer in layersNode.Layers)
{
this.Map.Layers.Add(mapLayer);
}
}
this.Map.ViewExtents = env.ToExtent();
}