private IRtssc GetSelectedRtssc(bool isStartMode) { RadDropDownList ddlRoute = isStartMode ? ddlRouteStart : ddlRouteStop; RadDropDownList ddlTroncon = isStartMode ? ddlTronconStart : ddlTronconStop; RadDropDownList ddlSection = isStartMode ? ddlSectionStart : ddlSectionStop; RadDropDownList ddlSousRoute = isStartMode ? ddlSousRouteStart : ddlSousRouteStop; TextBoxBase mtxtChainageSelection = isStartMode ? mtxtChainageSelectionStart : mtxtChainageSelectionStop; IRtssc rtssc = null; AcquisitionTriggerMode triggerMode = GetSelectedTriggerMode(isStartMode); if (triggerMode == AcquisitionTriggerMode.Rtssc || triggerMode == AcquisitionTriggerMode.RtsscProximity || triggerMode == AcquisitionTriggerMode.EndSection) { var ValidateControl = new Func <RadDropDownList, bool>(ddlControl => ddlControl.SelectedIndex != -1 && ddlControl.SelectedValue.ToString() == ddlControl.Text); if (ValidateControl(ddlRoute) && ValidateControl(ddlTroncon) && ValidateControl(ddlSection) && ValidateControl(ddlSousRoute)) { double chainage; if (!double.TryParse(mtxtChainageSelection.Text, out chainage)) { chainage = 0; } rtssc = new Rtssc( (string)ddlRoute.SelectedValue, (string)ddlTroncon.SelectedValue, (string)ddlSection.SelectedValue, (string)ddlSousRoute.SelectedValue, chainage: chainage); } } return(rtssc); }
public void FillRtss(IRtssc rtssc, DateTime date) { var request = new ObtenirInformationSousRouteRequete { RTSS = rtssc.NumeroRTSS, DateConsultation = date }; ObtenirInformationSousRouteReponse response = this.ObtenirInformationSousRoute(request); int length; if (response.Longueur != null && int.TryParse(response.Longueur, out length)) { rtssc.Longueur = length; } int ide; if (int.TryParse(response.Identifiant, out ide)) { rtssc.Ide = ide; } else { rtssc.Ide = 0; } rtssc.Statut = response.Statut; }
public static DirectionBgr GetEncodedDirection(IRtssc rtssc) { if (rtssc == null) { return(DirectionBgr.Unknown); } if (rtssc.CodeSousRoute == "3" || EstCarrefourGiratoire(rtssc)) { return(DirectionBgr.ForwardChaining); } // driving on right side if (rtssc.CodeCoteChaussee == "D") { return(DirectionBgr.ForwardChaining); } // driving on left side if (rtssc.CodeCoteChaussee == "G") { return(DirectionBgr.BackwardChaining); } // by default, the direction remains unknown return(DirectionBgr.Unknown); }
public override double GetSectionLength(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } using (var cnn = new NpgsqlConnection(this.ConnectionString)) using (var cmd = cnn.CreateCommand()) { cmd.CommandText = @"SELECT longueur FROM reseau_exe WHERE num_rts = :p_route || :p_troncon || :p_section || :p_sousRoute LIMIT 1" ; cmd.Parameters.AddWithValue(":p_route", rtssc.Route); cmd.Parameters.AddWithValue(":p_sousRoute", rtssc.SousRoute); cmd.Parameters.AddWithValue(":p_section", rtssc.Section); cmd.Parameters.AddWithValue(":p_troncon", rtssc.Troncon); cnn.Open(); return(Convert.ToDouble(cmd.ExecuteScalar())); } }
public Rtssc(IRtssc rtssc, double?chainage = null) : this() { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } this.Route = rtssc.Route; this.Troncon = rtssc.Troncon; this.Section = rtssc.Section; this.SousRoute = rtssc.SousRoute; this.Voie = rtssc.Voie; this.Longueur = rtssc.Longueur; this.NumeroRTSS = rtssc.NumeroRTSS; this.CentreDeServiceID = rtssc.CentreDeServiceID; this.CentreDeServiceName = rtssc.CentreDeServiceName; this.DirectionGeneraleID = rtssc.DirectionGeneraleID; this.DirectionGeneraleName = rtssc.DirectionGeneraleName; this.DirectionTerritorialeID = rtssc.DirectionTerritorialeID; this.DirectionTerritorialeName = rtssc.DirectionTerritorialeName; this.Chainage = chainage; }
public static bool EstRoute(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } // I = chaussée créée par la présence d'un îlot séparateur ou déviateur return(rtssc.CodeSousRoute == "0" || rtssc.CodeSousRoute == "I"); }
public static bool EstCarrefourGiratoire(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } // carrefour = "G" return(rtssc.CodeSousRoute == "G"); }
public static bool EstBretelle(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } // bretelle = "3", "4" ou "V" // V = chaussée parallèle à une autoroute qui assure la circulation de transit return(rtssc.CodeSousRoute == "3" || rtssc.CodeSousRoute == "4" || rtssc.CodeSousRoute == "V"); }
private async Task <IRtssc> GetNextRTSSCFromRTSS(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } // By default, start at a 'chaînage' value equal to 5 to increase the probability // that the geoCoordinate returned when querying BGR is the one we are looking for. // Doing the inverse operation, i.e. the RTSS obtained from the geoCoordinate, // should be on the same 'tronçon/section' with approximately the same 'chaînage' value Rtssc rtsscTemp = new Rtssc(rtssc, 5); GeoCoordinate coord = await AgentBroker.Instance.TryExecuteOnFirst <IBgrDirectionalAgent, GeoCoordinate>(agent => agent.GeoCodage(rtsscTemp)).GetValueOrDefault(null); return(await AgentBroker.Instance.TryExecuteOnFirst <IBgrDirectionalAgent, IRtssc>(agent => agent.GetNextRtsscSameDirection(coord)).GetValueOrDefault(null)); }
public override GeoCoordinate GeoCodage(IRtssc rtssc) { if (rtssc == null) { throw new ArgumentNullException("rtssc"); } using (var cnn = new NpgsqlConnection(this.ConnectionString)) using (var cmd = cnn.CreateCommand()) { cmd.CommandText = @"SELECT st_X(the_geom) as x, st_Y(the_geom) as y FROM ( SELECT st_SetSrid(st_MakePoint(:p_x, :p_y), :p_sridIn), :p_sridOut) AS the_geom FROM reseau_exe WHERE (:p_ideSousRoute IS NOT NULL AND ide_sous_r = :p_ideSousRoute) OR (:p_numRts IS NOT NULL AND num_rts = :p_numRts) LIMIT 1 ) t" ; cmd.Parameters.AddWithValue("p_sridIn", SridBgr); cmd.Parameters.AddWithValue("p_sridOut", SridNorthAmerica); cmd.Parameters.AddWithValue("p_ideSousRoute", rtssc.Ide); cmd.Parameters.AddWithValue("p_numRts", rtssc.NumeroRTSS); cnn.Open(); using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult)) { if (reader.Read()) { return new GeoCoordinate { Longitude = Convert.ToDouble(reader["x"]), Latitude = Convert.ToDouble(reader["y"]) } } ; else { return(null); } } } }
public int CompareTo(IRtssc other) { if (other == null) { return(1); } else { int currentCheck; return ((currentCheck = string.Compare(this.Route, other.Route, StringComparison.OrdinalIgnoreCase)) != 0 ? currentCheck : (currentCheck = string.Compare(this.Troncon, other.Troncon, StringComparison.OrdinalIgnoreCase)) != 0 ? currentCheck : (currentCheck = string.Compare(this.Section, other.Section, StringComparison.OrdinalIgnoreCase)) != 0 ? currentCheck : (currentCheck = string.Compare(this.SousRoute, other.SousRoute, StringComparison.OrdinalIgnoreCase)) != 0 ? currentCheck : this.Chainage.GetValueOrDefault().CompareTo(other.Chainage.GetValueOrDefault())); } }
protected override IRtssc ObtenirRtsscSuivant(GeoCoordinate coord, double searchRadiusInMeters, DirectionBgr direction) { if (coord == null) { throw new ArgumentNullException("coord"); } if (searchRadiusInMeters < 0) { throw new ArgumentOutOfRangeException("searchRadiusInMeters", "searchRadiusInMeters must be greater than or equal to 0."); } IRtssc rtssc = GeoCodageInverse(coord); if (rtssc == null) { return(null); } double distance; if (direction == DirectionBgr.ForwardChaining) { distance = rtssc.Longueur - rtssc.Chainage.Value + 1; } else { distance = -1 * (rtssc.Chainage.Value + 5); } long absoluteDistance = Convert.ToInt64(Math.Abs(distance)); rtssc = SelectRtssc(coord, searchRadiusInMeters, DateTime.Now) .Where(r => r.Longueur <= absoluteDistance) .FirstOrDefault(); if (rtssc != null) { rtssc.Chainage = distance >= 0 ? distance : rtssc.Longueur + distance; } return(rtssc); }
public T Geocode <T>(IRtssc rtssc) // dateRef non utilisé where T : GeoCoordinate, new() { double x = 0, y = 0, m = 0; double lat = 0, lon = 0; int identSRoute = 0; // géocodage du rtssc this.GeocodePoint(rtssc.Route, rtssc.Troncon, rtssc.Section, rtssc.SousRoute, (int)rtssc.Chainage.Value, null, "", DateTime.Now, ref x, ref y, ref m, ref identSRoute); // convertion des coordonnées lambert vers GPS this.TransformerCoordonees(x, y, SystemCoordLambert, SystemCoordGps, ref lon, ref lat); return(new T { Longitude = lon, Latitude = lat, Altitude = 0 }); }
public bool Equals(IRtssc other, bool ignoreChainage) { if (other == null) { return(false); } else { bool equals = string.Equals(this.Route, other.Route, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Troncon, other.Troncon, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Section, other.Section, StringComparison.OrdinalIgnoreCase) && string.Equals(this.SousRoute, other.SousRoute, StringComparison.OrdinalIgnoreCase); if (equals && !ignoreChainage) { equals = this.Chainage == other.Chainage; } return(equals); } }
public bool Equals(IRtssc other) { return(Equals(other, false)); }
public static IObservable <IRtssc> GetBgrTraceFromGps(this IObservable <GeoCoordinate> gpsTrace, int bufferSize, BgrDataTypes allowedDataTypes, bool allowSkipIfProcessing, Func <GeoCoordinate, IEnumerable <IRtssc>, IRtssc> geocodageInverse) { if (gpsTrace == null) { throw new ArgumentNullException("gpsTrace"); } if (bufferSize < 0) { throw new ArgumentOutOfRangeException("bufferSize", bufferSize, "bufferSize doit être supérieur ou égal à 0."); } if (geocodageInverse == null) { throw new ArgumentNullException("geocodageInverse"); } var buffer = new Queue <IRtssc>(bufferSize + 1); GeoCoordinate lastCoord = null; IRtssc previous = null; Func <GeoCoordinate, IRtssc> convert = coord => { IRtssc currentRtssc; if (previous != null && coord.Latitude == lastCoord.Latitude && coord.Longitude == lastCoord.Longitude) { currentRtssc = previous; } else { currentRtssc = geocodageInverse(coord, buffer); } if (currentRtssc == null) { return(null); } bool previousAndCurrentAreSameRtss = currentRtssc.Equals(previous, ignoreChainage: true); currentRtssc.Direction = GetEncodedDirection(currentRtssc); // insert into the buffer the original RTSSC // not the current one which will possibly be updated with the most common direction in the buffer var originalRtssc = new Rtssc(currentRtssc); // insert the RTSSC into the buffer only if it is different from the previous RTSS or if the rounded 'chaînage' has changed if (previous == null || !previousAndCurrentAreSameRtss || Convert.ToInt32(originalRtssc.Chainage.GetValueOrDefault()) - Convert.ToInt32(previous.Chainage.GetValueOrDefault()) != 0) { buffer.Enqueue(originalRtssc); } if (buffer.Count > bufferSize) { buffer.Dequeue(); } if (currentRtssc.Direction == DirectionBgr.Unknown) { if (previous != null) { if (previousAndCurrentAreSameRtss) { int compare = currentRtssc.Chainage.GetValueOrDefault().CompareTo(previous.Chainage.GetValueOrDefault()); if (compare > 0) { originalRtssc.Direction = DirectionBgr.ForwardChaining; } else if (compare < 0) { originalRtssc.Direction = DirectionBgr.BackwardChaining; } else { originalRtssc.Direction = DirectionBgr.Unknown; } } currentRtssc.Direction = buffer .Where(r => r.Direction != DirectionBgr.Unknown && r.Equals(currentRtssc, ignoreChainage: true)) .Select(data => (DirectionBgr)data.Direction) .GroupBy(d => d) .OrderByDescending(g => g.Count()) .Select(g => g.Key) .FirstOrDefault(); } } lastCoord = coord; previous = originalRtssc; return(currentRtssc); }; IObservable <IRtssc> output; if (allowSkipIfProcessing) { output = gpsTrace.SkipIfProcessing(coord => Task.Run(() => convert(coord))); } else { output = gpsTrace.Select(convert); } return(output .Where(data => data != null) .Publish() .RefCount()); }
public abstract double GetSectionLength(IRtssc rtssc);
public abstract GeoCoordinate GeoCodage(IRtssc rtssc);
public double GetSectionLength(IRtssc rtssc) { return(this.Provider.GetSectionLength(rtssc)); }
public GeoCoordinate GeoCodage(IRtssc rtssc) { return(this.Provider.GeoCodage(rtssc)); }
private static Task <double> GetSectionLength(IRtssc rtssc) { return(AgentBroker.Instance.TryExecuteOnFirst <IBgrDirectionalAgent, double>(agent => agent.GetSectionLength(rtssc)).GetValueOrDefault(-1)); }
public Rtssc(IRtssc rtssc) : this(rtssc, rtssc.Chainage) { }