2

Ich habe Benutzer aktuellen Standort dh CLLocation Coordinate (Standort lat & lang) und Benutzer ist auf Rennstrecke in eine Richtung mit Hilfe des Benutzers aktuellen Standort Ich habe eine Region jetzt erstellt Ich möchte etwas mehr Rennstreckenkoordinaten (zB 2m, 4m, 6m von der Rennstrecke in senkrechter Richtung) und die Strecke ist 10 m lang. Bitte überprüfen Sie das Bild und die roten Punkte sind auf der Spur. Please check this imageErzeuge senkrechten Lat lange von einzelnen clocation Koordinate von X Meter

+0

alle Updates zu diesem Thema? – StefanS

Antwort

0
/** 
* Returns the destination point from initial point having travelled the given distance on the 
* given initial bearing (bearing normally varies around path followed). 
* 
* @param {double} distance - Distance travelled, in same units as earth radius (default: metres). 
* @param {double} bearing - Initial bearing in degrees from north. 
* 
* @returns {CLLocationCoordinate} Destination point. 
*/ 

#define kEarthRadius 6378137 

- (CLLocationCoordinate2D)destinationPointWithStartingPoint:(MKMapPoint)initialPoint distance:(double)distance andBearing:(double)bearing { 
    CLLocationCoordinate2D location = MKCoordinateForMapPoint(initialPoint); 

    double delta = distance/kEarthRadius; 
    double omega = [self degreesToRadians:bearing]; 

    double phi1 = [self degreesToRadians:location.latitude]; 
    double lambda1 = [self degreesToRadians:location.longitude]; 

    double phi2 = asin(sin(phi1)*cos(delta) + cos(phi1) * sin(delta) * cos(omega)); 
    double x = cos(delta) - sin(phi1) * sin(phi2); 
    double y = sin(omega) * sin(delta) * cos(phi1); 
    double lambda2 = lambda1 + atan2(y, x); 

    return CLLocationCoordinate2DMake([self radiansToDegrees:phi2], ([self radiansToDegrees:lambda2]+540)%360-180); 
} 

- (CLLocationCoordinate2D)rhumbDestinationPointForInitialPoint:(MKMapPoint)initialPoint distance:(double)distance andBearing:(double)bearing { 
    CLLocationCoordinate2D location = MKCoordinateForMapPoint(initialPoint); 

    double delta = distance/kEarthRadius; 
    double omega = [self degreesToRadians:bearing]; 

    double phi1 = [self degreesToRadians:location.latitude]; 
    double lambda1 = [self degreesToRadians:location.longitude]; 

    double delta_phi = delta * cos(omega); 
    double phi2 = phi1 + delta_phi; 

    // check for some daft bugger going past the pole, normalise latitude if so 
    if (fabs(phi2) > M_PI/2) { 
    phi2 = phi2 > 0 ? M_PI-phi2 : -M_PI-phi2; 
    } 

    double delta_gamma = log(tan(phi2/2+M_PI/4)/tan(phi1/2+M_PI/4)); 
    double q = fabs(delta_gamma) > 10e-12 ? delta_phi/delta_gamma : cos(phi1); 

    double delta_lambda = delta*sin(omega)/q; 
    double lambda2 = lambda1 + delta_lambda; 

    return CLLocationCoordinate2DMake([self radiansToDegrees:phi2], ([self radiansToDegrees:lambda2]+540)%360-180); 
} 

- (double)degreesToRadians:(double)degrees { 
    return degrees * M_PI/180.0; 
} 

- (double)radiansToDegrees:(double)radians { 
    return radians * 180.0/M_PI; 
} 

Adapted from: http://www.movable-type.co.uk/scripts/latlong.html
Mehr Informationen über Lager: https://en.wikipedia.org/wiki/Bearing_(navigation)
Und Loxodrome: https://en.wikipedia.org/wiki/Rhumb_line

+1

stackoverflow ist als Anleitung gedacht, nicht um ganz spezifische Lösungen zu geben! – GreatDane