Compare commits
5 Commits
7a4acb5bb6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcc9e0e1ec | ||
|
|
3337f7216e | ||
|
|
cf5956e248 | ||
|
|
2a8d03bae5 | ||
|
|
87174bfb83 |
6
index.js
6
index.js
@ -1,8 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
MapBuilder: require('./svgmap/svg-map-builder'),
|
map_builder: require('./svgmap/svg-map-builder'),
|
||||||
|
style_adaptor: require('./svgmap/helpers/style-adaptor'),
|
||||||
|
svg_nodes: require('./svgmap/drawers/svg-nodes'),
|
||||||
MapSaver: require('./svgmap/svg-map-saver'),
|
MapSaver: require('./svgmap/svg-map-saver'),
|
||||||
BBox: require('./libs/bbox'),
|
BBox: require('./libs/bbox'),
|
||||||
StyleAdaptor: require('./svgmap/helpers/style-adaptor'),
|
|
||||||
SvgNode: require('./svgmap/svg-node'),
|
SvgNode: require('./svgmap/svg-node'),
|
||||||
SvgNodes: require('./svgmap/drawers/svg-nodes'),
|
|
||||||
}
|
}
|
||||||
16
libs/bbox.js
16
libs/bbox.js
@ -71,6 +71,22 @@ class BBox {
|
|||||||
clone(){
|
clone(){
|
||||||
return BBox.fromLTRB(this.l, this.t, this.r, this.b)
|
return BBox.fromLTRB(this.l, this.t, this.r, this.b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expand(dx, dy){
|
||||||
|
dy = dy === null ? dx : dy
|
||||||
|
console.log(dx, dy)
|
||||||
|
this.l -= dx
|
||||||
|
this.r += dx
|
||||||
|
this.t -= dy
|
||||||
|
this.b += dy
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
expandPerc(perc){
|
||||||
|
const w = this.w() * perc / 100
|
||||||
|
const h = this.h() * perc / 100
|
||||||
|
return this.expand(w, h)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BBox
|
module.exports = BBox
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
class Transfrom {
|
class Transfrom {
|
||||||
static fromCoordSyses(cs1, cs2){
|
static fromCoordSystems(cs1, cs2){
|
||||||
let tr = new Transfrom()
|
let tr = new Transfrom()
|
||||||
|
|
||||||
tr.cs1 = cs1
|
tr.cs1 = cs1
|
||||||
|
|||||||
12
package.json
12
package.json
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "app_mapbuilder",
|
"name": "@timal/app_mapbuilder",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Svg map builder tools",
|
"description": "Svg map builder tools",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -8,9 +8,15 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://git.dev.aurora.hub01.site/djerom/app_mapbuilder.git"
|
"url": "http://git.db.timal.kz/djerom/app_mapbuilder.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://npm.db.timal.kz/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
module.exports = class {
|
|
||||||
|
|
||||||
set_scale(scale){
|
|
||||||
this.scale = scale
|
|
||||||
}
|
|
||||||
|
|
||||||
get_bbox(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 }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
wells_layer(wells){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
render(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,116 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
module.exports = class {
|
|
||||||
constructor(url){
|
|
||||||
this.url = url
|
|
||||||
}
|
|
||||||
|
|
||||||
get_wells(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const SvgNodes = require("./svg-nodes");
|
const SvgNodes = require("./svg-nodes");
|
||||||
|
|
||||||
module.exports = (name) => SvgNodes.group(['<metadata id="CorelCorpID_WWPTCorel-Layer"/>']).set_attr("id", name);
|
module.exports = (name) => SvgNodes.group([`<metadata id="CorelCorpID_${name}Corel-Layer"/>`]).set_attr("id", name);
|
||||||
@ -94,7 +94,7 @@ function ring_sectors(r0, r1, sectors) {
|
|||||||
|
|
||||||
function text(text) {
|
function text(text) {
|
||||||
let node = new SvgNode("text");
|
let node = new SvgNode("text");
|
||||||
node.items = [text];
|
node.items = text ? [text] : [];
|
||||||
node.set_attrs({ x: 0, y: 0 });
|
node.set_attrs({ x: 0, y: 0 });
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@ -117,6 +117,10 @@ const defs = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function corel_layer(name) {
|
||||||
|
return new SvgNode('g', null, [`<metadata id="CorelCorpID_${name}Corel-Layer"/>`]).set_attr("id", name)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
node,
|
node,
|
||||||
svg,
|
svg,
|
||||||
@ -129,6 +133,7 @@ module.exports = {
|
|||||||
ring_sector,
|
ring_sector,
|
||||||
ring_sectors,
|
ring_sectors,
|
||||||
text,
|
text,
|
||||||
|
corel_layer
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.default = module.exports;
|
module.exports.default = module.exports;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ function pt(wopt, wwpt, rmm, ppu, style) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function it(rmm, ppu, style) {
|
function it(rmm, ppu, style) {
|
||||||
return SvgNodes.circle(rmm * ppu).add_style(style.wit);
|
return SvgNodes.circle(rmm * ppu).add_style(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -1,9 +1,20 @@
|
|||||||
const SvgNode = require("./svg-node.js");
|
|
||||||
const SvgNodes = require("./drawers/svg-nodes.js");
|
|
||||||
const Defs = require('./helpers/style-defs')
|
|
||||||
const well_ring = require('./drawers/well-ring')
|
const well_ring = require('./drawers/well-ring')
|
||||||
const well_head = require('./drawers/well-head')
|
const well_head = require('./drawers/well-head')
|
||||||
const corel_layer = require('./drawers/corel-layer')
|
const corel_layer = require('./drawers/corel-layer')
|
||||||
|
const BBox = require('../libs/bbox')
|
||||||
|
const SvgNode = require('./svg-node')
|
||||||
|
const svg_nodes = require('./drawers/svg-nodes')
|
||||||
|
|
||||||
|
function get_bbox(data, min_size = 1000) {
|
||||||
|
let bbox = BBox.from_array(data)
|
||||||
|
|
||||||
|
if (bbox.w() == 0 || bbox.h() == 0) {
|
||||||
|
bbox.r += min_size;
|
||||||
|
bbox.b += min_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
function build_pt_layer(wells, settings, style) {
|
function build_pt_layer(wells, settings, style) {
|
||||||
function t2r(tons) {
|
function t2r(tons) {
|
||||||
@ -13,19 +24,22 @@ function build_pt_layer(wells, settings, style) {
|
|||||||
|
|
||||||
let { ppu } = settings;
|
let { ppu } = settings;
|
||||||
|
|
||||||
let svg = corel_layer("WWPT");
|
const wells_layer = corel_layer("wells");
|
||||||
|
const rings_layer = corel_layer("rings");
|
||||||
// Круги
|
// Круги
|
||||||
svg.append(wells.map((x) => well_ring.pt(x.wopt, x.wwpt, t2r(x.wlpt), ppu, style).move(x.lx, x.ly)));
|
rings_layer.append(wells.map((x) => well_ring.pt(x.wopt, x.wwpt, t2r(x.wlpt), ppu, style).move(x.lx, x.ly)));
|
||||||
|
|
||||||
// Знак скважины
|
// Знак скважины
|
||||||
svg.append(
|
wells_layer.append(
|
||||||
wells.map((x) => well_head[t2r(x.wlpt) > 1.6 ? "prod" : "gray"](ppu, style).move(x.lx, x.ly))
|
wells.map((x) => well_head[t2r(x.wlpt) > 1.6 ? "prod" : "gray"](ppu, style).move(x.lx, x.ly))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Имя скважины
|
// Имя скважины
|
||||||
svg.append(wells.map((x) => well_head.name(x.name, ppu, style).move(x.lx, x.ly)));
|
wells_layer.append(wells.map((x) => well_head.name(x.name, ppu, style).move(x.lx, x.ly)));
|
||||||
// Обводненность
|
// Обводненность
|
||||||
svg.append(wells.map((x) => well_head.wlp(x.wlf, ppu, style).move(x.lx, x.ly)));
|
wells_layer.append(wells.map((x) => well_head.wlp(x.wlf, ppu, style).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
let svg = svg_nodes.container([rings_layer, wells_layer])
|
||||||
|
|
||||||
return { svg };
|
return { svg };
|
||||||
}
|
}
|
||||||
@ -38,23 +52,28 @@ function build_it_layer(wells, settings, style) {
|
|||||||
|
|
||||||
let { ppu } = settings;
|
let { ppu } = settings;
|
||||||
|
|
||||||
let svg = corel_layer("WWIT");
|
const wells_layer = corel_layer("wells");
|
||||||
|
const rings_layer = corel_layer("rings");
|
||||||
|
|
||||||
// Круги
|
// Круги
|
||||||
svg.append(wells.map((x) => well_ring.it(t2r(x.wwit), ppu, style).move(x.lx, x.ly)));
|
rings_layer.append(wells.map((x) => well_ring.it(t2r(x.wwit), ppu, style.wit).move(x.lx, x.ly)));
|
||||||
|
rings_layer.append(wells.map((x) => well_ring.it(t2r(x.wsit), ppu, style.sit).move(x.lx, x.ly)));
|
||||||
|
|
||||||
// Знак скважины
|
// Знак скважины
|
||||||
svg.append(
|
wells_layer.append(
|
||||||
wells.map((x) => well_head[t2r(x.wwit) > 1.6 ? "inj" : "gray"](ppu, style).move(x.lx, x.ly))
|
wells.map((x) => well_head[t2r(x.wwit) > 1.6 ? "inj" : "gray"](ppu, style).move(x.lx, x.ly))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Имя скважины
|
// Имя скважины
|
||||||
svg.append(wells.map((x) => well_head.name(x.name, ppu, style).move(x.lx, x.ly)));
|
wells_layer.append(wells.map((x) => well_head.name(x.name, ppu, style).move(x.lx, x.ly)));
|
||||||
|
|
||||||
|
let svg = svg_nodes.container([rings_layer, wells_layer])
|
||||||
|
|
||||||
return { svg };
|
return { svg };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
get_bbox,
|
||||||
build_pt_layer,
|
build_pt_layer,
|
||||||
build_it_layer,
|
build_it_layer,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module.exports = class SvgSaver {
|
|||||||
const csh = Math.abs(cs_mm.y1 - cs_mm.y0);
|
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);
|
const bbox_ppu = BBox.fromLTRB(cs_ppu.x0, cs_ppu.y0, cs_ppu.x1, cs_ppu.y1);
|
||||||
|
|
||||||
this.tr = transfrom.fromCoordSyses(cs1, cs_ppu);
|
this.tr = transfrom.fromCoordSystems(cs1, cs_ppu);
|
||||||
|
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
this.style = adaptor.update_styles(style, settings.ppu);
|
this.style = adaptor.update_styles(style, settings.ppu);
|
||||||
@ -35,10 +35,12 @@ module.exports = class SvgSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
append_defs(defs) {
|
append_defs(defs) {
|
||||||
|
if (!defs) return
|
||||||
this.svg.append(defs);
|
this.svg.append(defs);
|
||||||
}
|
}
|
||||||
|
|
||||||
append_svg(svg) {
|
append_svg(svg) {
|
||||||
|
if (!svg) return
|
||||||
this.svg.append(svg);
|
this.svg.append(svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ class SvgNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
append(...items){
|
append(...items){
|
||||||
this.items.push(...items)
|
this.items = [...this.items, ...items.filter(x => x)]
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,19 +46,18 @@ class SvgNode {
|
|||||||
// console.log(typeof node)
|
// console.log(typeof node)
|
||||||
// if (typeof node == 'undefined') return ''
|
// if (typeof node == 'undefined') return ''
|
||||||
if (typeof node == 'string') return node
|
if (typeof node == 'string') return node
|
||||||
else if (typeof node == 'object' && node.tag) return node.render()
|
else if (typeof node == 'object' && node.render) return node.render()
|
||||||
else if (Array.isArray(node)) return node.map(this._render_node).join('')
|
else if (Array.isArray(node)) return node.map(this._render_node).join('')
|
||||||
else return ''
|
else return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let attrs = Object.keys(this.attrs).filter(x => this.attrs[x]).map(x => ` ${x}="${this.attrs[x]}"`).join('')
|
let attrs = Object.keys(this.attrs).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 ? Array.isArray(this.items) ? this.items.map(x => this._render_node(x)).join('') : this._render_node(this.items) : ''
|
||||||
|
|
||||||
// console.log('this.items', this.items, items)
|
|
||||||
if (this.tag)
|
if (this.tag)
|
||||||
return `<${this.tag}${attrs}${style}${transfrom}>${items}</${this.tag}>`
|
return `<${this.tag}${attrs}${style}${transfrom}>${items}</${this.tag}>`
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user