🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych.msaccess
Article #137616

Re: Konwersja współrzędnych geograficznych - ciąg dalszy

#137616
From: Zbigniew Bratko
Date: Sun, 24 Jun 2018 08:33
90 lines
3353 bytes
W dniu 2018-06-23 o 17:13, Zbigniew Bratko pisze:
> W dniu 2018-06-23 o 10:20, Phantom pisze:
>> Witam
>>
>> dotyczy: przeliczania wartości duble na stopnie
>>
>> W poprzedniej konwersacji na ten temat znalazłem genialny kod 
>> Krzysztofa Noworyty na powyższe.
>> I tak dla wartości np.:
>> 50,2684844521002 (współrzędna geograficzna w układzie WGS)
>> funkcja zwraca:
>> +50°16'07" - oczywiście wynik jest prawidłowy, ale:
>> Wprowadzając tą samą wartość wgs (50,2684844521002) do GoogleMaps
>> otrzymuję:
>> 50°16'06.5" - czyli wynik jest dokładniejszy.
>>
>> Czy ktoś z grupowiczów ma pomysł na "podkręcenie" funkcji i 
>> zwiększenie dokładności obliczeń?
>> Funkcja poniżej:
>>
>> Function DoubleNaStopnie(dbSt As Double) As String
> 
> [...]
> 
>>
>> End Function
> 
> [...]
> 
> Przetestuj poniższą funkcję:

Poniższa funkcja nie działa prawidłowo

> 
> 
> '_____________________________________________________________
> Public Function zbDoubleNaStopnie(dblSt As Double) As String
> Dim dblMin As Double
> Dim dblSec As Double
> Dim sRet As String
> 

[...]

> 
> End Function

[...]

Ta jest bardziej uniwersalna i powinna działać dobrze:

'_______________________________________________________________
Public Function zbDoubleNaStopnie( _
                 ByVal dblSt As Double, _
                 ByVal bDigitAfterDec As Long) As String
Dim dblMin As Double
Dim dblSec As Double
Dim sRet As String

   ' znak
   sRet = IIf(dblSt < 0, "-", "")

   dblSt = Abs(dblSt)
   dblMin = (dblSt - Int(dblSt)) * 60
   dblSec = dblMin - Int(dblMin)

   ' stopnie i minuty
   sRet = sRet & CStr(Int(dblSt)) & Chr(176) & CStr(Int(dblMin)) & "'"
   ' sekundy i dziesiętne sekundy
   sRet = sRet & Trim(Str(bs_Round(dblSec * 60, bDigitAfterDec))) & Chr(34)

   zbDoubleNaStopnie = sRet

End Function
'____________________________________________________________
Public Function bs_Round(Number As Variant, _
                     NumDigitsAfterDecimal As Long) As Double

     If Not IsNumeric(Number) Then Err.Raise 5
     bs_Round = Sgn(Number) * Int(CDec(Abs(Number)) * _
                 (10 ^ NumDigitsAfterDecimal) + 0.5) / _
                 (10 ^ NumDigitsAfterDecimal)

End Function

-- 
Pozdrowienia
BraZby
www.faq.accdb.pl
www.accdb.pl
Technical Details
Message-ID: <pgnl06$77c$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <50bfe759-a437-4cc5-a1b7-2395f0e59ed0@googlegroups.com> <pglo3j$bst$1@node1.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Zbigniew Bratko <byle@co.pl>
Newsgroups: pl.comp.bazy-danych.msaccess
Subject: Re: Konwersja współrzędnych
 geograficznych - ciąg dalszy
Date: Sun, 24 Jun 2018 10:33:09 +0200
Organization: ATMAN - ATM S.A.
Lines: 90
Message-ID: <pgnl06$77c$1@node1.news.atman.pl>
References: <50bfe759-a437-4cc5-a1b7-2395f0e59ed0@googlegroups.com> <pglo3j$bst$1@node1.news.atman.pl>
NNTP-Posting-Host: 5.172.234.213
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1529829190 7404 5.172.234.213 (24 Jun 2018 08:33:10 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Sun, 24 Jun 2018 08:33:10 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
In-Reply-To: <pglo3j$bst$1@node1.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit