コード例 #1
0
 /// <summary>
 /// Constructor, generates PartitionKey and Id, sets defaults
 /// </summary>
 /// <remarks>PartitionKey = {project}_{areaOfInterest}_{name}</remarks>
 /// <remarks>If timestep == null: Id = {areaOfInterest}_{name}_{dateTime.ToString("o")}</remarks>
 /// <remarks>If timestep != null: Id = {areaOfInterest}_{name}_Ts{timestep}_{dateTime.ToString("o")}</remarks>
 public MeasurementV2(
     string type, string name,
     string schema, string project,
     string areaOfInterest, LocationV2 location,
     DateTime dateTime,
     List <PhysicalQuantityV2> physicalQuantities,
     int?timestep)
 {
     PartitionKey       = $"{project}_{areaOfInterest}_{name}";
     Id                 = $"{areaOfInterest}_{name}{(timestep != null ? ("_Ts" + timestep.ToString()) : "")}_{dateTime.ToString("o")}";
     Type               = type;
     Name               = name;
     Schema             = schema;
     Project            = project;
     this._rid          = "";
     this._self         = "";
     this._etag         = "";
     this._attachments  = "";
     this._ts           = null;
     AreaOfInterest     = areaOfInterest;
     Location           = location;
     DateTime           = dateTime;
     PhysicalQuantities = physicalQuantities;
     TimestepSec        = timestep;
 }
コード例 #2
0
 /// <summary>
 /// Constructor, generates PartitionKey and Id
 /// </summary>
 /// <remarks>PartitionKey = {project}_{areaOfInterest}_{name}</remarks>
 /// <remarks>Id = {areaOfInterest}_{name}_{dateTime.ToString("o")}</remarks>
 public MeasurementV2(
     string type, string name,
     string schema, string project, string rid,
     string self, string etag, string attachments,
     int?ts, string areaOfInterest, LocationV2 location,
     DateTime dateTime,
     List <PhysicalQuantityV2> physicalQuantities,
     int?timestep)
 {
     PartitionKey       = $"{project}_{areaOfInterest}_{name}";
     Id                 = $"{areaOfInterest}_{name}_{dateTime.ToString("o")}";
     Type               = type;
     Name               = name;
     Schema             = schema;
     Project            = project;
     this._rid          = rid;
     this._self         = self;
     this._etag         = etag;
     this._attachments  = attachments;
     this._ts           = ts;
     AreaOfInterest     = areaOfInterest;
     Location           = location;
     DateTime           = dateTime;
     PhysicalQuantities = physicalQuantities;
     TimestepSec        = timestep;
 }
コード例 #3
0
        private MeasurementV2 CreateMeasurementFromVariable(
            Variable variable,
            IObservation observation,
            Metadata metadata)
        {
            // Look up property based on string, get value
            var value = observation
                        .GetType()
                        .GetProperty(
                variable.FieldName
                .Replace("(", "")
                .Replace(")", ""))
                        .GetValue(observation, null);

            // Ensure value is a number
            if (!(value is double? ||
                  value is decimal?||
                  value is int? ||
                  value is null))
            {
                return(null);
            }

            string name = map.GetMeasurementName(variable.FieldName);

            // Check if variable is in list to be mapped
            if (String.IsNullOrEmpty(name))
            {
                return(null);
            }

            DateTime measurementDateTime =
                new DateTime(observation.TIMESTAMP.Ticks, DateTimeKind.Utc);

            List <PhysicalQuantityV2> physicalQuantities =
                new List <PhysicalQuantityV2>()
            {
                new PhysicalQuantityV2(
                    (double?)value,
                    variable.Units,
                    DateTime.UtcNow,
                    EtlEventId)
            };

            LocationV2 location = new LocationV2("Point",
                                                 map.GetLatFromStation(metadata),
                                                 map.GetLonFromStation(metadata));

            string areaOfInterest = map.GetFieldID(metadata);

            MeasurementV2 m = new MeasurementV2(
                DocumentType,
                name,
                Schema,
                Project,
                areaOfInterest,
                location,
                measurementDateTime,
                physicalQuantities,
                Timestep);

            return(m);
        }