@@ -9,15 +9,19 @@ Version: **1.3.1**
9
9
Add to your project with ` npm install @radiantearth/stac-fields --save `
10
10
11
11
Import the utilities to format values:
12
+
12
13
``` js
13
14
const StacFields = require (' @radiantearth/stac-fields' );
14
15
```
16
+
15
17
or
18
+
16
19
``` js
17
20
import StacFields from ' @radiantearth/stac-fields' ;
18
21
```
19
22
20
23
Format a value:
24
+
21
25
``` js
22
26
let stacItem = {
23
27
stac_version: ' 1.0.0' ,
@@ -47,12 +51,13 @@ for(let field in stacItem.properties) {
47
51
48
52
// Option 2: Group by extension and format item properties
49
53
// The second parameter is a filter function to skip specific properties or paths, remove to get all properties
50
- let groups = StacFields .formatStacProperties (stacItem, (key , path ) => key !== ' eo:bands' );
54
+ let groups = StacFields .formatItemProperties (stacItem, (key , path ) => key !== ' eo:bands' );
51
55
```
52
56
53
57
To filter by path (remove all common_name fields from bands):
58
+
54
59
``` js
55
- let groups = StacFields .formatStacProperties (stacItem, (key , path ) => ! (path[0 ] === ' eo:bands' && path[2 ] === ' common_name' ));
60
+ let groups = StacFields .formatItemProperties (stacItem, (key , path ) => ! (path[0 ] === ' eo:bands' && path[2 ] === ' common_name' ));
56
61
```
57
62
58
63
This library is written for the latest version of the STAC specification (1.0.0-rc.4).
@@ -157,11 +162,11 @@ Formatters are always functions that have the following signature:
157
162
158
163
` method(value : any, field : string, spec : object, context = null, parent = null) => string `
159
164
160
- - ` value ` is the value of the field in the STAC JSON.
161
- - ` field ` is the key of the field in the STAC JSON.
162
- - ` spec ` is the normalized object for the field from the ` fields.json ` .
163
- - ` context ` is the full STAC JSON.
164
- - ` parent ` is the parent object, if any.
165
+ * ` value ` is the value of the field in the STAC JSON.
166
+ * ` field ` is the key of the field in the STAC JSON.
167
+ * ` spec ` is the normalized object for the field from the ` fields.json ` .
168
+ * ` context ` is the full STAC JSON.
169
+ * ` parent ` is the parent object, if any.
165
170
166
171
The returned value is always expected to be a string.
167
172
It may contain HTML if the formatter is added to the ` htmlFormats ` array in ` fields.json ` .
0 commit comments