-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
670defe
commit 1408c01
Showing
17 changed files
with
1,352 additions
and
1,225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import GridRefParser from './GridRefParser'; | ||
import GridRefParserCI from './CI'; | ||
import GridRefParserGB from './GB'; | ||
import GridRefParserIE from './IE'; | ||
|
||
/** | ||
* returns a GridRefParser (GB, IE or CI-specific parser) or false | ||
* crudely tries to determine the country by trying each country in turn | ||
* | ||
* @param {string} rawGridRef | ||
* @return GridRefParser|FALSE | ||
*/ | ||
GridRefParser.factory = function (rawGridRef) { | ||
var parser; | ||
var cleanRef = rawGridRef.replace(/\s+/g, '').toUpperCase(); | ||
|
||
if (!cleanRef) { | ||
return false; | ||
} | ||
|
||
// if canonical ref form then be more efficient | ||
if (/^[A-Z]{1,2}\d{2}(?:[A-Z]|[NS][EW]|(?:\d{2}){0,4})?$/.test(cleanRef)) { | ||
// have simple well-formed grid ref | ||
|
||
if (/^.\d/.test(cleanRef)) { | ||
parser = new GridRefParserIE(); | ||
} else { | ||
if (cleanRef.charAt(0) === 'W') { | ||
parser = new GridRefParserCI(); | ||
} else { | ||
parser = new GridRefParserGB(); | ||
} | ||
} | ||
|
||
parser.parse_well_formed(cleanRef); | ||
|
||
return (parser.length && !parser.error) ? parser : false; | ||
} else { | ||
parser = new GridRefParserGB(); | ||
parser.parse(cleanRef); | ||
|
||
if (parser.length && !parser.error) { | ||
return parser; | ||
} | ||
|
||
if (cleanRef.charAt(0) === 'W') { | ||
parser = new GridRefParserCI(); | ||
parser.parse(cleanRef); | ||
|
||
if (parser.length && !parser.error) { | ||
return parser; | ||
} | ||
} else { | ||
parser = new GridRefParserIE(); | ||
parser.parse(cleanRef); | ||
|
||
if (parser.length && !parser.error) { | ||
return parser; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
export default GridRefParser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { deg2rad } from 'constants'; | ||
|
||
/** | ||
* represents lat lng | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const deg2rad = Math.PI / 180; | ||
const rad2deg = 180.0 / Math.PI; | ||
|
||
export { deg2rad, rad2deg }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* polyfill for browsers other than firefox | ||
*/ | ||
if (!('asinh' in Math)) { | ||
Math.asinh = function (x) { | ||
return Math.log(x + Math.sqrt(x * x + 1)); | ||
}; | ||
} | ||
|
||
/** | ||
* polyfill for browsers other than firefox and chrome | ||
*/ | ||
if (!('trunc' in Math)) { | ||
Math.trunc = function (x) { | ||
return x < 0 ? Math.ceil(x) : Math.floor(x); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters