Loading ...
Sorry, an error occurred while loading the content.
 

Introduction of Java Programmer

Expand Messages
  • sunburned.surveyor
    I d like to make a short introduction. I m an open source Java programmer that will be (hopefully) addins support for the GPX file format to the GeoTools
    Message 1 of 4 , May 9, 2008
      I'd like to make a short introduction.

      I'm an open source Java programmer that will be (hopefully) addins
      support for the GPX file format to the GeoTools library. I will be
      using this library to build support for GPX into OpenJUMP, an open
      source GIS editor.

      If there are any existing open source Java programming libraries used
      for reading and writing GPX I'd love to hear about them.

      Thanks,

      The Sunburned Surveyor
    • Karl-Petter Åkesson
      Hi, I have been looking around a bit but didn t find a couple of clean classes to just read and write gpx so has written that for my GPS logger software,
      Message 2 of 4 , May 10, 2008
        Hi,

        I have been looking around a bit but didn't find a couple of clean
        classes to just read and write gpx so has written that for my GPS logger
        software, http://www.yelloworb.com/software/mogtrails/ and another piece
        of software at work. I'm happy to make those classes open source though
        they are required to compile both on J2ME and J2SE so it might not be
        what you are looking for.

        /Kalle

        sunburned.surveyor wrote:
        >
        > I'd like to make a short introduction.
        >
        > I'm an open source Java programmer that will be (hopefully) addins
        > support for the GPX file format to the GeoTools library. I will be
        > using this library to build support for GPX into OpenJUMP, an open
        > source GIS editor.
        >
        > If there are any existing open source Java programming libraries used
        > for reading and writing GPX I'd love to hear about them.
        >
        > Thanks,
        >
        > The Sunburned Surveyor
        >
        >
      • Brad Orner
        Kalle, I’ve been working on my own java classes for working with GPX for a website I’m developing. I would strongly recommend going the JAXB route using
        Message 3 of 4 , May 11, 2008
          Kalle,



          I’ve been working on my own java classes for working with GPX for a website
          I’m developing. I would strongly recommend going the JAXB route using the
          gpsxml schema. JAXB is great – it makes reading and writing XML a snap (as
          long as the XML uses XML schema).



          In a nutshell, you run the utility ‘xjc’ for a given XML schema and it
          generates java classes for that schema. Those classes may then be used at
          runtime by a java executable. You’ll simply traverse the class tree using
          getters and setters to build out the model. Reading an XML file is called
          ‘unmarshalling’. Unmarshalling will create a tree of java objects from the
          XML file. Writing an XML file is called ‘marshalling’. Marshalling will
          take a tree of objects and write an XML file.



          Here’s some class snippets to give you the idea. GpxModel is a front-end
          class I wrote to access the JAXB unmarshaller and marshaller, which is
          created using a JAXBContext created for both 1.0 and 1.1 versions of the
          gpsxml schema (this will allow (un)marshalling support for both versions.





          Here’s a partial screen shot of Eclipse showing the packages generated by
          xjc (here’s one xjc resource, but a simple google will yield plenty
          http://www.cs.utah.edu/classes/cs5520/java/JAXB/jaxb/docs/xjc.html)













          Code snippet:



          import javax.xml.bind.JAXBElement;

          import javax.xml.bind.Marshaller;

          import javax.xml.bind.Unmarshaller;

          import javax.xml.bind.JAXBContext;

          import javax.xml.bind.JAXBException;

          import javax.xml.transform.stream.StreamSource;



          // the com.topgrafix.gpx packages and classes were

          // generated using JAXB’s xjc – run once for the gpx 1.0 schema

          // and a second time for the 1.1 schema.



          import com.topografix.gpx._1._0.Gpx;

          import com.topografix.gpx._1._1.*;



          public class GpxModel {

          private static final String JAXB_CONTEXT_PATH=

          "com.topografix.gpx._1._0:" +

          "com.topografix.gpx._1._1";



          private static JAXBContext jaxbContext =
          JAXBContext.newInstance(JAXB_CONTEXT_PATH);

          private static Unmarshaller unmarshaller

          private static Marshaller marshaller;



          private static void initialize() {

          try {

          jaxbContext = JAXBContext.newInstance(JAXB_CONTEXT_PATH);

          unmarshaller= GpxModel.jaxbContext.createUnmarshaller();

          marshaller = GpxModel.jaxbContext.createMarshaller();

          initialized = true;

          }

          catch (Exception e) {

          e.printStackTrace();

          }

          }



          public static JAXBContext getJaxbContext() {

          if (!initialized) { GpxModel.initialize();}

          return jaxbContext;

          }



          public static Unmarshaller getUnmarshaller() {

          if (!initialized) { GpxModel.initialize();}

          return unmarshaller;

          }



          public static Marshaller getMarshaller() {

          if (!initialized) { GpxModel.initialize();}

          return marshaller;

          }

          …

          }



          Here’s snippet for unmarshalling:



          File f = new File(“myroute.gpx”);

          try{

          System.out.println("unmarshalling " + f.getPath() + " ...");

          root = GpxModel.getUnmarshaller().unmarshal(f);

          }

          catch (Exception e) {

          System.err.println("unmarshal failure");

          e.printStackTrace();

          }

          //gpx v1.0 will have a Gpx root, v1.1 will have a GpxType as the root (as
          created

          // by xjc when run for each version of the schema

          if (root.getClass() == Gpx.class) {

          gpx = (Gpx)root;

          System.out.println( f.getPath() + " is gpx schema v. " +
          gpx.getVersion());

          }

          else if (root.getClass() == GpxType.class) {

          gpxtype = (GpxType)root;

          System.out.println( f.getPath() + " is gpx schema v. " +
          gpxtype.getVersion());

          }

          else {

          fail("unsupported root of class " + root.getClass().toString());

          }





          HTH,

          Brad





          _____

          From: gpsxml@yahoogroups.com [mailto:gpsxml@yahoogroups.com] On Behalf Of
          Karl-Petter Åkesson
          Sent: Saturday, May 10, 2008 3:49 AM
          To: gpsxml@yahoogroups.com
          Subject: Re: [gpsxml] Introduction of Java Programmer



          Hi,

          I have been looking around a bit but didn't find a couple of clean
          classes to just read and write gpx so has written that for my GPS logger
          software, http://www.yellowor <http://www.yelloworb.com/software/mogtrails/>
          b.com/software/mogtrails/ and another piece
          of software at work. I'm happy to make those classes open source though
          they are required to compile both on J2ME and J2SE so it might not be
          what you are looking for.

          /Kalle

          sunburned.surveyor wrote:
          >
          > I'd like to make a short introduction.
          >
          > I'm an open source Java programmer that will be (hopefully) addins
          > support for the GPX file format to the GeoTools library. I will be
          > using this library to build support for GPX into OpenJUMP, an open
          > source GIS editor.
          >
          > If there are any existing open source Java programming libraries used
          > for reading and writing GPX I'd love to hear about them.
          >
          > Thanks,
          >
          > The Sunburned Surveyor
          >
          >





          [Non-text portions of this message have been removed]
        • malek_baroudi2002
          ... Hello lists, I m about to develop a GPX component in spatialdataintegrator (SDI) with geotools 2.4.2 and it s work properly ! See the GPX+geotools module
          Message 4 of 4 , May 14, 2008
            --- In gpsxml@yahoogroups.com, "sunburned.surveyor"
            <sunburned.surveyor@...> wrote:
            >
            > I'd like to make a short introduction.
            >
            > I'm an open source Java programmer that will be (hopefully) addins
            > support for the GPX file format to the GeoTools library. I will be
            > using this library to build support for GPX into OpenJUMP, an open
            > source GIS editor.
            >
            > If there are any existing open source Java programming libraries used
            > for reading and writing GPX I'd love to hear about them.
            >
            > Thanks,
            >
            > The Sunburned Surveyor
            >
            Hello lists,
            I'm about to develop a GPX component in spatialdataintegrator (SDI)
            with geotools 2.4.2 and it's work properly !
            See the GPX+geotools module of Petter Bolla:
            http://docs.codehaus.org/display/GEOTOOLS/GPX+module
            For geotools 2.4.2 you have :
            http://metacortex.hu/~buci/gpx-2.4.zip
            And for geotools 2.5 see geotools javadoc.
            Thanks for Petter Bolla to have devolopping this module

            Regars Malek Baroudi
          Your message has been successfully submitted and would be delivered to recipients shortly.