许多网文谈到移动点有二种办法,一是删除后建立,二是通过前后点的偏移。
经过试验发现,可以采用更新坐标点的办法,实现点的移动,其他图元以此类推。(在MapXtreme 6.8下测试通过)
// 更新点,如果点不存在,则创建
public void UpdatePoint(string tableName, string ID, DPoint dPoint, short pCode, int pSize, Color color, string myLabel)
{
MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[mapControl1.Map.Alias];
FeatureLayer workLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[tableName + "层"];
MapInfo.Data.Table table = workLayer.Table;
FeatureGeometry point = new MapInfo.Geometry.Point(workLayer.CoordSys, dPoint);
SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("type='点' and index=" + "'" + ID + "'");
Feature feature = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(table, si);
if (feature == null)
{
SimpleVectorPointStyle spsPoint = new MapInfo.Styles.SimpleVectorPointStyle(pCode, color, pSize);
CompositeStyle pointStyle = new MapInfo.Styles.CompositeStyle(spsPoint);
Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
pointRow.Geometry = point;
pointRow.Style = pointStyle;
pointRow["type"] = "点";
pointRow["index"] = ID;
pointRow["value"] = myLabel;
table.InsertFeature(pointRow);
}
else
{
feature.Geometry = point;
feature["value"] = myLabel;
feature.Update();
}
}
浙公网安备 33010602011771号