updates
This commit is contained in:
parent
2a8d03bae5
commit
cf5956e248
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,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;
|
||||||
|
|||||||
@ -2,6 +2,8 @@ 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 BBox = require('../libs/bbox')
|
||||||
|
const SvgNode = require('./svg-node')
|
||||||
|
const svg_nodes = require('./drawers/svg-nodes')
|
||||||
|
|
||||||
function get_bbox(data, min_size = 1000) {
|
function get_bbox(data, min_size = 1000) {
|
||||||
let bbox = BBox.from_array(data)
|
let bbox = BBox.from_array(data)
|
||||||
@ -14,7 +16,6 @@ function get_bbox(data, min_size = 1000) {
|
|||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function build_pt_layer(wells, settings, style) {
|
function build_pt_layer(wells, settings, style) {
|
||||||
function t2r(tons) {
|
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)
|
// tonns/mm2 = tonns/cm2 / 100. S(mm)=Pi*r*r=tons/tons_in_cm2*100. r = sqrt(tons/tons_in_cm2*100 / PI)
|
||||||
@ -23,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 };
|
||||||
}
|
}
|
||||||
@ -48,18 +52,21 @@ 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).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 };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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