-
Notifications
You must be signed in to change notification settings - Fork 12
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
Enable round-tripping unsupported types #19
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/NetTopologySuite.IO.SqlServerBytes/Geometries/UnsupportedGeometry.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,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using NetTopologySuite.IO.Properties; | ||
using NetTopologySuite.IO.Serialization; | ||
|
||
namespace NetTopologySuite.Geometries | ||
{ | ||
internal class UnsupportedGeometry : Geometry | ||
{ | ||
private readonly OpenGisType _shapeType; | ||
|
||
public UnsupportedGeometry(OpenGisType shapeType, Geography geography) | ||
: base(GeometryFactory.Default) | ||
{ | ||
_shapeType = shapeType; | ||
Geography = geography; | ||
} | ||
|
||
public Geography Geography { get; } | ||
|
||
private NotSupportedException Unsupported() | ||
=> new NotSupportedException(string.Format(Resources.UnexpectedGeographyType, _shapeType)); | ||
|
||
#region Unsupported overrides | ||
|
||
public override double Area => throw Unsupported(); | ||
public override Geometry Boundary => throw Unsupported(); | ||
public override Dimension BoundaryDimension => throw Unsupported(); | ||
public override Point Centroid => throw Unsupported(); | ||
public override Coordinate Coordinate => throw Unsupported(); | ||
public override Coordinate[] Coordinates => throw Unsupported(); | ||
public override Dimension Dimension => throw Unsupported(); | ||
public override string GeometryType => throw Unsupported(); | ||
public override Point InteriorPoint => throw Unsupported(); | ||
public override bool IsEmpty => throw Unsupported(); | ||
public override bool IsRectangle => throw Unsupported(); | ||
public override bool IsSimple => throw Unsupported(); | ||
public override bool IsValid => throw Unsupported(); | ||
public override double Length => throw Unsupported(); | ||
public override int NumGeometries => throw Unsupported(); | ||
public override int NumPoints => throw Unsupported(); | ||
public override OgcGeometryType OgcGeometryType => throw Unsupported(); | ||
|
||
protected override SortIndexValue SortIndex => throw Unsupported(); | ||
|
||
public override void Apply(ICoordinateFilter filter) => throw Unsupported(); | ||
public override void Apply(ICoordinateSequenceFilter filter) => throw Unsupported(); | ||
public override void Apply(IGeometryComponentFilter filter) => throw Unsupported(); | ||
public override void Apply(IGeometryFilter filter) => throw Unsupported(); | ||
public override bool Contains(Geometry g) => throw Unsupported(); | ||
public override Geometry ConvexHull() => throw Unsupported(); | ||
public override bool Covers(Geometry g) => throw Unsupported(); | ||
public override bool Crosses(Geometry g) => throw Unsupported(); | ||
public override double Distance(Geometry g) => throw Unsupported(); | ||
public override bool Equals(object o) => throw Unsupported(); | ||
public override bool EqualsExact(Geometry other, double tolerance) => throw Unsupported(); | ||
public override bool EqualsTopologically(Geometry g) => throw Unsupported(); | ||
public override Geometry GetGeometryN(int n) => throw Unsupported(); | ||
public override int GetHashCode() => throw Unsupported(); | ||
public override double[] GetOrdinates(Ordinate ordinate) => throw Unsupported(); | ||
public override bool Intersects(Geometry g) => throw Unsupported(); | ||
public override bool IsWithinDistance(Geometry geom, double distance) => throw Unsupported(); | ||
public override void Normalize() => throw Unsupported(); | ||
public override bool Overlaps(Geometry g) => throw Unsupported(); | ||
public override IntersectionMatrix Relate(Geometry g) => throw Unsupported(); | ||
public override bool Relate(Geometry g, string intersectionPattern) => throw Unsupported(); | ||
public override Geometry Reverse() => throw Unsupported(); | ||
public override string ToString() => throw Unsupported(); | ||
public override bool Touches(Geometry g) => throw Unsupported(); | ||
|
||
protected override int CompareToSameClass(object o) => throw Unsupported(); | ||
protected override int CompareToSameClass(object o, IComparer<CoordinateSequence> comp) => throw Unsupported(); | ||
protected override Envelope ComputeEnvelopeInternal() => throw Unsupported(); | ||
protected override Geometry CopyInternal() => throw Unsupported(); | ||
protected override bool IsEquivalentClass(Geometry other) => throw Unsupported(); | ||
|
||
#endregion | ||
} | ||
} |
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 |
---|---|---|
|
@@ -238,6 +238,12 @@ private Geometry ToGeometry(Geography geography) | |
geometries.Remove(shapeIndex); | ||
break; | ||
|
||
case OpenGisType.CircularString: | ||
case OpenGisType.CompoundCurve: | ||
case OpenGisType.CurvePolygon: | ||
case OpenGisType.FullGlobe: | ||
return new UnsupportedGeometry(shape.Type, geography); | ||
Comment on lines
+241
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, if a GeometryCollection contains one of these, the whole collection will be returned as unsupported. A slightly better solution might be to return a GeometryCollection containing an UnsupportedGeometry. |
||
|
||
default: | ||
throw new ParseException(string.Format(Resources.UnexpectedGeographyType, shape.Type)); | ||
} | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😈 This and
Equals
probably breaks EF Core. We need to refine this a bit. I also haven't tested the experience with other parts of NTS.