@eturnity/eturnity_maths
Advanced tools
Comparing version 6.32.0 to 6.33.0-qa.0
{ | ||
"name": "@eturnity/eturnity_maths", | ||
"version": "6.32.0", | ||
"version": "6.33.0-qa.0", | ||
"author": "Eturnity Team", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,4 +5,62 @@ import { | ||
export function lon2tile(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); } | ||
export function lat2tile(lat,zoom) { return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); } | ||
export function tile2long(x,z) { | ||
return (x/Math.pow(2,z)*360-180); | ||
} | ||
export function tile2lat(y,z) { | ||
var n=Math.PI-2*Math.PI*y/Math.pow(2,z); | ||
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n)))); | ||
} | ||
export function latLngToTileXY(lat,lng,zoom){ | ||
const xTile = lon2tile(lng,zoom) | ||
const yTile = lat2tile(lat,zoom) | ||
return { | ||
x:xTile, | ||
y:yTile | ||
} | ||
} | ||
export function tileXYZToLatLng(x,y,zoom){ | ||
const longitude=tile2long(x,zoom) | ||
const latitude=tile2lat(y,zoom) | ||
return {lat: latitude,lng: longitude}; | ||
} | ||
export function distanceToDeltaLatLng(x, y, latitude) { | ||
export function tileToCorners(x,y,zoom,lat,lng){ | ||
const tileAltitude=0 | ||
const tileLatLng=tileXYZToLatLng(x,y,zoom) | ||
const deltaLat=tileLatLng.lat-lat | ||
const deltaLng=tileLatLng.lng-lng | ||
let { x:x_mm, y:y_mm }=deltaLatLngToDistance(deltaLat, deltaLng, lat) | ||
let size=(earthRadius * 2000 * Math.PI / Math.pow(2.0, zoom))*Math.cos(lat*Math.PI/180) | ||
let corner0={ | ||
x:x_mm, | ||
y:y_mm, | ||
z:tileAltitude | ||
} | ||
let corner1={ | ||
x:x_mm+size, | ||
y:y_mm, | ||
z:tileAltitude | ||
} | ||
let corner2={ | ||
x:x_mm+size, | ||
y:y_mm-size, | ||
z:tileAltitude | ||
} | ||
let corner3={ | ||
x:x_mm, | ||
y:y_mm-size, | ||
z:tileAltitude | ||
} | ||
return [ | ||
corner3, | ||
corner0, | ||
corner1, | ||
corner2, | ||
] | ||
} | ||
export function distanceToDeltaLatLng(x, y, latitude) { | ||
//x,y,z in ENU coords | ||
@@ -9,0 +67,0 @@ let lat = (180 / Math.PI) * (y / 1000) / earthRadius |
@@ -24,3 +24,3 @@ import { | ||
} | ||
export function updateOutlineFromInclineDirection(incline, direction, outline,initialAverageHeight) { | ||
export function updateOutlineFromInclineDirection(incline, direction, outline,initialAverageHeight,isRoofOnRoof = false) { | ||
const newNormalVector = {} | ||
@@ -33,3 +33,2 @@ newNormalVector.x = | ||
let meanPoint = meanVector(outline) | ||
let minAltitude=Math.min(...outline.map(p=>p.z)) | ||
meanPoint.z=initialAverageHeight | ||
@@ -40,4 +39,12 @@ let newOutline = outline.map((p) => { | ||
//if some points are with negative altitude, we offset the whole roof | ||
const newMinAltitude = Math.min(...newOutline.map((p) => p.z)) | ||
let altitudeOffset=newMinAltitude-minAltitude | ||
let altitudeOffset | ||
let minAltitude=Math.min(...outline.map(p=>p.z)) | ||
let maxAltitude=Math.max(...outline.map(p=>p.z)) | ||
let newMinAltitude = Math.min(...newOutline.map((p) => p.z)) | ||
let newMaxAltitude = Math.max(...newOutline.map((p) => p.z)) | ||
if(isRoofOnRoof && maxAltitude!=0){ | ||
altitudeOffset=newMaxAltitude-maxAltitude | ||
}else{ | ||
altitudeOffset=newMinAltitude-minAltitude | ||
} | ||
newOutline.forEach((p) => (p.z -= altitudeOffset)) | ||
@@ -44,0 +51,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
99082
3088
0
2