Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function dmsPointToWkt(point) {
const latitude = parseDmsCoordinate(point.latitude)
const longitude = parseDmsCoordinate(point.longitude)
const _latitude = dmsCoordinateToDD(latitude)
const _longitude = dmsCoordinateToDD(longitude)
return new wkx.Point(_longitude, _latitude)
}
break
case 'polygon':
if (dd.polygon.list.length > 0) {
dd.polygon.list.map(point => points.push(ddPointToWkt(point)))
const p1 = points[0]
const p2 = points[points.length - 1]
if (p1.x !== p2.x || p1.y !== p2.y) {
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const nw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.north)
const ne = new wkx.Point(dd.boundingbox.east, dd.boundingbox.north)
const se = new wkx.Point(dd.boundingbox.east, dd.boundingbox.south)
const sw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.south)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}
function usngGridToWktPoint(grid) {
const LL = converter.USNGtoLL(grid, true)
return new wkx.Point(LL.lon, LL.lat)
}
wkt = new wkx.LineString(points).toWkt()
}
break
case 'polygon':
if (dd.polygon.list.length > 0) {
dd.polygon.list.map(point => points.push(ddPointToWkt(point)))
const p1 = points[0]
const p2 = points[points.length - 1]
if (p1.x !== p2.x || p1.y !== p2.y) {
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const nw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.north)
const ne = new wkx.Point(dd.boundingbox.east, dd.boundingbox.north)
const se = new wkx.Point(dd.boundingbox.east, dd.boundingbox.south)
const sw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.south)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}
if (p1.x !== p2.x || p1.y !== p2.y) {
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const grid = converter.isUSNG(usng.boundingbox)
const bbox = converter.USNGtoLL(grid, false)
const minLon = bbox.west
const minLat = bbox.south
const maxLon = bbox.east
const maxLat = bbox.north
const nw = new wkx.Point(minLon, maxLat)
const ne = new wkx.Point(maxLon, maxLat)
const se = new wkx.Point(maxLon, minLat)
const sw = new wkx.Point(minLon, minLat)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const grid = converter.isUSNG(usng.boundingbox)
const bbox = converter.USNGtoLL(grid, false)
const minLon = bbox.west
const minLat = bbox.south
const maxLon = bbox.east
const maxLat = bbox.north
const nw = new wkx.Point(minLon, maxLat)
const ne = new wkx.Point(maxLon, maxLat)
const se = new wkx.Point(maxLon, minLat)
const sw = new wkx.Point(minLon, minLat)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}
}
break
case 'polygon':
if (dd.polygon.list.length > 0) {
dd.polygon.list.map(point => points.push(ddPointToWkt(point)))
const p1 = points[0]
const p2 = points[points.length - 1]
if (p1.x !== p2.x || p1.y !== p2.y) {
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const nw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.north)
const ne = new wkx.Point(dd.boundingbox.east, dd.boundingbox.north)
const se = new wkx.Point(dd.boundingbox.east, dd.boundingbox.south)
const sw = new wkx.Point(dd.boundingbox.west, dd.boundingbox.south)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}
const p2 = points[points.length - 1]
if (p1.x !== p2.x || p1.y !== p2.y) {
points.push(new wkx.Point(p1.x, p1.y))
}
wkt = new wkx.Polygon(points).toWkt()
}
break
case 'boundingbox':
const grid = converter.isUSNG(usng.boundingbox)
const bbox = converter.USNGtoLL(grid, false)
const minLon = bbox.west
const minLat = bbox.south
const maxLon = bbox.east
const maxLat = bbox.north
const nw = new wkx.Point(minLon, maxLat)
const ne = new wkx.Point(maxLon, maxLat)
const se = new wkx.Point(maxLon, minLat)
const sw = new wkx.Point(minLon, minLat)
wkt = new wkx.Polygon([nw, ne, se, sw, nw]).toWkt()
break
}
return wkt
}