本文整理汇总了C#中IPrecisionModel.MakePrecise方法的典型用法代码示例。如果您正苦于以下问题:C# IPrecisionModel.MakePrecise方法的具体用法?C# IPrecisionModel.MakePrecise怎么用?C# IPrecisionModel.MakePrecise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPrecisionModel
的用法示例。
在下文中一共展示了IPrecisionModel.MakePrecise方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DensifyPoints
/// <summary>
/// Densifies a coordinate sequence.
/// </summary>
/// <param name="pts">The coordinate sequence to densify</param>
/// <param name="distanceTolerance">The distance tolerance (<see cref="DistanceTolerance"/>)</param>
/// <param name="precModel">The precision model to apply on the new coordinates</param>
/// <returns>The densified coordinate sequence</returns>
private static Coordinate[] DensifyPoints(Coordinate[] pts,
double distanceTolerance, IPrecisionModel precModel)
{
var seg = new LineSegment();
var coordList = new CoordinateList();
for (int i = 0; i < pts.Length - 1; i++)
{
seg.P0 = pts[i];
seg.P1 = pts[i + 1];
coordList.Add(seg.P0, false);
double len = seg.Length;
int densifiedSegCount = (int) (len/distanceTolerance) + 1;
if (densifiedSegCount > 1)
{
double densifiedSegLen = len/densifiedSegCount;
for (int j = 1; j < densifiedSegCount; j++)
{
double segFract = (j*densifiedSegLen)/len;
var p = seg.PointAlong(segFract);
precModel.MakePrecise(p);
coordList.Add(p, false);
}
}
}
coordList.Add(pts[pts.Length - 1], false);
return coordList.ToCoordinateArray();
}
示例2: PreciseCoordinateTester
private static void PreciseCoordinateTester(IPrecisionModel pm,
double x1, double y1,
double x2, double y2)
{
var p = new Coordinate(x1, y1);
pm.MakePrecise(p);
var pPrecise = new Coordinate(x2, y2);
Assert.IsTrue(p.Equals2D(pPrecise), "Expected {0}, but got {1}", pPrecise, p);
}
示例3: GetEnvelopeExternal
/// <summary>
/// Get Envelope in external coordinates.
/// </summary>
/// <param name="precisionModel">The precision model to use</param>
/// <param name="envelope">The envelope to get</param>
/// <returns></returns>
public static Envelope GetEnvelopeExternal(IPrecisionModel precisionModel, Envelope envelope)
{
// Get envelope in external coordinates
var min = new Coordinate(envelope.MinX, envelope.MinY);
precisionModel.MakePrecise(min);
var max = new Coordinate(envelope.MaxX, envelope.MaxY);
precisionModel.MakePrecise(max);
var bounds = new Envelope(min.X, max.X, min.Y, max.Y);
return bounds;
//return GetEnvelopeExternal(envelope);
}
示例4: RandomOrdinate
private static double RandomOrdinate(Ordinate o, IPrecisionModel pm)
{
switch (o)
{
case Ordinate.X:
return pm.MakePrecise(-180 + 360 * Rnd.NextDouble());
case Ordinate.Y:
return pm.MakePrecise(-90 + 180 * Rnd.NextDouble());
case Ordinate.Z:
return 200 * Rnd.NextDouble();
case Ordinate.M:
return 200 + 200 * Rnd.NextDouble();
default:
throw new NotSupportedException();
}
}
示例5: Round
static Coordinate[] Round(ICoordinateSequence seq, IPrecisionModel pm)
{
if (seq.Count == 0) return new Coordinate[0];
CoordinateList coordList = new CoordinateList();
// copy coordinates and reduce
for (int i = 0; i < seq.Count; i++)
{
var coord = new Coordinate(
seq.GetOrdinate(i, Ordinate.X),
seq.GetOrdinate(i, Ordinate.Y));
pm.MakePrecise(coord);
coordList.Add(coord, false);
}
Coordinate[] coords = coordList.ToCoordinateArray();
//TODO: what if seq is too short?
return coords;
}
示例6: ReadCompressedXYZM
private static ICoordinateSequence ReadCompressedXYZM(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
{
var startOrdinateValues = import.GetDoubles(buffer, ref offset, 4);
var ret = factory.Create(number, Ordinates.XYM);
var handleZ = (ret.Ordinates & Ordinates.Z) == Ordinates.Z;
var handleM = (ret.Ordinates & Ordinates.M) == Ordinates.M;
var x = startOrdinateValues[0];
ret.SetOrdinate(0, Ordinate.X, precisionModel.MakePrecise(x));
var y = startOrdinateValues[1];
ret.SetOrdinate(0, Ordinate.Y, precisionModel.MakePrecise(y));
var z = handleZ ? startOrdinateValues[2] : Coordinate.NullOrdinate;
ret.SetOrdinate(0, Ordinate.Z, z);
var m = handleM ? startOrdinateValues[3] : Coordinate.NullOrdinate;
ret.SetOrdinate(0, Ordinate.M, m);
if (number == 1) return ret;
var ordinateValues = import.GetSingles(buffer, ref offset, (number - 2) * 4);
var j = 0;
int i;
for (i = 1; i < number - 1; i++)
{
x += ordinateValues[j++];
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(x));
y += ordinateValues[j++];
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(y));
if (handleZ) z += ordinateValues[j++];
ret.SetOrdinate(i, Ordinate.Z, z);
if (handleM) m += ordinateValues[j++];
ret.SetOrdinate(i, Ordinate.M, m);
}
startOrdinateValues = import.GetDoubles(buffer, ref offset, 4);
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(startOrdinateValues[0]));
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(startOrdinateValues[1]));
z = handleZ ? startOrdinateValues[2] : Coordinate.NullOrdinate;
ret.SetOrdinate(i, Ordinate.Z, z);
m = handleM ? startOrdinateValues[3] : Coordinate.NullOrdinate;
ret.SetOrdinate(i, Ordinate.M, m);
return ret;
}
示例7: ReadCompressedXY
private static ICoordinateSequence ReadCompressedXY(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
{
var startOrdinateValues = import.GetDoubles(buffer, ref offset, 2);
var ret = factory.Create(number, import.HandleOrdinates);
var x = startOrdinateValues[0];
var y = startOrdinateValues[1];
ret.SetOrdinate(0, Ordinate.X, precisionModel.MakePrecise(x));
ret.SetOrdinate(0, Ordinate.Y, precisionModel.MakePrecise(y));
if (number == 1) return ret;
var ordinateValues = import.GetSingles(buffer, ref offset, (number - 2) * 2);
var j = 0;
int i;
for (i = 1; i < number - 1; i++)
{
x = x + ordinateValues[j++];
y = y + ordinateValues[j++];
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(x));
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(y));
}
startOrdinateValues = import.GetDoubles(buffer, ref offset, 2);
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(startOrdinateValues[0]));
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(startOrdinateValues[1]));
return ret;
}
示例8: ReadXYZM
private static ICoordinateSequence ReadXYZM(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
{
var ordinateValues = import.GetDoubles(buffer, ref offset, number * 4);
var ret = factory.Create(number, import.HandleOrdinates);
var handleZ = (ret.Ordinates & Ordinates.Z) == Ordinates.Z;
var handleM = (ret.Ordinates & Ordinates.M) == Ordinates.M;
var j = 0;
for (var i = 0; i < number; i++)
{
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(ordinateValues[j++]));
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(ordinateValues[j++]));
if (handleZ) ret.SetOrdinate(i, Ordinate.Z, precisionModel.MakePrecise(ordinateValues[j]));
j++;
if (handleM) ret.SetOrdinate(i, Ordinate.M, precisionModel.MakePrecise(ordinateValues[j]));
j++;
}
return ret;
}
示例9: ReadXY
private static ICoordinateSequence ReadXY(byte[] buffer, ref int offset, int number, GaiaImport import, ICoordinateSequenceFactory factory, IPrecisionModel precisionModel)
{
var ordinateValues = import.GetDoubles(buffer, ref offset, number * 2);
var ret = factory.Create(number, Ordinates.XY);
var j = 0;
for (var i = 0; i < number; i++)
{
ret.SetOrdinate(i, Ordinate.X, precisionModel.MakePrecise(ordinateValues[j++]));
ret.SetOrdinate(i, Ordinate.Y, precisionModel.MakePrecise(ordinateValues[j++]));
}
return ret;
}