app_mapbuilder/svgmap/svg-map-builder.js
2022-04-25 16:19:31 +05:00

74 lines
2.0 KiB
JavaScript

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')
function get_wells_bbox(data) {
let bbox = BBox.from_array(data.map((w) => ({ x: w.whx, y: w.why })));
if (bbox.w() == 0 || bbox.h() == 0) {
bbox.r += 1000;
bbox.b += 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)
return Math.sqrt(((tons / settings.tons_in_cm2) * 100) / Math.PI);
}
let { ppu } = settings;
let svg = corel_layer("WWPT");
// Круги
svg.append(wells.map((x) => well_ring.pt(x.wopt, x.wwpt, t2r(x.wlpt), ppu, style).move(x.lx, x.ly)));
// Знак скважины
svg.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)));
// Обводненность
svg.append(wells.map((x) => well_head.wlp(x.wlf, ppu, style).move(x.lx, x.ly)));
return { svg };
}
function build_it_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)
return Math.sqrt(((tons / settings.tons_in_cm2) * 100) / Math.PI);
}
let { ppu } = settings;
let svg = corel_layer("WWIT");
// Круги
svg.append(wells.map((x) => well_ring.it(t2r(x.wwit), ppu, style).move(x.lx, x.ly)));
// Знак скважины
svg.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)));
return { svg };
}
module.exports = {
get_wells_bbox,
build_pt_layer,
build_it_layer,
};
module.exports.default = module.exports;