public void EqualWhenSameInstance() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); var testSubject = position1; Assert.IsTrue(testSubject == position1); }
public void EqualWhenEverythingMatches() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); object position2 = new GeometryPosition(10, 20, 30, 40); Assert.IsTrue(position1.Equals(position2)); }
public void NotEqualPositions() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); GeometryPosition position2 = new GeometryPosition(40, 30, 20, 10); Assert.IsTrue(position1 != position2); }
public void NotEqualObjects() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); GeometryPosition position2 = new GeometryPosition(10, 20, 30, 40); Assert.False(position1.Equals(position2)); }
public void Points() { GeometryPosition position = new GeometryPosition(2.0, 3.0); Assert.AreEqual("geo.distance(geography'POINT(2 3)', Foo) < 3", SearchFilter.Create($"geo.distance({position}, Foo) < 3")); Assert.AreEqual("geo.distance(geography'POINT(2 3)', Foo) < 3", SearchFilter.Create($"geo.distance({new GeometryPosition(2.0, 3.0, 5.0)}, Foo) < 3")); Assert.AreEqual("geo.distance(geography'POINT(2 3)', Foo) < 3", SearchFilter.Create($"geo.distance({new PointGeometry(position)}, Foo) < 3")); }
public void GetHashCodeImplementation() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); Assert.Equal(2139226112, position1.GetHashCode()); GeometryPosition position2 = new GeometryPosition(10, 20, null, null); Assert.Equal(48234496, position2.GetHashCode()); }
public void GetHashCodeImplementation() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); Assert.AreEqual(2139226112, position1.GetHashCode()); GeometryPosition position2 = new GeometryPosition(10, 20, null, null); Assert.AreEqual(48234496, position2.GetHashCode()); }
protected override GeometryPosition OnLineTo(GeometryPosition position) { if (!this.processingGeography) { ValidateGeometryPosition(position.X, position.Y, position.Z, position.M); } this.AddControlPoint(position.X, position.Y); if (this.processingGeography) { throw new FormatException(Strings.Validator_UnexpectedGeography); } return(position); }
/// <summary> /// Convert a <see cref="GeometryPosition"/> to an OData value. /// </summary> /// <param name="position">The position.</param> /// <returns>The OData representation of the position.</returns> private static string EncodeGeometry(GeometryPosition position) { const int maxLength = 19 + // "geography'POINT( )'".Length 2 * // Lat and Long each have: (15 + // Maximum precision for a double (without G17) 1 + // Optional decimal point 1); // Optional negative sign StringBuilder odata = new StringBuilder(maxLength); odata.Append("geography'POINT("); odata.Append(JsonSerialization.Double(position.Longitude, CultureInfo.InvariantCulture)); odata.Append(" "); odata.Append(JsonSerialization.Double(position.Latitude, CultureInfo.InvariantCulture)); odata.Append(")'"); return(odata.ToString()); }
internal static void SendFigure(this GeometryLineString GeometryLineString, GeometryPipeline pipeline) { Util.CheckArgumentNull(GeometryLineString, "GeometryLineString"); for (int i = 0; i < GeometryLineString.Points.Count; i++) { GeometryPoint point = GeometryLineString.Points[i]; GeometryPosition position = new GeometryPosition(point.X, point.Y, point.Z, point.M); if (i == 0) { pipeline.BeginFigure(position); } else { pipeline.LineTo(position); } } if (GeometryLineString.Points.Count > 0) { pipeline.EndFigure(); } }
public override void BeginFigure(GeometryPosition position) { }
public override void BeginFigure(GeometryPosition position) { logger.AddCoordinates(PipelineMethod.GeometryBeginFigure, position.X, position.Y, position.Z, position.M); }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected virtual GeometryPosition OnLineTo(GeometryPosition position) { return position; }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> public override void LineTo(GeometryPosition position) { both.OnLineTo(position); }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> /// <returns> /// The position to be passed down the pipeline /// </returns> protected override GeometryPosition OnLineTo(GeometryPosition position) { this.WriteControlPoint(position.X, position.Y, position.Z, position.M); return position; }
/// <summary> /// Begins a figure. /// </summary> /// <param name="position">The position of the control point.</param> public override void BeginFigure(GeometryPosition position) { this.Destination.BeginFigure(this.ConvertPosition(position)); }
protected virtual GeometryPosition OnBeginFigure(GeometryPosition position) { return(position); }
protected override GeometryPosition OnBeginFigure(GeometryPosition position) { this.BeginFigure(new Action<double, double, double?, double?>(SpatialValidatorImplementation.NestedValidator.ValidateGeometryPosition), position.X, position.Y, position.Z, position.M); return position; }
/// <summary> /// Implemented by a subclass to handle the start of a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected override GeometryPosition OnBeginFigure(GeometryPosition position) { BeginFigure(ValidateGeometryPosition, position.X, position.Y, position.Z, position.M); return position; }
public void NotEqualPositions() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); GeometryPosition position2 = new GeometryPosition(40, 30, 20, 10); Assert.True(position1 != position2); }
public void EqualWhenSameInstance() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); var testSubject = position1; Assert.True(testSubject == position1); }
public void EqualWhenEverythingMatches() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); object position2 = new GeometryPosition(10, 20, 30, 40); Assert.True(position1.Equals(position2)); }
public void NotEqualToNull() { GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40); Assert.False(position1.Equals(null)); }
public override void LineTo(GeometryPosition position) { sum += this.sign * (position.X + position.Y); }
protected virtual GeometryPosition OnLineTo(GeometryPosition position) { return(position); }
public override void BeginFigure(GeometryPosition position) { sum += this.sign * (position.X + position.Y); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected override GeometryPosition OnBeginFigure(GeometryPosition position) { WriteFigureScope(position.X, position.Y, position.Z, position.M); return(position); }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> /// <returns> /// The position to be passed down the pipeline /// </returns> protected override GeometryPosition OnLineTo(GeometryPosition position) { this.WriteControlPoint(position.X, position.Y, position.Z, position.M); return(position); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> public override void BeginFigure(GeometryPosition position) { both.OnBeginFigure(position); }
public override void BeginFigure(GeometryPosition position) { Debug.Assert(position != null, "ForwardingSegment should have validated nullness"); this.builder.BeginFigure(position.X, position.Y, position.Z, position.M); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected virtual GeometryPosition OnBeginFigure(GeometryPosition position) { return position; }
public override void LineTo(GeometryPosition position) { this.builder.LineTo(position.X, position.Y, position.Z, position.M); }
public override void LineTo(GeometryPosition position) { logger.AddCoordinates(PipelineMethod.GeometryAddLineTo, position.X, position.Y, position.Z, position.M); }
public override void LineTo(GeometryPosition position) { this.tracingPipe.Trace("Geometry.LineTo", position); }
public override void LineTo(GeometryPosition position) { }
public override void BeginFigure(GeometryPosition position) { this.parent.coordinates.Add(new PositionData(position.X, position.Y, position.Z, position.M)); }
/// <summary> /// Create an OData filter expression from an interpolated string. The /// interpolated values will be quoted and escaped as necessary. /// </summary> /// <param name="filter">An interpolated filter string.</param> /// <param name="formatProvider"> /// Format provider used to convert values to strings. /// <see cref="CultureInfo.InvariantCulture"/> is used as a default. /// </param> /// <returns>A valid OData filter expression.</returns> public static string Create(FormattableString filter, IFormatProvider formatProvider) { if (filter == null) { return(null); } formatProvider ??= CultureInfo.InvariantCulture; string[] args = new string[filter.ArgumentCount]; for (int i = 0; i < filter.ArgumentCount; i++) { args[i] = filter.GetArgument(i) switch { // Null null => "null", // Boolean bool x => x.ToString(formatProvider).ToLowerInvariant(), // Numeric sbyte x => x.ToString(formatProvider), byte x => x.ToString(formatProvider), short x => x.ToString(formatProvider), ushort x => x.ToString(formatProvider), int x => x.ToString(formatProvider), uint x => x.ToString(formatProvider), long x => x.ToString(formatProvider), ulong x => x.ToString(formatProvider), decimal x => x.ToString(formatProvider), // Floating point float x => JsonSerialization.Float(x, formatProvider), double x => JsonSerialization.Double(x, formatProvider), // Dates as 8601 with a time zone DateTimeOffset x => JsonSerialization.Date(x, formatProvider), DateTime x => JsonSerialization.Date(x, formatProvider), #if EXPERIMENTAL_SPATIAL // Points GeometryPosition x => EncodeGeometry(x), PointGeometry x => EncodeGeometry(x), // Polygons LineGeometry x => EncodeGeometry(x), PolygonGeometry x => EncodeGeometry(x), #endif // Text string x => Quote(x), char x => Quote(x.ToString(formatProvider)), StringBuilder x => Quote(x.ToString()), // Everything else object x => throw new ArgumentException( $"Unable to convert argument {i} from type {x.GetType()} to an OData literal.") }; } string text = string.Format(formatProvider, filter.Format, args); return(text); }
/// <summary> /// Implemented by a subclass to handle the addition of a waypoint to a Geometry figure /// </summary> /// <param name="position">Next position</param> /// <returns>the GeometryPosition to be passed down the pipeline</returns> protected override GeometryPosition OnLineTo(GeometryPosition position) { if (!this.processingGeography) { ValidateGeometryPosition(position.X, position.Y, position.Z, position.M); } AddControlPoint(position.X, position.Y); if (this.processingGeography) { throw new FormatException(Strings.Validator_UnexpectedGeography); } return position; }
public abstract void BeginFigure(GeometryPosition position);
public override void BeginFigure(GeometryPosition position) { this.builder.BeginFigure(position.X, position.Y, position.Z, position.M); }
public abstract void LineTo(GeometryPosition position);
public override void BeginFigure(GeometryPosition position) { this.tracingPipe.Trace("Geometry.BeginFigure", position); }
/// <summary> /// Adds a geometric control point. /// </summary> /// <param name="position">The position of the control point.</param> public override void LineTo(GeometryPosition position) { this.Destination.LineTo(this.ConvertPosition(position)); }
/// <summary> /// Converts the position with the Y coordinate as latitude. /// </summary> /// <param name="position">The position to convert.</param> /// <returns>The converted position</returns> internal static GeographyPosition ConvertWithYCoordinateAsLatitude(GeometryPosition position) { return new GeographyPosition(position.Y, position.X, position.Z, position.M); }
public override void BeginFigure(GeometryPosition position) { this.both.OnBeginFigure(position); }
/// <summary>Draws a point in the specified coordinate.</summary> /// <param name="position">The position of the line.</param> public abstract void LineTo(GeometryPosition position);
public override void LineTo(GeometryPosition position) { this.both.OnLineTo(position); }
protected override GeometryPosition OnLineTo(GeometryPosition position) { this.AddLineTo(position.X, position.Y, position.Z, position.M); return position; }
protected override GeometryPosition OnBeginFigure(GeometryPosition position) { this.WriteFigureScope(position.X, position.Y, position.Z, position.M); return position; }
/// <summary> /// Converts the position with the Y coordinate as latitude. /// </summary> /// <param name="position">The position to convert.</param> /// <returns>The converted position</returns> internal static GeographyPosition ConvertWithYCoordinateAsLatitude(GeometryPosition position) { return(new GeographyPosition(position.Y, position.X, position.Z, position.M)); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected override GeometryPosition OnBeginFigure(GeometryPosition position) { BeginFigure(); this.WriteControlPoint(position.X, position.Y, position.Z, position.M); return(position); }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> /// <returns> /// The position to be passed down the pipeline /// </returns> protected override GeometryPosition OnLineTo(GeometryPosition position) { this.AddLineTo(position.X, position.Y, position.Z, position.M); return(position); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected override GeometryPosition OnBeginFigure(GeometryPosition position) { BeginFigure(); this.WriteControlPoint(position.X, position.Y, position.Z, position.M); return position; }