修复多段线面积错误

optLineOffset
ChenX 5 years ago
parent 10d748b67d
commit 6ee3d6d7ce

@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`多段线面积 1`] = `"0.00000"`;
exports[`多段线面积 2`] = `"105946.37829"`;
exports[`多段线面积 3`] = `"183539.66828"`;
exports[`多段线面积 4`] = `"11783.91238"`;
exports[`多段线面积 5`] = `"0.00000"`;
exports[`多段线面积 6`] = `"117468.55553"`;

@ -0,0 +1,16 @@
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import "../Utils/jest.util";
test('多段线面积', () =>
{
let d =
{ "file": [6, "Polyline", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 2, [9.569377990430496, 149.52153110047848], 0, [441.3875598086124, 373.2057416267944], 0, false, "Polyline", 5, 2, 102, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 3, [612.4401913875597, 147.12918660287082], 0, [1139.952153110048, 383.9712918660287], 0, [1203.349282296651, 160.28708133971296], 0, false, "Polyline", 5, 2, 103, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 3, [1493.5406698564593, 8.612440191387606], 0, [2302.3923444976076, 372.0095693779905], 0, [2302.3923444976076, -81.81818181818187], 0, true, "Polyline", 5, 2, 104, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 3, [2601.818181818182, 136.88995215311004], 0, [3033.2057416267944, 495.59808612440185], -1.4100385033366523, [3122.2966507177034, 256.4593301435407], 0, false, "Polyline", 5, 2, 105, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 2, [3438.803827751196, -13.157894736842092], -0.37911328762272817, [3745.933014354067, -285.11961722488024], 0, false, "Polyline", 5, 2, 106, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 3, [4261.253588516746, -110.68899521531104], 0, [5012.899521531101, 99.37799043062196], -0.5470946737007636, [4261.253588516747, -110.68899521531102], 0, false], "basePt": { "x": 9.569377990430496, "y": -285.1196172248802, "z": 0 } }
let pls = LoadEntityFromFileData(d) as Polyline[];
for (let pl of pls)
{
expect(pl.Area).toMatchNumberSnapshot();
}
});

@ -1,6 +1,7 @@
import { ShapeManager } from "../../DatabaseServices/ShapeManager"; import { ShapeManager } from "../../DatabaseServices/ShapeManager";
import { Region } from "../../DatabaseServices/Entity/Region"; import { Region } from "../../DatabaseServices/Entity/Region";
import { app } from "../../ApplicationServices/Application"; import { app } from "../../ApplicationServices/Application";
import { Shape } from "../../DatabaseServices/Shape";
export function DrawShapeManage(sm: ShapeManager) export function DrawShapeManage(sm: ShapeManager)
{ {
@ -11,3 +12,13 @@ export function DrawShapeManage(sm: ShapeManager)
app.Database.ModelSpace.Append(reg1); app.Database.ModelSpace.Append(reg1);
} }
export function DrawShape(sp: Shape)
{
let reg1 = new Region();
//@ts-ignore
reg1.m_ShapeManager = new ShapeManager().AppendShapeList(sp);
reg1 = reg1.Clone();
app.Database.ModelSpace.Append(reg1);
}

@ -360,7 +360,7 @@ export class Polyline extends Curve
} }
get Area2() get Area2()
{ {
if (this.NumberOfVertices < 3 && this.GetBuilgeAt(0) === 0) if (this.EndParam < 2)
return 0; return 0;
let { pts, buls } = this.PtsBuls; let { pts, buls } = this.PtsBuls;

@ -22,6 +22,7 @@ export class ShapeManager
AppendShapeList(shapes: Shape | Shape[]) AppendShapeList(shapes: Shape | Shape[])
{ {
Array.isArray(shapes) ? this.m_ShapeList.push(...shapes) : this.m_ShapeList.push(shapes); Array.isArray(shapes) ? this.m_ShapeList.push(...shapes) : this.m_ShapeList.push(shapes);
return this;
} }
Clear() Clear()
{ {

Loading…
Cancel
Save