сделана рисовка карты накопленных запасов
This commit is contained in:
parent
764c77692a
commit
6ea104aa08
66
src/back_.js
66
src/back_.js
@ -4,6 +4,8 @@ import axios from "axios";
|
|||||||
import SvgMapParser from "./svgmap/SvgMapParser.js";
|
import SvgMapParser from "./svgmap/SvgMapParser.js";
|
||||||
import SvgNodes from "./svgmap/SvgNodes.js";
|
import SvgNodes from "./svgmap/SvgNodes.js";
|
||||||
|
|
||||||
|
import math_lib from './libs/math.js'
|
||||||
|
|
||||||
const back_url = "http://localhost:4000";
|
const back_url = "http://localhost:4000";
|
||||||
|
|
||||||
const path = "../../data/2022-03-16";
|
const path = "../../data/2022-03-16";
|
||||||
@ -12,7 +14,7 @@ const path = "../../data/2022-03-16";
|
|||||||
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-sm.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('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-inch.svg')
|
||||||
// let file = fs.readFileSync(`${path}/49_Кар тек и сум отб 7 об_вост-mm.svg`)
|
// let file = fs.readFileSync(`${path}/49_Кар тек и сум отб 7 об_вост-mm.svg`)
|
||||||
let file = fs.readFileSync(`D:/dev/git/kz/prodmaps/src/49_Кар тек и сум отб 7 об_вост.svg`);
|
let file = fs.readFileSync(`D:/dev/git/kz/prodmaps/tmp/49_Кар тек и сум отб 7 об_вост.svg`);
|
||||||
|
|
||||||
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-px.svg')
|
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-px.svg')
|
||||||
|
|
||||||
@ -110,29 +112,69 @@ async function start() {
|
|||||||
|
|
||||||
// console.log(wells)
|
// console.log(wells)
|
||||||
|
|
||||||
const query_all = `SELECT well, whx, why FROM wells`// WHERE well='${anchor.w1.name}'`;
|
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}'`;
|
||||||
|
|
||||||
|
|
||||||
|
// const query_all = `SELECT well, whx, why FROM wells`// WHERE well='${anchor.w1.name}'`;
|
||||||
// const query_all = `SELECT well, whx, why FROM wells WHERE well='${anchor.w1.name}' OR well='${anchor.w2.name}'`;
|
// const query_all = `SELECT well, whx, why FROM wells WHERE well='${anchor.w1.name}' OR well='${anchor.w2.name}'`;
|
||||||
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||||
|
console.log(all_wells.map(x => x.wlf)) //.slice(0, 1))
|
||||||
|
|
||||||
let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.tr21.trx(x.whx), ly: tr.tr21.try(x.why) }));
|
let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.tr21.trx(x.whx), ly: tr.tr21.try(x.why) }));
|
||||||
|
|
||||||
console.log(mapped_wells.slice(0, 2));
|
|
||||||
|
|
||||||
let svg = SvgNodes.svg().set_attrs({
|
|
||||||
width: sc.w + "mm",
|
|
||||||
height: sc.h + "mm",
|
|
||||||
viewBox: `0 0 ${sc.w * sc.k} ${sc.h * sc.k}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
svg = SvgNodes.group()
|
// let svg = SvgNodes.svg().set_attrs({
|
||||||
|
// width: sc.w + "mm",
|
||||||
|
// height: sc.h + "mm",
|
||||||
|
// viewBox: `0 0 ${sc.w * sc.k} ${sc.h * sc.k}`,
|
||||||
|
// });
|
||||||
|
|
||||||
|
let svg = SvgNodes.group(['<metadata id="CorelCorpID_1000Corel-Layer"/>']).set_attr("id", "WLPT")
|
||||||
|
|
||||||
|
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).set_style(styles.gpt)));
|
||||||
|
|
||||||
|
// Круги
|
||||||
|
let g_wopts = SvgNodes.group()
|
||||||
|
svg.append(g_wopts)
|
||||||
|
g_wopts.append(mapped_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(mapped_wells.map((x) => SvgNodes.ring_sector(1.5 * sc.k, 6 * sc.k, 0, 120).move(x.lx, x.ly).set_style(styles.gpt)));
|
|
||||||
svg.append(mapped_wells.map((x) => SvgNodes.circle(1.5 * sc.k).move(x.lx, x.ly).set_style(styles.wellhead)));
|
svg.append(mapped_wells.map((x) => SvgNodes.circle(1.5 * sc.k).move(x.lx, x.ly).set_style(styles.wellhead)));
|
||||||
svg.append(mapped_wells.map((x) => SvgNodes.text(x.well).move(x.lx, x.ly).set_style(styles.wellhead)));
|
svg.append(mapped_wells.map((x) => SvgNodes.text(x.well).move(x.lx + 1.7 * sc.k, x.ly).set_style(styles.wellhead)));
|
||||||
|
svg.append(mapped_wells.map((x) => SvgNodes.text(`${Math.round(x.wlf * 1000)/10 || ''}%`).move(x.lx + 1.7 * sc.k, x.ly + 1 * sc.k).set_style(styles.wlf)));
|
||||||
|
|
||||||
let data = file.toString().replace('</svg>', svg.render() + '</svg>')
|
let data = file.toString().replace('</svg>', svg.render() + '</svg>')
|
||||||
|
|
||||||
fs.writeFileSync("out.svg", data) //svg.render());
|
fs.writeFileSync("../tmp/out.svg", data) //svg.render());
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
|||||||
7
src/libs/math.js
Normal file
7
src/libs/math.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
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
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -2,23 +2,34 @@
|
|||||||
"wellhead": {
|
"wellhead": {
|
||||||
"font-family": "Times New Roman",
|
"font-family": "Times New Roman",
|
||||||
"font-weight": "bold",
|
"font-weight": "bold",
|
||||||
"stroke-width": "0.5mm",
|
"stroke-width": "2.5mm",
|
||||||
"font-size":"10pt",
|
"font-size": 500,
|
||||||
"stroke": "#fff",
|
"stroke": "#fff",
|
||||||
"fill": "#000"
|
"fill": "#000"
|
||||||
},
|
},
|
||||||
|
"wlf": {
|
||||||
|
"font-family": "Times New Roman",
|
||||||
|
"font-weight": "bold",
|
||||||
|
"stroke-width": "0",
|
||||||
|
"alignment-baseline": "hanging",
|
||||||
|
"font-size": 300,
|
||||||
|
"font-style": "italic",
|
||||||
|
"stroke": "#fff",
|
||||||
|
"fill": "#00f"
|
||||||
|
},
|
||||||
|
|
||||||
"gpt": {
|
"gpt": {
|
||||||
"stroke-width": 1,
|
"stroke-width": 20,
|
||||||
"stroke": "#000",
|
"stroke": "#000",
|
||||||
"fill": "#ff0"
|
"fill": "#ff0"
|
||||||
},
|
},
|
||||||
"opt": {
|
"opt": {
|
||||||
"stroke-width": 1,
|
"stroke-width": 10,
|
||||||
"stroke": "#000",
|
"stroke": "#000",
|
||||||
"fill": "#B86B41"
|
"fill": "#B86B41"
|
||||||
},
|
},
|
||||||
"wpt": {
|
"wpt": {
|
||||||
"stroke-width": 1,
|
"stroke-width": 10,
|
||||||
"stroke": "#000",
|
"stroke": "#000",
|
||||||
"fill": "#67c2e5"
|
"fill": "#67c2e5"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,13 +65,6 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
text(text) {
|
|
||||||
let node = new SvgNode("text");
|
|
||||||
node.items = [text];
|
|
||||||
node.set_attrs({x: 0, y: 0})
|
|
||||||
return node;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param r0
|
* @param r0
|
||||||
@ -80,12 +73,19 @@ export default {
|
|||||||
* @param a1
|
* @param a1
|
||||||
* @param { [{v, style}] } rings
|
* @param { [{v, style}] } rings
|
||||||
*/
|
*/
|
||||||
sectored_ring(r0, r1, rings){
|
ring_sectors(r0, r1, sectors){
|
||||||
let sum = rings.reduce((s,c) => s + c.v, 0)
|
let sum = sectors.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 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 => SvgNodes.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).set_style(x.style))
|
let items = angs.map(x => this.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).set_style(x.style))
|
||||||
|
|
||||||
return SvgNodes.group(items)
|
return this.group(items)
|
||||||
|
},
|
||||||
|
|
||||||
|
text(text) {
|
||||||
|
let node = new SvgNode("text");
|
||||||
|
node.items = [text];
|
||||||
|
node.set_attrs({x: 0, y: 0})
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user