コード例 #1
0
        public void EqualWhenSameInstance()
        {
            GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
            var testSubject            = position1;

            Assert.IsTrue(testSubject == position1);
        }
コード例 #2
0
        public void EqualWhenEverythingMatches()
        {
            GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
            object           position2 = new GeometryPosition(10, 20, 30, 40);

            Assert.IsTrue(position1.Equals(position2));
        }
コード例 #3
0
        public void NotEqualPositions()
        {
            GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
            GeometryPosition position2 = new GeometryPosition(40, 30, 20, 10);

            Assert.IsTrue(position1 != position2);
        }
コード例 #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));
        }
コード例 #5
0
 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"));
 }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
 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);
 }
コード例 #9
0
        /// <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());
        }
コード例 #10
0
 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();
     }
 }
コード例 #11
0
 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();
     }
 }
コード例 #12
0
 public override void BeginFigure(GeometryPosition position)
 {
 }
コード例 #13
0
ファイル: LoggingPipelines.cs プロジェクト: zhonli/odata.net
 public override void BeginFigure(GeometryPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeometryBeginFigure, position.X, position.Y, position.Z, position.M);
 }
コード例 #14
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <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;
 }
コード例 #15
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Draw a point in the specified coordinate
 /// </summary>
 /// <param name="position">Next position</param>
 public override void LineTo(GeometryPosition position)
 {
     both.OnLineTo(position);
 }
コード例 #16
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 GeometryPosition OnLineTo(GeometryPosition position)
 {
     this.WriteControlPoint(position.X, position.Y, position.Z, position.M);
     return position;
 }
コード例 #17
0
 /// <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));
 }
コード例 #18
0
ファイル: DrawBoth.cs プロジェクト: modulexcite/pash-1
 protected virtual GeometryPosition OnBeginFigure(GeometryPosition position)
 {
     return(position);
 }
コード例 #19
0
 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;
 }
コード例 #20
0
 /// <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;
 }
コード例 #21
0
 public void NotEqualPositions()
 {
     GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
     GeometryPosition position2 = new GeometryPosition(40, 30, 20, 10);
     Assert.True(position1 != position2);
 }
コード例 #22
0
 public void EqualWhenSameInstance()
 {
     GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
     var testSubject = position1;
     Assert.True(testSubject == position1);
 }
コード例 #23
0
 public void EqualWhenEverythingMatches()
 {
     GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
     object position2 = new GeometryPosition(10, 20, 30, 40);
     Assert.True(position1.Equals(position2));
 }
コード例 #24
0
 public void NotEqualToNull()
 {
     GeometryPosition position1 = new GeometryPosition(10, 20, 30, 40);
     Assert.False(position1.Equals(null));
 }
コード例 #25
0
 public override void LineTo(GeometryPosition position)
 {
     sum += this.sign * (position.X + position.Y);
 }
コード例 #26
0
ファイル: DrawBoth.cs プロジェクト: modulexcite/pash-1
 protected virtual GeometryPosition OnLineTo(GeometryPosition position)
 {
     return(position);
 }
コード例 #27
0
 public override void BeginFigure(GeometryPosition position)
 {
     sum += this.sign * (position.X + position.Y);
 }
コード例 #28
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 GeometryPosition OnBeginFigure(GeometryPosition position)
 {
     WriteFigureScope(position.X, position.Y, position.Z, position.M);
     return(position);
 }
コード例 #29
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));
 }
コード例 #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 GeometryPosition OnLineTo(GeometryPosition position)
 {
     this.WriteControlPoint(position.X, position.Y, position.Z, position.M);
     return(position);
 }
コード例 #31
0
 public override void BeginFigure(GeometryPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeometryBeginFigure, position.X, position.Y, position.Z, position.M);
 }
コード例 #32
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Begin drawing a figure
 /// </summary>
 /// <param name="position">Next position</param>
 public override void BeginFigure(GeometryPosition position)
 {
     both.OnBeginFigure(position);
 }
コード例 #33
0
 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);
 }
コード例 #34
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <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;
 }
コード例 #35
0
 public override void LineTo(GeometryPosition position)
 {
     this.builder.LineTo(position.X, position.Y, position.Z, position.M);
 }
コード例 #36
0
ファイル: LoggingPipelines.cs プロジェクト: zhonli/odata.net
 public override void LineTo(GeometryPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeometryAddLineTo, position.X, position.Y, position.Z, position.M);
 }
コード例 #37
0
 public override void LineTo(GeometryPosition position)
 {
     this.tracingPipe.Trace("Geometry.LineTo", position);
 }
コード例 #38
0
 public override void LineTo(GeometryPosition position)
 {
 }
コード例 #39
0
ファイル: SpatialTestUtils.cs プロジェクト: sivethe/odata.net
 public override void BeginFigure(GeometryPosition position)
 {
     this.parent.coordinates.Add(new PositionData(position.X, position.Y, position.Z, position.M));
 }
コード例 #40
0
        /// <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);
        }
コード例 #41
0
            /// <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;
            }
コード例 #42
0
 public override void LineTo(GeometryPosition position)
 {
     logger.AddCoordinates(PipelineMethod.GeometryAddLineTo, position.X, position.Y, position.Z, position.M);
 }
コード例 #43
0
ファイル: GeometryPipeline.cs プロジェクト: nickchal/pash
 public abstract void BeginFigure(GeometryPosition position);
コード例 #44
0
 public override void BeginFigure(GeometryPosition position)
 {
     this.builder.BeginFigure(position.X, position.Y, position.Z, position.M);
 }
コード例 #45
0
ファイル: GeometryPipeline.cs プロジェクト: nickchal/pash
 public abstract void LineTo(GeometryPosition position);
コード例 #46
0
 public override void BeginFigure(GeometryPosition position)
 {
     this.tracingPipe.Trace("Geometry.BeginFigure", position);
 }
コード例 #47
0
 /// <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));
 }
コード例 #48
0
 /// <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));
 }
コード例 #49
0
 /// <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);
 }
コード例 #50
0
ファイル: DrawBoth.cs プロジェクト: modulexcite/pash-1
 public override void BeginFigure(GeometryPosition position)
 {
     this.both.OnBeginFigure(position);
 }
コード例 #51
0
ファイル: GeometryPipeline.cs プロジェクト: tapika/swupd
 /// <summary>Draws a point in the specified coordinate.</summary>
 /// <param name="position">The position of the line.</param>
 public abstract void LineTo(GeometryPosition position);
コード例 #52
0
ファイル: DrawBoth.cs プロジェクト: modulexcite/pash-1
 public override void LineTo(GeometryPosition position)
 {
     this.both.OnLineTo(position);
 }
コード例 #53
0
 protected override GeometryPosition OnLineTo(GeometryPosition position)
 {
     this.AddLineTo(position.X, position.Y, position.Z, position.M);
     return position;
 }
コード例 #54
0
 /// <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));
 }
コード例 #55
0
 protected override GeometryPosition OnBeginFigure(GeometryPosition position)
 {
     this.WriteFigureScope(position.X, position.Y, position.Z, position.M);
     return position;
 }
コード例 #56
0
 /// <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));
 }
コード例 #57
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 GeometryPosition OnBeginFigure(GeometryPosition position)
 {
     BeginFigure();
     this.WriteControlPoint(position.X, position.Y, position.Z, position.M);
     return(position);
 }
コード例 #58
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 GeometryPosition OnLineTo(GeometryPosition position)
 {
     this.AddLineTo(position.X, position.Y, position.Z, position.M);
     return(position);
 }
コード例 #59
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 GeometryPosition OnBeginFigure(GeometryPosition position)
 {
     BeginFigure();
     this.WriteControlPoint(position.X, position.Y, position.Z, position.M);
     return position;
 }