![]() |
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Und wenn Du die "Delphi 5"-Variante nimmst und den Settings-Parameter beim Format-Befehl weglässt?
|
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Delphi-Quellcode:
So geht es. Danke für deine Geduld!DecimalSeparator := '.'; showmessage(Format('%s %.2d%s %.3f %s %.3d%s %.3f', [ Data.NSOrientation, Data.NSDegree, DEGREESIGN, Data.NSMinutes, Data.EWOrientation, Data.EWDegree, DEGREESIGN, Data.EWMinutes])); Leider macht er aus: N 49° 41.66 E 8° 31.672 N 49° 41.660 E 8° 31.672 richtig wäre: N 49° 41.066 E 8° 31.672 Gibt es da auch möglichkeiten? |
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Ich wüsste nicht, da ja die eingehende Zahl faktisch falsch ist, und zwar ihr Wert und nicht nur ihre Darstellung. Es sei denn, Du kennst Kriterien, anhand derer Du das erkennen könntest, dann müsstest Du sie halt korrigieren.
|
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
ok, dann werde ich einfach die anzahl der ziffern prüfen und wenn <3 dann füge ich eine 0 voran.
|
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Bist Du wirklich sicher, dass das so stimmt? Immerhin sind 3,50 und 3,05 ja unterschiedliche Zahlen, ich hätte da meine Bedenken.
|
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
ja bei Geo Koordinaten gilt:
N 49° 8.66 E 8° 31.672 = N 49° 08.066 E 8° 31.672 Ist ja logisch es ist ja 8.66 also achttausendsechundsechzig, würde die null dahinter kommen N 49° 8.660 E 8° 31.672, wäre es ja achttausensechHUNDERTsechundsechzig und wäre ganz wo anders :) |
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Dann habe ich anscheinend die Notation nicht verstanden, ich war der Meinung, es geht um Fließkommazahlen.
|
AW: String auf bestimmtest Format (Geokoordinaten) prüfen und verbessern
Habe mir das nun so umgebaut und so funktioniert es für meine zwecke:
Delphi-Quellcode:
Noch mal Danke für deine Geduld!
type
TGeoData = record NSOrientation: char; NSDegree: integer; NSMinutes: string; EWOrientation: char; EWDegree: integer; EWMinutes: string; end; const DEGREESIGN = '°'; ORIGINAL = 'N 49° 8.66 E 8° 1.72'; var CurrentPos, NextPos: integer; Data: TGeoData; GeoData, s: string; tempstr : String; pos1 : Integer; begin DecimalSeparator := '.'; ZeroMemory(@Data, SizeOf(Data)); GeoData := StringReplace(ORIGINAL, ' ', '', [rfReplaceAll]); Data.NSOrientation := GeoData[1]; CurrentPos := 2; NextPos := Pos(DEGREESIGN, GeoData); Data.NSDegree := StrToInt(Copy(GeoData, CurrentPos, NextPos - CurrentPos)); CurrentPos := NextPos + 1; NextPos := PosEx('E', AnsiUpperCase(GeoData), CurrentPos); if NextPos = 0 then NextPos := PosEx('W', AnsiUpperCase(GeoData), CurrentPos); TempStr := Copy(GeoData, CurrentPos, NextPos - CurrentPos); pos1 := pos('.',TempStr); if pos1 = 2 then insert('0',tempstr,1); pos1 := pos('.',TempStr); if (pos1 = 3) and (length(tempstr)=5) then insert('0',tempstr,4); data.nsminutes := tempstr; CurrentPos := NextPos + 1; Data.EWOrientation := GeoData[NextPos]; NextPos := PosEx(DEGREESIGN, GeoData, CurrentPos); Data.EWDegree := StrToInt(Copy(GeoData, CurrentPos, NextPos - CurrentPos)); CurrentPos := NextPos + 1; TempStr := Copy(GeoData, CurrentPos, MAXINT); pos1 := pos('.',TempStr); if pos1 = 2 then insert('0',tempstr,1); pos1 := pos('.',TempStr); if (pos1 = 3) and (length(tempstr)=5) then insert('0',tempstr,4); Data.EWMinutes := tempstr; s := Format('%s %.2d%s %s %s %.3d%s %s', [ Data.NSOrientation, Data.NSDegree, DEGREESIGN, Data.NSMinutes, Data.EWOrientation, Data.EWDegree, DEGREESIGN, Data.EWMinutes]); ShowMessage(s); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz