fiscalia_bo-nest-helpers 0.0.27 → 0.0.28
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 +6 -0
- package/dist/ms-geojson/dto/ms-geojson.dto.js +33 -0
- package/dist/ms-geojson/dto/ms-geojson.dto.js.map +1 -0
- package/dist/ms-geojson/index.d.ts +2 -0
- package/dist/ms-geojson/index.js +8 -0
- package/dist/ms-geojson/index.js.map +1 -0
- package/dist/ms-geojson/ms-geojson.module.d.ts +5 -0
- package/dist/ms-geojson/ms-geojson.module.js +35 -0
- package/dist/ms-geojson/ms-geojson.module.js.map +1 -0
- package/dist/ms-geojson/ms-geojson.service.d.ts +5 -0
- package/dist/ms-geojson/ms-geojson.service.js +44 -0
- package/dist/ms-geojson/ms-geojson.service.js.map +1 -0
- package/package.json +2 -1
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.ValidateCoordinatesPolygonDTO = exports.Coordinates = void 0;
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
14
|
+
const class_validator_1 = require("class-validator");
|
15
|
+
class Coordinates {
|
16
|
+
}
|
17
|
+
__decorate([
|
18
|
+
(0, class_transformer_1.Type)(() => Number),
|
19
|
+
(0, class_validator_1.IsArray)(),
|
20
|
+
(0, class_validator_1.IsNumber)({}, { each: true }),
|
21
|
+
__metadata("design:type", Array)
|
22
|
+
], Coordinates.prototype, "coordinates", void 0);
|
23
|
+
exports.Coordinates = Coordinates;
|
24
|
+
class ValidateCoordinatesPolygonDTO {
|
25
|
+
}
|
26
|
+
__decorate([
|
27
|
+
(0, class_transformer_1.Type)(() => Coordinates),
|
28
|
+
(0, class_validator_1.IsArray)(),
|
29
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
30
|
+
__metadata("design:type", Array)
|
31
|
+
], ValidateCoordinatesPolygonDTO.prototype, "polygonCoordinates", void 0);
|
32
|
+
exports.ValidateCoordinatesPolygonDTO = ValidateCoordinatesPolygonDTO;
|
33
|
+
//# sourceMappingURL=ms-geojson.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-geojson.dto.js","sourceRoot":"","sources":["../../../src/ms-geojson/dto/ms-geojson.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAoE;AAEpE,MAAa,WAAW;CAKvB;AAJC;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;gDACC;AAJhC,kCAKC;AAED,MAAa,6BAA6B;CAKzC;AAJC;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,WAAW,CAAC;IACvB,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;yEACG;AAJpC,sEAKC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MsGeoJsonModule = exports.MsGeoJsonService = void 0;
|
4
|
+
var ms_geojson_service_1 = require("./ms-geojson.service");
|
5
|
+
Object.defineProperty(exports, "MsGeoJsonService", { enumerable: true, get: function () { return ms_geojson_service_1.MsGeoJsonService; } });
|
6
|
+
var ms_geojson_module_1 = require("./ms-geojson.module");
|
7
|
+
Object.defineProperty(exports, "MsGeoJsonModule", { enumerable: true, get: function () { return ms_geojson_module_1.MsGeoJsonModule; } });
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ms-geojson/index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var MsGeoJsonModule_1;
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.MsGeoJsonModule = void 0;
|
11
|
+
const common_1 = require("@nestjs/common");
|
12
|
+
const ms_geojson_service_1 = require("./ms-geojson.service");
|
13
|
+
let MsGeoJsonModule = MsGeoJsonModule_1 = class MsGeoJsonModule {
|
14
|
+
static register() {
|
15
|
+
return {
|
16
|
+
module: MsGeoJsonModule_1,
|
17
|
+
imports: [],
|
18
|
+
providers: [ms_geojson_service_1.MsGeoJsonService],
|
19
|
+
exports: [ms_geojson_service_1.MsGeoJsonService],
|
20
|
+
};
|
21
|
+
}
|
22
|
+
static async registerAsync() {
|
23
|
+
return {
|
24
|
+
module: MsGeoJsonModule_1,
|
25
|
+
imports: [],
|
26
|
+
providers: [MsGeoJsonModule_1],
|
27
|
+
exports: [MsGeoJsonModule_1],
|
28
|
+
};
|
29
|
+
}
|
30
|
+
};
|
31
|
+
MsGeoJsonModule = MsGeoJsonModule_1 = __decorate([
|
32
|
+
(0, common_1.Module)({})
|
33
|
+
], MsGeoJsonModule);
|
34
|
+
exports.MsGeoJsonModule = MsGeoJsonModule;
|
35
|
+
//# sourceMappingURL=ms-geojson.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-geojson.module.js","sourceRoot":"","sources":["../../src/ms-geojson/ms-geojson.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,6DAAwD;AAGjD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAI1B,MAAM,CAAC,QAAQ;QACb,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC,qCAAgB,CAAC;YAC7B,OAAO,EAAE,CAAC,qCAAgB,CAAC;SAC5B,CAAC;IACJ,CAAC;IAKD,MAAM,CAAC,KAAK,CAAC,aAAa;QACxB,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC,iBAAe,CAAC;YAC5B,OAAO,EAAE,CAAC,iBAAe,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF,CAAA;AAxBY,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CAwB3B;AAxBY,0CAAe"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { Coordinates, ValidateCoordinatesPolygonDTO } from './dto/ms-geojson.dto';
|
2
|
+
export declare class MsGeoJsonService {
|
3
|
+
validateData(input: any): ValidateCoordinatesPolygonDTO;
|
4
|
+
validateCoordinatesGeoJson(coordinatesPolygon: any, { coordinates }: Coordinates): Promise<any>;
|
5
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.MsGeoJsonService = void 0;
|
10
|
+
const common_1 = require("@nestjs/common");
|
11
|
+
const ms_geojson_dto_1 = require("./dto/ms-geojson.dto");
|
12
|
+
const class_validator_1 = require("class-validator");
|
13
|
+
const turf = require("@turf/turf");
|
14
|
+
let MsGeoJsonService = class MsGeoJsonService {
|
15
|
+
validateData(input) {
|
16
|
+
const dto = new ms_geojson_dto_1.ValidateCoordinatesPolygonDTO();
|
17
|
+
if (Array.isArray(input))
|
18
|
+
dto.polygonCoordinates = input === null || input === void 0 ? void 0 : input.map((coords) => ({ coordinates: coords }));
|
19
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
20
|
+
if (errors.length > 0) {
|
21
|
+
throw new Error('La entrada de datos es inválida.');
|
22
|
+
}
|
23
|
+
return dto;
|
24
|
+
}
|
25
|
+
async validateCoordinatesGeoJson(coordinatesPolygon, { coordinates }) {
|
26
|
+
try {
|
27
|
+
this.validateData(coordinatesPolygon);
|
28
|
+
const polygonCoordinates = coordinatesPolygon;
|
29
|
+
const pointCoordinates = coordinates;
|
30
|
+
const pointGeoJSON = turf.point(pointCoordinates);
|
31
|
+
const polygonGeoJSON = turf.polygon([polygonCoordinates]);
|
32
|
+
const isPointInside = turf.booleanPointInPolygon(pointGeoJSON, polygonGeoJSON);
|
33
|
+
return { isValid: isPointInside };
|
34
|
+
}
|
35
|
+
catch (error) {
|
36
|
+
throw error.message;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
};
|
40
|
+
MsGeoJsonService = __decorate([
|
41
|
+
(0, common_1.Injectable)()
|
42
|
+
], MsGeoJsonService);
|
43
|
+
exports.MsGeoJsonService = MsGeoJsonService;
|
44
|
+
//# sourceMappingURL=ms-geojson.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-geojson.service.js","sourceRoot":"","sources":["../../src/ms-geojson/ms-geojson.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAkF;AAClF,qDAA+C;AAC/C,mCAAmC;AAG5B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAM3B,YAAY,CAAC,KAAU;QACrB,MAAM,GAAG,GAAG,IAAI,8CAA6B,EAAE,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACtB,GAAG,CAAC,kBAAkB,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,CAAC,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC/F,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IASD,KAAK,CAAC,0BAA0B,CAC9B,kBAAuB,EACvB,EAAE,WAAW,EAAe;QAE5B,IAAI;YACF,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;YACtC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;YAC9C,MAAM,gBAAgB,GAAG,WAAW,CAAC;YACrC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAClD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;YAC/E,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;SACnC;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAC,OAAO,CAAC;SACrB;IACH,CAAC;CACF,CAAA;AAxCY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAwC5B;AAxCY,4CAAgB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "fiscalia_bo-nest-helpers",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.28",
|
4
4
|
"author": "UTIC",
|
5
5
|
"contact": {
|
6
6
|
"name": "Unidad de Tecnologías de la Información y Comunicación - Ministerio Público",
|
@@ -13,6 +13,7 @@
|
|
13
13
|
"dist/ms-personas/*",
|
14
14
|
"dist/http-service/*",
|
15
15
|
"dist/services/*",
|
16
|
+
"dist/ms-geojson/*",
|
16
17
|
"dist/helpers/*",
|
17
18
|
"dist/types/*",
|
18
19
|
"dist/index.d.ts",
|