本文整理汇总了C#中ICoordinateSequence.GetCoordinate方法的典型用法代码示例。如果您正苦于以下问题:C# ICoordinateSequence.GetCoordinate方法的具体用法?C# ICoordinateSequence.GetCoordinate怎么用?C# ICoordinateSequence.GetCoordinate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICoordinateSequence
的用法示例。
在下文中一共展示了ICoordinateSequence.GetCoordinate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
public void Filter(ICoordinateSequence seq, int i)
{
if (i == 0) return;
seq.GetCoordinate(i - 1, p0);
seq.GetCoordinate(i, p1);
rcc.CountSegment(p0, p1);
}
示例2: LocatePointInRing
/// <summary>
/// Determines the <see cref="Location"/> of a point in a ring.
/// </summary>
/// <param name="p">The point to test</param>
/// <param name="ring">A coordinate sequence forming a ring</param>
/// <returns>The location of the point in the ring</returns>
public static Location LocatePointInRing(Coordinate p, ICoordinateSequence ring)
{
var counter = new RayCrossingCounter(p);
var p1 = new Coordinate();
var p2 = new Coordinate();
for (var i = 1; i < ring.Count; i++)
{
ring.GetCoordinate(i, p1);
ring.GetCoordinate(i - 1, p2);
counter.CountSegment(p1, p2);
if (counter.IsOnSegment)
return counter.Location;
}
return counter.Location;
}
示例3: HasIntersection
/// <summary>
///
/// </summary>
/// <param name="seq0"></param>
/// <param name="seq1"></param>
/// <returns></returns>
public bool HasIntersection(ICoordinateSequence seq0, ICoordinateSequence seq1)
{
for (int i = 1; i < seq0.Count && ! hasIntersection; i++)
{
seq0.GetCoordinate(i - 1, pt00);
seq0.GetCoordinate(i, pt01);
for (int j = 1; j < seq1.Count && ! hasIntersection; j++)
{
seq1.GetCoordinate(j - 1, pt10);
seq1.GetCoordinate(j, pt11);
li.ComputeIntersection(pt00, pt01, pt10, pt11);
if (li.HasIntersection)
hasIntersection = true;
}
}
return hasIntersection;
}
示例4: Copy
public static MCoordinate[] Copy(ICoordinateSequence coordSeq)
{
MCoordinate[] copy = new MCoordinate[coordSeq.Count];
for (int i = 0; i < coordSeq.Count; i++)
{
copy[i] = new MCoordinate(coordSeq.GetCoordinate(i));
}
return copy;
}
示例5: AverageNormal
/**
* Computes an average normal vector from a list of polygon coordinates.
* Uses Newell's method, which is based
* on the fact that the vector with components
* equal to the areas of the projection of the polygon onto
* the Cartesian axis planes is normal.
*
* @param seq the sequence of coordinates for the polygon
* @return a normal vector
*/
private static Vector3D AverageNormal(ICoordinateSequence seq)
{
var n = seq.Count;
var sum = new Coordinate(0, 0, 0);
var p1 = new Coordinate(0, 0, 0);
var p2 = new Coordinate(0, 0, 0);
for (var i = 0; i < n - 1; i++)
{
seq.GetCoordinate(i, p1);
seq.GetCoordinate(i + 1, p2);
sum.X += (p1.Y - p2.Y) * (p1.Z + p2.Z);
sum.Y += (p1.Z - p2.Z) * (p1.X + p2.X);
sum.Z += (p1.X - p2.X) * (p1.Y + p2.Y);
}
sum.X /= n;
sum.Y /= n;
sum.Z /= n;
var norm = Vector3D.Create(sum).Normalize();
return norm;
}
示例6: DoTest
private static void DoTest(ICoordinateSequence forward, ICoordinateSequence reversed)
{
const double eps = 1e-12;
Assert.AreEqual(forward.Count, reversed.Count, "Coordinate sequences don't have same size");
Assert.AreEqual(forward.Ordinates, reversed.Ordinates, "Coordinate sequences don't serve same ordinate values");
var ordinates = OrdinatesUtility.ToOrdinateArray(forward.Ordinates);
var j = forward.Count;
for (var i = 0; i < forward.Count; i++)
{
j--;
foreach(var ordinate in ordinates)
Assert.AreEqual(forward.GetOrdinate(i, ordinate), reversed.GetOrdinate(j, ordinate), eps, string.Format("{0} values are not within tolerance", ordinate));
var cf = forward.GetCoordinate(i);
var cr = reversed.GetCoordinate(j);
Assert.IsFalse(ReferenceEquals(cf, cr), "Coordinate sequences deliver same coordinate instances");
Assert.IsTrue(cf.Equals(cr), "Coordinate sequences do not provide equal coordinates");
}
}
示例7: Length
/// <summary>
/// Computes the length of a linestring specified by a sequence of points.
/// </summary>
/// <param name="pts">The points specifying the linestring</param>
/// <returns>The length of the linestring</returns>
public static double Length(ICoordinateSequence pts)
{
// optimized for processing CoordinateSequences
int n = pts.Count;
if (n <= 1) return 0.0;
double len = 0.0;
var p = new Coordinate();
pts.GetCoordinate(0, p);
double x0 = p.X;
double y0 = p.Y;
for (int i = 1; i < n; i++)
{
pts.GetCoordinate(i, p);
double x1 = p.X;
double y1 = p.Y;
double dx = x1 - x0;
double dy = y1 - y0;
len += Math.Sqrt(dx * dx + dy * dy);
x0 = x1;
y0 = y1;
}
return len;
}
示例8: CreateMultiPoint
/// <summary>
/// Creates a MultiPoint using the given CoordinateSequence; a null or empty CoordinateSequence will
/// create an empty MultiPoint.
/// </summary>
/// <param name="coordinates">A CoordinateSequence possibly empty, or null.</param>
public IMultiPoint CreateMultiPoint(ICoordinateSequence coordinates)
{
if (coordinates == null)
coordinates = CoordinateSequenceFactory.Create(new ICoordinate[] { });
List<IPoint> points = new List<IPoint>();
for (int i = 0; i < coordinates.Count; i++)
points.Add(CreatePoint(coordinates.GetCoordinate(i)));
return CreateMultiPoint(points.ToArray());
}
示例9: SignedArea
/// <summary>
/// Computes the signed area for a ring.
/// <remarks>
/// <para>
/// The signed area is
/// </para>
/// <list type="Table">
/// <item>positive</item><description>if the ring is oriented CW</description>
/// <item>negative</item><description>if the ring is oriented CCW</description>
/// <item>zero</item><description>if the ring is degenerate or flat</description>
/// </list>
/// </remarks>
/// </summary>
/// <param name="ring">The coordinates forming the ring</param>
/// <returns>The signed area of the ring</returns>
public static double SignedArea(ICoordinateSequence ring)
{
var n = ring.Count;
if (n < 3)
return 0.0;
/**
* Based on the Shoelace formula.
* http://en.wikipedia.org/wiki/Shoelace_formula
*/
var p0 = new Coordinate();
var p1 = new Coordinate();
var p2 = new Coordinate();
ring.GetCoordinate(0, p1);
ring.GetCoordinate(1, p2);
var x0 = p1.X;
p2.X -= x0;
var sum = 0.0;
for (var i = 1; i < n - 1; i++)
{
p0.Y = p1.Y;
p1.X = p2.X;
p1.Y = p2.Y;
ring.GetCoordinate(i + 1, p2);
p2.X -= x0;
sum += p1.X * (p0.Y - p2.Y);
}
return sum / 2.0;
}
示例10: WriteCompressedXYZM
private static void WriteCompressedXYZM(ICoordinateSequence coordinateSequence, GaiaExport export, BinaryWriter bw)
{
var wd = export.WriteDouble;
// Write initial coordinate
var cprev = coordinateSequence.GetCoordinate(0);
var mprev = coordinateSequence.GetOrdinate(0, Ordinate.M);
wd(bw, cprev.X, cprev.Y, cprev.Z, mprev);
var maxIndex = coordinateSequence.Count - 1;
if (maxIndex <= 0) return;
var ws = export.WriteSingle;
for (var i = 1; i < maxIndex; i++)
{
var c = coordinateSequence.GetCoordinate(i);
var fx = (float)(c.X - cprev.X);
var fy = (float)(c.Y - cprev.Y);
var fz = (float)(c.Z - cprev.Z);
var fm = (float)(coordinateSequence.GetOrdinate(i, Ordinate.M) - mprev);
ws(bw, fx, fy, fz, fm);
cprev = c;
}
cprev = coordinateSequence.GetCoordinate(maxIndex);
mprev = coordinateSequence.GetOrdinate(maxIndex, Ordinate.M);
wd(bw, cprev.X, cprev.Y, cprev.Z, mprev);
}
示例11: Transform
public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
{
var clone = new Coordinate();
for (var i = 0; i < coordinateSequence.Count; i++)
{
clone.CoordinateValue = coordinateSequence.GetCoordinate(i);
clone = Transform(clone);
coordinateSequence.SetOrdinate(i, Ordinate.X, clone.X);
coordinateSequence.SetOrdinate(i, Ordinate.Y, clone.Y);
if (DimTarget > 2)
coordinateSequence.SetOrdinate(i, Ordinate.Z, clone.Z);
}
return coordinateSequence;
}
示例12: WriteCompressedXY
private static void WriteCompressedXY(ICoordinateSequence coordinateSequence, GaiaExport export, BinaryWriter bw)
{
var wd = export.WriteDouble;
// Write initial coordinate
var cprev = coordinateSequence.GetCoordinate(0);
wd(bw, cprev.X, cprev.Y);
var ws = export.WriteSingle;
var maxIndex = coordinateSequence.Count - 1;
if (maxIndex <= 0) return;
for (var i = 1; i < maxIndex; i++)
{
var c = coordinateSequence.GetCoordinate(i);
var fx = (float)(c.X - cprev.X);
var fy = (float)(c.Y - cprev.Y);
ws(bw, fx, fy);
cprev = c;
}
// Write last coordinate
cprev = coordinateSequence.GetCoordinate(maxIndex);
wd(bw, cprev.X, cprev.Y);
}
示例13: IsEqual
/// <summary>
/// Tests for equality using all supported accessors,
/// to provides test coverage for them.
/// </summary>
/// <param name="seq"></param>
/// <param name="coords"></param>
/// <returns></returns>
bool IsEqual(ICoordinateSequence seq, Coordinate[] coords)
{
if (seq.Count != coords.Length)
return false;
Coordinate p = new Coordinate();
for (int i = 0; i < seq.Count; i++)
{
if (!coords[i].Equals(seq.GetCoordinate(i)))
return false;
// Ordinate named getters
if (coords[i].X != seq.GetX(i))
return false;
if (coords[i].Y != seq.GetY(i))
return false;
// Ordinate indexed getters
if (coords[i].X != seq.GetOrdinate(i, Ordinate.X))
return false;
if (coords[i].Y != seq.GetOrdinate(i, Ordinate.Y))
return false;
if (coords[i].Z != seq.GetOrdinate(i, Ordinate.Z))
return false;
// Coordinate getter
seq.GetCoordinate(i, p);
if (coords[i].X != p.X)
return false;
if (coords[i].Y != p.Y)
return false;
//TODO: Remove commented line below when NTS supports Z ordinates in CoordinateArraySequence.GetCoordinate and PackedCoordinateSequence.GetCoordinate
//if (coords[i].Z != p.Z) return false;
}
return true;
}
示例14: IsAllCoordsEqual
bool IsAllCoordsEqual(ICoordinateSequence seq, Coordinate coord)
{
for (int i = 0; i < seq.Count; i++)
{
if (!coord.Equals(seq.GetCoordinate(i)))
return false;
if (coord.X != seq.GetOrdinate(i, Ordinate.X))
return false;
if (coord.Y != seq.GetOrdinate(i, Ordinate.Y))
return false;
if (coord.Z != seq.GetOrdinate(i, Ordinate.Z))
return false;
}
return true;
}
示例15: Length
/// <summary>
/// Computes the length of a linestring specified by a sequence of points.
/// </summary>
/// <param name="pts">The points specifying the linestring.</param>
/// <returns>The length of the linestring.</returns>
public static double Length(ICoordinateSequence pts)
{
if (pts.Count < 1)
return 0.0;
double sum = 0.0;
for (int i = 1; i < pts.Count; i++)
sum += pts.GetCoordinate(i).Distance(pts.GetCoordinate(i - 1));
return sum;
}