/// <summary> /// Creates ShapePageSet.Enumerator which can be used to cycle very large datasets. /// </summary> /// <param name="parent"></param> public Enumerator(ShapeReader parent) { _source = parent._source; _pageSize = parent.PageSize; _envelope = parent.Envelope; Reset(); }
/// <summary> /// Update header extents from the geometries in a IShapeSource /// </summary> /// <param name="src"></param> protected void UpdateExtents(IShapeSource src) { var sr = new ShapeReader(src); Extent env = null; foreach (var page in sr) { foreach (var shape in page) { Extent shapeExtent = shape.Value.Range.Extent; if (env == null) { env = (Extent)shapeExtent.Clone(); } else { env.ExpandToInclude(shapeExtent); } } } // Extents for an empty file are unspecified according to the specification, so do nothing if (null == env) { return; } var sh = new ShapefileHeader(Filename); sh.SetExtent(env); sh.Save(); }
private static void SelectShape(ISelectShape action, IShapeSource shapeSource, bool undo) { switch (action.Type) { case SelectType.Deselect: if (undo) { shapeSource.Select(action.ShapeIndex); } else { shapeSource.Deselect(); } break; case SelectType.Select: if (undo) { shapeSource.Deselect(); } else { shapeSource.Select(action.ShapeIndex); } break; default: break; } }
/// <summary> /// Select the features in an IShapeSource /// </summary> /// <param name="sr"></param> /// <param name="filterExpression"></param> /// <param name="envelope"></param> /// <param name="startIndex"></param> /// <param name="maxCount"></param> /// <returns></returns> protected IFeatureSet Select(IShapeSource sr, string filterExpression, Envelope envelope, ref int startIndex, int maxCount) { var shapes = sr.GetShapes(ref startIndex, maxCount, envelope); AttributeTable at = GetAttributeTable(Filename); var result = new FeatureSet(FeatureType.Polygon); bool schemaDefined = false; foreach (var pair in shapes) { DataTable td = at.SupplyPageOfData(pair.Key, 1); if (td.Select(filterExpression).Length > 0) { if (!schemaDefined) { schemaDefined = true; result.CopyTableSchema(td); } var f = new Feature(pair.Value) { RecordNumber = pair.Key + 1, DataRow = td.Rows[0] }; result.Features.Add(f); f.UpdateEnvelope(); } } return(result); }
public static SurfaceStoreData CreateStoreData( IShapeSurface surface) { SurfaceStoreData result = new SurfaceStoreData(); IShapeSource src = surface.Source; // save the last ghost surface.NewGhost(ShapeType.None); result._picture = src.Background; result._size = src.Size; if (!src.NamedHatchStyle.IsEmpty) { result._namedHatchStyle = (NamedHatchStylesForXmlSerialize)src.NamedHatchStyle; } if (!src.NamedTextureStyle.IsEmpty) { result._namedTextureStyle = (NamedTextureStylesForXmlSerialize)src.NamedTextureStyle; } IList <IShape> shapes = src.Shapes; if (shapes != null && shapes.Count > 0) { result._shapes = new ShapeForXmlSerialize[shapes.Count]; for (int i = 0; i < shapes.Count; i++) { result._shapes[i] = new ShapeForXmlSerialize(shapes[i]); } } return(result); }
/// <summary> /// Creates ShapePageSet.Enumerator which can be used to cycle very large datasets. /// </summary> /// <param name="parent"></param> public Enumerator(ShapeReader parent) { _source = parent._source; _count = -1; _index = -1; _pageSize = parent.PageSize; _envelope = parent.Envelope; }
private void UnbindSource(IShapeSource source) { if (source != null) { source.CurrentChanged -= new EventHandler(source_CurrentChanged); source.Loading -= new EventHandler(source_Loading); source.Loaded -= new EventHandler(source_Loaded); source.GhostChanged -= new EventHandler(source_GhostChanged); } }
private static void NewShape(INewShape action, IShapeSource shapeSource, bool undo) { if (undo) { shapeSource.Remove(); } else { shapeSource.Add(action.Data); } }
private static void ModifyShape(IModifyShape action, IShapeSource shapeSource, bool undo) { if (undo) { shapeSource.Modify(action.ShapeIndex, action.OldData); } else { shapeSource.Modify(action.ShapeIndex, action.NewData); } }
private static void CreateGhost(ICreateGhost action, IShapeSource shapeSource, bool undo) { if (undo) { shapeSource.ResetGhost(); } else { shapeSource.SetNewShape(action.Data); } }
private static void DeleteShape(IDeleteShape action, IShapeSource shapeSource, bool undo) { if (undo) { shapeSource.Enable(action.ShapeIndex); } else { shapeSource.Disable(action.ShapeIndex); } }
public TextEditorForm(IShapeSource layer) { m_layer = layer; m_box = new TextBox(); FontSize = 12; m_box.Multiline = true; m_box.ScrollBars = ScrollBars.Both; m_box.BorderStyle = BorderStyle.FixedSingle; m_box.Dock = DockStyle.Fill; FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; Controls.Add(m_box); }
/// <summary> /// Conditionally modify attributes as searched in a single pass via client supplied callback. /// </summary> /// <param name="sr">ShapeSource for this feature source</param> /// <param name="envelope">The envelope for vector filtering.</param> /// <param name="chunkSize">Number of shapes to request from the ShapeSource in each chunk</param> /// <param name="featureEditCallback">Callback on each feature</param> protected void SearchAndModifyAttributes(IShapeSource sr, Envelope envelope, int chunkSize, FeatureSourceRowEditEvent featureEditCallback) { var samp = new ShapefileFeatureSourceSearchAndModifyAttributeParameters(featureEditCallback); AttributeTable at = null; int startIndex = 0; do { samp.CurrentSearchAndModifyAttributeshapes = sr.GetShapes(ref startIndex, chunkSize, envelope); if (samp.CurrentSearchAndModifyAttributeshapes.Count > 0) { if (null == at) { at = GetAttributeTable(Filename); } at.Edit(samp.CurrentSearchAndModifyAttributeshapes.Keys, samp.OnRowEditEvent); } } while (samp.CurrentSearchAndModifyAttributeshapes.Count == chunkSize); }
public static void Execute(IAction action, IShapeSource shapeSource, bool undo) { if (action == null) { throw new ArgumentNullException("action"); } if (shapeSource == null) { throw new ArgumentNullException("shapeSource"); } switch (action.Action) { case ActionType.NewShape: NewShape(action as INewShape, shapeSource, undo); break; case ActionType.ModifyShape: ModifyShape(action as IModifyShape, shapeSource, undo); break; case ActionType.SelectShape: SelectShape(action as ISelectShape, shapeSource, undo); break; case ActionType.DeleteShape: DeleteShape(action as IDeleteShape, shapeSource, undo); break; case ActionType.CreateGhost: CreateGhost(action as ICreateGhost, shapeSource, undo); break; default: throw new NotSupportedException("action = " + action.Action.ToString()); } }
public ShapeSelector(IShapeSource source) { _source = source; }
/// <summary> /// Update header extents from the geometries in a IShapeSource /// </summary> /// <param name="src"></param> protected void UpdateExtents(IShapeSource src) { var sr = new ShapeReader(src); Extent env = null; foreach (var page in sr) { foreach (var shape in page) { Extent shapeExtent = shape.Value.Range.Extent; if (env == null) { env = (Extent)shapeExtent.Clone(); } else { env.ExpandToInclude(shapeExtent); } } } // Extents for an empty file are unspecified according to the specification, so do nothing if (null == env) return; var sh = new ShapefileHeader(Filename); sh.SetExtent(env); sh.Save(); }
/// <summary> /// Select the features in an IShapeSource /// </summary> /// <param name="sr"></param> /// <param name="filterExpression"></param> /// <param name="envelope"></param> /// <param name="startIndex"></param> /// <param name="maxCount"></param> /// <returns></returns> protected IFeatureSet Select(IShapeSource sr, string filterExpression, IEnvelope envelope, ref int startIndex, int maxCount) { var shapes = sr.GetShapes(ref startIndex, maxCount, envelope); AttributeTable at = GetAttributeTable(Filename); var result = new FeatureSet(FeatureType.Polygon); bool schemaDefined = false; foreach (var pair in shapes) { DataTable td = at.SupplyPageOfData(pair.Key, 1); if (td.Select(filterExpression).Length > 0) { if (!schemaDefined) { schemaDefined = true; result.CopyTableSchema(td); } var f = new Feature(pair.Value) {RecordNumber = pair.Key + 1, DataRow = td.Rows[0]}; result.Features.Add(f); f.UpdateEnvelope(); } } return result; }
/// <summary> /// Conditionally modify attributes as searched in a single pass via client supplied callback. /// </summary> /// <param name="sr">ShapeSource for this feature source</param> /// <param name="envelope">The envelope for vector filtering.</param> /// <param name="chunkSize">Number of shapes to request from the ShapeSource in each chunk</param> /// <param name="featureEditCallback">Callback on each feature</param> protected void SearchAndModifyAttributes(IShapeSource sr, IEnvelope envelope, int chunkSize, FeatureSourceRowEditEvent featureEditCallback) { var samp = new ShapefileFeatureSourceSearchAndModifyAttributeParameters(featureEditCallback); AttributeTable at = null; int startIndex = 0; do { samp.CurrentSearchAndModifyAttributeshapes = sr.GetShapes(ref startIndex, chunkSize, envelope); if (samp.CurrentSearchAndModifyAttributeshapes.Count > 0) { if (null == at) at = GetAttributeTable(Filename); at.Edit(samp.CurrentSearchAndModifyAttributeshapes.Keys, samp.OnRowEditEvent); } } while (samp.CurrentSearchAndModifyAttributeshapes.Count == chunkSize); }
/// <summary> /// Creates a new reader class for paging through a shape source. /// </summary> /// <param name="source">The IShapeSource to cycle through.</param> public ShapeReader(IShapeSource source) { _source = source; PageSize = 50000; }
public ActionBuilder(IShapeSource source) { _source = source; }