Beispiel #1
0
        public void EqualWhenSameInstance()
        {
            GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
            var testSubject             = position1;

            Assert.True(testSubject == position1);
        }
Beispiel #2
0
        public void EqualWhenEverythingMatches()
        {
            GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
            object            position2 = new GeographyPosition(10, 20, 30, 40);

            Assert.True(position1.Equals(position2));
        }
Beispiel #3
0
        public void NotEqualPositions()
        {
            GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
            GeographyPosition position2 = new GeographyPosition(10, 20, null, 40);

            Assert.True(position1 != position2);
        }
Beispiel #4
0
        public void NotEqualObjects()
        {
            GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
            GeometryPosition  position2 = new GeometryPosition(10, 20, 30, 40);

            Assert.False(position1.Equals(position2));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 /// <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());
        }
Beispiel #8
0
 /// <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);
 }
Beispiel #9
0
        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());
        }
Beispiel #10
0
 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);
 }
Beispiel #11
0
        /// <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)
 {
 }
Beispiel #13
0
 public override void LineTo(GeographyPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeographyAddLineTo, position.Latitude, position.Longitude, position.Z, position.M);
 }
Beispiel #14
0
 /// <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;
 }
Beispiel #15
0
 /// <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);
        }
Beispiel #17
0
 /// <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);
 }
Beispiel #18
0
 public override void LineTo(GeographyPosition position)
 {
     this.tracingPipe.Trace("Geography.LineTo", position);
 }
 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 NotEqualPositions()
 {
     GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
     GeographyPosition position2 = new GeographyPosition(10, 20, null, 40);
     Assert.True(position1 != position2);
 }
 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 NotEqualToNull()
 {
     GeographyPosition position1 = new GeographyPosition(10, 20, 30, 40);
     Assert.False(position1.Equals(null));
 }
Beispiel #24
0
 public override void LineTo(GeographyPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeographyAddLineTo, position.Latitude, position.Longitude, position.Z, position.M);
 }
 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);
 }
Beispiel #27
0
 /// <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;
 }
Beispiel #29
0
 /// <summary>Begins drawing a figure.</summary>
 /// <param name="position">The position of the figure.</param>
 public abstract void BeginFigure(GeographyPosition position);
Beispiel #30
0
 /// <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;
 }
Beispiel #32
0
 /// <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;
 }
Beispiel #34
0
 /// <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;
 }
Beispiel #35
0
 /// <summary>Draws a point in the specified coordinate.</summary>
 /// <param name="position">The position of the line.</param>
 public abstract void LineTo(GeographyPosition position);
Beispiel #36
0
 public override void BeginFigure(GeographyPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeographyBeginFigure, position.Latitude, position.Longitude, position.Z, position.M);
 }
Beispiel #37
0
 protected virtual GeographyPosition OnBeginFigure(GeographyPosition position)
 {
     return(position);
 }
 public override void BeginFigure(GeographyPosition position)
 {
 }
Beispiel #39
0
 protected virtual GeographyPosition OnLineTo(GeographyPosition position)
 {
     return(position);
 }
Beispiel #40
0
 public override void BeginFigure(GeographyPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeographyBeginFigure, position.Latitude, position.Longitude, 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 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);
 }
Beispiel #43
0
 /// <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);
 }
Beispiel #44
0
 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;
 }
Beispiel #46
0
 /// <summary>Begins drawing a figure.</summary>
 /// <param name="position">The position of the figure.</param>
 public abstract void BeginFigure(GeographyPosition 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;
            }
Beispiel #48
0
 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();
 }
Beispiel #50
0
 public override void LineTo(GeographyPosition position)
 {
     this.both.OnLineTo(position);
 }
 public Geography AsPoint(GeographyPosition position)
 {
     return(CreateGeography(SpatialType.Point, position, WritePoint));
 }
Beispiel #52
0
 public override void BeginFigure(GeographyPosition position)
 {
     this.both.OnBeginFigure(position);
 }
Beispiel #53
0
 protected override GeographyPosition OnLineTo(GeographyPosition position)
 {
     this.AddLineTo(position.Longitude, position.Latitude, position.Z, position.M);
     return position;
 }
Beispiel #54
0
 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);
 }
Beispiel #55
0
 protected override GeographyPosition OnBeginFigure(GeographyPosition position)
 {
     this.WriteFigureScope(position.Longitude, position.Latitude, position.Z, position.M);
     return position;
 }
Beispiel #56
0
 /// <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);
 }
Beispiel #57
0
 protected override GeographyPosition OnLineTo(GeographyPosition position)
 {
     this.WriteControlPoint(position.Longitude, position.Latitude, position.Z, position.M);
     return position;
 }