GeoPoint getLatitudeE6 () returns -80000000, but getLongitudeE6 () returns the correct value

A very strange mistake, which I don’t seem to know, looked at her for about an hour, trying to reorganize to fix this problem, but I can’t understand, maybe a fresh set of eyes can help me. Below is a short code. Any help is appreciated.

KML coordinate sequence example

-98.493095,29.416311,0.000000

KMLHandler.java (I read in kml in string format)

String[] coords = s.split(",");  
   if ( coords.length == 3 ) {  
      GeoPoint gp = GeoPointUtils.getGeoPoint(coords[0].trim(), coords[1].trim());
      ((Region)overlayItem).addCoordinate(gp);
      Log.d(TAG, "gp.getLat(): " + gp.getLatitudeE6())
      Log.d(TAG, "gp.getLong():" + gp.getLongitudeE6());
    }

GeoPointUtils.java

public static GeoPoint getGeoPoint(double latitude , double longitude) {
   Log.d(TAG, "GeoPointUtils.getGeoPoint(double)");
   Log.d(TAG, "\tIncoming lat -> " + latitude);
   Log.d(TAG, "\tConverted lat -> " + (int) (latitude * 1E6));
   Log.d(TAG, "\tIncoming long -> " + longitude);
   Log.d(TAG, "\tConverted long -> " + (int) (longitude * 1E6));

   return new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
}

public static GeoPoint getGeoPoint(String latitude , String longitude) {
   Log.d(TAG, "GeoPointUtils.getGeoPoint(String)");
   Log.d(TAG, "\tIncoming lat -> " + latitude);
   Log.d(TAG, "\tConverted lat -> " + Double.parseDouble(latitude));
   Log.d(TAG, "\tIncoming long -> " + longitude);
   Log.d(TAG, "\tConverted long -> " + Double.parseDouble(longitude));

   return getGeoPoint(Double.parseDouble(latitude), Double.parseDouble(longitude));
}

Logcat results (sorry for syntax highlighting)

GeoPointUtils.getGeoPoint(String)
   Incoming lat  -> -98.493095
   Converted lat -> -98.493095
   Incoming long ->  29.416311
   Converted long -> 29.416311
GeoPointUtils.getGeoPoint(double)
   Incoming lat  -> -98.493095
   Converted lat -> -98493095
   Incoming long ->  29.416311
   Converted long -> 29416311
gp.getLat(): -80000000
gp.getLong(): 29416311
+3
source share
2 answers

Latitude only from -90 to +90 degrees. It's your problem?

If you are trying to build a point in San Antonio, Texas, you switched your lat and for a long time .;)

+2
source

: , -90.. + 90 . , -98,5 , , - .

, , - , , , - - .

 You expected gp.getLat(): -98493095
 You got      gp.getLat(): -80000000
+3

Source: https://habr.com/ru/post/1788050/