Skip to content

Commit 507e65c

Browse files
author
Hailey Johnson
committed
broken tests :/
1 parent c7e954f commit 507e65c

3 files changed

Lines changed: 16 additions & 19 deletions

File tree

cdm/core/src/main/java/ucar/nc2/ft/point/writer/CFPointWriter.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.beust.jcommander.Parameter;
1010
import com.beust.jcommander.ParameterDescription;
1111
import com.beust.jcommander.ParameterException;
12+
import com.google.common.collect.Iterables;
1213
import com.google.common.collect.Iterators;
1314
import com.google.common.collect.PeekingIterator;
1415
import org.slf4j.Logger;
@@ -266,26 +267,34 @@ private static int writeStationProfileFeatureCollection(FeatureDatasetPoint data
266267
List<Variable> extraVariables = new ArrayList<>();
267268
List<StationFeature> flattenFeatures = new ArrayList<>();
268269

270+
int countProfiles = 0;
271+
int name_strlen = 0;
269272
for (DsgFeatureCollection dsgFeatures : dataset.getPointFeatureCollectionList()) {
270273
extraVariables.addAll(dsgFeatures.getExtraVariables());
271274
flattenFeatures.addAll(((StationProfileFeatureCollection) dsgFeatures).getStationFeatures());
275+
for (StationProfileFeature station : (StationProfileFeatureCollection) dsgFeatures) {
276+
name_strlen = Math.max(name_strlen, station.getName().length());
277+
for (ProfileFeature fp : station) {
278+
countProfiles += Iterables.size((station));
279+
}
280+
}
272281
}
273282

274283
cfWriter.setExtraVariables(extraVariables);
275284
cfWriter.setStations(flattenFeatures);
276-
cfWriter.setFeatureAuxInfo(0, 0);
285+
cfWriter.setFeatureAuxInfo(countProfiles, name_strlen);
277286
cfWriter.writeHeader(flattenFeatures);
278287

279288
int count = 0;
280289
for (DsgFeatureCollection featureCollection : dataset.getPointFeatureCollectionList()) {
281290
cfWriter.resetObsIndex();
282-
for (StationFeature station : ((StationProfileFeatureCollection) featureCollection).getStationFeatures()) {
283-
StationProfileFeature spf = (StationProfileFeature) station;
291+
for (StationProfileFeature station : (StationProfileFeatureCollection) featureCollection) {
284292
cfWriter.resetProfileIndex();
285-
for (ProfileFeature pf : spf) {
293+
station.resetIteration();
294+
for (ProfileFeature pf : station) {
286295
if (pf.getTime() == null)
287296
continue; // assume this means its an "incomplete multidimensional"
288-
count += cfWriter.writeProfile(spf, pf);
297+
count += cfWriter.writeProfile(station, pf);
289298
if (debug && count % 100 == 0)
290299
logger.debug(String.format("%d ", count));
291300
if (debug && count % 1000 == 0)

cdm/core/src/main/java/ucar/nc2/ft/point/writer/WriterCFStationProfileCollection.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package ucar.nc2.ft.point.writer;
77

88
import com.google.common.collect.ImmutableList;
9-
import com.google.common.collect.Iterables;
109
import org.slf4j.Logger;
1110
import org.slf4j.LoggerFactory;
1211
import ucar.ma2.*;
@@ -138,15 +137,6 @@ public void writeHeader(List<StationFeature> stations) throws IOException {
138137
for (StationFeature sf : stnList) {
139138
writeStationData(sf);
140139
stationIndexMap.put(sf.getName(), count);
141-
// for (ProfileFeature p : (StationProfileFeature) sf) {
142-
// int countPoints = 0;
143-
// if (p.size() >= 0) {
144-
// countPoints += p.size();
145-
// } else {
146-
// countPoints += Iterables.size(p);
147-
// }
148-
// writeProfileData(count, p, countPoints);
149-
// }
150140
count++;
151141
}
152142
}

cdm/core/src/main/java/ucar/nc2/ft/point/writer2/WriterCFStationProfileCollection.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ protected void writeHeader(List<StationFeature> stations) throws IOException {
139139
stationIndexMap.put(sf.getName(), count);
140140
for (ProfileFeature p : (StationProfileFeature) sf) {
141141
int countPoints = 0;
142-
if (p.size() >= 0) {
143-
countPoints += p.size();
144-
} else {
145-
countPoints += Iterables.size(p);
142+
for (PointFeature pf : p) {
143+
countPoints++;
146144
}
147145
writeProfileData(count, p, countPoints);
148146
}

0 commit comments

Comments
 (0)