Skip to content

Commit a72268e

Browse files
committed
fix #1274 add support for precision and orientation on geo shape type mapping
1 parent 05ac23d commit a72268e

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

src/Nest/Domain/Mapping/Descriptors/GeoShapeMappingDescriptor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ public GeoShapeMappingDescriptor<T> TreeLevels(int treeLevels)
3030
return this;
3131
}
3232

33+
public GeoShapeMappingDescriptor<T> Precision(GeoPrecision precision)
34+
{
35+
this._Mapping.Precision = precision;
36+
return this;
37+
}
38+
39+
public GeoShapeMappingDescriptor<T> Orientation(GeoOrientation orientation)
40+
{
41+
this._Mapping.Orientation = orientation;
42+
return this;
43+
}
44+
3345
public GeoShapeMappingDescriptor<T> DistanceErrorPercentage(double distanceErrorPercentage)
3446
{
3547
this._Mapping.DistanceErrorPercentage = distanceErrorPercentage;

src/Nest/Domain/Mapping/Types/GeoShapeMapping.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public class GeoShapeMapping : IElasticType
1919
[JsonProperty("tree"), JsonConverter(typeof(StringEnumConverter))]
2020
public GeoTree? Tree { get; set; }
2121

22+
[JsonProperty("precision")]
23+
public GeoPrecision? Precision { get; set; }
24+
25+
[JsonProperty("orientation")]
26+
public GeoOrientation? Orientation { get; set; }
27+
2228
[JsonProperty("tree_levels")]
2329
public int? TreeLevels { get; set; }
2430

src/Nest/Enums/GeoOrientation.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System.Runtime.Serialization;
4+
5+
namespace Nest
6+
{
7+
[JsonConverter(typeof(StringEnumConverter))]
8+
public enum GeoOrientation
9+
{
10+
[EnumMember(Value = "cw")]
11+
ClockWise,
12+
[EnumMember(Value = "ccw")]
13+
CounterClockWise
14+
}
15+
}

src/Nest/Enums/GeoPrecision.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System.Runtime.Serialization;
4+
5+
namespace Nest
6+
{
7+
[JsonConverter(typeof(StringEnumConverter))]
8+
public enum GeoPrecision
9+
{
10+
[EnumMember(Value = "in")]
11+
Inch,
12+
[EnumMember(Value = "yd")]
13+
Yard,
14+
[EnumMember(Value = "mi")]
15+
Miles,
16+
[EnumMember(Value = "km")]
17+
Kilometers,
18+
[EnumMember(Value = "m")]
19+
Meters,
20+
[EnumMember(Value = "cm")]
21+
Centimeters,
22+
[EnumMember(Value = "mm")]
23+
Millimeters
24+
}
25+
}

src/Nest/Nest.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@
242242
<Compile Include="DSL\Filter\GeoHashCellFilterDescriptor.cs" />
243243
<Compile Include="DSL\DeleteScriptDescriptor.cs" />
244244
<Compile Include="ElasticClient-GetIndex.cs" />
245+
<Compile Include="Enums\GeoOrientation.cs" />
246+
<Compile Include="Enums\GeoPrecision.cs" />
245247
<Compile Include="Enums\GetIndexFeature.cs" />
246248
<Compile Include="DSL\GetScriptDescriptor.cs" />
247249
<Compile Include="DSL\SearchExistsDescriptor.cs" />

0 commit comments

Comments
 (0)