Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
latitude: dms.boundingbox.north,
longitude: dms.boundingbox.east,
}
const se = {
latitude: dms.boundingbox.south,
longitude: dms.boundingbox.east,
}
const sw = {
latitude: dms.boundingbox.south,
longitude: dms.boundingbox.west,
}
const _nw = dmsPointToWkt(nw)
const _ne = dmsPointToWkt(ne)
const _se = dmsPointToWkt(se)
const _sw = dmsPointToWkt(sw)
wkt = new wkx.Polygon([_nw, _ne, _se, _sw, _nw]).toWkt()
break
}
return wkt
}
break
case 'line':
if (usng.line.list.length > 0) {
usng.line.list.map(grid => points.push(usngGridToWktPoint(grid)))
wkt = new wkx.LineString(points).toWkt()
}
break
case 'polygon':
if (usng.polygon.list.length > 0) {
usng.polygon.list.map(grid => points.push(usngGridToWktPoint(grid)))
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 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
}
break
case 'line':
if (dms.line.list.length > 0) {
dms.line.list.map(point => points.push(dmsPointToWkt(point)))
wkt = new wkx.LineString(points).toWkt()
}
break
case 'polygon':
if (dms.polygon.list.length > 0) {
dms.polygon.list.map(point => points.push(dmsPointToWkt(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 = {
latitude: dms.boundingbox.north,
longitude: dms.boundingbox.west,
}
const ne = {
latitude: dms.boundingbox.north,
longitude: dms.boundingbox.east,
}
const se = {
latitude: dms.boundingbox.south,
longitude: dms.boundingbox.east,
}
const sw = {
function computeCircle(point, distance, n) {
if (distance < 0 || n < 0) {
return null
}
const points = []
for (let i = 0; i < n; i++) {
points.push(computeDestination(point, (360 * i) / n, distance))
}
points.push(points[0])
return new wkx.Polygon(points)
}
break
case 'line':
if (dd.line.list.length > 0) {
dd.line.list.map(point => points.push(ddPointToWkt(point)))
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 (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
}
}
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
}