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(){
|
||||
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
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
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) {
|
||||
let node = new SvgNode("text");
|
||||
node.items = [text];
|
||||
node.items = text ? [text] : [];
|
||||
node.set_attrs({ x: 0, y: 0 });
|
||||
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 = {
|
||||
node,
|
||||
svg,
|
||||
@ -129,6 +133,7 @@ module.exports = {
|
||||
ring_sector,
|
||||
ring_sectors,
|
||||
text,
|
||||
corel_layer
|
||||
};
|
||||
|
||||
module.exports.default = module.exports;
|
||||
|
||||
@ -2,6 +2,8 @@ const well_ring = require('./drawers/well-ring')
|
||||
const well_head = require('./drawers/well-head')
|
||||
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)
|
||||
@ -14,7 +16,6 @@ function get_bbox(data, min_size = 1000) {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
||||
function build_pt_layer(wells, settings, style) {
|
||||
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)
|
||||
@ -23,19 +24,22 @@ function build_pt_layer(wells, settings, style) {
|
||||
|
||||
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))
|
||||
);
|
||||
|
||||
// Имя скважины
|
||||
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 };
|
||||
}
|
||||
@ -48,18 +52,21 @@ function build_it_layer(wells, settings, style) {
|
||||
|
||||
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))
|
||||
);
|
||||
|
||||
// Имя скважины
|
||||
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 };
|
||||
}
|
||||
|
||||
@ -35,10 +35,12 @@ module.exports = class SvgSaver {
|
||||
}
|
||||
|
||||
append_defs(defs) {
|
||||
if (!defs) return
|
||||
this.svg.append(defs);
|
||||
}
|
||||
|
||||
append_svg(svg) {
|
||||
if (!svg) return
|
||||
this.svg.append(svg);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ class SvgNode {
|
||||
}
|
||||
|
||||
append(...items){
|
||||
this.items.push(...items)
|
||||
this.items = [...this.items, ...items.filter(x => x)]
|
||||
return this
|
||||
}
|
||||
|
||||
@ -46,19 +46,18 @@ class SvgNode {
|
||||
// console.log(typeof node)
|
||||
// if (typeof node == 'undefined') return ''
|
||||
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 return ''
|
||||
}
|
||||
|
||||
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]}`) : '')
|
||||
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 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)
|
||||
return `<${this.tag}${attrs}${style}${transfrom}>${items}</${this.tag}>`
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user