Skip to content

Commit

Permalink
fix obsolete warning from forward port of #3770
Browse files Browse the repository at this point in the history
(cherry picked from commit 7c4996f)
  • Loading branch information
Mpdreamz committed Jun 2, 2019
1 parent 2163889 commit a15f3b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 175 deletions.
50 changes: 7 additions & 43 deletions src/Nest/Mapping/Types/Geo/GeoShape/GeoShapeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
public class GeoShapeAttribute : ElasticsearchDocValuesPropertyAttributeBase, IGeoShapeProperty
{
public GeoShapeAttribute() : base(FieldType.GeoShape) { }

/// <inheritdoc cref="IGeoShapeProperty.DistanceErrorPercentage" />
public double DistanceErrorPercentage
{
get => (Self.Precision != null) | (Self.TreeLevels != null)
? Self.DistanceErrorPercentage.GetValueOrDefault(0)
: Self.DistanceErrorPercentage.GetValueOrDefault(0.025);
set => Self.DistanceErrorPercentage = value;
}

bool? IGeoShapeProperty.IgnoreMalformed { get; set; }
bool? IGeoShapeProperty.IgnoreZValue { get; set; }
GeoOrientation? IGeoShapeProperty.Orientation { get; set; }
private IGeoShapeProperty Self => this;
GeoStrategy? IGeoShapeProperty.Strategy { get; set; }
bool? IGeoShapeProperty.Coerce { get; set; }

/// <inheritdoc cref="IGeoShapeProperty.IgnoreMalformed" />
public bool IgnoreMalformed
Expand All @@ -35,53 +33,19 @@ public GeoOrientation Orientation
set => Self.Orientation = value;
}

/// <inheritdoc cref="IGeoShapeProperty.PointsOnly" />
public bool PointsOnly
{
get => Self.PointsOnly.GetValueOrDefault(false);
set => Self.PointsOnly = value;
}

/// <inheritdoc cref="IGeoShapeProperty.Strategy" />
public GeoStrategy Strategy
{
get => Self.Strategy.GetValueOrDefault(GeoStrategy.Recursive);
set => Self.Strategy = value;
}

/// <inheritdoc cref="IGeoShapeProperty.Tree" />
public GeoTree Tree
{
get => Self.Tree.GetValueOrDefault(GeoTree.Geohash);
set => Self.Tree = value;
}

/// <inheritdoc cref="IGeoShapeProperty.TreeLevels" />
public int TreeLevels
{
get => Self.TreeLevels.GetValueOrDefault(50);
set => Self.TreeLevels = value;
}

/// <inheritdoc cref="IGeoShapeProperty.Coerce" />
public bool Coerce
{
get => Self.Coerce.GetValueOrDefault(true);
set => Self.Coerce = value;
}

double? IGeoShapeProperty.DistanceErrorPercentage { get; set; }
bool? IGeoShapeProperty.IgnoreMalformed { get; set; }
bool? IGeoShapeProperty.IgnoreZValue { get; set; }
GeoOrientation? IGeoShapeProperty.Orientation { get; set; }
bool? IGeoShapeProperty.PointsOnly { get; set; }
Distance IGeoShapeProperty.Precision { get; set; }
private IGeoShapeProperty Self => this;
GeoStrategy? IGeoShapeProperty.Strategy { get; set; }

GeoTree? IGeoShapeProperty.Tree { get; set; }
int? IGeoShapeProperty.TreeLevels { get; set; }

bool? IGeoShapeProperty.Coerce { get; set; }
}
}
112 changes: 0 additions & 112 deletions src/Nest/Mapping/Types/Geo/GeoShape/GeoShapeProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ namespace Nest
[InterfaceDataContract]
public interface IGeoShapeProperty : IDocValuesProperty
{
/// <summary>
/// Used as a hint to the Prefix<see cref="Tree" /> about how precise it should be.
/// Defaults to 0.025 (2.5%) with 0.5 as the maximum supported value.
/// </summary>
/// <remarks>
/// NOTE: This value will default to 0 if a <see cref="Precision" /> or <see cref="TreeLevels" /> definition
/// is explicitly defined. This guarantees spatial precision at the level defined in the mapping.
/// This can lead to significant memory usage for high resolution shapes with low error
/// (e.g. large shapes at 1m with &lt; 0.001 error).
/// To improve indexing performance (at the cost of query accuracy) explicitly define <see cref="TreeLevels" /> or
/// <see cref="Precision" /> along with a reasonable <see cref="DistanceErrorPercentage" />,
/// noting that large shapes will have greater false positives.
/// </remarks>
[DataMember(Name ="distance_error_pct")]
[Obsolete("Removed in Elasticsearch 6.6")]
double? DistanceErrorPercentage { get; set; }

/// <summary>
/// If <c>true</c>, malformed geojson shapes are ignored. If false (default),
/// malformed geojson shapes throw an exception and reject the whole document.
Expand Down Expand Up @@ -57,27 +40,6 @@ public interface IGeoShapeProperty : IDocValuesProperty
[DataMember(Name ="orientation")]
GeoOrientation? Orientation { get; set; }

/// <summary>
/// Configures the geo_shape field type for point shapes only. Defaults to <c>false</c>.
/// This optimizes index and search performance
/// for the geohash and quadtree when it is known that only points will be indexed.
/// At present geo_shape queries can not be executed on geo_point field types.
/// This option bridges the gap by improving point performance on a geo_shape field
/// so that geo_shape queries are optimal on a point only field.
/// </summary>
[DataMember(Name ="points_only")]
[Obsolete("Removed in Elasticsearch 6.6")]
bool? PointsOnly { get; set; }

/// <summary>
/// Used instead of <see cref="TreeLevels" /> to set an appropriate value for the <see cref="TreeLevels" />
/// parameter. The value specifies the desired precision and Elasticsearch will calculate
/// the best tree_levels value to honor this precision.
/// </summary>
[DataMember(Name ="precision")]
[Obsolete("Removed in Elasticsearch 6.6")]
Distance Precision { get; set; }

/// <summary>
/// Defines the approach for how to represent shapes at indexing and search time.
/// It also influences the capabilities available so it is recommended to let
Expand All @@ -86,25 +48,6 @@ public interface IGeoShapeProperty : IDocValuesProperty
[DataMember(Name ="strategy")]
GeoStrategy? Strategy { get; set; }

/// <summary>
/// Name of the PrefixTree implementation to be used.
/// Defaults to <see cref="GeoTree.Geohash" />
/// </summary>
[DataMember(Name ="tree")]
[Obsolete("Removed in Elasticsearch 6.6")]
GeoTree? Tree { get; set; }

/// <summary>
/// Maximum number of layers to be used by the Prefix<see cref="Tree" />. This can be used to control the
/// precision of shape representations and therefore how many terms are indexed.
/// Defaults to the default value of the chosen Prefix<see cref="Tree" /> implementation. Since this parameter requires a
/// certain level of understanding of the underlying implementation, users may use the
/// <see cref="Precision" /> parameter instead.
/// </summary>
[DataMember(Name ="tree_levels")]
[Obsolete("Removed in Elasticsearch 6.6")]
int? TreeLevels { get; set; }

/// <summary>
/// Should the data be coerced into becoming a valid geo shape (for instance closing a polygon)
/// </summary>
Expand All @@ -118,10 +61,6 @@ public class GeoShapeProperty : DocValuesPropertyBase, IGeoShapeProperty
{
public GeoShapeProperty() : base(FieldType.GeoShape) { }

/// <inheritdoc />
[Obsolete("Removed in Elasticsearch 6.6")]
public double? DistanceErrorPercentage { get; set; }

/// <inheritdoc />
public bool? IgnoreMalformed { get; set; }

Expand All @@ -131,25 +70,9 @@ public GeoShapeProperty() : base(FieldType.GeoShape) { }
/// <inheritdoc />
public GeoOrientation? Orientation { get; set; }

/// <inheritdoc />
[Obsolete("Removed in Elasticsearch 6.6")]
public bool? PointsOnly { get; set; }

/// <inheritdoc />
[Obsolete("Removed in Elasticsearch 6.6")]
public Distance Precision { get; set; }

/// <inheritdoc />
public GeoStrategy? Strategy { get; set; }

/// <inheritdoc />
[Obsolete("Removed in Elasticsearch 6.6")]
public GeoTree? Tree { get; set; }

/// <inheritdoc />
[Obsolete("Removed in Elasticsearch 6.6")]
public int? TreeLevels { get; set; }

/// <inheritdoc />
public bool? Coerce { get; set; }
}
Expand All @@ -163,55 +86,20 @@ public class GeoShapePropertyDescriptor<T>
public GeoShapePropertyDescriptor() : base(FieldType.GeoShape) { }


[Obsolete("Removed in Elasticsearch 6.6")]
double? IGeoShapeProperty.DistanceErrorPercentage { get; set; }
bool? IGeoShapeProperty.IgnoreMalformed { get; set; }
bool? IGeoShapeProperty.IgnoreZValue { get; set; }
GeoOrientation? IGeoShapeProperty.Orientation { get; set; }

[Obsolete("Removed in Elasticsearch 6.6")]
bool? IGeoShapeProperty.PointsOnly { get; set; }

[Obsolete("Removed in Elasticsearch 6.6")]
Distance IGeoShapeProperty.Precision { get; set; }
GeoStrategy? IGeoShapeProperty.Strategy { get; set; }

[Obsolete("Removed in Elasticsearch 6.6")]
GeoTree? IGeoShapeProperty.Tree { get; set; }

[Obsolete("Removed in Elasticsearch 6.6")]
int? IGeoShapeProperty.TreeLevels { get; set; }
bool? IGeoShapeProperty.Coerce { get; set; }

/// <inheritdoc cref="IGeoShapeProperty.Tree" />

[Obsolete("Removed in Elasticsearch 6.6")]
public GeoShapePropertyDescriptor<T> Tree(GeoTree? tree) => Assign(tree, (a, v) => a.Tree = v);

/// <inheritdoc cref="IGeoShapeProperty.TreeLevels" />
[Obsolete("Removed in Elasticsearch 6.6")]
public GeoShapePropertyDescriptor<T> TreeLevels(int? treeLevels) => Assign(treeLevels, (a, v) => a.TreeLevels = v);

/// <inheritdoc cref="IGeoShapeProperty.Strategy" />
public GeoShapePropertyDescriptor<T> Strategy(GeoStrategy? strategy) => Assign(strategy, (a, v) => a.Strategy = v);

/// <inheritdoc cref="IGeoShapeProperty.Precision" />
[Obsolete("Removed in Elasticsearch 6.6")]
public GeoShapePropertyDescriptor<T> Precision(double precision, DistanceUnit unit) =>
Assign(new Distance(precision, unit), (a, v) => a.Precision = v);

/// <inheritdoc cref="IGeoShapeProperty.Orientation" />
public GeoShapePropertyDescriptor<T> Orientation(GeoOrientation? orientation) => Assign(orientation, (a, v) => a.Orientation = v);

/// <inheritdoc cref="IGeoShapeProperty.DistanceErrorPercentage" />
[Obsolete("Removed in Elasticsearch 6.6")]
public GeoShapePropertyDescriptor<T> DistanceErrorPercentage(double? distanceErrorPercentage) =>
Assign(distanceErrorPercentage, (a, v) => a.DistanceErrorPercentage = v);

/// <inheritdoc cref="IGeoShapeProperty.PointsOnly" />
[Obsolete("Removed in Elasticsearch 6.6")]
public GeoShapePropertyDescriptor<T> PointsOnly(bool? pointsOnly = true) => Assign(pointsOnly, (a, v) => a.PointsOnly = v);

/// <inheritdoc cref="IGeoShapeProperty.IgnoreMalformed" />
public GeoShapePropertyDescriptor<T> IgnoreMalformed(bool? ignoreMalformed = true) =>
Assign(ignoreMalformed, (a, v) => a.IgnoreMalformed = v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ namespace Tests.Mapping.Types.Geo.GeoShape
public class GeoShapeTest
{
[GeoShape(
Tree = GeoTree.Quadtree,
Orientation = GeoOrientation.ClockWise,
Strategy = GeoStrategy.Recursive,
TreeLevels = 3,
PointsOnly = true,
DistanceErrorPercentage = 1.0,
Coerce = true)]
public object Full { get; set; }

Expand All @@ -27,12 +23,8 @@ public class GeoShapeAttributeTests : AttributeTestsBase<GeoShapeTest>
full = new
{
type = "geo_shape",
tree = "quadtree",
orientation = "cw",
strategy = "recursive",
tree_levels = 3,
points_only = true,
distance_error_pct = 1.0,
coerce = true
},
minimal = new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ public GeoShapePropertyTests(WritableCluster cluster, EndpointUsage usage) : bas
location = new
{
type = "geo_shape",
tree = "quadtree",
orientation = "cw",
strategy = "recursive",
tree_levels = 3,
points_only = true,
distance_error_pct = 1.0,
coerce = true
}
}
Expand All @@ -31,12 +27,8 @@ public GeoShapePropertyTests(WritableCluster cluster, EndpointUsage usage) : bas
protected override Func<PropertiesDescriptor<Project>, IPromise<IProperties>> FluentProperties => f => f
.GeoShape(s => s
.Name(p => p.Location)
.Tree(GeoTree.Quadtree)
.Orientation(GeoOrientation.ClockWise)
.Strategy(GeoStrategy.Recursive)
.TreeLevels(3)
.PointsOnly()
.DistanceErrorPercentage(1.0)
.Coerce()
);

Expand All @@ -46,12 +38,8 @@ public GeoShapePropertyTests(WritableCluster cluster, EndpointUsage usage) : bas
{
"location", new GeoShapeProperty
{
Tree = GeoTree.Quadtree,
Orientation = GeoOrientation.ClockWise,
Strategy = GeoStrategy.Recursive,
TreeLevels = 3,
PointsOnly = true,
DistanceErrorPercentage = 1.0,
Coerce = true
}
}
Expand Down

0 comments on commit a15f3b8

Please sign in to comment.