@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } InsituRecord that = (InsituRecord) o; if (Double.compare(that.value, value) != 0) { return false; } if (pos != null ? !pos.equals(that.pos) : that.pos != null) { return false; } if (stationName != null ? !stationName.equals(that.stationName) : that.stationName != null) { return false; } if (time != null ? !time.equals(that.time) : that.time != null) { return false; } return true; }
return false; if (!geoPos.equals(that.geoPos)) { return false;
/** * Returns the name for the given {@link GeoPos}, or an empty string if there is no such name. * @param geoPos the geo position to get the name for * @return the name, or an empty string if no such name exists */ public String getNameFor(GeoPos geoPos) { Iterable<Record> records = recordSource.getRecords(); for (Record record : records) { if (record.getLocation().equals(geoPos)) { return record.getStationName(); } } return ""; }
/** * Returns an array of {@link InsituRecord}s for the given variable name and the given {@link GeoPos}. * @param parameterName the variable name to get the records for * @param position the position to get the records for * @return an array of in-situ records */ public InsituRecord[] getValuesFor(String parameterName, GeoPos position) { final int columnIndex = getIndexForParameter(parameterName); final Iterable<Record> records = recordSource.getRecords(); final List<InsituRecord> parameterRecords = new ArrayList<InsituRecord>(); for (Record record : records) { final GeoPos pos = record.getLocation(); if (position != null && !pos.equals(position)) { continue; } final Date time = record.getTime(); final Double value = (Double) record.getAttributeValues()[columnIndex]; if (value == null) { continue; } final String stationName = record.getStationName() == null ? "" : record.getStationName(); final InsituRecord insituRecord = new InsituRecord(pos, time, stationName, value); parameterRecords.add(insituRecord); } sortRecordsAscending(parameterRecords); return parameterRecords.toArray(new InsituRecord[parameterRecords.size()]); }