// Path: igcParser/src/main/java/com/shollmann/android/igcparser/model/ILatLonRecord.java
// public interface ILatLonRecord {
//     LatLon getLatLon();
// }
// 
// Path: igcParser/src/main/java/com/shollmann/android/igcparser/model/LatLon.java
// public class LatLon implements Serializable {
//     private double lat;
//     private double lon;
// 
//     public LatLon(double lat, double lon) {
//         this.lat = lat;
//         this.lon = lon;
//     }
// 
//     public double getLat() {
//         return lat;
//     }
// 
//     public void setLat(double lat) {
//         this.lat = lat;
//     }
// 
//     public double getLon() {
//         return lon;
//     }
// 
//     public void setLon(double lon) {
//         this.lon = lon;
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(lat) + String.valueOf(lon);
//     }
// }


import java.io.File;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.google.android.gms.maps.model.LatLng;
import com.shollmann.android.igcparser.model.ILatLonRecord;
import com.shollmann.android.igcparser.model.LatLon;
/*
 * MIT License
 *
 * Copyright (c) 2016 Santiago Hollmann
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.shollmann.android.igcparser.util;




public class Utilities {
    private static final double METERS_IN_ONE_KILOMETER = 1000;
    private static DecimalFormat decimalFormatter = null;
    private static DecimalFormatSymbols symbols = null;

    public static LatLon generateCoordinates(String lat, String lon) {
        double latDegrees = Double.valueOf(lat.substring(0, 2));
        String latMinutes = lat.substring(2, 4);
        String latSeconds = lat.substring(4, lat.length() - 1);
        double latRealMinutes = Double.valueOf(latMinutes + "." + latSeconds) / 60;
        double latDecimalFormat = latDegrees + latRealMinutes;
        if (hasSuffix(lat, 'S')) {
            latDecimalFormat = -1 * latDecimalFormat;
        }

        double lonDegrees = Double.valueOf(lon.substring(0, 3));
        String lonMinutes = lon.substring(3, 5);
        String lonSeconds = lon.substring(5, lon.length() - 1);
        double lonRealMinutes = Double.valueOf(lonMinutes + "." + lonSeconds) / 60;
        double lonDecimalFormat = lonDegrees + lonRealMinutes;
        if (hasSuffix(lon, 'W')) {
            lonDecimalFormat = -1 * lonDecimalFormat;
        }
// Path: igcParser/src/main/java/com/shollmann/android/igcparser/model/ILatLonRecord.java
// public interface ILatLonRecord {
//     LatLon getLatLon();
// }
// 
// Path: igcParser/src/main/java/com/shollmann/android/igcparser/model/LatLon.java
// public class LatLon implements Serializable {
//     private double lat;
//     private double lon;
// 
//     public LatLon(double lat, double lon) {
//         this.lat = lat;
//         this.lon = lon;
//     }
// 
//     public double getLat() {
//         return lat;
//     }
// 
//     public void setLat(double lat) {
//         this.lat = lat;
//     }
// 
//     public double getLon() {
//         return lon;
//     }
// 
//     public void setLon(double lon) {
//         this.lon = lon;
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(lat) + String.valueOf(lon);
//     }
// }


// Path: igcParser/src/main/java/com/shollmann/android/igcparser/util/Utilities.java
import java.io.File;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.google.android.gms.maps.model.LatLng;
import com.shollmann.android.igcparser.model.ILatLonRecord;
import com.shollmann.android.igcparser.model.LatLon;

/*
 * MIT License
 *
 * Copyright (c) 2016 Santiago Hollmann
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.shollmann.android.igcparser.util;




public class Utilities {
    private static final double METERS_IN_ONE_KILOMETER = 1000;
    private static DecimalFormat decimalFormatter = null;
    private static DecimalFormatSymbols symbols = null;

    public static LatLon generateCoordinates(String lat, String lon) {
        double latDegrees = Double.valueOf(lat.substring(0, 2));
        String latMinutes = lat.substring(2, 4);
        String latSeconds = lat.substring(4, lat.length() - 1);
        double latRealMinutes = Double.valueOf(latMinutes + "." + latSeconds) / 60;
        double latDecimalFormat = latDegrees + latRealMinutes;
        if (hasSuffix(lat, 'S')) {
            latDecimalFormat = -1 * latDecimalFormat;
        }

        double lonDegrees = Double.valueOf(lon.substring(0, 3));
        String lonMinutes = lon.substring(3, 5);
        String lonSeconds = lon.substring(5, lon.length() - 1);
        double lonRealMinutes = Double.valueOf(lonMinutes + "." + lonSeconds) / 60;
        double lonDecimalFormat = lonDegrees + lonRealMinutes;
        if (hasSuffix(lon, 'W')) {
            lonDecimalFormat = -1 * lonDecimalFormat;
        }
        return new LatLon(latDecimalFormat, lonDecimalFormat);