@hestia-earth/schema-convert 14.2.0 → 14.3.1
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/json.js +39 -36
- package/package.json +1 -1
package/json.js
CHANGED
|
@@ -243,6 +243,44 @@ var validateGeoJSONFormat = function (value) {
|
|
|
243
243
|
? value
|
|
244
244
|
: null;
|
|
245
245
|
};
|
|
246
|
+
var parseGeoJSONValue = function (value) {
|
|
247
|
+
var result;
|
|
248
|
+
try {
|
|
249
|
+
result = {
|
|
250
|
+
type: 'FeatureCollection',
|
|
251
|
+
features: [{
|
|
252
|
+
type: 'Feature',
|
|
253
|
+
properties: {},
|
|
254
|
+
geometry: wkt_1.wktToGeoJSON(value)
|
|
255
|
+
}]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (e1) {
|
|
259
|
+
try {
|
|
260
|
+
var data = JSON.parse(value);
|
|
261
|
+
return result = ['Polygon', 'MultiPolygon'].includes(data.type)
|
|
262
|
+
? {
|
|
263
|
+
type: 'FeatureCollection',
|
|
264
|
+
features: [{
|
|
265
|
+
type: 'Feature',
|
|
266
|
+
properties: {},
|
|
267
|
+
geometry: data
|
|
268
|
+
}]
|
|
269
|
+
}
|
|
270
|
+
: ['Feature'].includes(data.type)
|
|
271
|
+
? {
|
|
272
|
+
type: 'FeatureCollection',
|
|
273
|
+
features: [__assign(__assign({}, data), { properties: {} // make sure they are set or it is invalid
|
|
274
|
+
})]
|
|
275
|
+
}
|
|
276
|
+
: data;
|
|
277
|
+
}
|
|
278
|
+
catch (e2) {
|
|
279
|
+
return throwError('Unable to parse GeoJSON value. Please make sure the formatting is correct.');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return result ? validateGeoJSONFormat(result) : value;
|
|
283
|
+
};
|
|
246
284
|
/**
|
|
247
285
|
* If the user provided a non-object where an object was expected, assume it was meant to be the `name` property.
|
|
248
286
|
* For Blank Nodes, we assume it is the `term.name`.
|
|
@@ -340,42 +378,7 @@ var propertyTypeToValue = {
|
|
|
340
378
|
? extendDataFromSchema(data, schema, schemaType, _i, includeDefaults)
|
|
341
379
|
: data;
|
|
342
380
|
},
|
|
343
|
-
'http://json.schemastore.org/geojson': function (value) {
|
|
344
|
-
var result;
|
|
345
|
-
try {
|
|
346
|
-
result = {
|
|
347
|
-
type: 'FeatureCollection',
|
|
348
|
-
features: [{
|
|
349
|
-
type: 'Feature',
|
|
350
|
-
properties: {},
|
|
351
|
-
geometry: wkt_1.wktToGeoJSON(value)
|
|
352
|
-
}]
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
catch (e1) {
|
|
356
|
-
try {
|
|
357
|
-
var data = JSON.parse(value);
|
|
358
|
-
return result = ['Polygon', 'MultiPolygon'].includes(data.type)
|
|
359
|
-
? {
|
|
360
|
-
type: 'FeatureCollection',
|
|
361
|
-
features: [{
|
|
362
|
-
type: 'Feature',
|
|
363
|
-
properties: {},
|
|
364
|
-
geometry: data
|
|
365
|
-
}]
|
|
366
|
-
}
|
|
367
|
-
: ['Feature'].includes(data.type)
|
|
368
|
-
? {
|
|
369
|
-
type: 'FeatureCollection',
|
|
370
|
-
features: [__assign(__assign({}, data), { properties: {} // make sure they are set or it is invalid
|
|
371
|
-
})]
|
|
372
|
-
}
|
|
373
|
-
: data;
|
|
374
|
-
}
|
|
375
|
-
catch (e2) { }
|
|
376
|
-
}
|
|
377
|
-
return result ? validateGeoJSONFormat(result) : value;
|
|
378
|
-
}
|
|
381
|
+
'http://json.schemastore.org/geojson': function (value) { return isEmptyCell(value) ? undefined : parseGeoJSONValue(value); }
|
|
379
382
|
};
|
|
380
383
|
var getPropertyDefinition = function (schema, key, ignoreErrors, value) {
|
|
381
384
|
if (ignoreErrors === void 0) { ignoreErrors = false; }
|