Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 268 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Install dotnet-format
run: dotnet tool install -g dotnet-format

- name: Check code format
run: dotnet format --no-restore --verify-no-changes
Comment thread
lukaskabrt marked this conversation as resolved.

- name: Restore dependencies
run: dotnet restore
Expand Down
456 changes: 253 additions & 203 deletions src/Benchmark.SpatialLite.Osm/Program.cs

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Benchmark.SpatialLite.Osm")]
[assembly: AssemblyTrademark("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ebe5e8af-6eda-4967-ab80-df979d3dd720")]
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Benchmark.SpatialLite.Osm")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ebe5e8af-6eda-4967-ab80-df979d3dd720")]
340 changes: 178 additions & 162 deletions src/SpatialLite.Core/API/Coordinate.cs
Original file line number Diff line number Diff line change
@@ -1,169 +1,185 @@
using System;

namespace SpatialLite.Core.API {
namespace SpatialLite.Core.API;

/// <summary>
/// Represents a location in the coordinate space.
/// </summary>
/// <remarks>
/// A Coordinate may include a M value. The M value allows an application to associate some measure with the <c>Coordinate</c>.
/// </remarks>
public struct Coordinate : IEquatable<Coordinate>
{

/// <summary>
/// Represents a location in the coordinate space.
/// Represents an empty coordinate.
/// </summary>
/// <remarks>
/// A Coordinate may include a M value. The M value allows an application to associate some measure with the <c>Coordinate</c>.
/// The empty coordinate has all coordinates equal to NaN.
/// </remarks>
public struct Coordinate : IEquatable<Coordinate> {

/// <summary>
/// Represents an empty coordinate.
/// </summary>
/// <remarks>
/// The empty coordinate has all coordinates equal to NaN.
/// </remarks>
public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN);

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y ordinates.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
public Coordinate(double x, double y) {
X = x;
Y = y;
Z = double.NaN;
M = double.NaN;
}

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y, Z ordinates.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
/// <param name="z">Z-coordinate value.</param>
public Coordinate(double x, double y, double z) {
X = x;
Y = y;
Z = z;
M = double.NaN;
}

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y, Z ordinates and M value.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
/// <param name="z">Z-coordinate value.</param>
/// <param name="m">Measured value associated with the Coordinate.</param>
public Coordinate(double x, double y, double z, double m) {
X = x;
Y = y;
Z = z;
M = m;
}

/// <summary>
/// Gets the X-coordinate
/// </summary>
public double X { get; set; }

/// <summary>
/// Gets the Y-coordinate
/// </summary>
public double Y { get; set; }

/// <summary>
/// Gets the Z-coordinate
/// </summary>
public double Z { get; set; }

/// <summary>
/// Gets the M value
/// </summary>
public double M { get; set; }

/// <summary>
/// Gets a value indicating whether this coordinate has assigned <see cref="Coordinate.Z"/> coordinate.
/// </summary>
public bool Is3D {
get {
return !double.IsNaN(this.Z);
}
}

/// <summary>
/// Gets a value indicating whether this coordinate has assigned <see cref="Coordinate.M"/> value.
/// </summary>
public bool IsMeasured {
get {
return !double.IsNaN(this.M);
}
}

/// <summary>
/// Determiens whether specific Coordinates values are equal
/// </summary>
/// <param name="lhs">Coordinate to compare</param>
/// <param name="rhs">Coordinate to compare</param>
/// <returns>true if the specified <c>Coordinate</c> values are equal; otherwise, false.</returns>
public static bool operator ==(Coordinate lhs, Coordinate rhs) {
return lhs.Equals(rhs);
}

/// <summary>
/// Determiens whether specific Coordinate values are not equal
/// </summary>
/// <param name="lhs">Coordinate to compare</param>
/// <param name="rhs">Coordinate to compare</param>
/// <returns>true if the specified <c>Coordinate</c> values are not equal; otherwise, false.</returns>
public static bool operator !=(Coordinate lhs, Coordinate rhs) {
return !(lhs == rhs);
}

/// <summary>
/// Returns a <c>string</c> that represents the current <c>Coordinate</c>.
/// </summary>
/// <returns>A <c>string</c> that represents the current <c>Coordinate</c></returns>
public override string ToString() {
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M);
}

/// <summary>
/// Determines whether specific <c>object</c> instance is equal to the current <c>Coordinate</c>.
/// </summary>
/// <param name="obj">The <c>object</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>object</c> is equal to the current <c>Coordinate</c>; otherwise, false.</returns>
public override bool Equals(object obj) {
Coordinate? other = obj as Coordinate?;
if (other == null) {
return false;
}

return this.Equals(other.Value);
}

/// <summary>
/// Determines whether two <c>Coordinate</c> values are equal.
/// </summary>
/// <param name="other">The <c>Coordinate</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>Coordinate</c> is equal to the current <c>Coordinate</c>; otherwise, false.</returns>
public bool Equals(Coordinate other) {
return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) &&
((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) &&
((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) &&
((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M)));
}

/// <summary>
/// Serves as a hash function for the <c>Coordinate</c> structure.
/// </summary>
/// <returns>Hash code for current Coordinate value.</returns>
public override int GetHashCode() {
return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode();
}

/// <summary>
/// Determines whether two <c>Coordinate</c> are equal in 2D space.
/// </summary>
/// <param name="other">The <c>Coordinate</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>Coordinate</c> is equal to the current <c>Coordinate</c> in 2D space otherwise, false.</returns>
public bool Equals2D(Coordinate other) {
return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) &&
((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y)));
}
}
public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN);

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y ordinates.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
public Coordinate(double x, double y)
{
X = x;
Y = y;
Z = double.NaN;
M = double.NaN;
}

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y, Z ordinates.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
/// <param name="z">Z-coordinate value.</param>
public Coordinate(double x, double y, double z)
{
X = x;
Y = y;
Z = z;
M = double.NaN;
}

/// <summary>
/// Initializes a new instance of the <c>Coordinate</c> struct with X, Y, Z ordinates and M value.
/// </summary>
/// <param name="x">X-coordinate value.</param>
/// <param name="y">Y-coordinate value.</param>
/// <param name="z">Z-coordinate value.</param>
/// <param name="m">Measured value associated with the Coordinate.</param>
public Coordinate(double x, double y, double z, double m)
{
X = x;
Y = y;
Z = z;
M = m;
}

/// <summary>
/// Gets the X-coordinate
/// </summary>
public double X { get; set; }

/// <summary>
/// Gets the Y-coordinate
/// </summary>
public double Y { get; set; }

/// <summary>
/// Gets the Z-coordinate
/// </summary>
public double Z { get; set; }

/// <summary>
/// Gets the M value
/// </summary>
public double M { get; set; }

/// <summary>
/// Gets a value indicating whether this coordinate has assigned <see cref="Coordinate.Z"/> coordinate.
/// </summary>
public bool Is3D
{
get
{
return !double.IsNaN(this.Z);
}
}

/// <summary>
/// Gets a value indicating whether this coordinate has assigned <see cref="Coordinate.M"/> value.
/// </summary>
public bool IsMeasured
{
get
{
return !double.IsNaN(this.M);
}
}

/// <summary>
/// Determiens whether specific Coordinates values are equal
/// </summary>
/// <param name="lhs">Coordinate to compare</param>
/// <param name="rhs">Coordinate to compare</param>
/// <returns>true if the specified <c>Coordinate</c> values are equal; otherwise, false.</returns>
public static bool operator ==(Coordinate lhs, Coordinate rhs)
{
return lhs.Equals(rhs);
}

/// <summary>
/// Determiens whether specific Coordinate values are not equal
/// </summary>
/// <param name="lhs">Coordinate to compare</param>
/// <param name="rhs">Coordinate to compare</param>
/// <returns>true if the specified <c>Coordinate</c> values are not equal; otherwise, false.</returns>
public static bool operator !=(Coordinate lhs, Coordinate rhs)
{
return !(lhs == rhs);
}

/// <summary>
/// Returns a <c>string</c> that represents the current <c>Coordinate</c>.
/// </summary>
/// <returns>A <c>string</c> that represents the current <c>Coordinate</c></returns>
public override string ToString()
{
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M);
}

/// <summary>
/// Determines whether specific <c>object</c> instance is equal to the current <c>Coordinate</c>.
/// </summary>
/// <param name="obj">The <c>object</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>object</c> is equal to the current <c>Coordinate</c>; otherwise, false.</returns>
public override bool Equals(object obj)
{
Coordinate? other = obj as Coordinate?;
if (other == null)
{
return false;
}

return this.Equals(other.Value);
}

/// <summary>
/// Determines whether two <c>Coordinate</c> values are equal.
/// </summary>
/// <param name="other">The <c>Coordinate</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>Coordinate</c> is equal to the current <c>Coordinate</c>; otherwise, false.</returns>
public bool Equals(Coordinate other)
{
return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) &&
((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) &&
((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) &&
((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M)));
}

/// <summary>
/// Serves as a hash function for the <c>Coordinate</c> structure.
/// </summary>
/// <returns>Hash code for current Coordinate value.</returns>
public override int GetHashCode()
{
return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode();
}

/// <summary>
/// Determines whether two <c>Coordinate</c> are equal in 2D space.
/// </summary>
/// <param name="other">The <c>Coordinate</c> to compare with the current <c>Coordinate</c></param>
/// <returns>true if the specified <c>Coordinate</c> is equal to the current <c>Coordinate</c> in 2D space otherwise, false.</returns>
public bool Equals2D(Coordinate other)
{
return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) &&
((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y)));
}
}
Loading
Loading