Compare commits
9 Commits
5fc055a05d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bef0a68e3a | ||
|
|
0d72ce921e | ||
|
|
9e13e9ec1a | ||
|
|
3fd00f9e3f | ||
|
|
c26ed9d057 | ||
|
|
9a169e5872 | ||
|
|
6ea104aa08 | ||
|
|
764c77692a | ||
|
|
7380ceee7e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/node_modules/
|
/node_modules/
|
||||||
/public/build/
|
/public/build/
|
||||||
|
/tmp
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
12
index.html
12
index.html
@@ -111,7 +111,7 @@
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
set_style(style) {
|
add_style(style) {
|
||||||
this.style = { ...this.style || {}, ...style }
|
this.style = { ...this.style || {}, ...style }
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -385,13 +385,13 @@
|
|||||||
axios.post('http://localhost:4000/proxy/sqlite', { query }).then(x => x.data)
|
axios.post('http://localhost:4000/proxy/sqlite', { query }).then(x => x.data)
|
||||||
.then(wells => {
|
.then(wells => {
|
||||||
|
|
||||||
let layer_wells = wells.map(w => circle(15).set_style(style_wellhead).move(w.whx, w.why).render())
|
let layer_wells = wells.map(w => circle(15).add_style(style_wellhead).move(w.whx, w.why).render())
|
||||||
let layer_wells_wpr = wells.map(w => svg_sector(70, 0, 70).set_style(style_wir).move(w.whx, w.why).render())
|
let layer_wells_wpr = wells.map(w => svg_sector(70, 0, 70).add_style(style_wir).move(w.whx, w.why).render())
|
||||||
|
|
||||||
let layer_wells_gpr = wells.map(w => svg_sector(70, 70, 130).set_style(style_gpr).move(w.whx, w.why).render())
|
let layer_wells_gpr = wells.map(w => svg_sector(70, 70, 130).add_style(style_gpr).move(w.whx, w.why).render())
|
||||||
let layer_wells_opr = wells.map(w => svg_sector(70, 130, 360).set_style(style_opr).move(w.whx, w.why).render())
|
let layer_wells_opr = wells.map(w => svg_sector(70, 130, 360).add_style(style_opr).move(w.whx, w.why).render())
|
||||||
|
|
||||||
let layer_well_names = wells.map(w => svg_text(w.well).set_style(style_wellhead_text).move(w.whx + 10, w.why - 10).render())
|
let layer_well_names = wells.map(w => svg_text(w.well).add_style(style_wellhead_text).move(w.whx + 10, w.why - 10).render())
|
||||||
// let layers = [...layer_wells, ...layer_wells_wpr, ...layer_well_names]
|
// let layers = [...layer_wells, ...layer_wells_wpr, ...layer_well_names]
|
||||||
// let layers = layer_wells_wpr
|
// let layers = layer_wells_wpr
|
||||||
let layers = [...layer_wells_wpr, ...layer_wells_gpr, ...layer_wells_opr, ...layer_wells, ...layer_well_names,
|
let layers = [...layer_wells_wpr, ...layer_wells_gpr, ...layer_wells_opr, ...layer_wells, ...layer_well_names,
|
||||||
|
|||||||
77
package-lock.json
generated
77
package-lock.json
generated
@@ -10,8 +10,11 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
|
"fast-xml-parser": "^4.0.7",
|
||||||
"sirv-cli": "^2.0.0",
|
"sirv-cli": "^2.0.0",
|
||||||
"svelte-toasts": "^1.1.2"
|
"svelte-toasts": "^1.1.2",
|
||||||
|
"svg-parser": "^2.0.4",
|
||||||
|
"xml-js": "^1.6.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
@@ -363,6 +366,21 @@
|
|||||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/fast-xml-parser": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.7.tgz",
|
||||||
|
"integrity": "sha512-dMtibyus3kC7nbxj1CpVtysLzO13UOAZEFAb5vpQg3T4O6qvetmSePpXKFx5KPNCHKoGwjtgjfF5DOyn7s1ylQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"strnum": "^1.0.5"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"fxparser": "src/cli/cli.js"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "paypal",
|
||||||
|
"url": "https://paypal.me/naturalintelligence"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
@@ -915,6 +933,11 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/sax": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
|
},
|
||||||
"node_modules/semiver": {
|
"node_modules/semiver": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
||||||
@@ -1000,6 +1023,11 @@
|
|||||||
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/strnum": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
|
||||||
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -1038,6 +1066,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/svelte-toasts/-/svelte-toasts-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/svelte-toasts/-/svelte-toasts-1.1.2.tgz",
|
||||||
"integrity": "sha512-m+yL4eEKXyJoyjTYaH1j1GFwF0Pi8YDqnVfwWPDmwi4712iZesv+TNCmToSNlav3R5Vkmc8ZBRkT8DOcu3sywQ=="
|
"integrity": "sha512-m+yL4eEKXyJoyjTYaH1j1GFwF0Pi8YDqnVfwWPDmwi4712iZesv+TNCmToSNlav3R5Vkmc8ZBRkT8DOcu3sywQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/svg-parser": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ=="
|
||||||
|
},
|
||||||
"node_modules/terser": {
|
"node_modules/terser": {
|
||||||
"version": "5.12.1",
|
"version": "5.12.1",
|
||||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz",
|
||||||
@@ -1110,6 +1143,17 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/xml-js": {
|
||||||
|
"version": "1.6.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||||
|
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||||
|
"dependencies": {
|
||||||
|
"sax": "^1.2.4"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"xml-js": "bin/cli.js"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1377,6 +1421,14 @@
|
|||||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"fast-xml-parser": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.7.tgz",
|
||||||
|
"integrity": "sha512-dMtibyus3kC7nbxj1CpVtysLzO13UOAZEFAb5vpQg3T4O6qvetmSePpXKFx5KPNCHKoGwjtgjfF5DOyn7s1ylQ==",
|
||||||
|
"requires": {
|
||||||
|
"strnum": "^1.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fill-range": {
|
"fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
@@ -1782,6 +1834,11 @@
|
|||||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"sax": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
|
},
|
||||||
"semiver": {
|
"semiver": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
||||||
@@ -1851,6 +1908,11 @@
|
|||||||
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"strnum": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
|
||||||
|
},
|
||||||
"supports-color": {
|
"supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -1877,6 +1939,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/svelte-toasts/-/svelte-toasts-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/svelte-toasts/-/svelte-toasts-1.1.2.tgz",
|
||||||
"integrity": "sha512-m+yL4eEKXyJoyjTYaH1j1GFwF0Pi8YDqnVfwWPDmwi4712iZesv+TNCmToSNlav3R5Vkmc8ZBRkT8DOcu3sywQ=="
|
"integrity": "sha512-m+yL4eEKXyJoyjTYaH1j1GFwF0Pi8YDqnVfwWPDmwi4712iZesv+TNCmToSNlav3R5Vkmc8ZBRkT8DOcu3sywQ=="
|
||||||
},
|
},
|
||||||
|
"svg-parser": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ=="
|
||||||
|
},
|
||||||
"terser": {
|
"terser": {
|
||||||
"version": "5.12.1",
|
"version": "5.12.1",
|
||||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz",
|
||||||
@@ -1920,6 +1987,14 @@
|
|||||||
"integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==",
|
"integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
|
},
|
||||||
|
"xml-js": {
|
||||||
|
"version": "1.6.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||||
|
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||||
|
"requires": {
|
||||||
|
"sax": "^1.2.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"name": "svelte-app",
|
"name": "svelte-app",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"dev": "rollup -c -w",
|
"dev": "rollup -c -w",
|
||||||
@@ -20,7 +21,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
|
"fast-xml-parser": "^4.0.7",
|
||||||
"sirv-cli": "^2.0.0",
|
"sirv-cli": "^2.0.0",
|
||||||
"svelte-toasts": "^1.1.2"
|
"svelte-toasts": "^1.1.2",
|
||||||
|
"svg-parser": "^2.0.4",
|
||||||
|
"xml-js": "^1.6.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
151
src/App.svelte
151
src/App.svelte
@@ -9,7 +9,8 @@
|
|||||||
import file_lib from "./libs/file";
|
import file_lib from "./libs/file";
|
||||||
|
|
||||||
import Modal from "./components/Modal.svelte";
|
import Modal from "./components/Modal.svelte";
|
||||||
import MapApp from './services/map'
|
|
||||||
|
import SvgMapParser from './svgmap/SvgMap.js'
|
||||||
|
|
||||||
import get_bbox from './libs/bbox'
|
import get_bbox from './libs/bbox'
|
||||||
|
|
||||||
@@ -29,21 +30,21 @@
|
|||||||
let WellsRenderer = {
|
let WellsRenderer = {
|
||||||
// [{x,y}]
|
// [{x,y}]
|
||||||
heads(wells, r, style) {
|
heads(wells, r, style) {
|
||||||
return wells.map((w) => SvgNodes.circle(r).set_style(style).move(w.x, w.y));
|
return wells.map((w) => SvgNodes.circle(r).add_style(style).move(w.x, w.y));
|
||||||
},
|
},
|
||||||
|
|
||||||
// [{x,y,name}]
|
// [{x,y,name}]
|
||||||
names(wells, style, shift) {
|
names(wells, style, shift) {
|
||||||
return wells.map((w) =>
|
return wells.map((w) =>
|
||||||
SvgNodes.text(w.name)
|
SvgNodes.text(w.name)
|
||||||
.set_style(style)
|
.add_style(style)
|
||||||
.move(w.x + shift.x, w.y + shift.y)
|
.move(w.x + shift.x, w.y + shift.y)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
// {x,y,ring[1,2,3,4,5]}
|
// {x,y,ring[1,2,3,4,5]}
|
||||||
ring(x, y, r0, r1, a0, a1, style) {
|
ring(x, y, r0, r1, a0, a1, style) {
|
||||||
return SvgNodes.ring_sector(r0, r1, a0, a1).move(x, y).set_style(style);
|
return SvgNodes.ring_sector(r0, r1, a0, a1).move(x, y).add_style(style);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -81,7 +82,9 @@
|
|||||||
// console.log(res.form['some'].value)
|
// console.log(res.form['some'].value)
|
||||||
let file = await file_lib.toBase64(res.form["file"]);
|
let file = await file_lib.toBase64(res.form["file"]);
|
||||||
|
|
||||||
let ans = await axios.post(`${back_url}/import/excel`, { name: "production_injection", file });
|
const name_hash = {'well': 'well_name'}
|
||||||
|
|
||||||
|
let ans = await axios.post(`${back_url}/import/excel`, { name: "production_injection", file, name_hash });
|
||||||
console.log(ans);
|
console.log(ans);
|
||||||
// ui.modal.show(`Hallo ${res.form['some'].value}`, ['ok'])
|
// ui.modal.show(`Hallo ${res.form['some'].value}`, ['ok'])
|
||||||
|
|
||||||
@@ -91,6 +94,114 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function load_back() {
|
||||||
|
const form = `Выберите файл подложки <br>
|
||||||
|
<input type="file" name="file" accept=".svg"/>`; // multiple
|
||||||
|
|
||||||
|
let res = await ui.modal.show(form, ["ok", "cancel"]);
|
||||||
|
if (res.code != 'ok') return;
|
||||||
|
|
||||||
|
// console.log(res);
|
||||||
|
// console.log(res.form['some'].value)
|
||||||
|
let file = await file_lib.read(res.form["file"]);
|
||||||
|
|
||||||
|
let parser = new SvgMapParser()
|
||||||
|
parser.parse(file)
|
||||||
|
|
||||||
|
console.log(parser.get_map_scale())
|
||||||
|
|
||||||
|
|
||||||
|
let layers = parser.get_layers()
|
||||||
|
let options = layers.map(x => `<option value="${x.properties.id}">${x.properties.id}</option>`)
|
||||||
|
let select_layer_form = `Выберите слой с привязкой <select name="layer">${options}</select>`
|
||||||
|
let res2 = await ui.modal.show(select_layer_form, ["ok", "cancel"]);
|
||||||
|
if (res2.code != 'ok') return;
|
||||||
|
|
||||||
|
// console.log(res2)
|
||||||
|
|
||||||
|
let layer2 = layers.filter(x => x.properties.id == res2.form['layer'].value)[0]
|
||||||
|
console.log('layer2', layer2)
|
||||||
|
|
||||||
|
let anchor = parser.extract_anchor(layer2)
|
||||||
|
console.log('anchor', anchor)
|
||||||
|
|
||||||
|
|
||||||
|
const query = `SELECT well, whx, why FROM wells WHERE well='${anchor.w1.name}' OR well='${anchor.w2.name}'`;
|
||||||
|
let wells = await axios.post(`${back_url}/proxy/sqlite`, { query }).then((x) => x.data.data);
|
||||||
|
|
||||||
|
let ww1 = wells.filter(x => x.well == anchor.w1.name)[0]
|
||||||
|
let ww2 = wells.filter(x => x.well == anchor.w2.name)[0]
|
||||||
|
|
||||||
|
console.log(ww1, ww2)
|
||||||
|
|
||||||
|
if (!ww1) return ui.modal.show(`Скважины ${anchor.w1.name} не найдено в базе.`, ["ok"]);
|
||||||
|
if (!ww2) return ui.modal.show(`Скважины ${anchor.w2.name} не найдено в базе.`, ["ok"]);
|
||||||
|
|
||||||
|
anchor.w1.whx = ww1.whx
|
||||||
|
anchor.w1.why = ww1.why
|
||||||
|
anchor.w2.whx = ww2.whx
|
||||||
|
anchor.w2.why = ww2.why
|
||||||
|
|
||||||
|
|
||||||
|
let shift_args = {dx: 0, dy: 0, scale: 1}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(anchor)
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
var oParser = new DOMParser();
|
||||||
|
var oDOM = oParser.parseFromString(file, "application/xml");
|
||||||
|
// temp0.childNodes[2].viewBox.baseVal // rect {x,y,width,height}
|
||||||
|
// temp0.childNodes[2].width.baseVal.value
|
||||||
|
// temp0.childNodes[2].height.baseVal.value
|
||||||
|
|
||||||
|
// Find pivots
|
||||||
|
let svg = oDOM.getElementsByTagName('svg')[0]
|
||||||
|
let layer = svg.children[svg.children.length - 1]
|
||||||
|
|
||||||
|
function extract_well(pivot_group){
|
||||||
|
let ellipse = pivot_group.getElementsByTagName('ellipse')[0]
|
||||||
|
let x = ellipse.cx.baseVal.value
|
||||||
|
let y = ellipse.cy.baseVal.value
|
||||||
|
|
||||||
|
let text = pivot_group.getElementsByTagName('text')[0]
|
||||||
|
let name = text.childNodes[0].nodeValue
|
||||||
|
return {x, y, name}
|
||||||
|
}
|
||||||
|
|
||||||
|
// let w1 = extract_well(layer.children[layer.children.length - 1])
|
||||||
|
// let w2 = extract_well(layer.children[layer.children.length - 2])
|
||||||
|
// console.log(w1, w2)
|
||||||
|
|
||||||
|
// // Map dist
|
||||||
|
// let map_dx = w2.x - w1.x
|
||||||
|
// let map_dy = w2.x - w1.x
|
||||||
|
// let map_d = Math.sqrt(map_dx * map_dx + map_dy * map_dy)
|
||||||
|
// console.log('map_d', map_d)
|
||||||
|
|
||||||
|
// Определим масштаб карты
|
||||||
|
|
||||||
|
// temp0.viewBox.baseVal.x
|
||||||
|
|
||||||
|
|
||||||
|
// console.log(oDOM)
|
||||||
|
|
||||||
|
// console.log(file);
|
||||||
|
|
||||||
|
// let ans = await axios.post(`${back_url}/import/excel`, { name: "wells", file });
|
||||||
|
// console.log(ans);
|
||||||
|
|
||||||
|
// toasts.add({
|
||||||
|
// description: "File loaded",
|
||||||
|
// type: 'success',
|
||||||
|
// });
|
||||||
|
|
||||||
|
// ui.modal.show(`Hallo ${res.form['some'].value}`, ['ok'])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let ui = {
|
let ui = {
|
||||||
modal: {},
|
modal: {},
|
||||||
};
|
};
|
||||||
@@ -100,21 +211,6 @@
|
|||||||
|
|
||||||
// file_lib.download()
|
// file_lib.download()
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param r0
|
|
||||||
* @param r1
|
|
||||||
* @param a0
|
|
||||||
* @param a1
|
|
||||||
* @param { [{v, style}] } rings
|
|
||||||
*/
|
|
||||||
function sectored_ring(r0, r1, rings){
|
|
||||||
let sum = rings.reduce((s,c) => s + c.v, 0)
|
|
||||||
let angs = rings.reduce((s, c, i) => [...s, {...c, a0: i && s[i - 1].a1, a1: c.v + (i && s[i - 1].a1)}], [])
|
|
||||||
let items = angs.map(x => SvgNodes.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).set_style(x.style))
|
|
||||||
|
|
||||||
return SvgNodes.group(items)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -142,17 +238,17 @@
|
|||||||
let a0 = 0;
|
let a0 = 0;
|
||||||
let a1 = 130;
|
let a1 = 130;
|
||||||
let layer_gpt = scaled_wells.map((w) =>
|
let layer_gpt = scaled_wells.map((w) =>
|
||||||
SvgNodes.ring_sector(r0, r1, a0, a1).move(w.whx, w.why).set_style(styles.gpt)
|
SvgNodes.ring_sector(r0, r1, a0, a1).move(w.whx, w.why).add_style(styles.gpt)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let layer_wells = scaled_wells.map((w) =>
|
let layer_wells = scaled_wells.map((w) =>
|
||||||
SvgNodes.circle(whr).set_attrs({ cx: w.whx, cy: w.why }).set_style(styles.wellhead)
|
SvgNodes.circle(whr).set_attrs({ cx: w.whx, cy: w.why }).add_style(styles.wellhead)
|
||||||
);
|
);
|
||||||
let layer_wellnames = scaled_wells.map((w) =>
|
let layer_wellnames = scaled_wells.map((w) =>
|
||||||
SvgNodes.text(w.well)
|
SvgNodes.text(w.well)
|
||||||
.set_style(styles.style_wellhead)
|
.add_style(styles.style_wellhead)
|
||||||
.move(w.whx + shift.x, w.why + shift.y)
|
.move(w.whx + shift.x, w.why + shift.y)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -160,18 +256,18 @@
|
|||||||
sectored_ring(0, 50, [{v: 10, style: styles.gpt}, {v: 20, style: styles.opt}, {v: 30, style: styles.wopt}]).move(w.whx, w.why)
|
sectored_ring(0, 50, [{v: 10, style: styles.gpt}, {v: 20, style: styles.opt}, {v: 30, style: styles.wopt}]).move(w.whx, w.why)
|
||||||
);
|
);
|
||||||
|
|
||||||
// let layer_wells_wpr = wells.map((w) => svg_sector(70, 0, 70).set_style(style_wir).move(w.whx, w.why).render());
|
// let layer_wells_wpr = wells.map((w) => svg_sector(70, 0, 70).add_style(style_wir).move(w.whx, w.why).render());
|
||||||
|
|
||||||
// let layer_wells_gpr = wells.map((w) =>
|
// let layer_wells_gpr = wells.map((w) =>
|
||||||
// svg_sector(70, 70, 130).set_style(style_gpr).move(w.whx, w.why).render()
|
// svg_sector(70, 70, 130).add_style(style_gpr).move(w.whx, w.why).render()
|
||||||
// );
|
// );
|
||||||
// let layer_wells_opr = wells.map((w) =>
|
// let layer_wells_opr = wells.map((w) =>
|
||||||
// svg_sector(70, 130, 360).set_style(style_opr).move(w.whx, w.why).render()
|
// svg_sector(70, 130, 360).add_style(style_opr).move(w.whx, w.why).render()
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// let layer_well_names = wells.map((w) =>
|
// let layer_well_names = wells.map((w) =>
|
||||||
// svg_text(w.well)
|
// svg_text(w.well)
|
||||||
// .set_style(style_wellhead_text)
|
// .add_style(style_wellhead_text)
|
||||||
// .move(w.whx + 10, w.why - 10)
|
// .move(w.whx + 10, w.why - 10)
|
||||||
// .render()
|
// .render()
|
||||||
// );
|
// );
|
||||||
@@ -210,6 +306,7 @@
|
|||||||
<button on:click={() => build_map()}>Build map</button>
|
<button on:click={() => build_map()}>Build map</button>
|
||||||
<button on:click={() => save()}>Download</button>
|
<button on:click={() => save()}>Download</button>
|
||||||
<button on:click={() => func()}>Func</button>
|
<button on:click={() => func()}>Func</button>
|
||||||
|
<button on:click={() => load_back()}>Load_back</button>
|
||||||
|
|
||||||
<div bind:this={map_host} style="border: 1px solid #f00;" />
|
<div bind:this={map_host} style="border: 1px solid #f00;" />
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
366
src/back_.js
Normal file
366
src/back_.js
Normal file
@@ -0,0 +1,366 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
import SvgMap from "./svgmap/SvgMap.js";
|
||||||
|
import SvgMapBuilder from "./svgmap/SvgMapBuilder.js";
|
||||||
|
import CoordSystem from "./libs/CoordSystem.js";
|
||||||
|
import SvgNode from "./svgmap/SvgNode.js";
|
||||||
|
import SvgNodes from "./svgmap/SvgNodes.js";
|
||||||
|
import Transfrom from "./libs/Transform.js";
|
||||||
|
import BBox from "./libs/bbox.js";
|
||||||
|
|
||||||
|
import sql_pi from "./services/sql/prod_inj.js";
|
||||||
|
|
||||||
|
// import SvgNodes from "./svgmap/SvgNodes.js";
|
||||||
|
|
||||||
|
// import math_lib from './libs/math.js'
|
||||||
|
|
||||||
|
const back_url = "http://localhost:4000";
|
||||||
|
|
||||||
|
const path = "../../data/prodmaps";
|
||||||
|
|
||||||
|
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост.svg')
|
||||||
|
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-sm.svg')
|
||||||
|
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-inch.svg')
|
||||||
|
// let file = fs.readFileSync(`${path}/49_Кар тек и сум отб 7 об_вост-mm.svg`)
|
||||||
|
// let file = fs.readFileSync(`${path}/49_Кар тек и сум отб 7 об_вост.svg`);
|
||||||
|
|
||||||
|
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-px.svg')
|
||||||
|
|
||||||
|
const query = (sql) => axios.post(`${back_url}/proxy/sqlite`, { query: sql }).then((x) => x.data.data);
|
||||||
|
|
||||||
|
let styles = JSON.parse(fs.readFileSync("./moc/styles.json").toString());
|
||||||
|
|
||||||
|
const all_settings = {
|
||||||
|
pt: {
|
||||||
|
tons_in_cm2: 20000,
|
||||||
|
ppu: 100, // 100
|
||||||
|
styles,
|
||||||
|
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||||
|
map_scale: (1 / 10000) * 1000,
|
||||||
|
},
|
||||||
|
|
||||||
|
it: {
|
||||||
|
tons_in_cm2: 100000,
|
||||||
|
ppu: 100, // 100
|
||||||
|
styles,
|
||||||
|
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||||
|
map_scale: (1 / 10000) * 1000,
|
||||||
|
},
|
||||||
|
|
||||||
|
pr: {
|
||||||
|
tons_in_cm2: 50,
|
||||||
|
ppu: 100,
|
||||||
|
styles,
|
||||||
|
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||||
|
map_scale: (1 / 10000) * 1000,
|
||||||
|
},
|
||||||
|
|
||||||
|
ir: {
|
||||||
|
tons_in_cm2: 50,
|
||||||
|
ppu: 100,
|
||||||
|
styles,
|
||||||
|
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||||
|
map_scale: (1 / 10000) * 1000,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// all_settings.styles = SvgMapBuilder.update_styles(all_settings.styles, all_settings.ppu)
|
||||||
|
|
||||||
|
let parser = new SvgMap();
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
await parser.parse(file.toString());
|
||||||
|
|
||||||
|
let sc = parser.get_map_scale();
|
||||||
|
console.log("scale is", sc);
|
||||||
|
|
||||||
|
let layers = parser.get_layers();
|
||||||
|
console.log(layers.map((x) => x.properties.id));
|
||||||
|
|
||||||
|
let name = "скв";
|
||||||
|
let layer = layers.filter((x) => x.properties.id == name)[0];
|
||||||
|
// console.log(layer)
|
||||||
|
|
||||||
|
// Получить координаты якоря
|
||||||
|
let anchor = parser.extract_anchor(layer);
|
||||||
|
console.log("anchor", anchor);
|
||||||
|
|
||||||
|
const query = `SELECT well, whx, why FROM wells WHERE well='${anchor.w1.name}' OR well='${anchor.w2.name}'`;
|
||||||
|
let wells = await axios.post(`${back_url}/proxy/sqlite`, { query }).then((x) => x.data.data);
|
||||||
|
console.log(wells);
|
||||||
|
|
||||||
|
let ww1 = wells.filter((x) => x.well == anchor.w1.name)[0];
|
||||||
|
let ww2 = wells.filter((x) => x.well == anchor.w2.name)[0];
|
||||||
|
|
||||||
|
if (!ww1) return ui.modal.show(`Скважины ${anchor.w1.name} не найдено в базе.`, ["ok"]);
|
||||||
|
if (!ww2) return ui.modal.show(`Скважины ${anchor.w2.name} не найдено в базе.`, ["ok"]);
|
||||||
|
|
||||||
|
// function cs(x0, y0, x1, y1) {
|
||||||
|
// return { x0, y0, x1, y1 };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// function build_tr(cs1, cs2) {
|
||||||
|
// let dx1 = cs1.x1 - cs1.x0
|
||||||
|
// let dy1 = cs1.y1 - cs1.y0
|
||||||
|
// let dx2 = cs2.x1 - cs2.x0
|
||||||
|
// let dy2 = cs2.y1 - cs2.y0
|
||||||
|
|
||||||
|
// const kx12 = dx2 / dx1
|
||||||
|
// const ky12 = dy2 / dy1;
|
||||||
|
// const kx21 = dx1 / dx2
|
||||||
|
// const ky21 = dy1 / dy2;
|
||||||
|
|
||||||
|
// let tr = {
|
||||||
|
// tr12: {
|
||||||
|
// trx(x) {
|
||||||
|
// return (x - cs1.x0) * kx12 + cs2.x0;
|
||||||
|
// },
|
||||||
|
// try(y) {
|
||||||
|
// return (y - cs1.y0) * ky12 + cs2.y0;
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// tr21: {
|
||||||
|
// trx(x) {
|
||||||
|
// return (x - cs2.x0) * kx21 + cs1.x0;
|
||||||
|
// },
|
||||||
|
// try(y) {
|
||||||
|
// return (y - cs2.y0) * ky21 + cs1.y0;
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
|
||||||
|
// return tr;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Функция перевода координат из глобальных в локальные.
|
||||||
|
const cs1 = new CoordSystem(anchor.w1.x, anchor.w1.y, anchor.w2.x, anchor.w2.y);
|
||||||
|
const cs2 = new CoordSystem(ww1.whx, ww1.why, ww2.whx, ww2.why);
|
||||||
|
// let tr = Transfrom.fromCoordSyses(cs2, cs1);
|
||||||
|
|
||||||
|
// let tr = Transfrom.fromCoordSyses(cs2, cs1);
|
||||||
|
|
||||||
|
// console.log('tr is:', tr);
|
||||||
|
|
||||||
|
// console.log(wells)
|
||||||
|
|
||||||
|
const DATE = "2023-01-01";
|
||||||
|
|
||||||
|
const query_all = `SELECT
|
||||||
|
wells.well, wells.whx, wells.why,
|
||||||
|
MAX(production_injections.date) as date
|
||||||
|
,SUM(production_injections.woptm) as wopt
|
||||||
|
,SUM(production_injections.wwptm) as wwpt
|
||||||
|
,SUM(production_injections.wsgptv) as wgpt
|
||||||
|
,SUM(production_injections.wwitv) as wwit
|
||||||
|
,SUM(production_injections.wwptm)+SUM(production_injections.woptm) as wlpt
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
wells.well=production_injections.well
|
||||||
|
AND production_injections.date<='${DATE}'
|
||||||
|
GROUP BY
|
||||||
|
wells.well
|
||||||
|
|
||||||
|
`; // WHERE well='${anchor.w1.name}'`;
|
||||||
|
|
||||||
|
// Получим максимально удаленные скважины не лежащие вдоль оси.
|
||||||
|
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||||
|
|
||||||
|
let bbox = BBox.from_array(all_wells.map((w) => ({ x: w.whx, y: w.why })));
|
||||||
|
console.log("BBOX", bbox);
|
||||||
|
console.log("BBOX", bbox.toLTWH());
|
||||||
|
console.log("BBOX", bbox.toLTRB());
|
||||||
|
|
||||||
|
tr = Transfrom.fromCoordSyses();
|
||||||
|
|
||||||
|
let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.trx(x.whx), ly: tr.try(x.why) }));
|
||||||
|
|
||||||
|
// const tons_in_cm2 = 10000
|
||||||
|
|
||||||
|
// function t2r(tons){
|
||||||
|
// // tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
|
// return Math.sqrt(tons / tons_in_cm2 * 100 / Math.PI)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// console.log(mapped_wells.filter(x => x.well == '213').map(x => ({...x, ttt: t2r(x.wlpt)})))
|
||||||
|
|
||||||
|
// console.log(math_lib.make_ranges(vals))
|
||||||
|
|
||||||
|
// svg.append(mapped_wells.map((x) => SvgNodes.ring_sector(1.5 * sc.k, 6 * sc.k, 0, 120).move(x.lx, x.ly).add_style(styles.gpt)));
|
||||||
|
|
||||||
|
const settings = {
|
||||||
|
tons_in_cm2: 10000,
|
||||||
|
styles,
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
let ti_layer = parser.build_tp_layer(mapped_wells, settings);
|
||||||
|
let svg = SvgNodes.svg()
|
||||||
|
.set_attr("width", "1000px")
|
||||||
|
.set_attr("height", "1000px")
|
||||||
|
.set_attr("viewBox", "0 0 1000 1000");
|
||||||
|
// let defs = new SvgNode('defs')
|
||||||
|
// defs.append(ti_layer.defs)
|
||||||
|
// console.log(ti_layer.defs.tag)
|
||||||
|
svg.append(ti_layer.defs);
|
||||||
|
svg.append(ti_layer.svg);
|
||||||
|
fs.writeFileSync(`${path}/out.svg`, svg.render());
|
||||||
|
}
|
||||||
|
|
||||||
|
// let ti_layer = parser.build_tp_layer(mapped_wells, settings)
|
||||||
|
// let data = file.toString()
|
||||||
|
// .replace('</defs>', ti_layer.defs.render() + '</defs>')
|
||||||
|
// .replace('</svg>', ti_layer.svg.render() + '</svg>')
|
||||||
|
// fs.writeFileSync("../tmp/out_prod.svg", data) //svg.render());
|
||||||
|
|
||||||
|
// let ti_layer_inj = parser.build_ti_layer(mapped_wells, settings)
|
||||||
|
// let data2 = file.toString()
|
||||||
|
// .replace('</defs>', ti_layer_inj.defs.render() + '</defs>')
|
||||||
|
// .replace('</svg>', ti_layer_inj.svg.render() + '</svg>')
|
||||||
|
// fs.writeFileSync("../tmp/out_inj.svg", data2) //svg.render());
|
||||||
|
}
|
||||||
|
|
||||||
|
class SvgSaver {
|
||||||
|
constructor(settings, bbox) {
|
||||||
|
// Функция перевода координат из глобальных в локальные.
|
||||||
|
const cs1 = new CoordSystem(bbox.l, bbox.t, bbox.r, bbox.b);
|
||||||
|
const cs_mm = cs1.clone().flipy().moveto(0, 0).scale(settings.map_scale);
|
||||||
|
const cs_ppu = cs_mm.clone().scale(settings.ppu);
|
||||||
|
const csw = Math.abs(cs_mm.x1 - cs_mm.x0);
|
||||||
|
const csh = Math.abs(cs_mm.y1 - cs_mm.y0);
|
||||||
|
const bbox_ppu = BBox.fromLTRB(cs_ppu.x0, cs_ppu.y0, cs_ppu.x1, cs_ppu.y1);
|
||||||
|
|
||||||
|
this.svg = SvgNodes.svg()
|
||||||
|
.set_attr("width", csw + "mm")
|
||||||
|
.set_attr("height", csh + "mm")
|
||||||
|
.set_attr("viewBox", `${bbox_ppu.l} ${bbox_ppu.t} ${bbox_ppu.w()} ${bbox_ppu.h()}`);
|
||||||
|
|
||||||
|
this.tr = Transfrom.fromCoordSyses(cs1, cs_ppu);
|
||||||
|
|
||||||
|
settings.styles = SvgMapBuilder.update_styles(settings.styles, settings.ppu);
|
||||||
|
}
|
||||||
|
|
||||||
|
append_defs(defs) {
|
||||||
|
this.svg.append(defs);
|
||||||
|
}
|
||||||
|
|
||||||
|
append_svg(svg) {
|
||||||
|
this.svg.append(svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
append_layer(layer) {
|
||||||
|
this.append_defs(layer.defs);
|
||||||
|
this.append_svg(layer.svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
save(filename) {
|
||||||
|
fs.writeFileSync(filename, this.svg.render());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_bbox(data){
|
||||||
|
let bbox = BBox.from_array(data);
|
||||||
|
if (bbox.w() == 0 || bbox.h() == 0) {
|
||||||
|
bbox.r += 1000;
|
||||||
|
bbox.b += 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bbox
|
||||||
|
}
|
||||||
|
|
||||||
|
async function build_map_pt(devobj) {
|
||||||
|
let wells = await query(sql_pi.totals(devobj));
|
||||||
|
wells = wells.filter((x) => x.wopt > 0);
|
||||||
|
if (!wells.length) return
|
||||||
|
|
||||||
|
let bbox = build_bbox(wells.map(w => ({ x: w.whx, y: w.why })));
|
||||||
|
const saver = new SvgSaver(all_settings.pt, bbox);
|
||||||
|
|
||||||
|
let mapped_wells = wells.map((x) => ({ ...x, lx: saver.tr.trx(x.whx), ly: saver.tr.try(x.why) }));
|
||||||
|
let tp_layer = SvgMapBuilder.build_tp_layer(mapped_wells, all_settings.pt);
|
||||||
|
|
||||||
|
saver.append_layer(tp_layer);
|
||||||
|
saver.save(`${path}/out_devobj-${devobj}-PT.svg`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function build_map_it(devobj) {
|
||||||
|
let wells = await query(sql_pi.totals(devobj));
|
||||||
|
wells = wells.filter((x) => x.wwit > 0);
|
||||||
|
if (!wells.length) return
|
||||||
|
|
||||||
|
let bbox = build_bbox(wells.map(w => ({ x: w.whx, y: w.why })));
|
||||||
|
const saver = new SvgSaver(all_settings.it, bbox);
|
||||||
|
|
||||||
|
let mapped_wells = wells.map((x) => ({ ...x, lx: saver.tr.trx(x.whx), ly: saver.tr.try(x.why) }));
|
||||||
|
let tp_layer = SvgMapBuilder.build_ti_layer(mapped_wells, all_settings.it);
|
||||||
|
|
||||||
|
saver.append_layer(tp_layer);
|
||||||
|
saver.save(`${path}/out_devobj-${devobj}-IT.svg`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function build_map_pr(devobj) {
|
||||||
|
console.log("build_map_pr", devobj);
|
||||||
|
|
||||||
|
const md = await query(sql_pi.max_date(devobj)).then((x) => x[0].date);
|
||||||
|
let wells = await query(sql_pi.rates(devobj, md))
|
||||||
|
wells = wells.filter((x) => x.wopr > 0);
|
||||||
|
if (!wells.length) return
|
||||||
|
|
||||||
|
let bbox = build_bbox(wells.map(w => ({ x: w.whx, y: w.why })));
|
||||||
|
const saver = new SvgSaver(all_settings.pr, bbox);
|
||||||
|
|
||||||
|
let mapped_wells = wells.map((x) => ({
|
||||||
|
...x,
|
||||||
|
wopt: x.wopr, //x.wopt / x.days,
|
||||||
|
wwpt: x.wwpr, // x.wwpt / x.days,
|
||||||
|
wlpt: x.wopr+x.wwpr, // (x.wopt + x.wwpt) / x.days,
|
||||||
|
// wlf: x.wwpt / (x.wopt + x.wwpt),
|
||||||
|
lx: saver.tr.trx(x.whx),
|
||||||
|
ly: saver.tr.try(x.why),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// let mapped_wells = wells.map((x) => ({ ...x, lx: saver.tr.trx(x.whx), ly: saver.tr.try(x.why) }));
|
||||||
|
let tp_layer = SvgMapBuilder.build_tp_layer(mapped_wells, all_settings.pr);
|
||||||
|
|
||||||
|
saver.append_layer(tp_layer);
|
||||||
|
saver.save(`${path}/out_devobj-${devobj}-PR.svg`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function build_map_ir(devobj) {
|
||||||
|
// const DATE = '2023-01-01'
|
||||||
|
|
||||||
|
const md = await query(sql_pi.max_date(devobj)).then((x) => x[0].date);
|
||||||
|
let wells = await query(sql_pi.rates(devobj, md))
|
||||||
|
wells = wells.filter((x) => x.wwir > 0);
|
||||||
|
if (!wells.length) return
|
||||||
|
|
||||||
|
let bbox = build_bbox(wells.map(w => ({ x: w.whx, y: w.why })));
|
||||||
|
const saver = new SvgSaver(all_settings.ir, bbox);
|
||||||
|
|
||||||
|
let mapped_wells = wells.map((x) => ({
|
||||||
|
...x,
|
||||||
|
wwit: x.wwir, //x.wwit / x.days,
|
||||||
|
lx: saver.tr.trx(x.whx),
|
||||||
|
ly: saver.tr.try(x.why),
|
||||||
|
}));
|
||||||
|
|
||||||
|
let tp_layer = SvgMapBuilder.build_ti_layer(mapped_wells, all_settings.ir);
|
||||||
|
|
||||||
|
saver.append_layer(tp_layer);
|
||||||
|
saver.save(`${path}/out_devobj-${devobj}-IR.svg`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function start2() {
|
||||||
|
const objects = await query(sql_pi.devobjs()).then((r) => r.map((x) => x.devobj));
|
||||||
|
|
||||||
|
objects.map(build_map_pt);
|
||||||
|
objects.map(build_map_it)
|
||||||
|
objects.map(build_map_pr)
|
||||||
|
objects.map(build_map_ir)
|
||||||
|
}
|
||||||
|
|
||||||
|
start2();
|
||||||
54
src/libs/CoordSystem.js
Normal file
54
src/libs/CoordSystem.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
export default class CoordSystem{
|
||||||
|
/**
|
||||||
|
* Создает ненормированную систему координат с началом в x0,y0 и направлением x1,y1
|
||||||
|
* @param {*} x0
|
||||||
|
* @param {*} y0
|
||||||
|
* @param {*} x1
|
||||||
|
* @param {*} y1
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
constructor(x0, y0, x1, y1) {
|
||||||
|
this.x0 = x0
|
||||||
|
this.y0 = y0
|
||||||
|
this.x1 = x1
|
||||||
|
this.y1 = y1
|
||||||
|
}
|
||||||
|
|
||||||
|
scale(k){
|
||||||
|
this.x1 *= k
|
||||||
|
this.y1 *= k
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
move(dx, dy){
|
||||||
|
this.x0 += dx
|
||||||
|
this.y0 += dy
|
||||||
|
this.x1 += dx
|
||||||
|
this.y1 += dy
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
moveto(x, y){
|
||||||
|
let dx = x - this.x0
|
||||||
|
let dy = y - this.y0
|
||||||
|
return this.move(dx, dy)
|
||||||
|
}
|
||||||
|
|
||||||
|
flipx(){
|
||||||
|
let x = this.x0
|
||||||
|
this.x0 = this.x1
|
||||||
|
this.x1 = x
|
||||||
|
// this.x0 += 500
|
||||||
|
// this.x1 = 2 * this.x0 - this.x1 + 500
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
flipy(){
|
||||||
|
this.y1 = 2 * this.y0 - this.y1
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
clone(){
|
||||||
|
return new CoordSystem(this.x0, this.y0, this.x1, this.y1)
|
||||||
|
}
|
||||||
|
};
|
||||||
30
src/libs/Transform.js
Normal file
30
src/libs/Transform.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export default class Transfrom {
|
||||||
|
static fromCoordSyses(cs1, cs2){
|
||||||
|
let tr = new Transfrom()
|
||||||
|
|
||||||
|
tr.cs1 = cs1
|
||||||
|
tr.cs2 = cs2
|
||||||
|
|
||||||
|
let dx1 = cs1.x1 - cs1.x0;
|
||||||
|
let dy1 = cs1.y1 - cs1.y0;
|
||||||
|
let dx2 = cs2.x1 - cs2.x0;
|
||||||
|
let dy2 = cs2.y1 - cs2.y0;
|
||||||
|
|
||||||
|
tr.kx12 = dx1 ? dx2 / dx1 : 1;
|
||||||
|
tr.ky12 = dy1 ? dy2 / dy1 : 1;
|
||||||
|
|
||||||
|
return tr
|
||||||
|
}
|
||||||
|
|
||||||
|
trx(x){
|
||||||
|
return (x - this.cs1.x0) * this.kx12 + this.cs2.x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try(y){
|
||||||
|
return (y - this.cs1.y0) * this.ky12 + this.cs2.y0;
|
||||||
|
}
|
||||||
|
|
||||||
|
trp(p){
|
||||||
|
return {x: this.trx(p.x), y: this.trx(p.y)}
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/libs/bbox.js
106
src/libs/bbox.js
@@ -1,11 +1,95 @@
|
|||||||
module.exports = function (data) {
|
export default class BBox {
|
||||||
return data.reduce(
|
static fromLTWH(l, t, w, h){
|
||||||
(s, c) => ({
|
return BBox.fromLTRB(l, t, l + w, t + h)
|
||||||
l: Math.min(s.l, c.x),
|
}
|
||||||
t: Math.min(s.t, c.y),
|
|
||||||
r: Math.max(s.r, c.x),
|
static fromLTRB(l, t, r, b){
|
||||||
b: Math.max(s.b, c.y),
|
return Object.assign(new BBox(), {l: Math.min(l, r), t: Math.min(t, b), r: Math.max(l, r), b: Math.max(t, b)})
|
||||||
}),
|
}
|
||||||
{ l: data[0].x, t: data[0].y, r: data[0].x, b: data[0].y }
|
|
||||||
);
|
static from_array(arr_xy){
|
||||||
};
|
const bbox = BBox.fromLTWH(arr_xy[0].x, arr_xy[0].y, 0, 0)
|
||||||
|
return bbox.append_many(arr_xy)
|
||||||
|
}
|
||||||
|
|
||||||
|
w(){
|
||||||
|
return this.r - this.l
|
||||||
|
}
|
||||||
|
|
||||||
|
h(){
|
||||||
|
return this.b - this.t
|
||||||
|
}
|
||||||
|
|
||||||
|
toLTWH(){
|
||||||
|
const {l, t, r, b} = this
|
||||||
|
return {l, t, w: r - l, h: b - t }
|
||||||
|
}
|
||||||
|
|
||||||
|
toLTRB(){
|
||||||
|
const {l, t, r, b} = this
|
||||||
|
return {l, t, r, b}
|
||||||
|
}
|
||||||
|
|
||||||
|
toLTRBarr(){
|
||||||
|
const {l, t, r, b} = this
|
||||||
|
return [l, t, r, b]
|
||||||
|
}
|
||||||
|
|
||||||
|
append(x, y){
|
||||||
|
this.l = Math.min(this.l, x)
|
||||||
|
this.t = Math.min(this.t, y)
|
||||||
|
this.r = Math.max(this.r, x)
|
||||||
|
this.b = Math.max(this.b, y)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
append_many(arr_xy){
|
||||||
|
arr_xy.forEach(e => this.append(e.x, e.y))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
scale(k){
|
||||||
|
this.r = this.l + (this.r - this.l) * k
|
||||||
|
this.b = this.t + (this.b - this.t) * k
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
move(dx, dy){
|
||||||
|
this.l += dx
|
||||||
|
this.t += dy
|
||||||
|
this.r += dx
|
||||||
|
this.b += dy
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
moveto(x, y){
|
||||||
|
let dx = x - this.l
|
||||||
|
let dy = y - this.t
|
||||||
|
return this.move(dx, dy)
|
||||||
|
}
|
||||||
|
|
||||||
|
clone(){
|
||||||
|
return BBox.fromLTRB(this.l, this.t, this.r, this.b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// static from_data(data){
|
||||||
|
// return data.reduce(
|
||||||
|
// (s, c) => ({
|
||||||
|
// l: Math.min(s.l, c.x),
|
||||||
|
// t: Math.min(s.t, c.y),
|
||||||
|
// r: Math.max(s.r, c.x),
|
||||||
|
// b: Math.max(s.b, c.y),
|
||||||
|
// }),
|
||||||
|
// { l: data[0].x, t: data[0].y, r: data[0].x, b: data[0].y }
|
||||||
|
// );
|
||||||
|
// // return data.reduce(
|
||||||
|
// // (s, c) => ({
|
||||||
|
// // l: Math.min(s.l, c.x),
|
||||||
|
// // t: Math.min(s.t, c.y),
|
||||||
|
// // r: Math.max(s.r, c.x),
|
||||||
|
// // b: Math.max(s.b, c.y),
|
||||||
|
// // }),
|
||||||
|
// // { l: data[0].x, t: data[0].y, r: data[0].x, b: data[0].y }
|
||||||
|
// // );
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -22,7 +22,6 @@ export default {
|
|||||||
* @param {*} input
|
* @param {*} input
|
||||||
*/
|
*/
|
||||||
async toBase64(input) {
|
async toBase64(input) {
|
||||||
console.log(input)
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (input.files.length == 0){
|
if (input.files.length == 0){
|
||||||
resolve(null)
|
resolve(null)
|
||||||
@@ -52,5 +51,41 @@ export default {
|
|||||||
reject(error)
|
reject(error)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read data of file/files selected in input as string
|
||||||
|
* @param {*} input
|
||||||
|
*/
|
||||||
|
async read(input) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (input.files.length == 0){
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
else if (input.files.length == 1){
|
||||||
|
this.readFile(input.files[0]).then(resolve)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Promise.all(Array(...input.files).map(this.readFile)).then(resolve)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read data of file/files selected in input as string
|
||||||
|
* @param {*} input
|
||||||
|
*/
|
||||||
|
async readFile(file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.readAsText(file);
|
||||||
|
|
||||||
|
reader.onload = function () {
|
||||||
|
resolve(reader.result)
|
||||||
|
};
|
||||||
|
reader.onerror = function (error) {
|
||||||
|
reject(error)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
13
src/libs/math.js
Normal file
13
src/libs/math.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* Создает данные дл круговой диаграммы из набора значений v0,v1,v2,v3 -> [{a0: 0, a1: v0}, {a0: v0, a1: v0+v1}, {a0: v0+v1, a1: v0+v1+v2},]
|
||||||
|
* @param { [Number] } values Значения долей
|
||||||
|
* @param { boolean } norm Нормировать ли значения диапазонов в отрезок 0-1
|
||||||
|
* @returns Массив с диапазонами долей 1,2,3,4 -> [{0,0.1},{0.1,0.3},{0.3,0.6},{0.6,1}]
|
||||||
|
*/
|
||||||
|
make_ranges(values, norm = true) {
|
||||||
|
let ranges = values.reduce((s, c, i) => [...s, {...c, a0: i && s[i - 1].a1, a1: c + (i && s[i - 1].a1)}], [])
|
||||||
|
let max = ranges[ranges.length - 1].a1
|
||||||
|
return norm ? ranges.map(x => ({a0: x.a0 / max, a1: x.a1 / max})) : ranges
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,22 +1,76 @@
|
|||||||
{
|
{
|
||||||
"wellhead": {
|
"_units": {
|
||||||
"stroke-width": 1,
|
"1pt":"1pt",
|
||||||
|
"1mm":"1mm"
|
||||||
|
},
|
||||||
|
|
||||||
|
"black-line": {
|
||||||
|
"stroke-width": "1pt",
|
||||||
"stroke": "#000",
|
"stroke": "#000",
|
||||||
|
"fill": "none"
|
||||||
|
},
|
||||||
|
|
||||||
|
"white-body": {
|
||||||
"fill": "#fff"
|
"fill": "#fff"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"wellhead-name": {
|
||||||
|
"font-family": "Times New Roman",
|
||||||
|
"font-weight": "bold",
|
||||||
|
"font-size": "12pt",
|
||||||
|
"fill": "#000",
|
||||||
|
"dx":1.7,
|
||||||
|
"dy":"-1"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wellhead-black": {
|
||||||
|
"stroke-width": "0.1mm",
|
||||||
|
"stroke": "#fff",
|
||||||
|
"fill": "#000"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wellhead-gray": {
|
||||||
|
"stroke-width": "0.1mm",
|
||||||
|
"stroke": "#000",
|
||||||
|
"fill": "#ddd"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wellhead-tri": {
|
||||||
|
"stroke-width": "0.1pt",
|
||||||
|
"stroke": "#fff",
|
||||||
|
"fill": "#000"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wlf": {
|
||||||
|
"font-family": "Times New Roman",
|
||||||
|
"font-weight": "bold",
|
||||||
|
"stroke-width": "0",
|
||||||
|
"font-size": "8pt",
|
||||||
|
"font-style": "italic",
|
||||||
|
"stroke": "#fff",
|
||||||
|
"fill": "#00f",
|
||||||
|
"dx": 1.7,
|
||||||
|
"dy": 3
|
||||||
|
},
|
||||||
|
|
||||||
"gpt": {
|
"gpt": {
|
||||||
"stroke-width": 0,
|
"stroke-width": 20,
|
||||||
"stroke": "#ff0",
|
"stroke": "#000",
|
||||||
"fill": "#ff0"
|
"fill": "#ff0"
|
||||||
},
|
},
|
||||||
"opt": {
|
"opt": {
|
||||||
"stroke-width": 1,
|
"stroke-width": 10,
|
||||||
"stroke": "#f00",
|
"stroke": "#000",
|
||||||
"fill": "#00f"
|
"fill": "url(#rg_opt)"
|
||||||
},
|
},
|
||||||
"wpt": {
|
"wpt": {
|
||||||
"stroke-width": 1,
|
"stroke-width": 10,
|
||||||
"stroke": "#f00",
|
"stroke": "#000",
|
||||||
"fill": "#00f"
|
"fill": "url(#rg_wpt)"
|
||||||
}
|
},
|
||||||
|
"wit": {
|
||||||
|
"stroke-width": 10,
|
||||||
|
"stroke": "#000",
|
||||||
|
"fill": "url(#rg1)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
116
src/services/sql/prod_inj.js
Normal file
116
src/services/sql/prod_inj.js
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
export default {
|
||||||
|
max_date(){
|
||||||
|
return `SELECT MAX(date(year||'-01-01', (month - 1)||' month')) as date FROM production_injections`
|
||||||
|
},
|
||||||
|
|
||||||
|
devobjs(){
|
||||||
|
return `SELECT distinct(object) as devobj FROM production_injections`
|
||||||
|
},
|
||||||
|
|
||||||
|
totals(devobj){
|
||||||
|
return `SELECT
|
||||||
|
wells.well, wells.whx, wells.why
|
||||||
|
,SUM(production_injections.woptm) as wopt
|
||||||
|
,SUM(production_injections.wwptm) as wwpt
|
||||||
|
,SUM(production_injections.wsgptv) as wgpt
|
||||||
|
,SUM(production_injections.wwitv) as wwit
|
||||||
|
,SUM(production_injections.days) as days
|
||||||
|
,SUM(production_injections.wwptm)+SUM(production_injections.woptm) as wlpt
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
wells.well=production_injections.well
|
||||||
|
AND production_injections.object='${devobj}'
|
||||||
|
GROUP BY
|
||||||
|
wells.well
|
||||||
|
ORDER BY
|
||||||
|
wlpt DESC, wwit DESC`
|
||||||
|
},
|
||||||
|
|
||||||
|
rates(devobj, date){
|
||||||
|
date = new Date(date)
|
||||||
|
const year_month = date.getFullYear()*100 + date.getMonth()
|
||||||
|
return `SELECT
|
||||||
|
wells.well, wells.whx, wells.why
|
||||||
|
,SUM(production_injections.woptm)/SUM(production_injections.days) as wopr
|
||||||
|
,SUM(production_injections.wwptm)/SUM(production_injections.days) as wwpr
|
||||||
|
,SUM(production_injections.wsgptv)/SUM(production_injections.days) as wgpr
|
||||||
|
,SUM(production_injections.wwitv)/SUM(production_injections.days) as wwir
|
||||||
|
,SUM(production_injections.days) as days
|
||||||
|
,(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) / SUM(production_injections.days) as wlpr
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
wells.well=production_injections.well
|
||||||
|
AND production_injections.object='${devobj}'
|
||||||
|
AND (year*100+month)=${year_month}
|
||||||
|
GROUP BY
|
||||||
|
wells.well`
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
production_injection(field, devobj, date){
|
||||||
|
const f_date = date ? `AND year*1000+month=${date.getFullYear()*1000+date.getMonth()}` : ''
|
||||||
|
console.log(f_date)
|
||||||
|
|
||||||
|
return `SELECT
|
||||||
|
wells.well, wells.whx, wells.why
|
||||||
|
,SUM(production_injections.woptm) as wopt
|
||||||
|
,SUM(production_injections.wwptm) as wwpt
|
||||||
|
,SUM(production_injections.wsgptv) as wgpt
|
||||||
|
,SUM(production_injections.wwitv) as wwit
|
||||||
|
,SUM(production_injections.days) as days
|
||||||
|
,SUM(production_injections.wwptm)+SUM(production_injections.woptm) as wlpt
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
AND wells.well=production_injections.well
|
||||||
|
AND production_injections.object='${devobj}'
|
||||||
|
AND (year*1000+month)=${max_year_month}
|
||||||
|
GROUP BY
|
||||||
|
wells.well`
|
||||||
|
},
|
||||||
|
|
||||||
|
production_total(field, devobj){
|
||||||
|
return `SELECT
|
||||||
|
wells.well, wells.whx, wells.why
|
||||||
|
,SUM(production_injections.woptm) as wopt
|
||||||
|
,SUM(production_injections.wwptm) as wwpt
|
||||||
|
,SUM(production_injections.wsgptv) as wgpt
|
||||||
|
,SUM(production_injections.wwitv) as wwit
|
||||||
|
,SUM(production_injections.wwptm)+SUM(production_injections.woptm) as wlpt
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
wells.well=production_injections.well
|
||||||
|
AND object='${devobj}'
|
||||||
|
GROUP BY
|
||||||
|
wells.well`
|
||||||
|
},
|
||||||
|
|
||||||
|
injection_total(){
|
||||||
|
const query_all = `SELECT
|
||||||
|
wells.well, wells.whx, wells.why
|
||||||
|
,SUM(production_injections.woptm) as wopt
|
||||||
|
,SUM(production_injections.wwptm) as wwpt
|
||||||
|
,SUM(production_injections.wsgptv) as wgpt
|
||||||
|
,SUM(production_injections.wwitv) as wwit
|
||||||
|
,SUM(production_injections.wwptm)+SUM(production_injections.woptm) as wlpt
|
||||||
|
,SUM(production_injections.wwptm)/(SUM(production_injections.wwptm)+SUM(production_injections.woptm)) as wlf
|
||||||
|
FROM
|
||||||
|
wells, production_injections
|
||||||
|
WHERE
|
||||||
|
wells.well=production_injections.well
|
||||||
|
AND object='${devobj}'
|
||||||
|
GROUP BY
|
||||||
|
wells.well
|
||||||
|
HAVING
|
||||||
|
wwit>0
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
}
|
||||||
140
src/svgmap/SvgMap.js
Normal file
140
src/svgmap/SvgMap.js
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
import { parse } from "svg-parser";
|
||||||
|
|
||||||
|
import SvgNode from './SvgNode.js'
|
||||||
|
import SvgNodes from './SvgNodes.js'
|
||||||
|
|
||||||
|
export default class {
|
||||||
|
async parse(xml) {
|
||||||
|
let result1 = parse(xml);
|
||||||
|
|
||||||
|
this.svg = result1.children.filter((x) => x.tagName == "svg")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить слои документа. Имя слоя можно получить через поле id.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
get_layers() {
|
||||||
|
return this.svg.children.filter((x) => x.tagName == "g");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить данные масштаба карты.
|
||||||
|
* @returns {w, h, k, u} Ширина в мм, высота в мм, k * v[px] = v[мм], юниты (mm, cm, inch)
|
||||||
|
*/
|
||||||
|
get_map_scale() {
|
||||||
|
// console.log(this.svg)
|
||||||
|
let vb = this.svg.properties.viewBox.split(" ").map((x) => parseFloat(x));
|
||||||
|
let w = this.svg.properties.width;
|
||||||
|
let h = this.svg.properties.height;
|
||||||
|
|
||||||
|
let units = {
|
||||||
|
in: 25.4,
|
||||||
|
mm: 1,
|
||||||
|
cm: 10,
|
||||||
|
px: 0.0846646,
|
||||||
|
// '%': 1
|
||||||
|
};
|
||||||
|
|
||||||
|
const u = Object.keys(units).filter((x) => w.endsWith(x))[0];
|
||||||
|
if (!u) throw "Unsupported units";
|
||||||
|
|
||||||
|
w = Math.round(parseFloat(w.substring(0, w.length - u.length)) * units[u] * 100) / 100;
|
||||||
|
h = Math.round(parseFloat(h.substring(0, h.length - u.length)) * units[u] * 100) / 100;
|
||||||
|
let k = vb[2] / w;
|
||||||
|
|
||||||
|
return { w, h, k, u };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Достать из слоя опордные скважины
|
||||||
|
* @param {*} layer Слой в котором 2 последние группы содержат опорные скважины.
|
||||||
|
* @returns { w1, w2 } Опрорные скважины
|
||||||
|
*/
|
||||||
|
extract_anchor(layer) {
|
||||||
|
let w1 = this.extract_well(layer.children[layer.children.length - 1]);
|
||||||
|
let w2 = this.extract_well(layer.children[layer.children.length - 2]);
|
||||||
|
|
||||||
|
return { w1, w2 };
|
||||||
|
}
|
||||||
|
|
||||||
|
_flat(node) {
|
||||||
|
if (!node.children) return [node];
|
||||||
|
return node.children.reduce((s, c) => s.concat(this._flat(c)), [node]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить из группы данные скважины (имя, координаты)
|
||||||
|
* @param {*} pivot_group Svg группа
|
||||||
|
* @returns { {x, y, name} }
|
||||||
|
*/
|
||||||
|
extract_well(pivot_group) {
|
||||||
|
let flat = this._flat(pivot_group);
|
||||||
|
let ellipse = flat.filter((x) => x.tagName == "circle" || x.tagName == "ellipse")[0];
|
||||||
|
let tr = ellipse.properties.transform
|
||||||
|
.replace("matrix(", "")
|
||||||
|
.replace(")", "")
|
||||||
|
.split(" ")
|
||||||
|
.map((x) => parseFloat(x));
|
||||||
|
|
||||||
|
let text = flat.filter((x) => x.type == "text")[0];
|
||||||
|
let name = text.value;
|
||||||
|
return { x: tr[4], y: tr[5], name };
|
||||||
|
}
|
||||||
|
|
||||||
|
build_tp_layer(wells, settings){
|
||||||
|
const sc = this.get_map_scale()
|
||||||
|
|
||||||
|
function t2r(tons){
|
||||||
|
// tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
|
return Math.sqrt(tons / settings.tons_in_cm2 * 100 / Math.PI)
|
||||||
|
}
|
||||||
|
|
||||||
|
let {styles} = settings
|
||||||
|
|
||||||
|
let defs = new SvgNode("defs")
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg_opt", "#fff", "#B86B41"))
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg_wpt", "#fff", "#67c2e5"))
|
||||||
|
|
||||||
|
let svg = SvgNodes.group(['<metadata id="CorelCorpID_WWPTCorel-Layer"/>']).set_attr("id", "WWPT")
|
||||||
|
// Круги
|
||||||
|
svg.append(wells.map((x) => SvgNodes.ring_sectors(1.5 * sc.k, t2r(x.wlpt) * sc.k, [{v: x.wopt, style: styles.opt}, {v: x.wwpt, style: styles.wpt}]).move(x.lx, x.ly)));
|
||||||
|
// Знак скважины
|
||||||
|
svg.append(wells.map((x) => SvgNodes.circle(1.5 * sc.k).move(x.lx, x.ly).add_style(styles.wellhead)));
|
||||||
|
// Имя скважины
|
||||||
|
svg.append(wells.map((x) => SvgNodes.text(x.well).move(x.lx + styles.wellhead.dx * sc.k, x.ly + styles.wellhead.dy * sc.k).add_style(styles.wellhead)));
|
||||||
|
// Обводненность
|
||||||
|
svg.append(wells.map((x) => SvgNodes.text(`${Math.round(x.wlf * 1000)/10 || ''}%`).move(x.lx + styles.wlf.dx * sc.k, x.ly + styles.wlf.dy * sc.k).add_style(styles.wlf)));
|
||||||
|
|
||||||
|
return {defs, svg}
|
||||||
|
}
|
||||||
|
|
||||||
|
build_ti_layer(wells, settings){
|
||||||
|
const sc = this.get_map_scale()
|
||||||
|
|
||||||
|
function t2r(tons){
|
||||||
|
// tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
|
return Math.sqrt(tons / settings.tons_in_cm2 * 100 / Math.PI)
|
||||||
|
}
|
||||||
|
|
||||||
|
let {styles} = settings
|
||||||
|
|
||||||
|
let defs = SvgNodes.container()
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg1", "#fff", "#c1ff5e"))
|
||||||
|
|
||||||
|
let svg = SvgNodes.group(['<metadata id="CorelCorpID_WWITCorel-Layer"/>']).set_attr("id", "WWIT")
|
||||||
|
// Круги
|
||||||
|
// let g_rings = SvgNodes.group(['<metadata id="CorelCorpID_WWITRingsCorel-Layer"/>']).set_attr("id", "Круги")
|
||||||
|
// svg.append(g_rings)
|
||||||
|
svg.append(wells.map((x) => SvgNodes.circle(t2r(x.wwit) * sc.k).add_style(styles.wit).move(x.lx, x.ly)));
|
||||||
|
// Знак скважины
|
||||||
|
svg.append(wells.map((x) => SvgNodes.circle(1.5 * sc.k).move(x.lx, x.ly).add_style(styles.wellhead)));
|
||||||
|
// Имя скважины
|
||||||
|
svg.append(wells.map((x) => SvgNodes.text(x.well).move(x.lx + styles.wellhead.dx * sc.k, x.ly + styles.wellhead.dy * sc.k).add_style(styles.wellhead)));
|
||||||
|
// Обводненность
|
||||||
|
svg.append(wells.map((x) => SvgNodes.text(`${Math.round(x.wlf * 1000)/10 || ''}%`).move(x.lx + styles.wlf.dx * sc.k, x.ly + styles.wlf.dy * sc.k).add_style(styles.wlf)));
|
||||||
|
|
||||||
|
return {defs, svg}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
101
src/svgmap/SvgMapBuilder.js
Normal file
101
src/svgmap/SvgMapBuilder.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import SvgNode from "./SvgNode.js";
|
||||||
|
import SvgNodes from "./SvgNodes.js";
|
||||||
|
import SvgWellNodes from "./SvgWellNodes.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* Преобразовать размер шрифта в единицы карты
|
||||||
|
* @param { string | Number } v Значение для перевода "10mm", "22pt"
|
||||||
|
* @param {*} ppu Pixel per unit
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
fontsize2ppu(v, ppu) {
|
||||||
|
if (typeof v !== "string") return v;
|
||||||
|
|
||||||
|
if (v.endsWith("mm")) {
|
||||||
|
return parseFloat(v.substring(0, v.length - 2) * ppu * 100) / 69;
|
||||||
|
}
|
||||||
|
if (v.endsWith("pt")) {
|
||||||
|
return parseFloat(v.slice(0, v.length - 2)) * ppu * 100 / 283.46;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Перегоняет стиль в единицы карты (возвращает новый объект)
|
||||||
|
* @param {*} style Объект стиля для преобразования
|
||||||
|
* @param {*} ppu Pixel per unit
|
||||||
|
*/
|
||||||
|
update_style(style, ppu) {
|
||||||
|
let s = Object.assign({}, style);
|
||||||
|
const convertable = ["font-size", "stroke-width", "1pt", "1mm"];
|
||||||
|
Object.keys(s).forEach((k) => {
|
||||||
|
if (convertable.includes(k)) s[k] = this.fontsize2ppu(s[k], ppu);
|
||||||
|
});
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Перегоняет все стили в единицы карты (возвращает новый объект)
|
||||||
|
* @param {*} style Объект стиля для преобразования
|
||||||
|
* @param {*} ppu Pixel per unit
|
||||||
|
*/
|
||||||
|
update_styles(styles, ppu) {
|
||||||
|
return Object.keys(styles).reduce((s, c) => ({ ...s, [c]: this.update_style(styles[c], ppu) }), {});
|
||||||
|
},
|
||||||
|
|
||||||
|
build_tp_layer(wells, settings) {
|
||||||
|
function t2r(tons) {
|
||||||
|
// tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
|
return Math.sqrt(((tons / settings.tons_in_cm2) * 100) / Math.PI);
|
||||||
|
}
|
||||||
|
|
||||||
|
let { ppu, styles } = settings;
|
||||||
|
|
||||||
|
let defs = new SvgNode("defs");
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg_opt", "#fff", "#B86B41"));
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg_wpt", "#fff", "#67c2e5"));
|
||||||
|
|
||||||
|
let svg = SvgNodes.group(['<metadata id="CorelCorpID_WWPTCorel-Layer"/>']).set_attr("id", "WWPT");
|
||||||
|
// Круги
|
||||||
|
svg.append(wells.map((x) => SvgWellNodes.ring.pt(x.wopt, x.wwpt, t2r(x.wlpt), ppu, styles).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
// Знак скважины
|
||||||
|
svg.append(
|
||||||
|
wells.map((x) => SvgWellNodes.wellhead[t2r(x.wlpt) > 1.6 ? "prod" : "gray"](ppu, styles).move(x.lx, x.ly))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Имя скважины
|
||||||
|
svg.append(wells.map((x) => SvgWellNodes.wellhead.name(x.well, ppu, styles).move(x.lx, x.ly)));
|
||||||
|
// Обводненность
|
||||||
|
svg.append(wells.map((x) => SvgWellNodes.wellhead.wlp(x.wlf, ppu, styles).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
return { defs, svg };
|
||||||
|
},
|
||||||
|
|
||||||
|
build_ti_layer(wells, settings) {
|
||||||
|
function t2r(tons) {
|
||||||
|
// tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
|
return Math.sqrt(((tons / settings.tons_in_cm2) * 100) / Math.PI);
|
||||||
|
}
|
||||||
|
|
||||||
|
let { ppu, styles } = settings;
|
||||||
|
|
||||||
|
let defs = new SvgNode("defs");
|
||||||
|
defs.append(SvgNodes.defs.simple.radialGradient("rg1", "#fff", "#c1ff5e"));
|
||||||
|
|
||||||
|
let svg = SvgNodes.group(['<metadata id="CorelCorpID_WWITCorel-Layer"/>']).set_attr("id", "WWIT");
|
||||||
|
|
||||||
|
// Круги
|
||||||
|
svg.append(wells.map((x) => SvgWellNodes.ring.it(t2r(x.wwit), ppu, styles).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
// Знак скважины
|
||||||
|
svg.append(
|
||||||
|
wells.map((x) => SvgWellNodes.wellhead[t2r(x.wwit) > 1.6 ? "inj" : "gray"](ppu, styles).move(x.lx, x.ly))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Имя скважины
|
||||||
|
svg.append(wells.map((x) => SvgWellNodes.wellhead.name(x.well, ppu, styles).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
return { defs, svg };
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -5,8 +5,8 @@ export default class SvgNode {
|
|||||||
this.items = items || []
|
this.items = items || []
|
||||||
}
|
}
|
||||||
|
|
||||||
append(items){
|
append(...items){
|
||||||
this.items.push(items)
|
this.items.push(...items)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,18 +20,21 @@ export default class SvgNode {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
set_style(style) {
|
add_style(style) {
|
||||||
this.style = { ...this.style || {}, ...style }
|
this.style = { ...this.style || {}, ...style }
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_style(style) {
|
clear_style() {
|
||||||
this.style = null
|
this.style = null
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
move(x, y) {
|
move(x, y) {
|
||||||
this.transform = { x, y }
|
if (this.transform)
|
||||||
|
this.transform = { x: this.transform.x + x, y: this.transform.y + y }
|
||||||
|
else
|
||||||
|
this.transform = { x, y }
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,13 +52,16 @@ export default class SvgNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let attrs = Object.keys(this.attrs).map(x => ` ${x}="${this.attrs[x]}"`).join('')
|
let attrs = Object.keys(this.attrs).filter(x => this.attrs[x]).map(x => ` ${x}="${this.attrs[x]}"`).join('')
|
||||||
// console.log(this.style ? Object.keys(this.style).map(x => `${x}:${this.style[x]}`) : '')
|
// console.log(this.style ? Object.keys(this.style).map(x => `${x}:${this.style[x]}`) : '')
|
||||||
let style = this.style ? ' style="' + Object.keys(this.style).map(x => `${x}:${this.style[x]}`).join('; ') + '"' : ''
|
let style = this.style ? ' style="' + Object.keys(this.style).map(x => `${x}:${this.style[x]}`).join('; ') + '"' : ''
|
||||||
let transfrom = this.transform ? ` transform="translate(${this.transform.x},${this.transform.y})"` : ''
|
let transfrom = this.transform ? ` transform="translate(${this.transform.x},${this.transform.y})"` : ''
|
||||||
let items = this.items ? this.items.map(x => this._render_node(x)).join('') : ''
|
let items = this.items ? this.items.map(x => this._render_node(x)).join('') : ''
|
||||||
|
|
||||||
// console.log('this.items', this.items, items)
|
// console.log('this.items', this.items, items)
|
||||||
return `<${this.tag}${attrs}${style}${transfrom}>${items}</${this.tag}>`
|
if (this.tag)
|
||||||
|
return `<${this.tag}${attrs}${style}${transfrom}>${items}</${this.tag}>`
|
||||||
|
else
|
||||||
|
return items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import SvgNode from "./SvgNode";
|
import SvgNode from "./SvgNode.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// sector(r, a0, a1) {
|
// sector(r, a0, a1) {
|
||||||
@@ -18,11 +18,18 @@ export default {
|
|||||||
svg(){
|
svg(){
|
||||||
return new SvgNode('svg', {
|
return new SvgNode('svg', {
|
||||||
version: "1.1",
|
version: "1.1",
|
||||||
xmlns: "http://www.w3.org/2000/svg"
|
xmlns: "http://www.w3.org/2000/svg",
|
||||||
|
"xml:space":"preserve",
|
||||||
|
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
||||||
|
style: "shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||||
// viewBox: "0 0 2000 2000"
|
// viewBox: "0 0 2000 2000"
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
container(items){
|
||||||
|
return new SvgNode(null, null, items)
|
||||||
|
},
|
||||||
|
|
||||||
group(items){
|
group(items){
|
||||||
return new SvgNode("g", null, items)
|
return new SvgNode("g", null, items)
|
||||||
},
|
},
|
||||||
@@ -31,6 +38,22 @@ export default {
|
|||||||
return new SvgNode("circle", {r})
|
return new SvgNode("circle", {r})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ngon(r, n, ang = 0) {
|
||||||
|
const da = 2 * Math.PI / n
|
||||||
|
ang = ang * Math.PI / 180
|
||||||
|
const pts = Array(n).fill(0).map((x, i) => [Math.sin(i * da + ang) * r, Math.cos(i * da + ang) * r])
|
||||||
|
return new SvgNode("polygon", {points: pts.map(x => `${x[0]},${x[1]}`)})
|
||||||
|
},
|
||||||
|
|
||||||
|
spike1(w, h, ang){
|
||||||
|
const da = ang * Math.PI / 180
|
||||||
|
const sa = Math.sin(da)
|
||||||
|
const ca = Math.cos(da)
|
||||||
|
h = h / 2
|
||||||
|
const pts = `${-sa*h},${-ca*h} ${ca*w},${-sa*w}, ${sa*h},${ca*h}`
|
||||||
|
return new SvgNode("polygon", {points: pts})
|
||||||
|
},
|
||||||
|
|
||||||
sector(r, a0, a1) {
|
sector(r, a0, a1) {
|
||||||
const k = Math.PI / 180;
|
const k = Math.PI / 180;
|
||||||
let s0 = -Math.sin(a0 * k) * r;
|
let s0 = -Math.sin(a0 * k) * r;
|
||||||
@@ -62,10 +85,47 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param r0
|
||||||
|
* @param r1
|
||||||
|
* @param a0
|
||||||
|
* @param a1
|
||||||
|
* @param { [{v, style}] } rings
|
||||||
|
*/
|
||||||
|
ring_sectors(r0, r1, sectors){
|
||||||
|
let sum = sectors.reduce((s,c) => s + c.v, 0)
|
||||||
|
let angs = sectors.reduce((s, c, i) => [...s, {...c, a0: i && s[i - 1].a1, a1: c.v + (i && s[i - 1].a1)}], [])
|
||||||
|
let items = angs.map(x => this.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).add_style(x.style))
|
||||||
|
|
||||||
|
return this.group(items)
|
||||||
|
},
|
||||||
|
|
||||||
text(text) {
|
text(text) {
|
||||||
let node = new SvgNode("text");
|
let node = new SvgNode("text");
|
||||||
node.items = [text];
|
node.items = [text];
|
||||||
node.set_attrs({x: 0, y: 0})
|
node.set_attrs({x: 0, y: 0})
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
defs: {
|
||||||
|
simple: {
|
||||||
|
radialGradient(id, color0, color1){
|
||||||
|
let s0 = new SvgNode("stop", {offset: "0%", "stop-color": color0})
|
||||||
|
let s1 = new SvgNode("stop", {offset: "100%", "stop-color": color1})
|
||||||
|
return new SvgNode("radialGradient", {id}).append(s0, s1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
radialGradient(id, cx, cy, r){
|
||||||
|
return new SvgNode("radialGradient", {id, cx, cy, r})
|
||||||
|
},
|
||||||
|
|
||||||
|
stop(offset, color){
|
||||||
|
return new SvgNode("stop", {offset, "stop-color": color})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
86
src/svgmap/SvgWellNodes.js
Normal file
86
src/svgmap/SvgWellNodes.js
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import SvgNode from "./SvgNode.js";
|
||||||
|
import SvgNodes from "./SvgNodes.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
wellhead: {
|
||||||
|
name(text, ppu, styles) {
|
||||||
|
return SvgNodes.text(text)
|
||||||
|
.move(styles["wellhead-name"].dx * ppu, styles["wellhead-name"].dy * ppu)
|
||||||
|
.add_style(styles["wellhead-name"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
wlp(wlf, ppu, styles) {
|
||||||
|
return SvgNodes.text(`${Math.round(wlf * 1000) / 10 || ""}%`)
|
||||||
|
.move(styles.wlf.dx * ppu, styles.wlf.dy * ppu)
|
||||||
|
.add_style(styles.wlf);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Добывающая скважина
|
||||||
|
* @param {*} ppu
|
||||||
|
* @param {*} styles
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
prod(ppu, styles) {
|
||||||
|
return SvgNodes.circle(1.5 * ppu).add_style(styles["wellhead-black"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Нагнетательная
|
||||||
|
* @param {*} ppu
|
||||||
|
* @param {*} styles
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
inj(ppu, styles) {
|
||||||
|
const style_spike = {
|
||||||
|
"stroke-width": "0",
|
||||||
|
fill: '#000'
|
||||||
|
}
|
||||||
|
|
||||||
|
const style_blue = {
|
||||||
|
"stroke-width": Math.round(styles._units["1pt"]),
|
||||||
|
stroke: '#000',
|
||||||
|
fill: '#00f'
|
||||||
|
}
|
||||||
|
|
||||||
|
return SvgNodes.group([
|
||||||
|
SvgNodes.group([
|
||||||
|
SvgNodes.spike1(1.8 * ppu, 1.7 * ppu, 0).move(2 * ppu, 0),
|
||||||
|
SvgNodes.spike1(1.8 * ppu, 1.7 * ppu, 90).move(0, -2 * ppu),
|
||||||
|
SvgNodes.spike1(1.8 * ppu, 1.7 * ppu, 180).move(-2 * ppu, 0),
|
||||||
|
SvgNodes.spike1(1.8 * ppu, 1.7 * ppu, 270).move(0, 2 * ppu),
|
||||||
|
]).add_style(style_spike),
|
||||||
|
new SvgNode("line", { x1: -2 * ppu, x2: 2 * ppu, y1: 0, y2: 0 }),
|
||||||
|
new SvgNode("line", { y1: -2 * ppu, y2: 2 * ppu, x1: 0, x2: 0 }),
|
||||||
|
SvgNodes.circle(1.5 * ppu).add_style(style_blue)
|
||||||
|
]).add_style(style_blue);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Серая с треугольником с малым дебитом/нагнетанием
|
||||||
|
* @param {*} ppu
|
||||||
|
* @param {*} styles
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
gray(ppu, styles) {
|
||||||
|
return SvgNodes.group([
|
||||||
|
SvgNodes.circle(1.5 * ppu).add_style(styles["wellhead-gray"]),
|
||||||
|
SvgNodes.ngon(1.5 * ppu, 3, 0).add_style(styles["wellhead-black"]),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
ring: {
|
||||||
|
pt(wopt, wwpt, rmm, ppu, styles) {
|
||||||
|
return SvgNodes.ring_sectors(1.5 * ppu, rmm * ppu, [
|
||||||
|
{ v: wopt, style: styles.opt },
|
||||||
|
{ v: wwpt, style: styles.wpt },
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
it(rmm, ppu, styles) {
|
||||||
|
return SvgNodes.circle(rmm * ppu)
|
||||||
|
.add_style(styles.wit)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
33
src/svgmap/drawers/SvgWell.js
Normal file
33
src/svgmap/drawers/SvgWell.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
export default {
|
||||||
|
wellhead: {
|
||||||
|
prod(x, y, r, style){
|
||||||
|
return SvgNodes.circle(r).add_style(style).move(w.x, w.y);
|
||||||
|
},
|
||||||
|
|
||||||
|
inj(x, y, r, style){
|
||||||
|
return SvgNodes.circle(r).add_style(style).move(w.x, w.y);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// [{x,y}]
|
||||||
|
heads(wells, r, style) {
|
||||||
|
return wells.map((w) => SvgNodes.circle(r).add_style(style).move(w.x, w.y));
|
||||||
|
},
|
||||||
|
|
||||||
|
// [{x,y,name}]
|
||||||
|
names(wells, style, shift) {
|
||||||
|
return wells.map((w) =>
|
||||||
|
SvgNodes.text(w.name)
|
||||||
|
.add_style(style)
|
||||||
|
.move(w.x + shift.x, w.y + shift.y)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
// {x,y,ring[1,2,3,4,5]}
|
||||||
|
ring(x, y, r0, r1, a0, a1, style) {
|
||||||
|
return SvgNodes.ring_sector(r0, r1, a0, a1).move(x, y).add_style(style);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user