本文整理汇总了C#中PointClass.QueryCoords方法的典型用法代码示例。如果您正苦于以下问题:C# PointClass.QueryCoords方法的具体用法?C# PointClass.QueryCoords怎么用?C# PointClass.QueryCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointClass
的用法示例。
在下文中一共展示了PointClass.QueryCoords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMapGraphicTrack
public static void CreateMapGraphicTrack(ICreateGraphicTrackOptions pOptions, IAGAnimationTracks tracks, IAGAnimationContainer pContainer)
{
pOptions.PathGeometry=SimplifyPath2D(pOptions.PathGeometry,pOptions.ReverseOrder,pOptions.SimplificationFactor);
IAGAnimationType animType = new AnimationTypeMapGraphic();
//remove tracks with the same name if overwrite is true
if (pOptions.OverwriteTrack == true)
{
IArray trackArray = new ArrayClass();
trackArray = tracks.get_TracksOfType(animType);
int count = trackArray.Count;
for (int i = 0; i < count; i++)
{
IAGAnimationTrack temp = (IAGAnimationTrack)trackArray.get_Element(i);
if (temp.Name == pOptions.TrackName)
tracks.RemoveTrack(temp);
}
}
//create the new track
IAGAnimationTrack animTrack = tracks.CreateTrack(animType);
IAGAnimationTrackKeyframes animTrackKeyframes = (IAGAnimationTrackKeyframes)animTrack;
animTrackKeyframes.EvenTimeStamps = false;
animTrack.Name = pOptions.TrackName;
IGeometry path = pOptions.PathGeometry;
IPointCollection pointCollection = (IPointCollection)path;
ICurve curve = (ICurve)path;
double length = curve.Length;
double accuLength = 0;
//loop through all points to create the keyframes
int pointCount = pointCollection.PointCount;
if (pointCount <= 1)
return;
for (int i = 0; i < pointCount; i++)
{
IPoint currentPoint = pointCollection.get_Point(i);
IPoint nextPoint = new PointClass();
if (i < pointCount-1)
nextPoint = pointCollection.get_Point(i + 1);
IPoint lastPoint = new PointClass();
if (i == 0)
lastPoint = currentPoint;
else
lastPoint = pointCollection.get_Point(i-1);
IAGKeyframe tempKeyframe = animTrackKeyframes.CreateKeyframe(i);
//set keyframe properties
double x;
double y;
currentPoint.QueryCoords(out x, out y);
tempKeyframe.set_PropertyValue(0, currentPoint);
tempKeyframe.Name = "Map Graphic keyframe " + i.ToString();
//set keyframe timestamp
accuLength += CalculateDistance(lastPoint, currentPoint);
double timeStamp = accuLength / length;
tempKeyframe.TimeStamp = timeStamp;
double x1;
double y1;
double angle;
if (i < pointCount - 1)
{
nextPoint.QueryCoords(out x1, out y1);
if ((y1 - y) > 0)
angle = Math.Acos((x1 - x) / Math.Sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)));
else
{
angle = 6.2832 - Math.Acos((x1 - x) / Math.Sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)));
}
tempKeyframe.set_PropertyValue(1, angle);
}
else
{
IAGKeyframe lastKeyframe = animTrackKeyframes.get_Keyframe(i-1);
tempKeyframe.set_PropertyValue(1, lastKeyframe.get_PropertyValue(1));
}
}
//attach the point element
if(pOptions.PointElement != null)
animTrack.AttachObject(pOptions.PointElement);
//attach the track extension, which contains a line element for trace
IMapGraphicTrackExtension graphicTrackExtension = new MapGraphicTrackExtension();
graphicTrackExtension.ShowTrace = pOptions.AnimatePath;
IAGAnimationTrackExtensions trackExtensions = (IAGAnimationTrackExtensions)animTrack;
trackExtensions.AddExtension(graphicTrackExtension);
}
示例2: SimplifyPath2D
private static IGeometry SimplifyPath2D(IGeometry path, bool bReverse, double simpFactor)
{
IGeometry oldPath = path;
IPointCollection oldPointCollection = oldPath as IPointCollection;
IPolyline newPath = new PolylineClass();
IPointCollection newPointCollection = newPath as IPointCollection;
ISpatialReference sr = oldPath.SpatialReference;
int pointCount;
pointCount = oldPointCollection.PointCount;
double[] lastCoord = new double[2];
IPoint beginningPoint = new PointClass();
oldPointCollection.QueryPoint(bReverse ? (pointCount - 1) : 0, beginningPoint);
beginningPoint.QueryCoords(out lastCoord[0], out lastCoord[1]);
bool bKeep = true;
IPolyline oldLine = oldPath as IPolyline;
double length = oldLine.Length;
object Missing = Type.Missing;
newPointCollection.AddPoint(beginningPoint, ref Missing, ref Missing);
for (int i = 1; i < pointCount - 1; i++) //simplify 2D path
{
double[] coord = new double[2];
IPoint currentPoint = new PointClass();
oldPointCollection.QueryPoint(bReverse ? (pointCount - i - 1) : i, currentPoint);
currentPoint.QueryCoords(out coord[0], out coord[1]);
double[] d = new double[2];
d[0] = coord[0] - lastCoord[0];
d[1] = coord[1] - lastCoord[1];
double distance;
distance = Math.Sqrt(d[0] * d[0] + d[1] * d[1]);
if (distance < (0.25 * simpFactor * length))
{
bKeep = false;
}
else
{
bKeep = true;
}
if (bKeep)
{
newPointCollection.AddPoint(currentPoint, ref Missing, ref Missing);
lastCoord[0] = coord[0];
lastCoord[1] = coord[1];
}
}
IPoint finalPoint = new PointClass();
oldPointCollection.QueryPoint(bReverse ? 0 : (pointCount - 1), finalPoint);
newPointCollection.AddPoint(finalPoint, ref Missing, ref Missing);
newPath.SpatialReference = sr;
return (IGeometry)newPath;
}