// =====
// Copyright 2007 John Van Vliet, all rights reserved
// Here's my simple license, soon to be replaced by a proper license.
// What you can do:
// - read the code
// - play with the code
// - run the code
// - modify the code
// What you can't do:
// - re-publish the original code or any modified versions
// =====using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTemp
{
class Station
{
public string Country;
public string StationID;
public float Longitude;
public float Latitude;
private SortedList<byte, SortedList<DateTime, float?>> _series;
private Dictionary<byte, float> _seriesOffsets;
internal Station(string countryStation, float longitude, float latitude)
{
Country = countryStation.Substring(0, 3);
StationID = countryStation.Substring(3, 8);
Longitude = longitude;
Latitude = latitude;
_series = new SortedList<byte, SortedList<DateTime, float?>>();
_seriesOffsets = new Dictionary<byte, float>();
}
internal bool ContainsSeries(byte series)
{
return _series.ContainsKey(series);
}
internal void AddSeries(byte series)
{
if (_series.ContainsKey(series)) return;
_series.Add(series, new SortedList<DateTime, float?>());
}
internal SortedList<DateTime, float?> GetReadings(byte series)
{
if (!_series.ContainsKey(series)) return null;
return _series[series];
}
internal IList<byte> SeriesNumbers
{
get { return _series.Keys; }
}
internal void SetSeriesOffset(byte seriesNumber, float offset)
{
_seriesOffsets[seriesNumber] = offset;
}
internal float GetSeriesOffset(byte seriesNumber)
{
if (_seriesOffsets.ContainsKey(seriesNumber))
{
return _seriesOffsets[seriesNumber];
}
else
{
return 0.0f;
}
}
}
}
John V | 20-Sep-07 at 11:50 am | Permalink
There seems to be an issue when the input data contains stations with more than one series. The ouput has twice as many columns as it should.
OpenTemp.org :: 20070916 - First Release | 21-Jan-08 at 7:42 am | Permalink
[…] code is implemented in three files. Use the links below to discuss the code: Cell.cs Station.cs […]