Beispiel #1
0
 public Fact(QualityInformation Quality, SegmentInformation Segment, TemporalInformation Temporal, SpatialInformation Spatial, MeasureInformation Measure)
 {
     this._Quality = Quality;
     this._Segment = Segment;
     this.Temporal = Temporal;
     this.Spatial = Spatial;
     this.Measure = Measure;
 }
Beispiel #2
0
 public Fact(Int64 EntryId, int CarId, Int64 TripId, QualityInformation Quality, SegmentInformation Segment, TemporalInformation Temporal, SpatialInformation Spatial, MeasureInformation Measure, FlagInformation Flag)
 {
     this._EntryId = EntryId;
     this.CarId = CarId;
     this._TripId = TripId;
     this._Quality = Quality;
     this._Segment = Segment;
     this.Temporal = Temporal;
     this.Spatial = Spatial;
     this.Measure = Measure;
     this.Flag = Flag;
 }
        public int AddQualityInformation(QualityInformation QI)
        {
            string sql = @"INSERT INTO qualityinformation(satellites, hdop) VALUES (@satellites, @hdop)";

            NpgsqlCommand command = new NpgsqlCommand(sql, Connection);
            command.Parameters.AddWithValue("@satellites", QI.Sat);
            command.Parameters.AddWithValue("@hdop", QI.Hdop);

            return NonQuery(command, "qualityinformation");
        }
Beispiel #4
0
        public Fact(DataRow row)
        {
            if (row.Table.Columns.Contains("entryid")) {
                this._EntryId = row.Field<Int64>("entryid");
            }
            if (row.Table.Columns.Contains("carid")) {
                this.CarId = row.Field<int>("carid");
            }
            if (row.Table.Columns.Contains("tripid")) {
                this._TripId = row.Field<Int64>("tripid");
            }
            /*
            if (row.Table.Columns.Contains("localtripid")) {
                this._LocalTripId = row.Field<Int64>("localtripid");
            }
            */
            //Spatial Information
            if (row.Table.Columns.Contains("distancetolag") && row.Table.Columns.Contains("pathline")) {
                row["distancetolag"] = row["distancetolag"] is DBNull ? -1.0 : row["distancetolag"];
                row["pathline"] = row["pathline"] is DBNull ? null : row["pathline"];

                this.Spatial = new SpatialInformation(new GeoCoordinate(row.Field<double>("latitude"), row.Field<double>("longitude")), (double)row.Field<Single>("distancetolag"), row.Field<PostgisLineString>("pathline"));

            } else if (row.Table.Columns.Contains("pointlatitude")) {
                this.Spatial = new SpatialInformation(new GeoCoordinate(row.Field<double>("pointlatitude"), row.Field<double>("pointlongitude")), this._TripId);

            } else {
                this.Spatial = new SpatialInformation(new GeoCoordinate(row.Field<double>("latitude"), row.Field<double>("longitude")));
            }

            //Temporal Information
            if (row.Table.Columns.Contains("secondstolag")) {
                row["secondstolag"] = row["secondstolag"] is DBNull ? 0 : row["secondstolag"];
                this.Temporal = new TemporalInformation(DateTimeHelper.ConvertToDateTime(row.Field<int>("dateid"), row.Field<int>("timeid")), new TimeSpan(0, 0, row.Field<Int16>("secondstolag")));
            } else {
                this.Temporal = new TemporalInformation(DateTimeHelper.ConvertToDateTime(row.Field<int>("dateid"), row.Field<int>("timeid")));
            }

            //Measure Information
            if (row.Table.Columns.Contains("speed") && row.Table.Columns.Contains("acceleration") && row.Table.Columns.Contains("jerk")) {
                row["speed"] = row["speed"] is DBNull ? 0 : row["speed"];
                row["acceleration"] = row["acceleration"] is DBNull ? 0 : row["acceleration"];
                row["jerk"] = row["jerk"] is DBNull ? 0 : row["jerk"];
                this.Measure = new MeasureInformation((double)row.Field<Single>("speed"), (double)row.Field<Single>("acceleration"), (double)row.Field<Single>("jerk"));
            }

            //Flag Information
            if (row.Table.Columns.Contains("speeding")) {
                row["speeding"] = row["speeding"] is DBNull ? false : row["speeding"];
                row["accelerating"] = row["accelerating"] is DBNull ? false : row["accelerating"];
                row["jerking"] = row["jerking"] is DBNull ? false : row["jerking"];
                row["braking"] = row["braking"] is DBNull ? false : row["braking"];
                row["steadyspeed"] = row["steadyspeed"] is DBNull ? false : row["steadyspeed"];
                this.Flag = new FlagInformation(row.Field<bool>("speeding"), row.Field<bool>("accelerating"), row.Field<bool>("jerking"), row.Field<bool>("braking"), row.Field<bool>("steadyspeed"));
            }

            //Segment Information
            if (row.Table.Columns.Contains("segmentid") && row.Table.Columns.Contains("maxspeed")) {
                row["segmentid"] = row["segmentid"] is DBNull ? -1 : row["segmentid"];
                row["maxspeed"] = row["maxspeed"] is DBNull ? -1 : row["maxspeed"];
                this._Segment = new SegmentInformation(row.Field<int>("segmentid"), row.Field<Int16>("maxspeed"));
            }

            //Quality Information
            if (row.Table.Columns.Contains("qualityid") && row.Table.Columns.Contains("satellites") && row.Table.Columns.Contains("hdop")) {
                row["qualityid"] = row["qualityid"] is DBNull ? -1 : row["qualityid"];
                row["satellites"] = row["satellites"] is DBNull ? -1 : row["satellites"];
                row["hdop"] = row["hdop"] is DBNull ? -1 : row["hdop"];
                this._Quality = new QualityInformation(row.Field<Int16>("qualityid"), row.Field<Int16>("satellites"), (double)row.Field<Single>("hdop"));
            } else if (row.Table.Columns.Contains("qualityid")) {
                this._Quality = new QualityInformation(-1, -1, -1);
            }
        }