@hestia-earth/schema-convert
Advanced tools
Comparing version 14.3.0 to 14.3.1
77
json.js
@@ -246,2 +246,40 @@ "use strict"; | ||
}; | ||
var parseGeoJSONValue = function (value) { | ||
var result; | ||
try { | ||
result = { | ||
type: 'FeatureCollection', | ||
features: [{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: wkt_1.wktToGeoJSON(value) | ||
}] | ||
}; | ||
} | ||
catch (e1) { | ||
try { | ||
var data = JSON.parse(value); | ||
return result = ['Polygon', 'MultiPolygon'].includes(data.type) | ||
? { | ||
type: 'FeatureCollection', | ||
features: [{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: data | ||
}] | ||
} | ||
: ['Feature'].includes(data.type) | ||
? { | ||
type: 'FeatureCollection', | ||
features: [__assign(__assign({}, data), { properties: {} // make sure they are set or it is invalid | ||
})] | ||
} | ||
: data; | ||
} | ||
catch (e2) { | ||
return throwError('Unable to parse GeoJSON value. Please make sure the formatting is correct.'); | ||
} | ||
} | ||
return result ? validateGeoJSONFormat(result) : value; | ||
}; | ||
/** | ||
@@ -344,40 +382,3 @@ * If the user provided a non-object where an object was expected, assume it was meant to be the `name` property. | ||
}, | ||
'http://json.schemastore.org/geojson': function (value) { | ||
var result; | ||
try { | ||
result = { | ||
type: 'FeatureCollection', | ||
features: [{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: wkt_1.wktToGeoJSON(value) | ||
}] | ||
}; | ||
} | ||
catch (e1) { | ||
try { | ||
var data = JSON.parse(value); | ||
return result = ['Polygon', 'MultiPolygon'].includes(data.type) | ||
? { | ||
type: 'FeatureCollection', | ||
features: [{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: data | ||
}] | ||
} | ||
: ['Feature'].includes(data.type) | ||
? { | ||
type: 'FeatureCollection', | ||
features: [__assign(__assign({}, data), { properties: {} // make sure they are set or it is invalid | ||
})] | ||
} | ||
: data; | ||
} | ||
catch (e2) { | ||
return throwError('Unable to parse GeoJSON value. Please make sure the formatting is correct.'); | ||
} | ||
} | ||
return result ? validateGeoJSONFormat(result) : value; | ||
} | ||
'http://json.schemastore.org/geojson': function (value) { return isEmptyCell(value) ? undefined : parseGeoJSONValue(value); } | ||
}; | ||
@@ -384,0 +385,0 @@ var getPropertyDefinition = function (schema, key, ignoreErrors, value) { |
{ | ||
"name": "@hestia-earth/schema-convert", | ||
"version": "14.3.0", | ||
"version": "14.3.1", | ||
"description": "Hestia Schema Converters", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1289
61513