diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java index d35e2a8b7..c572ad70b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java @@ -212,8 +212,8 @@ public boolean hasZ() { * @return double value that represents the latitude. */ public Double getLatitude() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && xValues.length == 1) { - return xValues[0]; + if (null != internalType && internalType == InternalSpatialDatatype.POINT && yValues.length == 1) { + return yValues[0]; } return null; } @@ -224,8 +224,8 @@ public Double getLatitude() { * @return double value that represents the longitude. */ public Double getLongitude() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && yValues.length == 1) { - return yValues[0]; + if (null != internalType && internalType == InternalSpatialDatatype.POINT && xValues.length == 1) { + return xValues[0]; } return null; } diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/datatypes/SQLServerSpatialDatatypeTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/datatypes/SQLServerSpatialDatatypeTest.java index 210184e47..a31fc75b5 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/datatypes/SQLServerSpatialDatatypeTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/datatypes/SQLServerSpatialDatatypeTest.java @@ -968,8 +968,8 @@ public void testGetXGetY() throws SQLException { x = geog.getLatitude(); y = geog.getLongitude(); - assertEquals(x, 1); - assertEquals(y, 2); + assertEquals(x, 2); + assertEquals(y, 1); } @Test