Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spatial types to Core.Experimental #12251

Merged
merged 16 commits into from
May 22, 2020
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
namespace Azure.Core.Spatial
{
public sealed partial class CollectionGeometry : Azure.Core.Spatial.Geometry
{
public CollectionGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.Geometry> geometries) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public CollectionGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.Geometry> geometries, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.Geometry> Geometries { get { throw null; } }
}
public partial class Geometry
{
protected Geometry(Azure.Core.Spatial.GeometryProperties properties) { }
public Azure.Core.Spatial.GeometryProperties Properties { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct GeometryBoundingBox : System.IEquatable<Azure.Core.Spatial.GeometryBoundingBox>
{
private readonly int _dummyPrimitive;
public GeometryBoundingBox(double west, double south, double east, double north) { throw null; }
public GeometryBoundingBox(double west, double south, double east, double north, double? minAltitude, double? maxAltitude) { throw null; }
public double East { get { throw null; } }
public double? MaxAltitude { get { throw null; } }
public double? MinAltitude { get { throw null; } }
public double North { get { throw null; } }
public double South { get { throw null; } }
public double West { get { throw null; } }
public bool Equals(Azure.Core.Spatial.GeometryBoundingBox other) { throw null; }
public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
}
public partial class GeometryJsonConverter : System.Text.Json.Serialization.JsonConverter<Azure.Core.Spatial.Geometry>
{
public GeometryJsonConverter() { }
public override Azure.Core.Spatial.Geometry Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; }
public override void Write(System.Text.Json.Utf8JsonWriter writer, Azure.Core.Spatial.Geometry value, System.Text.Json.JsonSerializerOptions options) { }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct GeometryPosition : System.IEquatable<Azure.Core.Spatial.GeometryPosition>
{
private readonly int _dummyPrimitive;
public GeometryPosition(double longitude, double latitude) { throw null; }
public GeometryPosition(double longitude, double latitude, double? altitude) { throw null; }
public double? Altitude { get { throw null; } }
public double Latitude { get { throw null; } }
public double Longitude { get { throw null; } }
public bool Equals(Azure.Core.Spatial.GeometryPosition other) { throw null; }
public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Core.Spatial.GeometryPosition left, Azure.Core.Spatial.GeometryPosition right) { throw null; }
public static bool operator !=(Azure.Core.Spatial.GeometryPosition left, Azure.Core.Spatial.GeometryPosition right) { throw null; }
public override string ToString() { throw null; }
}
public partial class GeometryProperties
{
public GeometryProperties(Azure.Core.Spatial.GeometryBoundingBox? boundingBox = default(Azure.Core.Spatial.GeometryBoundingBox?), System.Collections.Generic.IReadOnlyDictionary<string, object?>? additionalProperties = null) { }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> AdditionalProperties { get { throw null; } }
public Azure.Core.Spatial.GeometryBoundingBox? BoundingBox { get { throw null; } }
}
public sealed partial class LineGeometry : Azure.Core.Spatial.Geometry
{
public LineGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.GeometryPosition> positions) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public LineGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.GeometryPosition> positions, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.GeometryPosition> Positions { get { throw null; } }
}
public sealed partial class MultiLineGeometry : Azure.Core.Spatial.Geometry
{
public MultiLineGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.LineGeometry> lines) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public MultiLineGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.LineGeometry> lines, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.LineGeometry> Lines { get { throw null; } }
}
public sealed partial class MultiPointGeometry : Azure.Core.Spatial.Geometry
{
public MultiPointGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.PointGeometry> points) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public MultiPointGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.PointGeometry> points, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.PointGeometry> Points { get { throw null; } }
}
public sealed partial class MultiPolygonGeometry : Azure.Core.Spatial.Geometry
{
public MultiPolygonGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.PolygonGeometry> polygons) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public MultiPolygonGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.PolygonGeometry> polygons, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.PolygonGeometry> Polygons { get { throw null; } }
}
public sealed partial class PointGeometry : Azure.Core.Spatial.Geometry
{
public PointGeometry(Azure.Core.Spatial.GeometryPosition position) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public PointGeometry(Azure.Core.Spatial.GeometryPosition position, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public Azure.Core.Spatial.GeometryPosition Position { get { throw null; } }
}
public sealed partial class PolygonGeometry : Azure.Core.Spatial.Geometry
{
public PolygonGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.LineGeometry> rings) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public PolygonGeometry(System.Collections.Generic.IEnumerable<Azure.Core.Spatial.LineGeometry> rings, Azure.Core.Spatial.GeometryProperties properties) : base (default(Azure.Core.Spatial.GeometryProperties)) { }
public System.Collections.Generic.IReadOnlyList<Azure.Core.Spatial.LineGeometry> Rings { get { throw null; } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
<Nullable>enable</Nullable>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
<NoWarn>$(NoWarn);AZC0001;AZC0012</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)Argument.cs" />
<Compile Include="$(AzureCoreSharedSources)HashCodeBuilder.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Azure.Core.Experimental.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]
39 changes: 39 additions & 0 deletions sdk/core/Azure.Core.Experimental/src/Spatial/CollectionGeometry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Linq;

namespace Azure.Core.Spatial
{
/// <summary>
/// Represents a geometry that is composed of multiple geometries.
/// </summary>
public sealed class CollectionGeometry : Geometry
{
/// <summary>
/// Initializes new instance of <see cref="CollectionGeometry"/>.
/// </summary>
/// <param name="geometries">The collection of inner geometries.</param>
public CollectionGeometry(IEnumerable<Geometry> geometries): this(geometries, DefaultProperties)
{
}

/// <summary>
/// Initializes new instance of <see cref="CollectionGeometry"/>.
/// </summary>
/// <param name="geometries">The collection of inner geometries.</param>
/// <param name="properties">The <see cref="GeometryProperties"/> associated with the geometry.</param>
public CollectionGeometry(IEnumerable<Geometry> geometries, GeometryProperties properties): base(properties)
{
Argument.AssertNotNull(geometries, nameof(geometries));

Geometries = geometries.ToArray();
}

/// <summary>
/// Gets the list of <see cref="Geometry"/> geometry is composed of.
/// </summary>
public IReadOnlyList<Geometry> Geometries { get; }
}
}
29 changes: 29 additions & 0 deletions sdk/core/Azure.Core.Experimental/src/Spatial/Geometry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Core.Spatial
{
/// <summary>
/// A base type for all spatial types.
/// </summary>
public class Geometry
{
internal static readonly GeometryProperties DefaultProperties = new GeometryProperties();

/// <summary>
/// The <see cref="GeometryProperties"/> associated with this <see cref="Geometry"/> instance.
/// </summary>
public GeometryProperties Properties { get; }

/// <summary>
/// Initializes a new instance of <see cref="Geometry"/>.
/// </summary>
/// <param name="properties">The <see cref="GeometryProperties"/> to use.</param>
protected Geometry(GeometryProperties properties)
{
Argument.AssertNotNull(properties, nameof(properties));

Properties = properties;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;

namespace Azure.Core.Spatial
{
/// <summary>
/// Represents information about the coordinate range of the <see cref="Geometry"/>.
/// </summary>
public readonly struct GeometryBoundingBox : IEquatable<GeometryBoundingBox>
{
/// <summary>
/// The westmost value of <see cref="Geometry"/> coordinates.
/// </summary>
public double West { get; }

/// <summary>
/// The southmost value of <see cref="Geometry"/> coordinates.
/// </summary>
public double South { get; }

/// <summary>
/// The eastmost value of <see cref="Geometry"/> coordinates.
/// </summary>
public double East { get; }

/// <summary>
/// The northmost value of <see cref="Geometry"/> coordinates.
/// </summary>
public double North { get; }

/// <summary>
/// The minimum altitude value of <see cref="Geometry"/> coordinates.
/// </summary>
public double? MinAltitude { get; }

/// <summary>
/// The maximum altitude value of <see cref="Geometry"/> coordinates.
/// </summary>
public double? MaxAltitude { get; }

/// <summary>
/// Initializes a new instance of <see cref="GeometryBoundingBox"/>.
/// </summary>
public GeometryBoundingBox(double west, double south, double east, double north) : this(west, south, east, north, null, null)
{
}

/// <summary>
/// Initializes a new instance of <see cref="GeometryBoundingBox"/>.
/// </summary>
public GeometryBoundingBox(double west, double south, double east, double north, double? minAltitude, double? maxAltitude)
{
West = west;
South = south;
East = east;
North = north;
MinAltitude = minAltitude;
MaxAltitude = maxAltitude;
}

/// <inheritdoc />
public bool Equals(GeometryBoundingBox other)
{
return West.Equals(other.West) &&
South.Equals(other.South) &&
East.Equals(other.East) &&
North.Equals(other.North) &&
Nullable.Equals(MinAltitude, other.MinAltitude) &&
Nullable.Equals(MaxAltitude, other.MaxAltitude);
}

/// <inheritdoc />
public override bool Equals(object? obj)
{
return obj is GeometryBoundingBox other && Equals(other);
}

/// <inheritdoc />
public override int GetHashCode()
{
return HashCodeBuilder.Combine(West, South, East, North, MinAltitude, MaxAltitude);
}
}
}
Loading