阅读:1202回复:0
如何实现车子移动?
网上有如下代码,用于gps车子移动的,它用的是OffsetByXY,如果我直接输入经纬度实现车子移动,应怎样改写?<BR>Catalog cat = MapInfo.Engine.Session.Current.Catalog;<BR> Table tbl = cat.GetTable("Animation");<BR> <BR> if (tbl != null) <BR> {<BR> //Update the position of the points<BR> SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("Name = 'Kelly'");<BR> Feature ftr = cat.SearchForFeature(tbl, si);<BR> SearchInfo si2 = MapInfo.Data.SearchInfoFactory.SearchWhere("Name = 'Greg'");<BR> Feature ftr2 = cat.SearchForFeature(tbl, si2);<BR> <BR> <BR>
<br> <P><BR> if (DateTime.Now.TimeOfDay.Seconds % 4 == 0)<BR> {<BR> ftr.Geometry.GeometryEditor.OffsetByXY(120.297919-ftr.Geometry.GeometricCentroid.x, 31.573062-ftr.Geometry.GeometricCentroid.y, DistanceUnit.Kilometer, DistanceType.Spherical);<BR> ftr2.Geometry.GeometryEditor.OffsetByXY(0, 25, DistanceUnit.Mile, DistanceType.Spherical);<BR> }<BR> else<BR> {<BR> ftr.Geometry.GeometryEditor.OffsetByXY(-10, 0, DistanceUnit.Mile, DistanceType.Spherical);<BR> ftr2.Geometry.GeometryEditor.OffsetByXY(10, 5, DistanceUnit.Mile, DistanceType.Spherical);<BR> }<BR> <BR> ftr.Geometry.EditingComplete();<BR> ftr2.Geometry.EditingComplete();<BR> ftr.Update();<BR> ftr2.Update();<BR> }</P> |
|