Skip to content

Commit

Permalink
Further tweaks
Browse files Browse the repository at this point in the history
- Mark irrelevant properties as Obsolete
- Use SetX / SetY / SetZ / SetM instead of SetOrdinate
- Small xmldoc fixes
- Remove a now-unnecessary rename of ParseException
  • Loading branch information
airbreather committed Sep 5, 2019
1 parent 2c3dc0a commit 4578ef8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/NetTopologySuite.IO.SqlServerBytes/SqlServerBytesReader.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO.Properties;
using GeoParseException = NetTopologySuite.IO.ParseException;

using Geography = NetTopologySuite.IO.Serialization.Geography;
using OpenGisType = NetTopologySuite.IO.Serialization.OpenGisType;
Expand Down Expand Up @@ -44,6 +44,7 @@ public SqlServerBytesReader(NtsGeometryServices services)
/// Gets or sets whether invalid linear rings should be fixed. Returns false since invalid rings are
/// disallowed. Setting does nothing.
/// </summary>
[Obsolete("This is unused within this library and will be removed in a later version. It was only needed when this type implemented an interface that no longer exists.")]
public virtual bool RepairRings
{
get => false;
Expand All @@ -54,6 +55,7 @@ public virtual bool RepairRings
/// Gets or sets whether the SpatialReference ID must be handled. Returns true since it's always handled.
/// Setting does nothing.
/// </summary>
[Obsolete("This is unused within this library and will be removed in a later version. It was only needed when this type implemented an interface that no longer exists.")]
public virtual bool HandleSRID
{
get => true;
Expand Down Expand Up @@ -154,17 +156,17 @@ private Geometry ToGeometry(Geography geography)
var point = geography.Points[pointIndex];
int coordinateIndex = pointIndex - figure.PointOffset;

coordinates.SetOrdinate(coordinateIndex, Ordinate.X, IsGeography ? point.Long : point.X);
coordinates.SetOrdinate(coordinateIndex, Ordinate.Y, IsGeography ? point.Lat : point.Y);
coordinates.SetX(coordinateIndex, IsGeography ? point.Long : point.X);
coordinates.SetY(coordinateIndex, IsGeography ? point.Lat : point.Y);

if (handleZ)
{
coordinates.SetOrdinate(coordinateIndex, Ordinate.Z, geography.ZValues[pointIndex]);
coordinates.SetZ(coordinateIndex, geography.ZValues[pointIndex]);
}

if (handleM)
{
coordinates.SetOrdinate(coordinateIndex, Ordinate.M, geography.MValues[pointIndex]);
coordinates.SetM(coordinateIndex, geography.MValues[pointIndex]);
}
}

Expand Down Expand Up @@ -237,7 +239,7 @@ private Geometry ToGeometry(Geography geography)
break;

default:
throw new GeoParseException(string.Format(Resources.UnexpectedGeographyType, shape.Type));
throw new ParseException(string.Format(Resources.UnexpectedGeographyType, shape.Type));
}

if (!geometries.ContainsKey(shape.ParentOffset))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public class SqlServerBytesWriter
private bool _emitM = true;

/// <summary>
/// Gets or sets the desired <see cref="ByteOrder"/>. Returns <see cref="ByteOrder.LittleEndian"/> since
/// Gets or sets the desired <see cref="IO.ByteOrder"/>. Returns <see cref="ByteOrder.LittleEndian"/> since
/// it's required. Setting does nothing.
/// </summary>
[Obsolete("This is unused within this library and will be removed in a later version. It was only needed when this type implemented an interface that no longer exists.")]
public virtual ByteOrder ByteOrder
{
get => ByteOrder.LittleEndian;
Expand All @@ -37,6 +38,7 @@ public virtual ByteOrder ByteOrder
/// Gets or sets whether the SpatialReference ID must be handled. Returns true since it's required. Setting
/// does nothing.
/// </summary>
[Obsolete("This is unused within this library and will be removed in a later version. It was only needed when this type implemented an interface that no longer exists.")]
public virtual bool HandleSRID
{
get => true;
Expand All @@ -46,6 +48,7 @@ public virtual bool HandleSRID
/// <summary>
/// Gets and <see cref="Ordinates"/> flag that indicate which ordinates can be handled.
/// </summary>
[Obsolete("This is unused within this library and will be removed in a later version. It was only needed when this type implemented an interface that no longer exists.")]
public virtual Ordinates AllowedOrdinates
=> Ordinates.XYZM;

Expand All @@ -54,7 +57,7 @@ public virtual Ordinates AllowedOrdinates
/// </summary>
/// <remarks>
/// No matter which <see cref="Ordinates"/> flag you supply, <see cref="Ordinates.XY"/> are always
/// processed, the rest is binary and 'ed with <see cref="AllowedOrdinates"/>.
/// processed, the rest is binary and 'ed with <see cref="Ordinates.XYZM"/>.
/// </remarks>
public virtual Ordinates HandleOrdinates
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using NetTopologySuite.IO.Properties;
using Xunit;

using GeoParseException = NetTopologySuite.IO.ParseException;

namespace NetTopologySuite.IO
{
public class SqlServerBytesReaderTest
Expand Down Expand Up @@ -166,7 +164,7 @@ public void HandleOrdinates_works()
[Fact]
public void Read_throws_when_circular_string()
{
var ex = Assert.Throws<GeoParseException>(
var ex = Assert.Throws<ParseException>(
() => Read("0000000002040300000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000000001000000020000000001000000FFFFFFFF0000000008"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CircularString"), ex.Message);
Expand All @@ -175,7 +173,7 @@ public void Read_throws_when_circular_string()
[Fact]
public void Read_throws_when_compound_curve()
{
var ex = Assert.Throws<GeoParseException>(
var ex = Assert.Throws<ParseException>(
() => Read("0000000002040400000000000000000000000000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F0000000000000840000000000000000001000000030000000001000000FFFFFFFF0000000009020000000203"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CompoundCurve"), ex.Message);
Expand All @@ -184,7 +182,7 @@ public void Read_throws_when_compound_curve()
[Fact]
public void Read_throws_when_curve_polygon()
{
var ex = Assert.Throws<GeoParseException>(
var ex = Assert.Throws<ParseException>(
() => Read("000000000204050000000000000000000040000000000000F03F000000000000F03F00000000000000400000000000000000000000000000F03F000000000000F03F00000000000000000000000000000040000000000000F03F01000000020000000001000000FFFFFFFF000000000A"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CurvePolygon"), ex.Message);
Expand All @@ -193,7 +191,7 @@ public void Read_throws_when_curve_polygon()
[Fact]
public void Read_throws_when_full_globe()
{
var ex = Assert.Throws<GeoParseException>(
var ex = Assert.Throws<ParseException>(
() => Read("E61000000224000000000000000001000000FFFFFFFFFFFFFFFF0B"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "FullGlobe"), ex.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using NetTopologySuite.IO.Properties;
using Xunit;

using GeoParseException = NetTopologySuite.IO.ParseException;

namespace NetTopologySuite.IO
{
public class SqlServerBytesWriterTest
Expand Down Expand Up @@ -204,7 +202,7 @@ public void Types_still_unknown(string wkt)
var reader = new WKTReader();

// NB: If this doesn't throw, we're unblocked and can add support
Assert.Throws<GeoParseException>(
Assert.Throws<ParseException>(
() => reader.Read(wkt));
}

Expand Down

0 comments on commit 4578ef8

Please sign in to comment.