清除图层中的图元【原】
2008-08-04 15:55 Jeffery Tao 阅读(278) 评论(0) 收藏 举报
/// <summary>
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class ClearPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public ClearPinPointCommand()
{
Name = "ClearPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias
/// and This method delete the pin point features added by AddPinPointCommand in a given point
/// and then streams the image back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
System.Drawing.Point[] points = ExtractPoints(DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
PointDeletion(map, points[0]);
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
/// <summary>
/// Delete a feature in the temporary layer.
/// </summary>
/// <param name="mapAlias">MapAlias of the map</param>
/// <param name="point">Point in pixels</param>
private void PointDeletion(Map map, System.Drawing.Point point)
{
// Do the search and show selections
SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(map, point, 10);
(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog["kb"];
if (table != null)
{
IResultSetFeatureCollection ifc = MapInfo.Engine.Session.Current.Catalog.Search(table, si);
foreach (Feature f in ifc)
{
table.DeleteFeature(f);
}
ifc.Close();
}
}
}
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class ClearPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public ClearPinPointCommand()
{
Name = "ClearPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias
/// and This method delete the pin point features added by AddPinPointCommand in a given point
/// and then streams the image back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
System.Drawing.Point[] points = ExtractPoints(DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
PointDeletion(map, points[0]);
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
/// <summary>
/// Delete a feature in the temporary layer.
/// </summary>
/// <param name="mapAlias">MapAlias of the map</param>
/// <param name="point">Point in pixels</param>
private void PointDeletion(Map map, System.Drawing.Point point)
{
// Do the search and show selections
SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(map, point, 10);
(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog["kb"];
if (table != null)
{
IResultSetFeatureCollection ifc = MapInfo.Engine.Session.Current.Catalog.Search(table, si);
foreach (Feature f in ifc)
{
table.DeleteFeature(f);
}
ifc.Close();
}
}
}
浙公网安备 33010602011771号