Socket
Socket
Sign inDemoInstall

geo-coordinates-parser

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-coordinates-parser - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

21

converter.js

@@ -192,2 +192,3 @@ //function for converting coordinates from a string to decimal and verbatim

//so we need to find the separating character, or if none, use the match values to split down the middle
var verbatimCoordinates = match[0].trim()
var verbatimLat

@@ -197,3 +198,3 @@ var verbatimLng

var sepChars = /[,/\u0020]/g //comma, forward slash and spacebar
var seps = coordsString.match(sepChars)
var seps = verbatimCoordinates.match(sepChars)

@@ -203,4 +204,4 @@ if (seps == null) {

var middle = Math.floor(coordsString.length/2)
verbatimLat = coordsString.substring(0, middle).trim()
verbatimLng = coordsString.substring(middle).trim()
verbatimLat = verbatimCoordinates.substring(0, middle).trim()
verbatimLng = verbatimCoordinates.substring(middle).trim()
}

@@ -225,5 +226,5 @@ else { //if length is odd then find the index of the middle value

if (middle == 0){
splitIndex = coordsString.indexOf(seps[0])
verbatimLat = coordsString.substring(0, splitIndex).trim()
verbatimLng = coordsString.substring(splitIndex + 1).trim()
splitIndex = verbatimCoordinates.indexOf(seps[0])
verbatimLat = verbatimCoordinates.substring(0, splitIndex).trim()
verbatimLng = verbatimCoordinates.substring(splitIndex + 1).trim()
}

@@ -234,3 +235,3 @@ else {

while (currSepIndex <= middle){
splitIndex = coordsString.indexOf(seps[currSepIndex], startSearchIndex)
splitIndex = verbatimCoordinates.indexOf(seps[currSepIndex], startSearchIndex)
startSearchIndex = splitIndex + 1

@@ -240,4 +241,4 @@ currSepIndex++

verbatimLat = coordsString.substring(0, splitIndex).trim()
verbatimLng = coordsString.substring(splitIndex + 1).trim()
verbatimLat = verbatimCoordinates.substring(0, splitIndex).trim()
verbatimLng = verbatimCoordinates.substring(splitIndex + 1).trim()

@@ -263,3 +264,3 @@ }

return {
verbatimCoordinates: coordsString,
verbatimCoordinates,
verbatimLatitude: verbatimLat,

@@ -266,0 +267,0 @@ verbatimLongitude: verbatimLng,

{
"name": "geo-coordinates-parser",
"version": "1.3.0",
"version": "1.3.1",
"description": "A Javascript function for reading a variety of coordinate formats and converting to decimal numbers. Builds on other efforts by returning the verbatim coordinates and the decimal coordinates all in one object.",

@@ -5,0 +5,0 @@ "main": "merge.js",

# Geo Coordinates Parser
A Javascript function for reading a variety of coordinate formats and converting to decimal latitude and longitude. Builds on other efforts for convenience by returning the verbatim coordinates and the decimal coordinates all in one object. Also includes a function to test existing decimal coordinates against those from the converter.
A Javascript function for reading a variety of coordinate formats and converting to decimal latitude and longitude. Builds on other efforts for convenience by returning the verbatim coordinates and the decimal coordinates all in one object. Can be used to extract coordinates from longer strings. Also includes a function to test existing decimal coordinates against those from the converter.

@@ -22,3 +22,10 @@ ##If you like this package please [star it on GitHub](https://github.com/ianengelbrecht/geo-coordinates-parser)

```js
let converted = convert('40° 26.7717, -79° 56.93172');
let converted;
try {
converted = convert('40° 26.7717, -79° 56.93172');
}
catch {
//we get here if the string is not valid coordinates
}
```

@@ -28,3 +35,9 @@ OR add the number of decimal places you want (but be reasonable, [see Coordinate Precision here](https://en.wikipedia.org/wiki/Decimal_degrees)) -- default is 5

```js
let converted = convert(coordinatesString, integerDecimalPlaces)
try{
let converted = convert(coordinatesString, integerDecimalPlaces)
//do stuff with coordinates...
}
catch{
//coordinates not valid
}
```

@@ -60,3 +73,3 @@ THEN

```
covert.formats
convert.formats
```

@@ -63,0 +76,0 @@

const convert = require('./converter')
const test = '± 1 km on Schweizer rd (R504) from Schweizer Reinecke to Ipelegeng.'
const test = 'Between Sannieshof and Bessiesvlei. 26.4558°S 25.8644°E.'
try{

@@ -4,0 +4,0 @@ let converted = convert(test)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc