@osimatic/helpers-js 1.4.3 → 1.4.4
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/location.js +8 -0
- package/package.json +1 -1
package/location.js
CHANGED
|
@@ -429,6 +429,10 @@ class PostalAddress {
|
|
|
429
429
|
|
|
430
430
|
class Polygon {
|
|
431
431
|
static format(geoJsonPolygon) {
|
|
432
|
+
if (typeof geoJsonPolygon == 'string') {
|
|
433
|
+
geoJsonPolygon = JSON.parse(geoJsonPolygon);
|
|
434
|
+
}
|
|
435
|
+
|
|
432
436
|
const rings = geoJsonPolygon.coordinates || [];
|
|
433
437
|
const ring0 = rings[0] || [];
|
|
434
438
|
const n = ring0.length ? ring0.length - (JSON.stringify(ring0[0])===JSON.stringify(ring0[ring0.length-1]) ? 1 : 0) : 0;
|
|
@@ -504,6 +508,10 @@ class GeographicCoordinates {
|
|
|
504
508
|
}
|
|
505
509
|
|
|
506
510
|
static formatPoint(geoJsonPoint, fractionDigit=6) {
|
|
511
|
+
if (typeof geoJsonPoint == 'string') {
|
|
512
|
+
geoJsonPoint = JSON.parse(geoJsonPoint);
|
|
513
|
+
}
|
|
514
|
+
|
|
507
515
|
const [long, lat] = geoJsonPoint.coordinates || [];
|
|
508
516
|
if (typeof long == 'undefined' || typeof lat == 'undefined') {
|
|
509
517
|
return '';
|