Skip to content

Instantly share code, notes, and snippets.

@myh-st
Forked from pjobson/latitude_longitude.txt
Created October 21, 2022 02:54
Show Gist options
  • Save myh-st/268c5000b54f4abec46e521efb1c156f to your computer and use it in GitHub Desktop.
Save myh-st/268c5000b54f4abec46e521efb1c156f to your computer and use it in GitHub Desktop.

Revisions

  1. @pjobson pjobson revised this gist Jul 8, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions latitude_longitude.txt
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ IN JS:

    Combined:

    patterns.lat.combined = new RegExp(`^(${patterns.lat.map(tt => tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lng.combined = new RegExp(`^(${patterns.lng.map(tt => tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`)
    patterns.lat.combined = new RegExp(`^(${patterns.lat.map(tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lng.combined = new RegExp(`^(${patterns.lng.map(tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`)


  2. @pjobson pjobson revised this gist Jul 8, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions latitude_longitude.txt
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ IN JS:

    Combined:

    patterns.lat.combined = new RegExp(`^(${_.map(patterns.lat, tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lng.combined = new RegExp(`^(${_.map(patterns.lng, tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lat.combined = new RegExp(`^(${patterns.lat.map(tt => tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lng.combined = new RegExp(`^(${patterns.lng.map(tt => tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`)


  3. @pjobson pjobson revised this gist Feb 20, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions latitude_longitude.txt
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@ Degrees Minutes Seconds (DMS)
    Use N, S, E or W as either the last character,
    which represents a compass direction North, South, East or West.
    D & M must be intergers, S may be an interger or float.
    DMS.latitude - /^(([1-8]?[0-9])\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|90\D+0\D+0)\D+[NSns]$/
    DMS.longitude - /^([1-7]?[0-9]\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|180\D+0\D+0)\D+[EWew]$/
    DMS.latitude - /^[\+-]?(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/
    DMS.longitude - /^[\+-]?([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/

    Degrees Decimal Minutes (DDM)
    40° 26.767′ N 79° 58.933′ W
    @@ -22,17 +22,17 @@ Degrees Decimal Minutes (DDM)
    which represents a compass direction North, South, East or West.
    The last degree, minute, or second of a latitude or longitude
    may contain a decimal portion.
    DDM.latitude - /^(([1-8]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|90(\D+0)?)\D+([NSns])$/
    DDM.longitude - /^((1[0-7][0-9]|[1-9]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|180(\D+0)?)\D+([EWew])$/
    DDM.latitude - /^[\+-]?(([1-8]?\d)\D+[1-6]?\d(\.\d{1,})?|90(\D+0)?)\D+[NSns]?$/
    DDM.longitude - /^[\+-]?((1[0-7]\d|[1-9]?\d)\D+[1-6]?\d(\.\d{1,})?|180(\D+0)?)\D+[EWew]?$/

    Decimal Degrees (DD)
    40.446° N 79.982° W
    Precede South latitudes and West longitudes with a minus sign.
    Latitudes range from -90 to 90
    Longitudes range from -180 to 180
    Up to 6 decimal places
    DD.latitude - /^[\+-]?(([1-8]?[0-9])(\.\d{1,6})?|90)\D*[NSns]?$/
    DD.longitude - /^[\+-]?((1[0-7][0-9]|[1-9]?[0-9])(\.\d{1,6})?|180)\D*[EWew]?$/
    DD.latitude - /^[\+-]?(([1-8]?\d)(\.\d{1,})?|90)\D*[NSns]?$/
    DD.longitude - /^[\+-]?((1[0-7]\d|[1-9]?\d)(\.\d{1,})?|180)\D*[EWew]?$/

    IN JS:

  4. @pjobson pjobson revised this gist Feb 7, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions latitude_longitude.txt
    Original file line number Diff line number Diff line change
    @@ -31,8 +31,8 @@ Decimal Degrees (DD)
    Latitudes range from -90 to 90
    Longitudes range from -180 to 180
    Up to 6 decimal places
    DD.latitude - /^[\+-]?(([1-8]?[0-9])(\.\d{1,6})?|90)\D*[NS]?$/
    DD.longitude - /^[\+-]?((1[0-7][0-9]|[1-9]?[0-9])(\.\d{1,6})?|180)\D*[EW]?$/
    DD.latitude - /^[\+-]?(([1-8]?[0-9])(\.\d{1,6})?|90)\D*[NSns]?$/
    DD.longitude - /^[\+-]?((1[0-7][0-9]|[1-9]?[0-9])(\.\d{1,6})?|180)\D*[EWew]?$/

    IN JS:

  5. @pjobson pjobson created this gist Aug 27, 2018.
    57 changes: 57 additions & 0 deletions latitude_longitude.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    Degrees Minutes Seconds (DMS)
    40° 26′ 46″ N 79° 58′ 56″ W
    40° 26′ 46″ S 79° 58′ 56″ E
    90° 0′ 0″ S 180° 0′ 0″ E
    40° 26′ 45.9996″ N 79° 58′ 55.2″ E
    Latitudes range from 0 to 90.
    Longitudes range from 0 to 180.
    Minutes & Seconds range from 0-60
    Use N, S, E or W as either the last character,
    which represents a compass direction North, South, East or West.
    D & M must be intergers, S may be an interger or float.
    DMS.latitude - /^(([1-8]?[0-9])\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|90\D+0\D+0)\D+[NSns]$/
    DMS.longitude - /^([1-7]?[0-9]\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|180\D+0\D+0)\D+[EWew]$/

    Degrees Decimal Minutes (DDM)
    40° 26.767′ N 79° 58.933′ W
    90° 0′ N 180° 0′ W
    90° N 180° W
    Latitudes range from 0 to 90.
    Longitudes range from 0 to 180.
    Use N, S, E or W as either the last character,
    which represents a compass direction North, South, East or West.
    The last degree, minute, or second of a latitude or longitude
    may contain a decimal portion.
    DDM.latitude - /^(([1-8]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|90(\D+0)?)\D+([NSns])$/
    DDM.longitude - /^((1[0-7][0-9]|[1-9]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|180(\D+0)?)\D+([EWew])$/

    Decimal Degrees (DD)
    40.446° N 79.982° W
    Precede South latitudes and West longitudes with a minus sign.
    Latitudes range from -90 to 90
    Longitudes range from -180 to 180
    Up to 6 decimal places
    DD.latitude - /^[\+-]?(([1-8]?[0-9])(\.\d{1,6})?|90)\D*[NS]?$/
    DD.longitude - /^[\+-]?((1[0-7][0-9]|[1-9]?[0-9])(\.\d{1,6})?|180)\D*[EW]?$/

    IN JS:

    const patterns = {
    lat: {
    isDMS: /^(([1-8]?[0-9])\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|90\D+0\D+0)\D+[NSns]$/,
    isDDM: /^(([1-8]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|90(\D+0)?)\D+([NSns])$/,
    isDD: /^[\+-]?(([1-8]?[0-9])(\.\d{1,6})?|90)\D*[NSns]?$/
    },
    lng: {
    isDMS: /^((1[0-7][0-9]|[1-9]?[0-9])\D+([1-5]?[0-9]|60)\D+([1-5]?[0-9]|60)(\.[0-9]+)?|180\D+0\D+0)\D+[EWew]$/,
    isDDM: /^((1[0-7][0-9]|[1-9]?[0-9])\D+[1-6]?[0-9](\.\d{1,3})?|180(\D+0)?)\D+([EWew])$/,
    isDD: /^[\+-]?((1[0-7][0-9]|[1-9]?[0-9])(\.\d{1,6})?|180)\D*[EWew]?$/
    }
    };

    Combined:

    patterns.lat.combined = new RegExp(`^(${_.map(patterns.lat, tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);
    patterns.lng.combined = new RegExp(`^(${_.map(patterns.lng, tt => `(${tt.toString().replace(/^\/\^(.+?)\$\//g,'$1')})`).join('|')})$`);