@eturnity/eturnity_maths 7.4.0-EPDM-9710.2 → 7.4.0-splitLine.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * elisee.reclus@eturnity.com
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3
+ };
package/package.json CHANGED
@@ -1,18 +1,11 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "7.4.0-EPDM-9710.2",
3
+ "version": "7.4.0-splitLine.1",
4
4
  "author": "Eturnity Team",
5
- "files": [
6
- "dist"
7
- ],
8
- "main": "./dist/eturnity_maths.umd.js",
9
- "module": "./dist/eturnity_maths.es.js",
5
+ "main": "src/index.js",
10
6
  "private": false,
11
7
  "scripts": {
12
- "test": "jest",
13
- "dev": "vite",
14
- "build": "vite build",
15
- "preview": "vite preview"
8
+ "test": "jest"
16
9
  },
17
10
  "repository": {
18
11
  "type": "git",
@@ -21,24 +14,17 @@
21
14
  "license": "ISC",
22
15
  "homepage": "https://bitbucket.org/eturnitydevs/eturnity_maths#readme",
23
16
  "dependencies": {
24
- "concaveman": "1.2.1",
25
- "lodash": "4.17.21",
26
- "planar-face-discovery": "2.0.7",
27
- "svd-js": "1.1.1",
28
- "uuid": "9.0.0"
17
+ "lodash": "^4.17.21",
18
+ "planar-face-discovery": "^2.0.7",
19
+ "svd-js": "^1.1.1",
20
+ "uuid": "^9.0.0",
21
+ "concaveman": "^1.2.1"
29
22
  },
30
23
  "devDependencies": {
31
- "@babel/core": "7.21.4",
32
- "@babel/preset-env": "7.21.4",
33
- "babel-jest": "29.5.0",
34
- "jest": "29.5.0",
35
- "vite": "2.7.2"
24
+ "@babel/core": "^7.21.4",
25
+ "@babel/preset-env": "^7.21.4",
26
+ "babel-jest": "^29.5.0",
27
+ "jest": "^29.5.0"
36
28
  },
37
- "description": "",
38
- "exports": {
39
- ".": {
40
- "import": "./dist/eturnity_maths.es.js",
41
- "require": "./dist/eturnity_maths.umd.js"
42
- }
43
- }
44
- }
29
+ "description": ""
30
+ }
@@ -0,0 +1,45 @@
1
+ const theme = {
2
+ colors: {
3
+ primary: '#282387',
4
+ secondary: '#818181',
5
+ tertiary: '#d5d5d5',
6
+ black: '#263238',
7
+ yellow: '#fdb813',
8
+ darkGray: '#818181',
9
+ mediumGray: '#d5d5d5',
10
+ lightGray: '#f2f2f2',
11
+ white: '#ffffff',
12
+ blue: '#48a2d0',
13
+ brightBlue: '#0068DE',
14
+ ballBlue: '#2CC0EB',
15
+ red: '#FF5656',
16
+ blue1: '#e4efff',
17
+ blue2: '#F6FAFF',
18
+ grey1: '#666',
19
+ grey2: '#c4c4c4',
20
+ grey3: '#b2b9c5',
21
+ grey4: '#dee2eb',
22
+ grey5: '#fafafa',
23
+ grey6: '#555d61',
24
+ turquoise: '#20A4CA',
25
+ green: '#99db0c',
26
+ purple: '#505ca6',
27
+ disabled: '#dfe1e1',
28
+ transparentWhite1: '#ffffff32',
29
+ transparentBlack1: '#263238e6',
30
+ transparentBlue1: '#20a4cae6',
31
+ blueElectric: '#66dffa',
32
+ eturnityGrey: '#263238'
33
+ },
34
+
35
+ screen: {
36
+ mobileSmall: '345px',
37
+ mobile: '425px',
38
+ mobileLarge: '530px',
39
+ tablet: '768px',
40
+ tabletLarge: '950px'
41
+ },
42
+ borderRadius: '4px'
43
+ }
44
+
45
+ export default theme
package/src/config.js ADDED
@@ -0,0 +1,77 @@
1
+ import theme from './assets/theme'
2
+
3
+ export const polygonCloseTolerance=15
4
+ export const snapToPointTolerance = 15
5
+ export const snapToIntersectionPointTolerance = 15
6
+ export const snapToLineTolerance = 10
7
+ export const distanceToCloseNode = 70
8
+ export const mmTolerance=1
9
+ export const earthRadius=6371008
10
+
11
+ export const layerColors = {
12
+ construction: { fillColor: 'transparent', strokeColor: theme.colors.blueElectric ,strokeWidth:3 },
13
+ roof: { fillColor: 'rgba(255, 255, 255, 0.1)', strokeColor: 'white' ,strokeWidth:0 },
14
+ roofInside: { fillColor: 'rgba(255, 255, 255, 0.1)', strokeColor: 'white' ,strokeWidth:1},
15
+ obstacle: { fillColor: theme.colors.red, strokeColor: 'red' ,strokeWidth:1 },
16
+ panel: { fillColor: 'rgba(115, 115, 229, 0.1)', strokeColor: '#ffffff' ,strokeWidth:1},
17
+ user_deactivated_panel: { fillColor: 'rgba(115, 115, 229, 0.1)', strokeColor: 'white' ,strokeWidth:4},
18
+ selectedPanel: { fillColor: '#0068DE80', strokeColor: theme.colors.blue ,strokeWidth:1},
19
+ snap: { fillColor: 'transparent', strokeColor: 'white' },
20
+ moduleField: { fillColor: 'rgba(255, 255, 255, 0.1)', strokeColor: 'white' ,strokeWidth:3 },
21
+ hoveredModuleFieldEdge: { strokeColor: theme.colors.blue ,strokeWidth:6 },
22
+ tmpModuleField: { fillColor: 'rgba(115, 115, 229, 0.4)', strokeColor: theme.colors.blue ,strokeWidth:2 },
23
+ selectedModuleField: {fillColor: '#0068DE80', strokeColor: theme.colors.blue ,strokeWidth:3},
24
+ highlight: { fillColor: 'rgba(255, 255, 255, 0.2)', strokeColor: 'white' ,strokeWidth:1 },
25
+ selectedRoof: { fillColor: '#0068DE80', strokeColor: 'white' ,strokeWidth:3 },
26
+ selectedObstacle: { fillColor: '#0068DE80', strokeColor: theme.colors.blue ,strokeWidth:2 },
27
+ selectedAndHighlighted: {fillColor: '#0068DEA0', strokeColor: theme.colors.blue ,strokeWidth:3},
28
+ flatWarning: {fillColor: '#ffff0090', strokeColor: 'yellow' ,strokeWidth:1},
29
+ customLength: { fillColor: 'transparent', strokeColor: theme.colors.blueElectric ,strokeWidth:1 }
30
+ }
31
+
32
+ export const baseEdgeOfModuleField=theme.colors.blueElectric
33
+ export const maximumGapLimit=500
34
+ export const defaultBaseHeight=3000
35
+ export const colorArrayBase=[
36
+ "#FF5656",
37
+ "#FDB813",
38
+ "#505CA6",
39
+ "#C84E4E",
40
+ "#8392EE",
41
+ "#6CD5D5",
42
+ "#90A650",
43
+ "#D27CCA",
44
+ "#6276DF",
45
+ ]
46
+ export const colorArray=colorArrayBase.map(c=>c+"c0")
47
+ export const layerTools={
48
+ map:[],
49
+ roof:["drawRoof","selectRoof"],
50
+ obstacle:["drawObstacle"],
51
+ margin:["selectMargin"],
52
+ panel:["selectModuleField"],
53
+ }
54
+ //3D visualisation:
55
+ export const beamRadius=0.05
56
+ export const maxMargin=2500
57
+ export const node3DRadius=0.05
58
+ export const beamColor="#ffffff"
59
+ export const node3DColor="white"
60
+ export const beamOpacity=0.3
61
+ export const node3dOpacity=0.3
62
+ export const dimMarginColor='#ff000020'
63
+ export const hitOption = {
64
+ segments: true,
65
+ stroke: true,
66
+ fill: true,
67
+ tolerance: 10
68
+ }
69
+ export const zoomFactor=Math.exp(Math.log(2)/10)
70
+ export const hitOptionPolygonStrict = {
71
+ segments: false,
72
+ stroke: false,
73
+ fill: true,
74
+ tolerance: 0
75
+ }
76
+
77
+ export const dragHeightSensitivity=20
package/src/coords.js ADDED
@@ -0,0 +1,24 @@
1
+ export function toRealityRefFunction(canvasSize, mmPerPx, layoutOffset) {
2
+ return (point) => {
3
+ let realityX = (point.x - layoutOffset.x) * mmPerPx
4
+ // let realityY = -(point.y - layoutOffset.y - (canvasSize.height*layoutOffset.zoom)/(100 * 2)) * mmPerPx
5
+ let realityY = -( point.y - layoutOffset.y) * mmPerPx
6
+
7
+ return { x: realityX, y: realityY, z: point.z }
8
+ }
9
+ }
10
+ export function toCanvasRefFunction(canvasSize, mmPerPx, layoutOffset) {
11
+ return (point) => {
12
+ if (!point) {
13
+ console.error('no point', point)
14
+ }
15
+ if (!canvasSize) {
16
+ console.error('no canvas Size')
17
+ return null
18
+ }
19
+ let canvasX = layoutOffset.x + point.x / mmPerPx
20
+ let canvasY = layoutOffset.y - point.y / mmPerPx
21
+
22
+ return { x: canvasX, y: canvasY, z: point.z }
23
+ }
24
+ }
package/src/geo.js ADDED
@@ -0,0 +1,107 @@
1
+ import {
2
+ earthRadius
3
+ } from './config'
4
+
5
+
6
+ export function lon2tile(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); }
7
+ 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))); }
8
+ export function tile2long(x,z) {
9
+ return (x/Math.pow(2,z)*360-180);
10
+ }
11
+ export function tile2lat(y,z) {
12
+ var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
13
+ return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
14
+ }
15
+ export function latLngToTileXY(lat,lng,zoom){
16
+ const xTile = lon2tile(lng,zoom)
17
+ const yTile = lat2tile(lat,zoom)
18
+ return {
19
+ x:xTile,
20
+ y:yTile
21
+ }
22
+ }
23
+
24
+ export function tileXYZToLatLng(x,y,zoom){
25
+ const longitude=tile2long(x,zoom)
26
+ const latitude=tile2lat(y,zoom)
27
+ return {lat: latitude,lng: longitude};
28
+ }
29
+
30
+ export function tileToCorners(x,y,zoom,lat,lng){
31
+ const tileAltitude=0
32
+ const tileLatLng=tileXYZToLatLng(x,y,zoom)
33
+ const deltaLat=tileLatLng.lat-lat
34
+ const deltaLng=tileLatLng.lng-lng
35
+ let { x:x_mm, y:y_mm }=deltaLatLngToDistance(deltaLat, deltaLng, lat)
36
+ let size=(earthRadius * 2000 * Math.PI / Math.pow(2.0, zoom))*Math.cos(lat*Math.PI/180)
37
+ let corner0={
38
+ x:x_mm,
39
+ y:y_mm,
40
+ z:tileAltitude
41
+ }
42
+ let corner1={
43
+ x:x_mm+size,
44
+ y:y_mm,
45
+ z:tileAltitude
46
+ }
47
+ let corner2={
48
+ x:x_mm+size,
49
+ y:y_mm-size,
50
+ z:tileAltitude
51
+ }
52
+ let corner3={
53
+ x:x_mm,
54
+ y:y_mm-size,
55
+ z:tileAltitude
56
+ }
57
+ return [
58
+ corner3,
59
+ corner0,
60
+ corner1,
61
+ corner2,
62
+ ]
63
+ }
64
+ export function distanceToDeltaLatLng(x, y, latitude) {
65
+ //x,y,z in ENU coords
66
+ let lat = (180 / Math.PI) * (y / 1000) / earthRadius
67
+ let lng =((180 / Math.PI) * (x / 1000) / earthRadius)/(Math.cos(((latitude) * Math.PI) / 180))
68
+ return { lat, lng }
69
+ }
70
+ export function deltaLatLngToDistance(deltaLat, deltaLng, latitude) {
71
+ //x,y,z in ENU coords
72
+ let y=earthRadius * deltaLat *1000/(180 / Math.PI)
73
+ let x=earthRadius* deltaLng * 1000 *(Math.cos(((latitude) * Math.PI) / 180))/(180 / Math.PI)
74
+ return { x, y }
75
+ }
76
+
77
+ export function datum2spherical(lat1, lat2, lng1, lng2) {
78
+ const earthOrigin = Math.PI * earthRadius
79
+
80
+ //const d = earthRadius * arccos[(sin(lat1) * sin(lat2)) + cos(lat1) * cos(lat2) * cos(lng2 – lng1)]
81
+ const averageLat = (lat1 + lat2) / 2
82
+ const x =
83
+ 1000 *
84
+ earthRadius *
85
+ arccos(
86
+ sin(averageLat) * sin(averageLat) +
87
+ cos(averageLat) * cos(averageLat) * cos(lng2 - lng1)
88
+ )
89
+ const y =
90
+ 1000 * earthRadius * arccos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2))
91
+
92
+ // const x = longitude * earthOrigin / 180.0;
93
+ // let y = Math.log(Math.tan((90 + latitude) * Math.PI / 360.0)) / (Math.PI / 180.0);
94
+
95
+ // y = y * earthOrigin / 180.0;
96
+
97
+ return { x, y }
98
+ }
99
+ function cos(deg) {
100
+ return Math.cos((deg * Math.PI) / 180)
101
+ }
102
+ function sin(deg) {
103
+ return Math.sin((deg * Math.PI) / 180)
104
+ }
105
+ function arccos(val) {
106
+ return Math.acos(val)
107
+ }