public static Coordinate createCoordinate ( Attributes attributes ) throws NumberFormatException { // Associate a latitude and a longitude to the point double lat ; double lon ; try { lat = Double . parseDouble ( attributes . getValue ( GPXTags . LAT ) ) ; } catch ( NumberFormatException e ) { throw new NumberFormatException ( "Cannot parse the latitude value" ) ; } try { lon = Double . parseDouble ( attributes . getValue ( GPXTags . LON ) ) ; } catch ( NumberFormatException e ) { throw new NumberFormatException ( "Cannot parse the longitude value" ) ; } String eleValue = attributes . getValue ( GPXTags . ELE ) ; double ele = Double . NaN ; if ( eleValue != null ) { try { ele = Double . parseDouble ( eleValue ) ; } catch ( NumberFormatException e ) { throw new NumberFormatException ( "Cannot parse the elevation value" ) ; } } return new Coordinate ( lon , lat , ele ) ; }
General method to create a coordinate from a gpx point .