fiscalia_bo-nest-helpers 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ms-geojson/dto/ms-geojson.dto.d.ts +15 -2
- package/dist/ms-geojson/dto/ms-geojson.dto.js +40 -8
- package/dist/ms-geojson/dto/ms-geojson.dto.js.map +1 -1
- package/dist/ms-geojson/ms-geojson.service.d.ts +3 -3
- package/dist/ms-geojson/ms-geojson.service.js +53 -25
- package/dist/ms-geojson/ms-geojson.service.js.map +1 -1
- package/dist/ms-pdf/types.d.ts +4 -1
- package/package.json +1 -1
@@ -1,6 +1,19 @@
|
|
1
1
|
export declare class Coordinates {
|
2
2
|
coordinates: [number, number];
|
3
3
|
}
|
4
|
-
|
5
|
-
|
4
|
+
declare class GeometryDto {
|
5
|
+
type: string;
|
6
|
+
coordinates: Object;
|
6
7
|
}
|
8
|
+
declare class properties {
|
9
|
+
name: string;
|
10
|
+
}
|
11
|
+
export declare class FeatureDto {
|
12
|
+
type: string;
|
13
|
+
geometry: GeometryDto;
|
14
|
+
id: string;
|
15
|
+
properties: {
|
16
|
+
name: properties;
|
17
|
+
};
|
18
|
+
}
|
19
|
+
export {};
|
@@ -9,25 +9,57 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.
|
12
|
+
exports.FeatureDto = exports.Coordinates = void 0;
|
13
13
|
const class_transformer_1 = require("class-transformer");
|
14
14
|
const class_validator_1 = require("class-validator");
|
15
15
|
class Coordinates {
|
16
16
|
}
|
17
17
|
__decorate([
|
18
|
-
(0, class_transformer_1.Type)(() => Number),
|
19
18
|
(0, class_validator_1.IsArray)(),
|
20
19
|
(0, class_validator_1.IsNumber)({}, { each: true }),
|
21
20
|
__metadata("design:type", Array)
|
22
21
|
], Coordinates.prototype, "coordinates", void 0);
|
23
22
|
exports.Coordinates = Coordinates;
|
24
|
-
class
|
23
|
+
class GeometryDto {
|
25
24
|
}
|
26
25
|
__decorate([
|
27
|
-
(0,
|
26
|
+
(0, class_validator_1.IsString)(),
|
27
|
+
(0, class_validator_1.IsNotEmpty)(),
|
28
|
+
__metadata("design:type", String)
|
29
|
+
], GeometryDto.prototype, "type", void 0);
|
30
|
+
__decorate([
|
28
31
|
(0, class_validator_1.IsArray)(),
|
29
|
-
(0, class_validator_1.
|
30
|
-
__metadata("design:type",
|
31
|
-
],
|
32
|
-
|
32
|
+
(0, class_validator_1.ArrayMinSize)(1),
|
33
|
+
__metadata("design:type", Object)
|
34
|
+
], GeometryDto.prototype, "coordinates", void 0);
|
35
|
+
class properties {
|
36
|
+
}
|
37
|
+
__decorate([
|
38
|
+
(0, class_validator_1.IsString)(),
|
39
|
+
(0, class_validator_1.IsNotEmpty)(),
|
40
|
+
__metadata("design:type", String)
|
41
|
+
], properties.prototype, "name", void 0);
|
42
|
+
class FeatureDto {
|
43
|
+
}
|
44
|
+
__decorate([
|
45
|
+
(0, class_validator_1.IsString)(),
|
46
|
+
(0, class_validator_1.IsNotEmpty)(),
|
47
|
+
__metadata("design:type", String)
|
48
|
+
], FeatureDto.prototype, "type", void 0);
|
49
|
+
__decorate([
|
50
|
+
(0, class_validator_1.ValidateNested)(),
|
51
|
+
(0, class_transformer_1.Type)(() => GeometryDto),
|
52
|
+
__metadata("design:type", GeometryDto)
|
53
|
+
], FeatureDto.prototype, "geometry", void 0);
|
54
|
+
__decorate([
|
55
|
+
(0, class_validator_1.IsString)(),
|
56
|
+
(0, class_validator_1.IsNotEmpty)(),
|
57
|
+
__metadata("design:type", String)
|
58
|
+
], FeatureDto.prototype, "id", void 0);
|
59
|
+
__decorate([
|
60
|
+
(0, class_transformer_1.Type)(() => properties),
|
61
|
+
(0, class_validator_1.IsNotEmpty)(),
|
62
|
+
__metadata("design:type", Object)
|
63
|
+
], FeatureDto.prototype, "properties", void 0);
|
64
|
+
exports.FeatureDto = FeatureDto;
|
33
65
|
//# sourceMappingURL=ms-geojson.dto.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ms-geojson.dto.js","sourceRoot":"","sources":["../../../src/ms-geojson/dto/ms-geojson.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,
|
1
|
+
{"version":3,"file":"ms-geojson.dto.js","sourceRoot":"","sources":["../../../src/ms-geojson/dto/ms-geojson.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAwG;AAGxG,MAAa,WAAW;CAIvB;AAHC;IAAC,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;gDACC;AAHhC,kCAIC;AAGD,MAAM,WAAW;CAQhB;AAPC;IAAC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yCACA;AAEb;IAAC,IAAA,yBAAO,GAAE;IACT,IAAA,8BAAY,EAAC,CAAC,CAAC;8BACH,MAAM;gDAAC;AAGtB,MAAM,UAAU;CAIf;AAHC;IAAC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wCACD;AAGd,MAAa,UAAU;CAiBtB;AAhBC;IAAC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wCACA;AAEb;IAAC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,WAAW,CAAC;8BACd,WAAW;4CAAC;AAEtB;IAAC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sCACF;AAGX;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC;IACtB,IAAA,4BAAU,GAAE;;8CACoB;AAhBnC,gCAiBC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Coordinates
|
1
|
+
import { Coordinates } from './dto/ms-geojson.dto';
|
2
2
|
export declare class MsGeoJsonService {
|
3
|
-
validateJson(
|
4
|
-
validateArrayCoordinatesGeoJson(coordinatesPolygon: any, { coordinates }: Coordinates, reverseCoordinates:
|
3
|
+
validateJson(dataGEOJSON: any): Promise<void>;
|
4
|
+
validateArrayCoordinatesGeoJson(coordinatesPolygon: any, { coordinates }: Coordinates, reverseCoordinates: Boolean): Promise<any>;
|
5
5
|
}
|
@@ -11,38 +11,66 @@ const common_1 = require("@nestjs/common");
|
|
11
11
|
const ms_geojson_dto_1 = require("./dto/ms-geojson.dto");
|
12
12
|
const class_validator_1 = require("class-validator");
|
13
13
|
const turf = require("@turf/turf");
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
14
15
|
let MsGeoJsonService = class MsGeoJsonService {
|
15
|
-
validateJson(
|
16
|
+
async validateJson(dataGEOJSON) {
|
16
17
|
var _a;
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
for (const item of dataGEOJSON) {
|
19
|
+
if (((_a = item.geometry) === null || _a === void 0 ? void 0 : _a.coordinates) && Array.isArray(item.geometry.coordinates[0])) {
|
20
|
+
let setCoordinatesValidate = [];
|
21
|
+
for (let cood of item.geometry.coordinates) {
|
22
|
+
let setCood = cood.map(e => {
|
23
|
+
return { coordinate: [e[0], e[1]] };
|
24
|
+
});
|
25
|
+
setCoordinatesValidate.push(setCood);
|
26
|
+
}
|
27
|
+
item.geometry.coordinates = setCoordinatesValidate;
|
28
|
+
}
|
29
|
+
const dto = (0, class_transformer_1.plainToClass)(ms_geojson_dto_1.FeatureDto, item);
|
30
|
+
const errors = await (0, class_validator_1.validate)(dto);
|
31
|
+
if (errors.length > 0) {
|
32
|
+
throw new Error('La entrada de datos es inválida.');
|
33
|
+
}
|
27
34
|
}
|
28
|
-
return dto;
|
29
35
|
}
|
30
36
|
async validateArrayCoordinatesGeoJson(coordinatesPolygon, { coordinates }, reverseCoordinates) {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
const isPointInside = turf.booleanPointInPolygon(pointGeoJSON, polygonGeoJSON);
|
41
|
-
return { isValid: isPointInside };
|
37
|
+
const coordinatesReal = JSON.parse(JSON.stringify(coordinatesPolygon));
|
38
|
+
let response = {
|
39
|
+
index: null,
|
40
|
+
isPointInside: false
|
41
|
+
};
|
42
|
+
await this.validateJson(coordinatesPolygon);
|
43
|
+
let setCoordinates = coordinates;
|
44
|
+
if (reverseCoordinates) {
|
45
|
+
setCoordinates = [coordinates[1], coordinates[0]];
|
42
46
|
}
|
43
|
-
|
44
|
-
|
47
|
+
for (let [i, cood] of coordinatesReal.entries()) {
|
48
|
+
if (cood.geometry.type === "MultiPolygon") {
|
49
|
+
const polygonGeoJSON = turf.multiPolygon(cood.geometry.coordinates);
|
50
|
+
const pointGeoJSON = turf.point(setCoordinates);
|
51
|
+
const isPointInside = turf.booleanPointInPolygon(pointGeoJSON, polygonGeoJSON);
|
52
|
+
if (isPointInside) {
|
53
|
+
response = {
|
54
|
+
index: i,
|
55
|
+
isPointInside
|
56
|
+
};
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
else if (cood.geometry.type === "Polygon") {
|
61
|
+
const polygonGeoJSON = turf.polygon(cood.geometry.coordinates);
|
62
|
+
const pointGeoJSON = turf.point(setCoordinates);
|
63
|
+
const isPointInside = turf.booleanPointInPolygon(pointGeoJSON, polygonGeoJSON);
|
64
|
+
if (isPointInside) {
|
65
|
+
response = {
|
66
|
+
index: i,
|
67
|
+
isPointInside
|
68
|
+
};
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
}
|
45
72
|
}
|
73
|
+
return response;
|
46
74
|
}
|
47
75
|
};
|
48
76
|
MsGeoJsonService = __decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ms-geojson.service.js","sourceRoot":"","sources":["../../src/ms-geojson/ms-geojson.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,
|
1
|
+
{"version":3,"file":"ms-geojson.service.js","sourceRoot":"","sources":["../../src/ms-geojson/ms-geojson.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,yDAA8D;AAC9D,qDAA2C;AAC3C,mCAAmC;AACnC,yDAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAQzB,KAAK,CAAC,YAAY,CAAC,WAAe;;QAChC,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;YAC9B,IAAG,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,WAAW,KAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAC;gBAC3E,IAAI,sBAAsB,GAAG,EAAE,CAAA;gBAC/B,KAAI,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAC;oBACxC,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE;wBACxB,OAAO,EAAC,UAAU,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAA;oBACjC,CAAC,CAAC,CAAA;oBACF,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;iBACrC;gBACD,IAAI,CAAC,QAAQ,CAAC,WAAW,GAAG,sBAAsB,CAAA;aACnD;YACD,MAAM,GAAG,GAAG,IAAA,gCAAY,EAAC,2BAAU,EAAE,IAAI,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,GAAG,CAAC,CAAC;YACnC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAA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AC;gBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;gBAC/E,IAAG,aAAa,EAAC;oBACf,QAAQ,GAAG;wBACT,KAAK,EAAC,CAAC;wBACP,aAAa;qBACd,CAAA;oBACD,MAAK;iBACN;aACF;SAEJ;QACD,OAAO,QAAQ,CAAA;IACnB,CAAC;CAEJ,CAAA;AA5EY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CA4E5B;AA5EY,4CAAgB"}
|
package/dist/ms-pdf/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
export type PaperFormat = 'Legal' | 'Folio' | 'Letter' | 'A3' | 'A4' | 'A5' | 'Tabloid';
|
1
2
|
export type MsPdfDataHeader = {
|
2
3
|
title1?: string;
|
3
4
|
title2?: string;
|
@@ -5,6 +6,7 @@ export type MsPdfDataHeader = {
|
|
5
6
|
urlQr?: string;
|
6
7
|
valueQrCode?: string;
|
7
8
|
hide?: boolean;
|
9
|
+
content?: string;
|
8
10
|
};
|
9
11
|
export type MsPdfDataFooter = {
|
10
12
|
tipoDocumento?: string;
|
@@ -12,6 +14,7 @@ export type MsPdfDataFooter = {
|
|
12
14
|
fechaHora?: string;
|
13
15
|
aprobadoFirmadoTexto?: string;
|
14
16
|
hide?: boolean;
|
17
|
+
content?: string;
|
15
18
|
};
|
16
19
|
type DataToRender = {
|
17
20
|
headerData?: MsPdfDataHeader;
|
@@ -19,7 +22,7 @@ type DataToRender = {
|
|
19
22
|
content: string;
|
20
23
|
};
|
21
24
|
export type MsPdfPageConfig = {
|
22
|
-
format?: string;
|
25
|
+
format?: string | PaperFormat;
|
23
26
|
orientation?: string;
|
24
27
|
width?: string;
|
25
28
|
height?: string;
|