Skip to content

Commit b391b15

Browse files
author
Thomas
committed
added fix so that nested l2-parameters in L2 process work again
1 parent d01ec02 commit b391b15

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

calvalus-processing/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
<groupId>org.esa.snap</groupId>
7878
<artifactId>snap-binning</artifactId>
7979
</dependency>
80+
<dependency>
81+
<groupId>org.esa.snap</groupId>
82+
<artifactId>snap-python</artifactId>
83+
</dependency>
8084
<dependency>
8185
<groupId>org.esa.snap</groupId>
8286
<artifactId>snap-envisat-reader</artifactId>

calvalus-processing/src/main/java/com/bc/calvalus/processing/beam/SnapOperatorAdapter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.esa.snap.core.gpf.OperatorSpi;
3131
import org.esa.snap.core.gpf.annotations.ParameterBlockConverter;
3232
import org.esa.snap.core.gpf.annotations.ParameterDescriptorFactory;
33+
import org.esa.snap.python.gpf.PyOperator;
3334

3435
import java.io.File;
3536
import java.io.IOException;
@@ -153,8 +154,8 @@ private Product getProcessedProduct(Product source, Product[] inputProducts, Str
153154
// transform request into parameter objects
154155
Map<String, Object> parameterMap;
155156
try {
156-
//parameterMap = getOperatorParameterMap(source, operatorName, operatorParameters);
157-
parameterMap = getOperatorParameterMap(source, null, operatorParameters);
157+
parameterMap = getOperatorParameterMap(source, operatorName, operatorParameters);
158+
// parameterMap = getOperatorParameterMap(source, null, operatorParameters);
158159
for (int i=0; i<getInputParameters().length; i+=2) {
159160
if ("output".equals(getInputParameters()[i])) {
160161
// drop parameter, is used later in SubsetProcessorAdapter
@@ -199,8 +200,8 @@ public static Map<String, Object> getOperatorParameterMap(Product inputProduct,
199200
} else {
200201
parameterBlockConverter = new ParameterBlockConverter();
201202
}
202-
if (operatorName != null) {
203-
Class<? extends Operator> operatorClass = getOperatorClass(operatorName);
203+
Class<? extends Operator> operatorClass = getOperatorClass(operatorName);
204+
if (!isPythonOperator(operatorClass)) {
204205
return parameterBlockConverter.convertXmlToMap(level2Parameters, operatorClass);
205206
} else {
206207
DomElement dom = parameterBlockConverter.convertXmlToDomElement(level2Parameters);
@@ -213,6 +214,10 @@ public static Map<String, Object> getOperatorParameterMap(Product inputProduct,
213214
}
214215
}
215216

217+
private static boolean isPythonOperator(Class<? extends Operator> operatorClass) {
218+
return PyOperator.class.isAssignableFrom(operatorClass);
219+
}
220+
216221
private static Class<? extends Operator> getOperatorClass(String operatorName) {
217222
OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operatorName);
218223
if (operatorSpi == null) {

0 commit comments

Comments
 (0)