public Feature[] GetFeatures(Envelope envelope) { if (_features == null) { return(null); } if (envelope == null) { return(null); } Envelope validExtent = _envelope.IntersectWith(envelope); if (validExtent == null) { return(null); } List <Feature> retFets = new List <Feature>(); foreach (Feature fet in _features) { if (validExtent.Contains(fet.Geometry.Envelope)) { retFets.Add(fet); } else { if (fet.Geometry.Envelope.IsInteractived(validExtent)) { retFets.Add(fet); fet.IsRepeatedOverGrids = true; } } } return(retFets.Count > 0 ? retFets.ToArray() : null); }
public Feature[] GetFeatures_NEW(Envelope envelope) { lock (lockObject) { if (envelope == null) { return(null); } if (_features == null && _featureCount == -1) { ReadRecords(null); } Envelope validExtent = _envelope.IntersectWith(envelope); if (validExtent == null) { return(null); } List <Feature> retFets = new List <Feature>(); FetchFeatures((fet) => { if (validExtent.Contains(fet.Geometry.Envelope)) { retFets.Add(fet); } else { if (fet.Geometry.Envelope.IsInteractived(validExtent)) { retFets.Add(fet); fet.IsRepeatedOverGrids = true; } } } ); if (_argOfLeveling != null && _argOfLeveling.Enabled && _shapeType == enumShapeType.Point) { using (LevelAdjuster set = new LevelAdjuster()) { set.BeginLevel = _argOfLeveling.BeginLevel; set.GridSize = _argOfLeveling.GridSize; set.Features = retFets.ToArray(); set.Do(); } } return(retFets.Count > 0 ? retFets.ToArray() : null); } }
public override bool Contains(Shape geometry) { if (!Envelope.Contains(geometry.Envelope)) { return(false); } if (geometry is ShapePoint) { return(GeometryMathLib.IsPointInPolygon(geometry as ShapePoint, this)); } else if (geometry is ShapePolyline) { ShapePolyline line = geometry as ShapePolyline; foreach (ShapeLineString part in line.Parts) { foreach (ShapePoint pt in part.Points) { if (!GeometryMathLib.IsPointInPolygon(pt, this)) { return(false); } } } return(true); } else if (geometry is ShapePolygon) { ShapePolygon ply = geometry as ShapePolygon; foreach (ShapeRing ring in ply.Rings) { foreach (ShapePoint pt in ring.Points) { if (!GeometryMathLib.IsPointInPolygon(pt, this)) { return(false); } } } return(true); } return(false); }
private bool HitTestByPoint(ShapePoint shapePoint, double tolerance) { if (this is ShapePoint) { Envelope evp = Envelope.Clone() as Envelope; evp = evp.Expand((float)tolerance); return(evp.Contains(shapePoint.Envelope)); } else if (this is ShapePolyline) { return(GeometryMathLib.GetDistance(this as ShapePolyline, shapePoint) < tolerance); } else if (this is ShapePolygon) { return((this as ShapePolygon).Contains(shapePoint)); } else { throw new NotSupportedException("暂不支持对\"" + this.GetType().ToString() + "\"进行点击测试。"); } }
public Feature[] HitTestByPrj(Envelope prjRect) { ILayer[] lyrs = _map.LayerContainer.Layers; if (lyrs == null || lyrs.Length == 0) { return(null); } List <Feature> fets = new List <Feature>(); foreach (IFeatureLayer y in lyrs) { if (!(y is IFeatureLayer)) { continue; } if (!_map.LayerContainer.IsSelectable(y.Name)) { continue; } BaseFeatureRenderer r = y.Renderer as BaseFeatureRenderer; if (r._currentFeatureRects.Count > 0) { foreach (Feature fet in r._currentFeatureRects.Keys) { if (fet.Geometry == null) { continue; } if (prjRect.Contains(fet.Geometry.Envelope)) { fets.Add(fet); } } } } return(fets.Count > 0 ? fets.ToArray() : null); }