本文整理汇总了C#中System.Point.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Point.ToString方法的具体用法?C# Point.ToString怎么用?C# Point.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Point
的用法示例。
在下文中一共展示了Point.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Point p1 = new Point(2, 3);
Point p2 = p1;
Console.WriteLine("p1: {0}", p1.ToString());
Console.WriteLine("Before: p1.Prop.SomeProperty = {0}", p1.Prop.SomeProperty);
Console.WriteLine("p2: {0}", p2.ToString());
Console.WriteLine("Before: p2.Prop.SomeProperty = {0}\n", p2.Prop.SomeProperty);
p2.Prop.SomeProperty = 69;
p1.X = 200;
p1.Y = 300;
Console.WriteLine("p1: {0}", p1.ToString());
Console.WriteLine("After: p1.Prop.SomeProperty = {0}", p1.Prop.SomeProperty);
Console.WriteLine("p2: {0}", p2.ToString());
Console.WriteLine("After: p2.Prop.SomeProperty = {0}", p2.Prop.SomeProperty);
p1.SomeFunctionToImplement();
Console.ReadLine();
}
示例2: Main
static void Main()
{
var point = new Point(2.3, 1, 0);
var secPoint = new Point(1, 2, 5);
var thirdPoint = new Point(3, 2, 2);
Console.WriteLine(point.ToString());
Console.WriteLine(Point.O);
Console.WriteLine(DistanceBnTwoPoints.CalcDistTwoPoints(point, Point.O));
var path = new Path();
path.AddPointsPath(point);
path.AddPointsPath(Point.O);
path.AddPointsPath(secPoint);
path.AddPointsPath(thirdPoint);
PathStorage.SavePath(path);
var pathLoad = PathStorage.LoadPath();
foreach (var p in pathLoad.Points)
{
Console.WriteLine(p);
}
Console.WriteLine(new string('-', 59));
}
示例3: TestMercator_1SP_Projection
public void TestMercator_1SP_Projection()
{
CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
new AxisInfo("Lat", AxisOrientationEnum.North));
//System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>(5);
System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>();
parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
parameters.Add(new ProjectionParameter("central_meridian", 110));
parameters.Add(new ProjectionParameter("scale_factor", 0.997));
parameters.Add(new ProjectionParameter("false_easting", 3900000));
parameters.Add(new ProjectionParameter("false_northing", 900000));
IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters);
IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
SharpMap.Geometries.Point pGeo = new SharpMap.Geometries.Point(120, -3);
SharpMap.Geometries.Point pUtm = trans.MathTransform.Transform(pGeo);
SharpMap.Geometries.Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
SharpMap.Geometries.Point expected = new Point(5009726.58, 569150.82);
Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_1SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString()));
Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_1SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString()));
}
示例4: TestAlbersProjection
public void TestAlbersProjection()
{
CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
new AxisInfo("Lat", AxisOrientationEnum.North));
//System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>(5);
System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>();
parameters.Add(new ProjectionParameter("central_meridian", -96));
parameters.Add(new ProjectionParameter("latitude_of_origin", 23));
parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
parameters.Add(new ProjectionParameter("false_easting", 0));
parameters.Add(new ProjectionParameter("false_northing", 0));
IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters);
IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
SharpMap.Geometries.Point pGeo = new SharpMap.Geometries.Point(-75, 35);
SharpMap.Geometries.Point pUtm = trans.MathTransform.Transform(pGeo);
SharpMap.Geometries.Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
SharpMap.Geometries.Point expected = new Point(1885472.7, 1535925);
Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), String.Format("Albers forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString()));
Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString()));
}
示例5: Run
public static void Run() {
var p1 = new Point(10, 10);
var p2 = new Point(20, 20);
// p1 does NOT get boxed to call ToString (a virtual method)
Console.WriteLine(p1.ToString()); // (10, 10)
// p DOES get boxed to call GetType (a non-virtual method)
Console.WriteLine(p1.GetType()); // Point
// p1 does NOT get boxed to call CompareTo
// p2 does NOT get boxed because CompareTo(Point) is called
Console.WriteLine(p1.CompareTo(p2)); // -1
// p1 DOES get boxed, and the reference is placed in c
IComparable c = p1;
Console.WriteLine(c.GetType()); // Point
// p1 does NOT get boxed to call ComapreTo
// Since CompareTo is not being passed a Point variable,
// CompareTo(Object) is called which requires a reference to
// a boxed Point
// c does NOT get boxed because it already refers to a boxed Point
Console.WriteLine(p1.CompareTo(c)); // 0
// c does NOT get boxed because it is already refers ti a boxed Point.
// p2 DOES get boxed because CompareTo(Object) is called
Console.WriteLine(c.CompareTo(p2)); // -1
// c is unboxed, and fields are copied into p2
p2 = (Point)c;
// Proves that the fields got copied into p2
Console.WriteLine(p2.ToString()); // (10, 10)
}
示例6: BuildMoveMessage
public static Message BuildMoveMessage(this Tile tile, Point to)
{
return new Message{
Type = GameConstants.MOVEMENT,
From = tile.Location.ToString(),
To = to.ToString(),
Name = tile.Name
};
}
示例7: Main
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Generic Structures *****\n");
// Point using ints.
Point<int> p = new Point<int>(10, 10);
Console.WriteLine("p.ToString()={0}", p.ToString());
p.ResetPoint();
Console.WriteLine("p.ToString()={0}", p.ToString());
Console.WriteLine();
// Point using double.
Point<double> p2 = new Point<double>(5.4, 3.3);
Console.WriteLine("p2.ToString()={0}", p2.ToString());
p2.ResetPoint();
Console.WriteLine("p2.ToString()={0}", p2.ToString());
Console.ReadKey();
}
示例8: BoxingAndUnboxingExample
public void BoxingAndUnboxingExample()
{
Point p = new Point(1, 1);
p.ToString().ShouldBe("1, 1");
p.Change(2, 2);
p.ToString().ShouldBe("2, 2");
object o = p;
o.ToString().ShouldBe("2, 2");
((Point)o).Change(3, 3);
o.ToString().ShouldBe("2, 2");
// Box p. Change the boxed object and discard it.
((IChangeBoxedPoint)p).Change(4, 4);
p.ToString().ShouldBe("2, 2");
// Change the already boxed object on the heap.
((IChangeBoxedPoint)o).Change(5, 5);
o.ToString().ShouldBe("5, 5");
}
示例9: ShouldSerializeToWkt
public void ShouldSerializeToWkt(double x, double y, double? z, string expectedWkt)
{
var wgs84Mock=new Mock<ICoordinateSystem>(MockBehavior.Loose);
var coords=new List<double>(new double[] { x, y });
if (z.HasValue)
coords.Add(z.Value);
var point=new Point() {
pos=new pos(),
CoordinateSystem=CommonServiceLocator.GetCoordinateSystemProvider().Wgs84
};
point.pos.Untyped.Value=string.Join(
" ",
coords.Select<double, string>(d => d.ToString(CultureInfo.InvariantCulture))
);
Assert.Equal<string>(expectedWkt, point.ToString());
}
示例10: run
public bool run(int n, int dimension, double c, Point X)
{
generator = new RandomPointGenerator();
planeProjector = new PlaneProjector();
pointProcessor = new PointProcessor();
Console.WriteLine("=================== NEW RUN ===================\n");
if (X == null)
{
X = generator.generatePoint(dimension);
}
Console.WriteLine("X= " + X.ToString() + "\n");
//Preparing background worker;
prepareObjects();
Object[] arguments = { n, dimension, c, X };
bgWorker.RunWorkerAsync(arguments);
return true;
}
示例11: GetCurrentValueCore
//.........这里部分代码省略.........
case AnimationType.To:
from = defaultOriginValue;
to = _keyValues[0];
validateOrigin = true;
break;
case AnimationType.By:
// According to the SMIL specification, a By animation is
// always additive. But we don't force this so that a
// user can re-use a By animation and have it replace the
// animations that precede it in the list without having
// to manually set the From value to the base value.
to = _keyValues[0];
foundation = defaultOriginValue;
validateOrigin = true;
break;
case AnimationType.FromTo:
from = _keyValues[0];
to = _keyValues[1];
if (IsAdditive)
{
foundation = defaultOriginValue;
validateOrigin = true;
}
break;
case AnimationType.FromBy:
from = _keyValues[0];
to = AnimatedTypeHelpers.AddPoint(_keyValues[0], _keyValues[1]);
if (IsAdditive)
{
foundation = defaultOriginValue;
validateOrigin = true;
}
break;
default:
Debug.Fail("Unknown animation type.");
break;
}
if (validateOrigin
&& !AnimatedTypeHelpers.IsValidAnimationValuePoint(defaultOriginValue))
{
throw new InvalidOperationException(
SR.Get(
SRID.Animation_Invalid_DefaultValue,
this.GetType(),
"origin",
defaultOriginValue.ToString(CultureInfo.InvariantCulture)));
}
if (validateDestination
&& !AnimatedTypeHelpers.IsValidAnimationValuePoint(defaultDestinationValue))
{
throw new InvalidOperationException(
SR.Get(
SRID.Animation_Invalid_DefaultValue,
this.GetType(),
"destination",
defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));
}
if (IsCumulative)
{
double currentRepeat = (double)(animationClock.CurrentIteration - 1);
if (currentRepeat > 0.0)
{
Point accumulator = AnimatedTypeHelpers.SubtractPoint(to, from);
accumulated = AnimatedTypeHelpers.ScalePoint(accumulator, currentRepeat);
}
}
// return foundation + accumulated + from + ((to - from) * progress)
return AnimatedTypeHelpers.AddPoint(
foundation,
AnimatedTypeHelpers.AddPoint(
accumulated,
AnimatedTypeHelpers.InterpolatePoint(from, to, progress)));
}
示例12: TestLambertConicConformal2SP_Projection
public void TestLambertConicConformal2SP_Projection()
{
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
IEllipsoid ellipsoid =
cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs =
cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich,
new AxisInfo("Lon", AxisOrientation.East),
new AxisInfo("Lat", AxisOrientation.North));
//Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>();
parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333));
parameters.Add(new ProjectionParameter("central_meridian", -99));
parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333));
parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333));
parameters.Add(new ProjectionParameter("false_easting", 2000000));
parameters.Add(new ProjectionParameter("false_northing", 0));
IProjection projection =
cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters);
IProjectedCoordinateSystem coordsys =
cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection,
LinearUnit.USSurveyFoot,
new AxisInfo("East", AxisOrientation.East),
new AxisInfo("North", AxisOrientation.North));
ICoordinateTransformation trans =
new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
Point pGeo = new Point(-96, 28.5);
Point pUtm = trans.MathTransform.Transform(pGeo);
Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
Point expected = new Point(2963503.91, 254759.80);
Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02),
String.Format(
"LambertConicConformal2SP forward transformation outside tolerance, Expected {0}, got {1}",
expected.ToString(), pUtm.ToString()));
Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001),
String.Format(
"LambertConicConformal2SP reverse transformation outside tolerance, Expected {0}, got {1}",
pGeo.ToString(), pGeo2.ToString()));
}
示例13: TestTransverseMercator_Projection
public void TestTransverseMercator_Projection()
{
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs =
cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich,
new AxisInfo("Lon", AxisOrientation.East),
new AxisInfo("Lat", AxisOrientation.North));
//Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>();
parameters.Add(new ProjectionParameter("latitude_of_origin", 49));
parameters.Add(new ProjectionParameter("central_meridian", -2));
parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717));
parameters.Add(new ProjectionParameter("false_easting", 400000));
parameters.Add(new ProjectionParameter("false_northing", -100000));
IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);
IProjectedCoordinateSystem coordsys =
cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection,
LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East),
new AxisInfo("North", AxisOrientation.North));
ICoordinateTransformation trans =
new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
Point pGeo = new Point(0.5, 50.5);
Point pUtm = trans.MathTransform.Transform(pGeo);
Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
Point expected = new Point(577274.99, 69740.50);
Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02),
String.Format(
"TransverseMercator forward transformation outside tolerance, Expected {0}, got {1}",
expected.ToString(), pUtm.ToString()));
Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001),
String.Format(
"TransverseMercator reverse transformation outside tolerance, Expected {0}, got {1}",
pGeo.ToString(), pGeo2.ToString()));
}
示例14: TestMercator_2SP_Projection
public void TestMercator_2SP_Projection()
{
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre);
IHorizontalDatum datum =
cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs =
cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich,
new AxisInfo("Lon", AxisOrientation.East),
new AxisInfo("Lat", AxisOrientation.North));
//Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>();
parameters.Add(new ProjectionParameter("latitude_of_origin", 42));
parameters.Add(new ProjectionParameter("central_meridian", 51));
parameters.Add(new ProjectionParameter("false_easting", 0));
parameters.Add(new ProjectionParameter("false_northing", 0));
IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters);
IProjectedCoordinateSystem coordsys =
cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection,
LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East),
new AxisInfo("North", AxisOrientation.North));
ICoordinateTransformation trans =
new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
Point pGeo = new Point(53, 53);
Point pUtm = trans.MathTransform.Transform(pGeo);
Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
Point expected = new Point(165704.29, 5171848.07);
Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02),
String.Format("Mercator_2SP forward transformation outside tolerance, Expected {0}, got {1}",
expected.ToString(), pUtm.ToString()));
Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001),
String.Format("Mercator_2SP reverse transformation outside tolerance, Expected {0}, got {1}",
pGeo.ToString(), pGeo2.ToString()));
}
示例15: Transform
public Point Transform(ProjFourWrapper destinationProj, Point point)
{
double[] x = new double[] { point.X };
double[] y = new double[] { point.Y };
if (this.IsLatLong)
{
x[0] = x[0] * DegreesToRadians;
y[0] = y[0] * DegreesToRadians;
}
int errno = pj_transform(this.projPJ, destinationProj.projPJ, 1, 0, x, y, new double[] {0}) ;
if (errno != 0)
{
throw new ProjFourException(errno, GetError() + " " + point.ToString());
}
if (destinationProj.IsLatLong)
{
x[0] = x[0] / DegreesToRadians;
y[0] = y[0] / DegreesToRadians;
}
Point p = new Point(x[0], y[0]);
p.LabelFieldValue = point.LabelFieldValue;
p.ThemeFieldValue = point.ThemeFieldValue;
return p;
}