Skip to content

Commit

Permalink
Flip X and Y coordinates for WKT and array formats in XYPoint (#156)
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen Tatikonda <[email protected]>
  • Loading branch information
naveentatikonda authored Sep 23, 2022
1 parent 7cdaf8d commit 1eebc3f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private XYPoint resetFromWKT(String value, boolean ignoreZValue) {
throw new OpenSearchParseException("[xy_point] supports only POINT among WKT primitives, but found [{}]", geometry.type());
}
Point point = (Point) geometry;
return reset(point.getY(), point.getX());
return reset(point.getX(), point.getY());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private static XYPoint parseXYPointArray(XContentParser subParser, final boolean
}
element++;
if (element == 1) {
y = subParser.doubleValue();
} else if (element == 2) {
x = subParser.doubleValue();
} else if (element == 2) {
y = subParser.doubleValue();
} else if (element == 3) {
XYPoint.assertZValue(ignoreZValue, subParser.doubleValue());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ private XContentParser xyAsString(double x, double y) throws IOException {

private XContentParser xyAsArray(double x, double y) throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.startArray().value(y).value(x).endArray();
content.startArray().value(x).value(y).endArray();
XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content));
parser.nextToken();
return parser;
}

private XContentParser xyAsWKT(double x, double y) throws IOException {
XContentBuilder content = JsonXContent.contentBuilder();
content.value("POINT (" + y + " " + x + ")");
content.value("POINT (" + x + " " + y + ")");
XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content));
parser.nextToken();
return parser;
Expand Down

0 comments on commit 1eebc3f

Please sign in to comment.