forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Polygon and Multi Polygon (ChilliCream#4394)
- Loading branch information
1 parent
e27df75
commit ba51ef9
Showing
57 changed files
with
1,667 additions
and
1,011 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/HotChocolate/Spatial/src/Types/Extensions/GeoJsonConverterExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections; | ||
using NetTopologySuite.Geometries; | ||
|
||
namespace HotChocolate.Types.Spatial.Serialization | ||
{ | ||
internal static class GeoJsonConverterExtensions | ||
{ | ||
public static bool TryConvertToCoordinates( | ||
this IList coordinatesList, | ||
out Coordinate[] coordinates) | ||
{ | ||
if (coordinatesList.Count == 0) | ||
{ | ||
coordinates = Array.Empty<Coordinate>(); | ||
return true; | ||
} | ||
|
||
coordinates = new Coordinate[coordinatesList.Count]; | ||
for (var i = 0; i < coordinates.Length; i++) | ||
{ | ||
if (coordinatesList[i] is Coordinate c) | ||
{ | ||
coordinates[i] = c; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/HotChocolate/Spatial/src/Types/GeoJsonCoordinatesType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using HotChocolate.Language; | ||
using HotChocolate.Types.Spatial.Properties; | ||
|
||
namespace HotChocolate.Types.Spatial | ||
{ | ||
/// <summary> | ||
/// <para> | ||
/// The Coordinates scalar type represents a list of arbitrary depth of positions | ||
/// </para> | ||
/// <para>https://tools.ietf.org/html/rfc7946#section-3.1.1</para> | ||
/// </summary> | ||
public sealed class GeoJsonCoordinatesType : ScalarType<object[]> | ||
{ | ||
public GeoJsonCoordinatesType() : base(WellKnownTypeNames.CoordinatesTypeName) | ||
{ | ||
Description = Resources.GeoJsonCoordinatesScalar_Description; | ||
} | ||
|
||
public override bool IsInstanceOfType(IValueNode valueSyntax) | ||
=> GeoJsonCoordinatesSerializer.Default.IsInstanceOfType(this, valueSyntax); | ||
|
||
public override object? ParseLiteral(IValueNode valueSyntax) | ||
=> GeoJsonCoordinatesSerializer.Default.ParseLiteral(this, valueSyntax); | ||
|
||
public override IValueNode ParseValue(object? value) | ||
=> GeoJsonCoordinatesSerializer.Default.ParseValue(this, value); | ||
|
||
public override IValueNode ParseResult(object? resultValue) | ||
=> GeoJsonCoordinatesSerializer.Default.ParseResult(this, resultValue); | ||
|
||
public override bool TryDeserialize(object? serialized, out object? value) | ||
=> GeoJsonCoordinatesSerializer.Default.TryDeserialize(this, serialized, out value); | ||
|
||
public override bool TrySerialize(object? value, out object? serialized) | ||
=> GeoJsonCoordinatesSerializer.Default.TrySerialize(this, value, out serialized); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/HotChocolate/Spatial/src/Types/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
HotChocolate.Types.Spatial.GeoJsonCoordinatesType | ||
HotChocolate.Types.Spatial.GeoJsonCoordinatesType.GeoJsonCoordinatesType() -> void | ||
HotChocolate.Types.Spatial.GeoJsonPolygonType.Resolvers | ||
HotChocolate.Types.Spatial.GeoJsonPolygonType.Resolvers.GetCoordinates(NetTopologySuite.Geometries.Polygon! polygon) -> NetTopologySuite.Geometries.Coordinate![]![]! | ||
HotChocolate.Types.Spatial.GeoJsonPolygonType.Resolvers.Resolvers() -> void | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.IsInstanceOfType(HotChocolate.Language.IValueNode! valueSyntax) -> bool | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.ParseLiteral(HotChocolate.Language.IValueNode! valueSyntax) -> object? | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.ParseResult(object? resultValue) -> HotChocolate.Language.IValueNode! | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.ParseValue(object? value) -> HotChocolate.Language.IValueNode! | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.TryDeserialize(object? serialized, out object? value) -> bool | ||
override HotChocolate.Types.Spatial.GeoJsonCoordinatesType.TrySerialize(object? value, out object? serialized) -> bool |
Oops, something went wrong.