File tree Expand file tree Collapse file tree 4 files changed +36
-10
lines changed Expand file tree Collapse file tree 4 files changed +36
-10
lines changed Original file line number Diff line number Diff line change @@ -132,11 +132,12 @@ The most important methods are:
132
132
import { Formatters } from ' @radiantearth/stac-fields' ;
133
133
Formatters .allowHtmlInCommonMark = false ;
134
134
```
135
+ * CrsCode (CRS Codes such as ` EPSG:1234 ` )
135
136
* CSV (array to comma-separated values)
136
137
* Date
137
138
* DOI (generate a link for a DOI)
138
139
* Duration (ISO 8601 duration)
139
- * EPSG (generate a link for an EPSG code)
140
+ * EPSG (generate a link for an EPSG code - deprecated in favor of CrsCode )
140
141
* Extent (array with two values formatted as range)
141
142
* FileDataType (explains the data types defined in the file extension)
142
143
* FileSize (formats a number of bytes into kB, MB, ...)
Original file line number Diff line number Diff line change 6
6
" https://stac-extensions.github.io/file/v1.0.0/schema.json" ,
7
7
" https://stac-extensions.github.io/view/v1.0.0/schema.json" ,
8
8
" https://stac-extensions.github.io/contacts/v0.1.1/schema.json" ,
9
- " https://stac-extensions.github.io/themes/v1.0.0/schema.json"
9
+ " https://stac-extensions.github.io/themes/v1.0.0/schema.json" ,
10
+ " https://stac-extensions.github.io/projection/v2.0.0/schema.json"
10
11
],
11
12
"id" : " LC08_L1TP_107018_20181001_20181001_01_RT" ,
12
13
"type" : " Feature" ,
62
63
"language" : {
63
64
"code" : " en"
64
65
},
66
+ "proj:code" : " EPSG:4326" ,
65
67
"file:checksum" : " 1114a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" ,
66
68
"file:data_type" : " uint16" ,
67
69
"file:size" : 2048 ,
Original file line number Diff line number Diff line change 1151
1151
"format" : " EPSG" ,
1152
1152
"summary" : " v"
1153
1153
},
1154
+ "proj:code" : {
1155
+ "label" : " Code" ,
1156
+ "format" : " CrsCode" ,
1157
+ "summary" : " v"
1158
+ },
1154
1159
"proj:wkt2" : {
1155
1160
"label" : " WKT2" ,
1156
1161
"explain" : " Well-Known Text, version 2" ,
Original file line number Diff line number Diff line change @@ -325,18 +325,36 @@ const Formatters = {
325
325
} ) ;
326
326
} ,
327
327
328
- formatEPSG ( value ) {
329
- // Remove leading 'epsg:' which people sometimes prepend
328
+ formatCrsCode ( value ) {
330
329
if ( typeof value === 'string' ) {
331
- value = value . replace ( / ^ e p s g : / i, '' ) ;
330
+ const [ authority , code ] = value . split ( ':' , 2 ) ;
331
+ switch ( authority . toUpperCase ( ) ) {
332
+ case 'EPSG' :
333
+ case 'ESRI' :
334
+ case 'IAU_2015' :
335
+ case 'IGNF' :
336
+ case 'MKG' :
337
+ case 'OGC' :
338
+ return _ . toLink ( `https://spatialreference.org/ref/${ authority . toLowerCase ( ) } /${ code } /` , value ) ;
339
+ default :
340
+ return DataTypes . string ( value ) ;
341
+ }
332
342
}
333
- value = parseInt ( value , 10 ) ;
334
- if ( value > 0 ) {
335
- return _ . toLink ( `http://epsg.io/${ value } ` , value ) ;
343
+
344
+ return DataTypes . null ( ) ;
345
+ } ,
346
+
347
+ /**
348
+ * @deprecated Use formatCrsCode instead
349
+ */
350
+ formatEPSG ( value ) {
351
+ if ( typeof value === 'number' ) {
352
+ return Formatters . formatCrsCode ( `EPSG:${ value } ` ) ;
336
353
}
337
- else {
338
- return DataTypes . null ( ) ;
354
+ else if ( typeof value === 'string' ) {
355
+ return Formatters . formatCrsCode ( value ) ;
339
356
}
357
+ return DataTypes . null ( ) ;
340
358
} ,
341
359
342
360
formatExtent ( value , field , spec = { } ) {
You can’t perform that action at this time.
0 commit comments