Commit 113177e3 authored by juminet's avatar juminet

[client/geothermie] carotte: remove color and add lithologic pattern

parent cf47d9f7
import * as debug from 'debug';
import { getLayersThicknesses, getPiezoValue, getLayersTotalDepth, getHydroLayerDepth, getSystem, getLayerDepth, getLayerId, getHydroLayerId, getHydroLayersThicknesses, getPiezoIndex, getElevation } from 'geothermie/src/queries/geothermie';
import { STRATIGRAPHY_COLORS, PIEZO_LAYERS_NAME, CANONICAL_PATTERN, UH_FOR_US_ID } from '../settings';
import { PIEZO_LAYERS_NAME, CANONICAL_PATTERN, UH_FOR_US_ID } from '../settings';
import { GraphXY, newGraphXY } from '../table/graph';
import { getLayout } from '../../queries/app';
import { Layout } from '../../events/route';
......@@ -101,7 +101,7 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
* @param vertices The array of the vertices of the polygon
* @param color The color of the polygon
*/
function drawPolygon(vertices: GraphXY[], fillColor: string, strokeColor: string = "black") {
function drawPolygon(vertices: GraphXY[], fillColor: string|null , strokeColor: string= "black") {
ctx.beginPath();
ctx.moveTo(vertices[0].x, vertices[0].y);
......@@ -110,7 +110,9 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
}
ctx.closePath();
ctx.fillStyle = fillColor;
if (fillColor !== null) {
ctx.fillStyle = fillColor;
}
ctx.fill();
ctx.strokeStyle = strokeColor;
ctx.stroke();
......@@ -279,7 +281,7 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
/**
* Draw a side of a level of the carrot
*/
function drawLevelSide(x0: number, y0: number, height: number, distanceV0V1: number, angle: number, color: string, patternId: number|null=null) {
function drawLevelSide(x0: number, y0: number, height: number, distanceV0V1: number, angle: number, color: string|null, patternId: number|null=null) {
const v0 = newGraphXY(x0, y0);
const v1 = newVertex(x0, y0, distanceV0V1, angle);
const v1_height = newGraphXY(v1.x, v1.y + height);
......@@ -303,9 +305,9 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
* \ \ /
* \\/
*/
function drawLevel(x0: number, y0: number, height: number, distanceV0V1: number, angle: number, colorLeft: string, colorRight: string, patternIdRight:number|null=null) {
drawLevelSide(x0, y0, height, distanceV0V1, angle, colorLeft);
drawLevelSide(x0 + (distanceV0V1 * Math.cos(angle)), y0 + (distanceV0V1 * Math.sin(angle)), height, distanceV0V1, -angle, colorRight, patternIdRight);
function drawLevel(x0: number, y0: number, height: number, distanceV0V1: number, angle: number, colorLeft: string|null, colorRight: string|null, patternId:number|null=null) {
drawLevelSide(x0, y0, height, distanceV0V1, angle, colorRight, patternId);
drawLevelSide(x0 + (distanceV0V1 * Math.cos(angle)), y0 + (distanceV0V1 * Math.sin(angle)), height, distanceV0V1, -angle, colorLeft, patternId);
}
/**
......@@ -347,8 +349,8 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
let totalHeight = buildingHeight;
let totalHeightWithMin = buildingHeight;
levels.forEach((lev, i) => {
const colorLeft = STRATIGRAPHY_COLORS[i];
const colorRight = STRATIGRAPHY_COLORS[i];
// const colorLeft = STRATIGRAPHY_COLORS[i];
// const colorRight = STRATIGRAPHY_COLORS[i];
let height = lev / ratio;
if (i == levels.length - 1) { // we draw the base of the carrot
......@@ -357,14 +359,14 @@ const withContext = (ctx: CanvasRenderingContext2D) => {
const heightWithMin = height < minHeight && lev != 0 ? minHeight : lev / ratio; // todo dans une fonction
if(getLayout() == 'technical') {
if(getLayout() === 'technical' || getLayout() === 'general' || getLayout() ==='license' || getLayout() ==='geology') {
const uh = UH_FOR_US_ID[i];
const uhId = getHydroLayerId(uh);
const patternIdRight = CANONICAL_PATTERN[uhId];
drawLevel(refPoint.x, totalHeight, height, distanceV0V1, Math.PI / 6, colorLeft, colorRight, patternIdRight);
const patternId = CANONICAL_PATTERN[uhId];
drawLevel(refPoint.x, totalHeight, height, distanceV0V1, Math.PI / 6, null, null, patternId);
} else {
const patternIdRight = null;
drawLevel(refPoint.x, totalHeight, height, distanceV0V1, Math.PI / 6, colorLeft, colorRight, patternIdRight);
const patternId = null;
drawLevel(refPoint.x, totalHeight, height, distanceV0V1, Math.PI / 6, null, null, patternId);
}
totalHeight = totalHeight + height;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="19.049999mm"
height="15.240705mm"
viewBox="0 0 19.049999 15.240705"
version="1.1"
id="svg4840"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="0.svg">
<defs
id="defs4834">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1474">
<path
d="m 250.947,408.551 h 10.94 v -17.889 h -10.94 z"
id="path1472"
inkscape:connector-curvature="0" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1464">
<path
d="m 207.887,408.551 h 43.262 v -17.889 h -43.262 z"
id="path1462"
inkscape:connector-curvature="0" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1454">
<path
d="m 250.947,390.817 h 10.94 v -25.468 h -10.94 z"
id="path1452"
inkscape:connector-curvature="0" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1444">
<path
d="m 207.887,390.817 h 43.262 v -25.468 h -43.262 z"
id="path1442"
inkscape:connector-curvature="0" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="-14.317187"
inkscape:cy="22.682053"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="2505"
inkscape:window-height="1412"
inkscape:window-x="55"
inkscape:window-y="0"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata4837">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-118.23095,-217.56452)" />
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment