Поправлен расчет координат при 1 скважине.
This commit is contained in:
parent
9a169e5872
commit
c26ed9d057
268
src/back_.js
268
src/back_.js
@ -21,7 +21,7 @@ const path = "../../data/prodmaps";
|
||||
// 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(`${path}/49_Кар тек и сум отб 7 об_вост.svg`);
|
||||
|
||||
// let file = fs.readFileSync('../data/2022-03-16/49_Кар тек и сум отб 7 об_вост-px.svg')
|
||||
|
||||
@ -29,11 +29,6 @@ let styles = JSON.parse(fs.readFileSync("./moc/styles.json").toString());
|
||||
|
||||
let parser = new SvgMap();
|
||||
|
||||
function build_scaler() {
|
||||
// Получить функцию для перевода координат из геологических в локальные.
|
||||
// Получить функцию для перевода расстояний кругов (из тонн в см2)
|
||||
}
|
||||
|
||||
async function start() {
|
||||
await parser.parse(file.toString());
|
||||
|
||||
@ -203,8 +198,7 @@ async function build_map_pt(devobj) {
|
||||
// const DATE = '2023-01-01'
|
||||
|
||||
const query_all = `SELECT
|
||||
wells.well, wells.whx, wells.why,
|
||||
MAX(production_injections.date) as date
|
||||
wells.well, wells.whx, wells.why
|
||||
,SUM(production_injections.woptm) as wopt
|
||||
,SUM(production_injections.wwptm) as wwpt
|
||||
,SUM(production_injections.wsgptv) as wgpt
|
||||
@ -267,8 +261,7 @@ async function build_map_it(devobj) {
|
||||
// const DATE = '2023-01-01'
|
||||
|
||||
const query_all = `SELECT
|
||||
wells.well, wells.whx, wells.why,
|
||||
MAX(production_injections.date) as date
|
||||
wells.well, wells.whx, wells.why
|
||||
,SUM(production_injections.woptm) as wopt
|
||||
,SUM(production_injections.wwptm) as wwpt
|
||||
,SUM(production_injections.wsgptv) as wgpt
|
||||
@ -288,18 +281,23 @@ async function build_map_it(devobj) {
|
||||
`
|
||||
|
||||
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||
|
||||
if (all_wells.length == 0){
|
||||
// fs.writeFileSync(`${path}/out_devobj-${devobj}.svg`, "");
|
||||
return
|
||||
}
|
||||
|
||||
let bbox = BBox.from_array(all_wells.map(w => ({x: w.whx, y: w.why})))
|
||||
if (bbox.w() == 0 || bbox.h() == 0){
|
||||
bbox.r += 1000
|
||||
bbox.b += 1000
|
||||
}
|
||||
|
||||
{
|
||||
const builder = new SvgMapBuilder()
|
||||
|
||||
const settings = {
|
||||
tons_in_cm2: 10000,
|
||||
tons_in_cm2: 20000,
|
||||
ppu: 100, // 100
|
||||
styles: builder.update_styles(styles, 100),
|
||||
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||
@ -314,6 +312,8 @@ async function build_map_it(devobj) {
|
||||
|
||||
let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.trx(x.whx), ly: tr.try(x.why) }));
|
||||
|
||||
// console.log(mapped_wells)
|
||||
|
||||
let ti_layer = builder.build_ti_layer(mapped_wells, settings)
|
||||
const csw = Math.abs(cs_mm.x1 - cs_mm.x0)
|
||||
const csh = Math.abs(cs_mm.y1 - cs_mm.y0)
|
||||
@ -343,14 +343,18 @@ async function build_map_it(devobj) {
|
||||
}
|
||||
|
||||
async function build_map_pty(devobj) {
|
||||
let sql_max_year = `SELECT strftime('%Y', max(date)) as max_year FROM production_injections`
|
||||
console.log('build_map_pty', devobj)
|
||||
|
||||
let sql_max_year = `SELECT max(year) as max_year FROM production_injections`
|
||||
const max_year = await axios.post(`${back_url}/proxy/sqlite`, { query: sql_max_year }).then((x) => x.data.data[0].max_year);
|
||||
|
||||
// const DATE = '2023-01-01'
|
||||
|
||||
// console.log(max_year)
|
||||
|
||||
const query_all = `SELECT
|
||||
wells.well, wells.whx, wells.why,
|
||||
MAX(production_injections.date) as date
|
||||
wells.well, wells.whx, wells.why
|
||||
,MAX(production_injections.year) as year
|
||||
,SUM(production_injections.woptm) as wopt
|
||||
,SUM(production_injections.wwptm) as wwpt
|
||||
,SUM(production_injections.wsgptv) as wgpt
|
||||
@ -362,7 +366,7 @@ async function build_map_pty(devobj) {
|
||||
WHERE
|
||||
wells.well=production_injections.well
|
||||
AND object='${devobj}'
|
||||
AND strftime('%Y', date)='${max_year}'
|
||||
AND year=${max_year}
|
||||
GROUP BY
|
||||
wells.well
|
||||
|
||||
@ -370,6 +374,7 @@ async function build_map_pty(devobj) {
|
||||
|
||||
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||
if (all_wells.length == 0){
|
||||
console.log('NO wells found')
|
||||
// fs.writeFileSync(`${path}/out_devobj-${devobj}-CP.svg`, "");
|
||||
return
|
||||
}
|
||||
@ -405,166 +410,105 @@ async function build_map_pty(devobj) {
|
||||
.set_attr("viewBox", `${bbox_ppu.l} ${bbox_ppu.t} ${bbox_ppu.w()} ${bbox_ppu.h()}`)
|
||||
svg.append(ti_layer.defs)
|
||||
svg.append(ti_layer.svg)
|
||||
|
||||
fs.writeFileSync(`${path}/out_devobj-${devobj}-PC.svg`, svg.render());
|
||||
}
|
||||
}
|
||||
|
||||
async function build_map_pr(devobj) {
|
||||
console.log('build_map_pty', devobj)
|
||||
|
||||
let sql_max_year = `SELECT MAX(year*1000+month) as max_year FROM production_injections`
|
||||
const max_year_month = await axios.post(`${back_url}/proxy/sqlite`, { query: sql_max_year }).then((x) => x.data.data[0].max_year);
|
||||
// console.log(max_year_month)
|
||||
// const DATE = '2023-01-01'
|
||||
|
||||
// console.log(max_year)
|
||||
|
||||
const query_all = `SELECT
|
||||
wells.well, wells.whx, wells.why
|
||||
,(year*1000+month) as aaa
|
||||
,production_injections.horizon
|
||||
,production_injections.segment
|
||||
,production_injections.object
|
||||
,SUM(production_injections.days) as days
|
||||
,SUM(production_injections.woptm) as wopt
|
||||
,SUM(production_injections.wwptm) as wwpt
|
||||
FROM
|
||||
wells, production_injections
|
||||
WHERE
|
||||
production_injections.woptm > 0
|
||||
AND wells.well=production_injections.well
|
||||
AND production_injections.object='${devobj}'
|
||||
AND (year*1000+month)=${max_year_month}
|
||||
GROUP BY
|
||||
wells.well
|
||||
`
|
||||
|
||||
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||
|
||||
console.log(all_wells)
|
||||
|
||||
if (all_wells.length == 0){
|
||||
console.log('NO wells found')
|
||||
// fs.writeFileSync(`${path}/out_devobj-${devobj}-CP.svg`, "");
|
||||
return
|
||||
}
|
||||
|
||||
let bbox = BBox.from_array(all_wells.map(w => ({x: w.whx, y: w.why})))
|
||||
|
||||
{
|
||||
const builder = new SvgMapBuilder()
|
||||
|
||||
const settings = {
|
||||
tons_in_cm2: 5,
|
||||
ppu: 100, // 100
|
||||
styles: builder.update_styles(styles, 100),
|
||||
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||
map_scale: 1 / 10000 * 1000
|
||||
}
|
||||
|
||||
// Функция перевода координат из глобальных в локальные.
|
||||
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)
|
||||
let tr = Transfrom.fromCoordSyses(cs1, cs_ppu);
|
||||
|
||||
let mapped_wells = all_wells.map((x) => ({ ...x,
|
||||
wopt: x.wopt / x.days,
|
||||
wwpt: x.wwpt / x.days,
|
||||
wlpt: (x.wopt + x.wwpt) / x.days,
|
||||
wlf: x.wwpt / (x.wopt + x.wwpt),
|
||||
lx: tr.trx(x.whx), ly: tr.try(x.why)
|
||||
}));
|
||||
|
||||
let ti_layer = builder.build_tp_layer(mapped_wells, settings)
|
||||
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)
|
||||
|
||||
let 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()}`)
|
||||
svg.append(ti_layer.defs)
|
||||
svg.append(ti_layer.svg)
|
||||
|
||||
fs.writeFileSync(`${path}/out_devobj-${devobj}-PR.svg`, svg.render());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function start2() {
|
||||
const DATE = '2023-01-01'
|
||||
|
||||
const sql_objects = `SELECT distinct(object) as devobj FROM production_injections`
|
||||
const sql_objects = `SELECT distinct(object) as devobj FROM production_injections where devobj=1` //x.wopt
|
||||
|
||||
let objects = await axios.post(`${back_url}/proxy/sqlite`, { query: sql_objects }).then((x) => x.data.data.map(y => y.devobj));
|
||||
|
||||
objects.map(build_map_pt)
|
||||
// objects.map(build_map_pt)
|
||||
objects.map(build_map_it)
|
||||
objects.map(build_map_pty)
|
||||
|
||||
return
|
||||
|
||||
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}'
|
||||
AND object='8'
|
||||
GROUP BY
|
||||
wells.well
|
||||
|
||||
`// WHERE well='${anchor.w1.name}'`;
|
||||
|
||||
// const query_all2 = `SELECT distinct(object) FROM production_injections limit 10`
|
||||
|
||||
let all_wells = await axios.post(`${back_url}/proxy/sqlite`, { query: query_all }).then((x) => x.data.data);
|
||||
|
||||
// console.log(all_wells)
|
||||
// return
|
||||
|
||||
let bbox = BBox.from_array(all_wells.map(w => ({x: w.whx, y: w.why})))
|
||||
|
||||
// let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.trx(x.whx), ly: tr.try(x.why) }));
|
||||
|
||||
// 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).set_style(styles.gpt)));
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
const builder = new SvgMapBuilder()
|
||||
|
||||
const settings = {
|
||||
tons_in_cm2: 10000,
|
||||
ppu: 100, // 100
|
||||
styles: builder.update_styles(styles, 100),
|
||||
// Масштаб 1мм карты / 1мм реальный (1000мм в 1м)
|
||||
map_scale: 1 / 10000 * 1000
|
||||
}
|
||||
|
||||
|
||||
console.log(settings)
|
||||
|
||||
function mm2ppu(v){
|
||||
if (v.endsWith('mm')){
|
||||
return parseFloat(v.slice(0, v.length - 2)) * settings.ppu * 100 / 69
|
||||
}
|
||||
}
|
||||
|
||||
function pt2ppu(v){
|
||||
if (v.endsWith('pt')){
|
||||
return parseFloat(v.slice(0, v.length - 2)) * settings.ppu * 100 / 283.46
|
||||
}
|
||||
}
|
||||
|
||||
function u2ppu(v){
|
||||
if (v.endsWith('mm')){
|
||||
return parseFloat(v.slice(0, v.length - 2)) * settings.ppu * 100 / 69
|
||||
}
|
||||
if (v.endsWith('pt')){
|
||||
return parseFloat(v.slice(0, v.length - 2)) * settings.ppu * 100 / 283.46
|
||||
}
|
||||
}
|
||||
|
||||
// mm = 25.4 * (px / 96)
|
||||
|
||||
// settings.styles.wellhead["font-family"] = "Courier New",
|
||||
// console.log(mm2ppu(settings.styles.wellhead['font-size']))
|
||||
// settings.styles.wellhead['font-size'] = u2ppu('10pt') //settings.styles.wellhead['font-size'])
|
||||
|
||||
// const query = `SELECT well, whx, why FROM wells WHERE well='203'`;
|
||||
const query = `SELECT well, whx, why FROM wells WHERE well='R-2'`;
|
||||
let wells = await axios.post(`${back_url}/proxy/sqlite`, { query }).then((x) => x.data.data);
|
||||
console.log(wells);
|
||||
let c = [wells[0].whx - bbox.l, wells[0].why - bbox.t]
|
||||
console.log(c)
|
||||
|
||||
|
||||
|
||||
// Функция перевода координат из глобальных в локальные.
|
||||
const cs1 = new CoordSystem(bbox.l, bbox.t, bbox.r, bbox.b)
|
||||
const cs_mm = cs1.clone().moveto(0, 0).scale(settings.map_scale)
|
||||
const cs_ppu = cs_mm.clone().scale(settings.ppu)
|
||||
let tr = Transfrom.fromCoordSyses(cs1, cs_ppu);
|
||||
|
||||
console.log('cs_mm', cs_mm, 'cs_ppu', cs_ppu)
|
||||
|
||||
|
||||
|
||||
|
||||
let mapped_wells = all_wells.map((x) => ({ ...x, lx: tr.trx(x.whx), ly: tr.try(x.why) }));
|
||||
|
||||
let ti_layer = builder.build_tp_layer(mapped_wells, settings)
|
||||
const csw = (cs_mm.x1 - cs_mm.x0)
|
||||
const csh = (cs_mm.y1 - cs_mm.y0)
|
||||
|
||||
let svg = SvgNodes.svg().set_attr("width", csw + "mm").set_attr("height", csh + "mm")
|
||||
// .set_attr("viewBox", "0 0 1000 1000")
|
||||
.set_attr("viewBox", `${cs_ppu.x0} ${cs_ppu.y0} ${(cs_ppu.x1 - cs_ppu.x0)} ${(cs_ppu.y1 - cs_ppu.y0)}`)
|
||||
// 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());
|
||||
|
||||
// objects.map(build_map_pr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@ export default class Transfrom {
|
||||
let dx2 = cs2.x1 - cs2.x0;
|
||||
let dy2 = cs2.y1 - cs2.y0;
|
||||
|
||||
tr.kx12 = dx2 / dx1;
|
||||
tr.ky12 = dy2 / dy1;
|
||||
tr.kx12 = dx1 ? dx2 / dx1 : 1;
|
||||
tr.ky12 = dy1 ? dy2 / dy1 : 1;
|
||||
|
||||
return tr
|
||||
}
|
||||
|
||||
@ -131,13 +131,13 @@ export default class {
|
||||
)
|
||||
);
|
||||
// Обводненность
|
||||
svg.append(
|
||||
wells.map((x) =>
|
||||
SvgNodes.text(`${Math.round(x.wlf * 1000) / 10 || ""}%`)
|
||||
.move(x.lx + styles.wlf.dx * ppu, x.ly + styles.wlf.dy * ppu)
|
||||
.set_style(styles.wlf)
|
||||
)
|
||||
);
|
||||
// svg.append(
|
||||
// wells.map((x) =>
|
||||
// SvgNodes.text(`${Math.round(x.wlf * 1000) / 10 || ""}%`)
|
||||
// .move(x.lx + styles.wlf.dx * ppu, x.ly + styles.wlf.dy * ppu)
|
||||
// .set_style(styles.wlf)
|
||||
// )
|
||||
// );
|
||||
|
||||
return { defs, svg };
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user