Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-03-2011
Luis Cuenca Luis Cuenca is offline
Registrado
 
Registrado: ago 2006
Posts: 9
Poder: 0
Luis Cuenca Va por buen camino
como crear un archivo gpx con delphi 7

Hola a todos, necesito crear un archivo gpx con delphi, estoy usando el componente txmldocument, y tengo el siguiente codigo, pero cuando lo trato de abrir con un programa para archivos gpx me dice que mi archivo no es gpx.

Ojala que me puedan ayudar, llevo varios dias y no encuentro la forma:

Código Delphi [-]
begin
// empty the document
XMLDoc.Active := False;
XMLDoc.XML.Text := '';
XMLDoc.Active := True;
// root
iXml := XmlDoc.DOMDocument;
xmlNode := iXml.appendChild (iXml.createElement ('xml'));
iAttribute := iXml.createAttribute ('version');
iAttribute.nodeValue := '1.0';
xmlNode.attributes.setNamedItem (iAttribute);
//GPX
gpxNode := xmlNode.appendChild(iXml.createElement ('gpx'));
iAttribute := iXml.createAttribute ('xmlns');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('version');
iAttribute.nodeValue := '1.1';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('creator');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('xmlns:xsi');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('xsi:schemaLocation');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
mNode := xmlNode.appendChild(iXml.createElement ('metadata'));
 
bNode := mNode.appendChild(iXml.createElement ('bounds'));
 
iAttribute := iXml.createAttribute ('minlat');
iAttribute.nodeValue := '19.38975200';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('minlon');
iAttribute.nodeValue := '-99.17971000';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('maxlat');
iAttribute.nodeValue := '19.39671900';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('maxlon');
iAttribute.nodeValue := '-99.17543500';
bNode.attributes.setNamedItem (iAttribute);
 
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trksegNode.attributes.setNamedItem (iAttribute);
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.38975200';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17543500';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'SUPERAMA';
trksegNode.attributes.setNamedItem (iAttribute);
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39119400';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17971000';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'CUMULUS1';
trksegNode.attributes.setNamedItem (iAttribute);
 
trkptNode := xmlNode.appendChild (iXml.createElement ('rte'));
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.38975200';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17543500';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'SUPERAMA';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39119400';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17971000';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'CUMULUS1';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trkNode.attributes.setNamedItem (iAttribute);
// show XML in memo
Memo1.Lines.Text := FormatXMLData (XMLDoc.XML.Text);
XMLDoc.SaveToFile('C:\Users\j\Desktop\borrar\codigo2.gpx');
 
end;

Última edición por Casimiro Notevi fecha: 02-03-2011 a las 01:06:05. Razón: Poner etiquetas [delphi] el código [/delphi]
Responder Con Cita
  #2  
Antiguo 02-03-2011
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is online now
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Hola Luis.
Un archivo GPX no es más que un XML con determinada estructura.

En mi caso, lo que he hecho es importar un fichero GPX hasta un Dataset, pero el paso contrario es igual de sencillo.
Para ello he utilizado el XML Mapper de Delphi.
Puedes revisar el proceso competo y descargar el código en esta entrada:
Cargar fichero GPX (XML) y acceder a los datos

Creo que no debe ser muy complejo, a partir de eso, generar el paso contrario.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
Respuesta



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
como crear archivo .xml para cfd richy08 Varios 8 17-12-2010 00:09:05
Error al crear archivo de excel con delphi lduron Varios 2 26-08-2010 16:02:29
Crear archivo imborrable con Delphi d3an Lazarus, FreePascal, Kylix, etc. 1 04-02-2010 15:05:10
como crear un archivo en php? gabrielflowers PHP 5 27-03-2008 22:12:18
Cómo crear archivo hlp.... oracle Varios 4 01-08-2005 14:19:12


La franja horaria es GMT +2. Ahora son las 16:14:10.


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