public static bool TryParse(string s, out GpsLocation result) { result = new GpsLocation(); if (string.IsNullOrEmpty(s)) { return(false); } int pos = 0; double latitude = double.NaN; double longitude = double.NaN; if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude)) { return(false); } if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude)) { return(false); } if (!IsValidLatitude(latitude) || !IsValidLongitude(longitude)) { return(false); } result.Latitude = latitude; result.Longitude = longitude; return(true); }
protected void processGpsMessage(string gpsMessage) { short status = nmeaParser.Parse(gpsMessage); switch (status) { case NmeaParser.LOCATION: if (locationChanged != null) { GpsLocation gpsLoc = this.nmeaParser.getLocationData(); if (gpsLoc != null) { locationChanged(gpsLoc); } } break; case NmeaParser.SATELLITE: if (satellitesChanged != null) { //satellitesChanged(gpsSatelites); } break; case NmeaParser.UNRECOGNIZED: break; case NmeaParser.CHECKSUM_INVALID: break; } }
public override bool Equals(object obj) { if (!(obj is GpsLocation)) { return(false); } GpsLocation other = (GpsLocation)obj; return(this.Latitude == other.Latitude && this.Longitude == other.Longitude); }
// images - hashtable (Point => Bitmap) public MapView(GpsLocation gpsLocation, Point centerImgPosition, Hashtable viewParts, Point[] orderingPoints) { // check if view parts contains center image if (viewParts[new Point(1, 1)] == null) throw new Exception("Can't instantiate map view without center image!"); this.gpsLocation = gpsLocation; this.viewParts = viewParts; this.centerImgPosition = centerImgPosition; this.orderingPoints = orderingPoints; }
public GpsLocation getLocationData() { GpsLocation gpsLoc = new GpsLocation( RecivedData.SatelliteTime, RecivedData.LatitudeString, RecivedData.LongitudeString, RecivedData.Speed, RecivedData.Course ); return(gpsLoc); }
public bool isLocationSignificant(GpsLocation newLocation) { if (gpsLocationsCache.Count == 0) { // when there is no cache location new location must be significant return true; } double deltaLocation = getLocationsDistance(gpsLocationsCache[0], newLocation); // if distance is to small skip processing if (deltaLocation < MIN_DELTA_LOCATION) { Debug.WriteLine("delta location to small.", this.ToString()); return false; } return true; }
public void update(GpsLocation currentGpsLocation, MapPackage currentMapPkg, int currentZoom) { this.currentGpsLocation = currentGpsLocation; this.currentMapPkg = currentMapPkg; this.currentZoom = currentZoom; }
public void setGpsLocation(GpsLocation gpsLocation) { this.gpsLocation = gpsLocation; }
public bool isValidForGpsLocation(GpsLocation gpsLoc) { return this.centerImgArea.contains(gpsLoc.getLatitude(), gpsLoc.getLongitude()); }
public void newPosition(GpsLocation gpsLocation) { // when gps location isn't known (invalid) skip processing if (!gpsLocation.isValid()) return; // when delta location is to small skip processing if (!this.gpsDataAnalyzer.isLocationSignificant(gpsLocation)) return; // add location to gps data analyzer this.gpsDataAnalyzer.addGpsLocation(gpsLocation); // set current gps location this.currentGpsLocation = gpsLocation; // update current map package retrieveCurrentMapPkg(); // when there is no map for location stop processing if (this.currentMapPkg == null) return; // update map view builder this.mapViewBuilder.update(currentGpsLocation, currentMapPkg, currentZoom); // update current map view or create new one if current doesn't match gps location if (mapViewBuilder.getResult() != null && mapViewBuilder.getResult().isValidForGpsLocation(this.currentGpsLocation)) { // when current map view match gps location update it mapViewBuilder.adjustCurrent(); } else { // create new map view when current doesn't match gps location mapViewBuilder.createNew(); if (this.loadingEventMsg != "") mapLoaded(); // find current named area for pois by current gps location findCurrentArea(); // find and set pois on newly created map view mapViewBuilder.loadPois(); } // update current map view estimated course mapViewBuilder.loadCourse(); // update current map view target mapViewBuilder.loadTarget(); if (mapViewBuilder.getResult() != null) { // display map view this.mapDisplayer.displayView(mapViewBuilder.getResult()); } }
private double getLocationsDistance(GpsLocation gl1, GpsLocation gl2) { // distance between two points return Math.Sqrt(Math.Pow(gl2.getLatitude() - gl1.getLatitude(), 2) + Math.Pow(gl2.getLongitude() - gl1.getLongitude(), 2)); }
public void addGpsLocation(GpsLocation gpsLoc) { gpsLocationsCache.Insert(0, gpsLoc); removeExcess(); }
public static bool TryParse(string s, out GpsLocation result) { result = new GpsLocation(); if (string.IsNullOrEmpty(s)) return false; int pos = 0; double latitude = double.NaN; double longitude = double.NaN; if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude)) return false; if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude)) return false; if (!IsValidLatitude(latitude) || !IsValidLongitude(longitude)) return false; result.Latitude = latitude; result.Longitude = longitude; return true; }
public void locationChanged(GpsLocation gpsLoc) { this.currentGpsLocation = gpsLoc; Invoke(this.updatePosHandler); }
public GpsLocation getLocationData() { GpsLocation gpsLoc = new GpsLocation( RecivedData.SatelliteTime, RecivedData.LatitudeString, RecivedData.LongitudeString, RecivedData.Speed, RecivedData.Course ); return gpsLoc; }