public void EqualWhenSameInstance() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); var testSubject = position1; Assert.True(testSubject == position1); }
public void EqualWhenEverythingMatches() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); object position2 = new GeographyPosition(10, 20, 30, 40); Assert.True(position1.Equals(position2)); }
public void NotEqualPositions() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); GeographyPosition position2 = new GeographyPosition(10, 20, null, 40); Assert.True(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 static GeographyLineString ConvertLineStringTo(DbGeography dbGeo) { Debug.Assert(dbGeo.SpatialTypeName == "LineString"); SpatialBuilder builder = SpatialBuilder.Create(); var pipeLine = builder.GeographyPipeline; pipeLine.SetCoordinateSystem(CoordinateSystem.DefaultGeography); pipeLine.BeginGeography(SpatialType.LineString); int numPionts = dbGeo.PointCount ?? 0; for (int n = 0; n < numPionts; n++) { DbGeography pointN = dbGeo.PointAt(n + 1); double lat = pointN.Latitude ?? 0; double lon = pointN.Longitude ?? 0; double? alt = pointN.Elevation; double? m = pointN.Measure; GeographyPosition position = new GeographyPosition(lat, lon, alt, m); if (n == 0) { pipeLine.BeginFigure(position); } else { pipeLine.LineTo(position); } } pipeLine.EndFigure(); pipeLine.EndGeography(); return((GeographyLineString)builder.ConstructedGeography); }
/// <summary> /// Continue drawing a Geography figure /// </summary> /// <param name="position">Next position</param> public override void LineTo(GeographyPosition position) { Util.CheckArgumentNull(position, "position"); DoAction( val => Current.LineTo(val), val => Next.LineTo(val), position); }
public void GetHashCodeImplementation() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); Assert.Equal(2139226112, position1.GetHashCode()); GeographyPosition position2 = new GeographyPosition(10, 20, null, null); Assert.Equal(48234496, position2.GetHashCode()); }
/// <summary> /// Begin drawing a Geography figure /// </summary> /// <param name="position">Next position</param> public override void BeginFigure(GeographyPosition position) { Util.CheckArgumentNull(position, "position"); DoAction( val => Current.BeginFigure(val), val => Next.BeginFigure(val), position); }
protected override GeographyPosition OnLineTo(GeographyPosition position) { if (this.processingGeography) { ValidateGeographyPosition(position.Latitude, position.Longitude, position.Z, position.M); } this.AddControlPoint(position.Latitude, position.Longitude); if (!this.processingGeography) { throw new FormatException(Strings.Validator_UnexpectedGeometry); } return(position); }
/// <summary> /// Converts an NTS LineString to a Microsoft.Spatial GeogaphyLineString. /// </summary> /// <param name="lineString">The NTS LineString.</param> /// <returns></returns> public static GeographyLineString ToGeographyLineString(this Geometry lineString) { if (lineString == null) { return(null); } Debug.Assert(lineString.GeometryType == "LineString"); var builder = SpatialBuilder.Create(); var pipeLine = builder.GeographyPipeline; pipeLine.SetCoordinateSystem(CoordinateSystem.DefaultGeography); pipeLine.BeginGeography(SpatialType.LineString); var numPionts = lineString.NumPoints; for (var n = 0; n < numPionts; n++) { var pointN = lineString.GetGeometryN(n + 1); var lat = pointN.Coordinate.Y; var lon = pointN.Coordinate.X; var alt = pointN.Coordinate.Z; var m = pointN.Length; var position = new GeographyPosition(lat, lon, alt, m); if (n == 0) { pipeLine.BeginFigure(position); } else { pipeLine.LineTo(position); } } pipeLine.EndFigure(); pipeLine.EndGeography(); return((GeographyLineString)builder.ConstructedGeography); }
public override void LineTo(GeographyPosition position) { }
public override void LineTo(GeographyPosition position) { logger.AddCoordinates(PipelineMethod.GeographyAddLineTo, position.Latitude, position.Longitude, 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 GeographyPosition OnBeginFigure(GeographyPosition position) { return position; }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> public override void BeginFigure(GeographyPosition position) { both.OnBeginFigure(position); }
public void GeoJsonSimpleRoundTripTest() { var position = new GeographyPosition(12, 34, -12, -34); var coordinateSystem = CoordinateSystem.Geography(54321); var writer = new GeoJsonObjectWriter(); GeographyPipeline pipeline = (SpatialPipeline)writer; pipeline.SetCoordinateSystem(coordinateSystem); pipeline.BeginGeography(SpatialType.Point); pipeline.BeginFigure(position); pipeline.EndFigure(); pipeline.EndGeography(); var actualPipeline = new CallSequenceLoggingPipeline(); var reader = new GeoJsonObjectReader(actualPipeline); reader.ReadGeography(writer.JsonObject); var expectedPipeline = new CallSequenceLoggingPipeline(); // TODO: move the set of calls back into a delegate if the APIs come back together expectedPipeline.GeographyPipeline.SetCoordinateSystem(coordinateSystem); expectedPipeline.GeographyPipeline.BeginGeography(SpatialType.Point); expectedPipeline.GeographyPipeline.BeginFigure(position); expectedPipeline.GeographyPipeline.EndFigure(); expectedPipeline.GeographyPipeline.EndGeography(); actualPipeline.Verify(expectedPipeline); }
/// <summary> /// Begin drawing a figure /// </summary> /// <param name="position">Next position</param> /// <returns>The position to be passed down the pipeline</returns> protected override GeographyPosition OnBeginFigure(GeographyPosition position) { BeginFigure(); WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M); return(position); }
public override void LineTo(GeographyPosition position) { this.tracingPipe.Trace("Geography.LineTo", position); }
public void NotEqualToNull() { GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40); Assert.False(position1.Equals(null)); }
protected override GeographyPosition OnBeginFigure(GeographyPosition position) { this.BeginFigure(new Action<double, double, double?, double?>(SpatialValidatorImplementation.NestedValidator.ValidateGeographyPosition), position.Latitude, position.Longitude, position.Z, position.M); return position; }
public override void LineTo(GeographyPosition position) { this.builder.LineTo(position.Latitude, position.Longitude, position.Z, position.M); }
/// <summary>Draws a point in the specified coordinate.</summary> /// <param name="position">The position of the line.</param> public abstract void LineTo(GeographyPosition 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 GeographyPosition OnBeginFigure(GeographyPosition position) { BeginFigure(ValidateGeographyPosition, position.Latitude, position.Longitude, position.Z, position.M); return position; }
/// <summary>Begins drawing a figure.</summary> /// <param name="position">The position of the figure.</param> public abstract void BeginFigure(GeographyPosition 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 GeographyPosition OnLineTo(GeographyPosition position) { // GeoJSON specification is that longitude is first WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M); return(position); }
public override void LineTo(GeographyPosition position) { this.sum += sign * position.Latitude; this.sum += sign * position.Longitude; }
/// <summary> /// Draw a point in the specified coordinate /// </summary> /// <param name="position">Next position</param> public override void LineTo(GeographyPosition position) { both.OnLineTo(position); }
public override void BeginFigure(GeographyPosition position) { this.sum += sign * position.Latitude; this.sum += sign * position.Longitude; }
/// <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 GeographyPosition OnLineTo(GeographyPosition position) { return position; }
public override void BeginFigure(GeographyPosition position) { logger.AddCoordinates(PipelineMethod.GeographyBeginFigure, position.Latitude, position.Longitude, position.Z, position.M); }
protected virtual GeographyPosition OnBeginFigure(GeographyPosition position) { return(position); }
public override void BeginFigure(GeographyPosition position) { }
protected virtual GeographyPosition OnLineTo(GeographyPosition position) { 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 GeographyPosition OnLineTo(GeographyPosition position) { // GeoJSON specification is that longitude is first WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M); return position; }
public override void BeginFigure(GeographyPosition position) { this.builder.BeginFigure(position.Latitude, position.Longitude, 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 GeographyPosition OnBeginFigure(GeographyPosition position) { WriteFigureScope(position.Longitude, position.Latitude, position.Z, position.M); return(position); }
public override void BeginFigure(GeographyPosition position) { this.tracingPipe.Trace("Geography.BeginFigure", 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 GeographyPosition OnBeginFigure(GeographyPosition position) { BeginFigure(); WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M); return position; }
/// <summary> /// Implemented by a subclass to handle the addition of a waypoint to a Geography figure /// </summary> /// <param name="position">Next position</param> /// <returns>the GeographyPosition to be passed down the pipeline</returns> protected override GeographyPosition OnLineTo(GeographyPosition position) { if (this.processingGeography) { ValidateGeographyPosition(position.Latitude, position.Longitude, position.Z, position.M); } AddControlPoint(position.Latitude, position.Longitude); if (!this.processingGeography) { throw new FormatException(Strings.Validator_UnexpectedGeometry); } return position; }
public override void BeginFigure(GeographyPosition position) { this.parent.coordinates.Add(new PositionData(position.Latitude, position.Longitude, position.Z, position.M)); }
private void WritePoint(GeographyPipeline pipeline, GeographyPosition position) { pipeline.BeginFigure(position); pipeline.EndFigure(); }
public override void LineTo(GeographyPosition position) { this.both.OnLineTo(position); }
public Geography AsPoint(GeographyPosition position) { return(CreateGeography(SpatialType.Point, position, WritePoint)); }
public override void BeginFigure(GeographyPosition position) { this.both.OnBeginFigure(position); }
protected override GeographyPosition OnLineTo(GeographyPosition position) { this.AddLineTo(position.Longitude, position.Latitude, position.Z, position.M); return position; }
public override void BeginFigure(GeographyPosition position) { Debug.Assert(position != null, "ForwardingSegment should have validated nullness"); this.builder.BeginFigure(position.Latitude, position.Longitude, position.Z, position.M); }
protected override GeographyPosition OnBeginFigure(GeographyPosition position) { this.WriteFigureScope(position.Longitude, position.Latitude, 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 GeographyPosition OnLineTo(GeographyPosition position) { this.AddLineTo(position.Longitude, position.Latitude, position.Z, position.M); return(position); }
protected override GeographyPosition OnLineTo(GeographyPosition position) { this.WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M); return position; }