Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #5  
Antiguo 18-09-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Iván.
Cita:
Empezado por radenf Ver Mensaje
...
En mi programa he implementado el uso de un javascript que llama a GoogleMaps sobre un TWebBrowser, que sólo acepta el formato de grados decimal (DDD)...
Ya había olvidado por que detestaba javascript... hasta ahora

Lo verifiqué con varias localizaciones y anduvo bién, pero fijate si en en las futuras pruebas continúa hacíendolo...
Código Delphi [-]
uses Clipbrd;

procedure CoordSexaToDec(const LatStr,LonStr: string; var Latitude,Longitude: Double);
{$J+}
const
  LASIGN: ShortInt = 1;
  LOSIGN: ShortInt = 1;
  VSIGN : array[Boolean] of ShortInt = (1,-1);
{$J-}
var
  laPCar, loPCar: Char;
  laDeg,   loDeg: Double;
  laMin,   loMin: Double;
  laSec,   loSec: Double;
  laDegA, loDegA: Double;
  laMinA, loMinA: Double;
  laSecA, loSecA: Double;
  ts            : TStrings;
begin
  // Signos
  laPCar:= UpCase(LatStr[Length(LatStr)]);
  loPCar:= UpCase(LonStr[Length(LonStr)]);
  LASIGN:= VSIGN[laPCar = 'S'];
  LOSIGN:= VSIGN[loPCar in ['O','W']];
  ts:= TStringList.Create;
  try
    // Latitud
    ts.CommaText:= LatStr;
    ts[2] := Copy(ts[2], 1, Pos('/', ts[2]) - 1);
    laSec := StrToFloat(ts[2])/100;
    laMin := StrToFloat(ts[1]);
    laDeg := StrToFloat(ts[0]);
    laSec := Abs(Round(laSec * 1000000) / 1000000);
    laMin := Abs(Round(laMin * 1000000) / 1000000);
    // Longitud
    ts.Clear;
    ts.CommaText:= LonStr;
    if loPCar = 'O' then loPCar:= 'W';
    ts[2] := Copy(ts[2], 1, Pos('/', ts[2]) - 1);
    loSec := StrToFloat(ts[2])/100;
    loMin := StrToFloat(ts[1]);
    loDeg := StrToFloat(ts[0]);
  finally
    ts.Free;
  end;
  loSec := Abs(Round(loSec * 1000000) / 1000000);
  loMin := Abs(Round(loMin * 1000000) / 1000000);
  // Calculos latitud
  laDegA:= Abs(Round(laDeg * 1000000));
  laMinA:= Abs(Round(laMin * 1000000));
  laSecA:= Abs(Round(laSec * 1000000));
  // Calculos longitud
  loDegA:= Abs(Round(loDeg * 1000000));
  loMinA:= Abs(Round(loMin * 1000000));
  loSecA:= Abs(Round(loSec * 1000000));
  // Verificar latitud
  if not (laPCar in ['N','S']) then
    raise Exception.Create('Error en la latitud');
  if not (loPCar in ['E','W']) then
    raise Exception.Create('Error en la longitud');
  if laDegA > 90 * 1000000 then
    raise Exception.Create('Error: Grados en latitud: -90 a 90');
  if laMinA > 60 * 1000000 then
    raise Exception.Create('Error: Minutos en latitud: 0 a 59');
  if laSecA > 59.99999999 * 1000000 then
    raise Exception.Create('Error: Segundos en latitud: 0 a 60');
  // Verificar longitud
  if loDegA > 180 * 1000000 then
    raise Exception.Create('Error: Grados en longitud: -180 a 180');
  if loMinA >  60 * 1000000 then
    raise Exception.Create('Error: Minutos en longitud: 0 a 59');
  if loSecA >  59.99999999 * 1000000 then
  raise Exception.Create('Error: Segundos en longitud: 0 a 60');
  // Resultado
  Latitude := Round(laDegA + laMinA / 60 + laSecA / 3600)* LASIGN / 1000000;
  Longitude:= Round(loDegA + loMinA / 60 + loSecA / 3600) * LOSIGN / 1000000;
end;

procedure TForm1.btnConvierteClick(Sender: TObject);
var
  Exif1, Exif2: string;
  Latitud, Longitud: Double;
begin
  // Como siempre el pueblo tira...
  Exif1:= '38,22,37/100S';
  Exif2:= '60,16,31/100W';

  CoordSexaToDec(Exif1,Exif2,Latitud,Longitud);

  Exif1:= StringReplace(FloatToStr(Latitud),',','.',[rfReplaceAll]);
  Exif2:= StringReplace(FloatToStr(Longitud),',','.',[rfReplaceAll]);
  Clipboard.AsText:= Exif1 + ', ' + Exif2;
  // A probar a google maps...
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 18-09-2014 a las 20:26:40. Razón: acomodar identación
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Convertir coordenadas GPS a UTM zona 30S briast Varios 3 31-05-2012 10:48:27
Como puedo convertir una imagen a una imagen semitransparente? antonio302050 Gráficos 0 27-03-2010 17:01:48
Lograr coordenadas de imagen. Besto Varios 5 14-08-2007 17:02:53
pasar coordenadas gps a coordenadas builder iaav1 C++ Builder 3 03-07-2006 19:59:02
Convertir un punto X,Y sobre una form a coordenadas Absolutas (Pantalla) Majo Gráficos 3 16-03-2004 16:57:14


La franja horaria es GMT +2. Ahora son las 13:17:34.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi