Skip to content

Commit

Permalink
Addresses #187 by correctly outputting a matrix from an asc file
Browse files Browse the repository at this point in the history
From now on (refer to the issue for context):
- write grid_data.contents will return a geometry (the enclosing envelope)
- write grid_data as matrix will return the matrix<float> of the values
- write grid_data as field will return the same values
  • Loading branch information
AlexisDrogoul committed Aug 31, 2024
1 parent 771e2cd commit f99d18c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gama.core/src/gama/core/util/file/GamaGridFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import gama.core.util.matrix.GamaField;
import gama.core.util.matrix.GamaFloatMatrix;
import gama.core.util.matrix.IField;
import gama.core.util.matrix.IMatrix;
import gama.gaml.statements.Facets;
import gama.gaml.types.GamaGeometryType;
import gama.gaml.types.IType;
Expand Down Expand Up @@ -353,7 +354,7 @@ private void customAscReader(final IScope scope) {
ascInfo[2] = xCorner;
} else if (yCorner == null && yCenter == null && line.contains("yllcorner")) {
yCorner = doubleVal(line);
//TODO: very suspicious, probably xllcenter and yllcenter
// TODO: very suspicious, probably xllcenter and yllcenter
} else if (xCorner == null && xCenter == null && line.contains("xllcorner")) { // AD To verify: the
// conditions are
// the same as two
Expand Down Expand Up @@ -849,4 +850,11 @@ public double[] getBand(final IScope scope, final int index) {
return Arrays.copyOf(records.bands.get(index), length(scope));
}

@Override
protected IMatrix _matrixValue(final IScope scope, final IType contentsType, final GamaPoint preferredSize,
final boolean copy) throws GamaRuntimeException {
getContents(scope);
return new GamaField(scope, this);
}

}

0 comments on commit f99d18c

Please sign in to comment.