Skip to content

Commit e96f960

Browse files
committed
Scope WRS helpers; update .gitignore
Moved WRS_ASSETS, WRS1_SPACECRAFT and related helper functions (imageStringProperty, isWrs1LandsatImage, wrsCollectionForSystem, matchCleanWrsFeature) into exports.createFunction in Algorithms/Landsat/cropToOverlapFree to avoid top-level globals. Updated .gitignore to ignore local logs, coverage/ and README.md. Changes preserve existing behavior while reducing global scope pollution.
1 parent e5103b5 commit e96f960

2 files changed

Lines changed: 49 additions & 44 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ yarn-error.log*
2323
doc.json
2424
openEEL_doc
2525
loadAll
26+
27+
# Local reports and coverage output.
28+
*.log
29+
coverage/
30+
README.md
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
// SPDX-License-Identifier: MIT
22

3-
var WRS_ASSETS = {
4-
WRS1: 'projects/openearthengine/assets/WRS/LANDSAT_WRS1_CUT_10KM',
5-
WRS2: 'projects/openearthengine/assets/WRS/LANDSAT_WRS2_CUT_10KM'
6-
};
7-
8-
var WRS1_SPACECRAFT = ee.List(['LANDSAT_1', 'LANDSAT_2', 'LANDSAT_3']);
9-
103
var inputs = [
114
{
125
name: 'landsatCollection',
@@ -32,42 +25,6 @@ var reference = {
3225
contributors: ['Mathieu Gravey']
3326
};
3427

35-
function imageStringProperty(image, propertyName, fallback) {
36-
return ee.String(ee.Algorithms.If(
37-
image.propertyNames().contains(propertyName),
38-
image.get(propertyName),
39-
fallback
40-
));
41-
}
42-
43-
function isWrs1LandsatImage(image) {
44-
return WRS1_SPACECRAFT.contains(imageStringProperty(image, 'SPACECRAFT_ID', ''));
45-
}
46-
47-
function wrsCollectionForSystem(isWrs1) {
48-
var wrs1 = ee.FeatureCollection(WRS_ASSETS.WRS1);
49-
var wrs2 = ee.FeatureCollection(WRS_ASSETS.WRS2);
50-
51-
return ee.FeatureCollection(ee.Algorithms.If(
52-
isWrs1,
53-
wrs1,
54-
wrs2
55-
));
56-
}
57-
58-
function matchCleanWrsFeature(image, wrs) {
59-
var path = ee.Number(image.get('WRS_PATH'));
60-
var row = ee.Number(image.get('WRS_ROW'));
61-
62-
return wrs.filter(ee.Filter.and(
63-
ee.Filter.eq('PATH', path),
64-
ee.Filter.or(
65-
ee.Filter.eq('ROW', row),
66-
ee.Filter.eq('ROW_', row)
67-
)
68-
));
69-
}
70-
7128
exports.createDocumentation = function() {
7229
return {
7330
inputs: inputs,
@@ -76,6 +33,49 @@ exports.createDocumentation = function() {
7633
};
7734

7835
exports.createFunction = function(internal, relPath, oeel) {
36+
var WRS_ASSETS = {
37+
WRS1: 'projects/openearthengine/assets/WRS/LANDSAT_WRS1_CUT_10KM',
38+
WRS2: 'projects/openearthengine/assets/WRS/LANDSAT_WRS2_CUT_10KM'
39+
};
40+
41+
var WRS1_SPACECRAFT = ee.List(['LANDSAT_1', 'LANDSAT_2', 'LANDSAT_3']);
42+
43+
function imageStringProperty(image, propertyName, fallback) {
44+
return ee.String(ee.Algorithms.If(
45+
image.propertyNames().contains(propertyName),
46+
image.get(propertyName),
47+
fallback
48+
));
49+
}
50+
51+
function isWrs1LandsatImage(image) {
52+
return WRS1_SPACECRAFT.contains(imageStringProperty(image, 'SPACECRAFT_ID', ''));
53+
}
54+
55+
function wrsCollectionForSystem(isWrs1) {
56+
var wrs1 = ee.FeatureCollection(WRS_ASSETS.WRS1);
57+
var wrs2 = ee.FeatureCollection(WRS_ASSETS.WRS2);
58+
59+
return ee.FeatureCollection(ee.Algorithms.If(
60+
isWrs1,
61+
wrs1,
62+
wrs2
63+
));
64+
}
65+
66+
function matchCleanWrsFeature(image, wrs) {
67+
var path = ee.Number(image.get('WRS_PATH'));
68+
var row = ee.Number(image.get('WRS_ROW'));
69+
70+
return wrs.filter(ee.Filter.and(
71+
ee.Filter.eq('PATH', path),
72+
ee.Filter.or(
73+
ee.Filter.eq('ROW', row),
74+
ee.Filter.eq('ROW_', row)
75+
)
76+
));
77+
}
78+
7979
return function() {
8080
var inputDictionary = internal.readInputs(
8181
Array.prototype.slice.call(arguments, 0),
@@ -96,4 +96,4 @@ exports.createFunction = function(internal, relPath, oeel) {
9696
return image.clip(cleanWrsFeature.geometry());
9797
});
9898
};
99-
};
99+
};

0 commit comments

Comments
 (0)