0

CoreLocationユーザーの動きを使用および追跡するアプリがあります。
ユーザーが歩いているか運転しているときに、各座標をローカル データベース (lat/lng/alt) に保存して、保存した座標に基づいてルートを描画できるようにします。
数日前、累積標高ゲインを追加し、このコードを

didLocationUpdate:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    netElevationGain += MAX(0, oldLocation.altitude - newLocation.altitude);
}

しかし、何かが間違っています。
私はアプリケーションを起動し、数マイル歩き回り始め、netElevationGainほぼ 500 メートルに達しました。それは決して正しいことではありません。これは、各ポイントのデータベースに保存され
たリストです。netElevation

0,41,43,44,47,52,55,62,73,80,91,100,114,140,146,153,159,180,199,208,228,240,259,275,320,329,349,359,366,375,381,392,408,419,428,437,446,449,462,469,478,486

高度
0.000000,181.678055,181.891495,182.786850,179.315399,177.035721,182.636307,181.259399,178.653015,192.552551,185.398819,182.693436,181.369766,154.306747,157.031693,159.748871,185.080856,198.080673,176.473877,178.646851,175.784424,178.184128,181.237488,188.956894,177.713181,193.673019,188.470184,182.749054,181.966507,181.547592,191.638657,198.713989,188.582977,197.977921,203.184540,205.108856,198.304123

ゲインを表示するには、単純に使用しますselect max(gain) from table where ...



アップデート

今、私は悪い値を取得します (降順):
Alt:

200.334869,200.594666,196.293945,195.240234,191.800446,192.622375,179.951385,179.185577,179.681122,177.843719,183.459595,174.170502,0.000000

利得:

307,301,294,285,275,269,252,246,234,227,217,202,0
4

1 に答える 1

4

リストした値を取得して、次のように実行しました。

NSArray *altitudes = @[ @(0.000000), @(181.678055), @(181.891495), @(182.786850), @(179.315399), 
                        @(177.035721), @(182.636307), @(181.259399), @(178.653015), @(192.552551), 
                        @(185.398819), @(182.693436), @(181.369766), @(154.306747), @(157.031693), 
                        @(159.748871), @(185.080856), @(198.080673), @(176.473877), @(178.646851), 
                        @(175.784424), @(178.184128), @(181.237488), @(188.956894), @(177.713181), 
                        @(193.673019), @(188.470184), @(182.749054), @(181.966507), @(181.547592), 
                        @(191.638657), @(198.713989), @(188.582977), @(197.977921), @(203.184540), 
                        @(205.108856), @(198.304123) ];

float netAlt = 0.0f;

// Start with the third value as we're only interesting in net gain
for (NSInteger i = 2; i < altitudes.count; i++) {
    float oldAlt = [altitudes[i-1] floatValue];
    float newAlt = [altitudes[i] floatValue];

    // newAlt - oldAlt because we're interested in the 
    // difference between current and previous
    float diff = newAlt - oldAlt;

    netAlt += MAX(0, diff);
    printf("%.0f,", netAlt);
}

これにより、次の出力が生成されました。

0,1,1,1,7,7,7,21,21,21,21,21,23,26,51,64,64,67,67,69,72,80,80,96,96, 96,96,96,106,113,113,122,127,129,129

これは私には合理的で現実的なように思えます。どのようにして値を取得したかはまったく明確ではありません。意味がありません。

于 2013-10-06T15:45:53.613 に答える