@@ -37,18 +37,18 @@ public class CartesianPoint implements ToXContentFragment {
37
37
private static final ParseField Y_FIELD = new ParseField ("y" );
38
38
private static final ParseField Z_FIELD = new ParseField ("z" );
39
39
40
- protected float x ;
41
- protected float y ;
40
+ protected double x ;
41
+ protected double y ;
42
42
43
43
public CartesianPoint () {
44
44
}
45
45
46
- public CartesianPoint (float x , float y ) {
46
+ public CartesianPoint (double x , double y ) {
47
47
this .x = x ;
48
48
this .y = y ;
49
49
}
50
50
51
- public CartesianPoint reset (float x , float y ) {
51
+ public CartesianPoint reset (double x , double y ) {
52
52
this .x = x ;
53
53
this .y = y ;
54
54
return this ;
@@ -69,11 +69,11 @@ public CartesianPoint resetFromCoordinates(String value, final boolean ignoreZVa
69
69
throw new ElasticsearchParseException ("failed to parse [{}], expected 2 or 3 coordinates "
70
70
+ "but found: [{}]" , vals , vals .length );
71
71
}
72
- final float x ;
73
- final float y ;
72
+ final double x ;
73
+ final double y ;
74
74
try {
75
- x = Float . parseFloat (vals [0 ].trim ());
76
- if (Float .isFinite (x ) == false ) {
75
+ x = Double . parseDouble (vals [0 ].trim ());
76
+ if (Double .isFinite (x ) == false ) {
77
77
throw new ElasticsearchParseException ("invalid [{}] value [{}]; " +
78
78
"must be between -3.4028234663852886E38 and 3.4028234663852886E38" ,
79
79
X_FIELD .getPreferredName (),
@@ -83,8 +83,8 @@ public CartesianPoint resetFromCoordinates(String value, final boolean ignoreZVa
83
83
throw new ElasticsearchParseException ("[{}]] must be a number" , X_FIELD .getPreferredName ());
84
84
}
85
85
try {
86
- y = Float . parseFloat (vals [1 ].trim ());
87
- if (Float .isFinite (y ) == false ) {
86
+ y = Double . parseDouble (vals [1 ].trim ());
87
+ if (Double .isFinite (y ) == false ) {
88
88
throw new ElasticsearchParseException ("invalid [{}] value [{}]; " +
89
89
"must be between -3.4028234663852886E38 and 3.4028234663852886E38" ,
90
90
Y_FIELD .getPreferredName (),
@@ -95,7 +95,7 @@ public CartesianPoint resetFromCoordinates(String value, final boolean ignoreZVa
95
95
}
96
96
if (vals .length > 2 ) {
97
97
try {
98
- CartesianPoint .assertZValue (ignoreZValue , Float . parseFloat (vals [2 ].trim ()));
98
+ CartesianPoint .assertZValue (ignoreZValue , Double . parseDouble (vals [2 ].trim ()));
99
99
} catch (NumberFormatException ex ) {
100
100
throw new ElasticsearchParseException ("[{}]] must be a number" , Y_FIELD .getPreferredName ());
101
101
}
@@ -116,14 +116,14 @@ private CartesianPoint resetFromWKT(String value, boolean ignoreZValue) {
116
116
"but found {}" , PointFieldMapper .CONTENT_TYPE , geometry .type ());
117
117
}
118
118
org .elasticsearch .geometry .Point point = (org .elasticsearch .geometry .Point ) geometry ;
119
- return reset (( float ) point .getX (), ( float ) point .getY ());
119
+ return reset (point .getX (), point .getY ());
120
120
}
121
121
122
- public float getX () {
122
+ public double getX () {
123
123
return this .x ;
124
124
}
125
125
126
- public float getY () {
126
+ public double getY () {
127
127
return this .y ;
128
128
}
129
129
@@ -134,8 +134,8 @@ public boolean equals(Object o) {
134
134
135
135
CartesianPoint point = (CartesianPoint ) o ;
136
136
137
- if (Float .compare (point .x , x ) != 0 ) return false ;
138
- if (Float .compare (point .y , y ) != 0 ) return false ;
137
+ if (Double .compare (point .x , x ) != 0 ) return false ;
138
+ if (Double .compare (point .y , y ) != 0 ) return false ;
139
139
140
140
return true ;
141
141
}
@@ -157,8 +157,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
157
157
158
158
public static CartesianPoint parsePoint (XContentParser parser , CartesianPoint point , boolean ignoreZvalue )
159
159
throws IOException , ElasticsearchParseException {
160
- float x = Float .NaN ;
161
- float y = Float .NaN ;
160
+ double x = Double .NaN ;
161
+ double y = Double .NaN ;
162
162
NumberFormatException numberFormatException = null ;
163
163
164
164
if (parser .currentToken () == XContentParser .Token .START_OBJECT ) {
@@ -172,7 +172,7 @@ public static CartesianPoint parsePoint(XContentParser parser, CartesianPoint po
172
172
case VALUE_NUMBER :
173
173
case VALUE_STRING :
174
174
try {
175
- x = subParser .floatValue (true );
175
+ x = subParser .doubleValue (true );
176
176
} catch (NumberFormatException e ) {
177
177
numberFormatException = e ;
178
178
}
@@ -187,7 +187,7 @@ public static CartesianPoint parsePoint(XContentParser parser, CartesianPoint po
187
187
case VALUE_NUMBER :
188
188
case VALUE_STRING :
189
189
try {
190
- y = subParser .floatValue (true );
190
+ y = subParser .doubleValue (true );
191
191
} catch (NumberFormatException e ) {
192
192
numberFormatException = e ;
193
193
}
@@ -202,7 +202,7 @@ public static CartesianPoint parsePoint(XContentParser parser, CartesianPoint po
202
202
case VALUE_NUMBER :
203
203
case VALUE_STRING :
204
204
try {
205
- CartesianPoint .assertZValue (ignoreZvalue , subParser .floatValue (true ));
205
+ CartesianPoint .assertZValue (ignoreZvalue , subParser .doubleValue (true ));
206
206
} catch (NumberFormatException e ) {
207
207
numberFormatException = e ;
208
208
}
@@ -222,12 +222,12 @@ public static CartesianPoint parsePoint(XContentParser parser, CartesianPoint po
222
222
}
223
223
}
224
224
if (numberFormatException != null ) {
225
- throw new ElasticsearchParseException ("[{}] and [{}] must be valid float values" , numberFormatException ,
225
+ throw new ElasticsearchParseException ("[{}] and [{}] must be valid double values" , numberFormatException ,
226
226
X_FIELD .getPreferredName (),
227
227
Y_FIELD .getPreferredName ());
228
- } else if (Float .isNaN (x )) {
228
+ } else if (Double .isNaN (x )) {
229
229
throw new ElasticsearchParseException ("field [{}] missing" , X_FIELD .getPreferredName ());
230
- } else if (Float .isNaN (y )) {
230
+ } else if (Double .isNaN (y )) {
231
231
throw new ElasticsearchParseException ("field [{}] missing" , Y_FIELD .getPreferredName ());
232
232
} else {
233
233
return point .reset (x , y );
@@ -240,9 +240,9 @@ public static CartesianPoint parsePoint(XContentParser parser, CartesianPoint po
240
240
if (subParser .currentToken () == XContentParser .Token .VALUE_NUMBER ) {
241
241
element ++;
242
242
if (element == 1 ) {
243
- x = subParser .floatValue ();
243
+ x = subParser .doubleValue ();
244
244
} else if (element == 2 ) {
245
- y = subParser .floatValue ();
245
+ y = subParser .doubleValue ();
246
246
} else {
247
247
throw new ElasticsearchParseException ("[{}}] field type does not accept > 2 dimensions" ,
248
248
PointFieldMapper .CONTENT_TYPE );
@@ -277,12 +277,12 @@ public static CartesianPoint parsePoint(Object value, CartesianPoint point, bool
277
277
}
278
278
}
279
279
280
- public static double assertZValue (final boolean ignoreZValue , float zValue ) {
280
+ public static double assertZValue (final boolean ignoreZValue , double zValue ) {
281
281
if (ignoreZValue == false ) {
282
282
throw new ElasticsearchParseException ("Exception parsing coordinates: found Z value [{}] but [{}] "
283
283
+ "parameter is [{}]" , zValue , IGNORE_Z_VALUE , ignoreZValue );
284
284
}
285
- if (Float .isFinite (zValue ) == false ) {
285
+ if (Double .isFinite (zValue ) == false ) {
286
286
throw new ElasticsearchParseException ("invalid [{}] value [{}]; " +
287
287
"must be between -3.4028234663852886E38 and 3.4028234663852886E38" ,
288
288
Z_FIELD .getPreferredName (),
0 commit comments