A few weeks ago I found an old photograph taken while we were doing a 4wd tour on the Mid North Coast of NSW. I wanted to scan and post this photo to the blog along with a Google Maps location.
The issue with this was I only had a rough idea where the photo was taken. During this 4wd tour we followed the directions in a printed book. This was 10 years ago and we did not have the use of a GPS to record our track. All I had to go on was the directions in the book. These directions made little sense trying to follow them on Google Maps as in many cases the tracks we followed are not named or marked in Google Maps.
However, the book did give GPS co-ordinates for key points on the tracks (major intersections or landmarks). I decided these could be used to provide a rough path followed and allow me to get my bearings while trying to follow the directions on Google Maps.
Once I tried to plot each of these points in Google Earth I realised it would be a slow process to import each of these points. An easier way would be to create a KML file of the points and load that into Google Earth. I had already written some code to produce a KML file of points from a CSV file so it was just a matter of loading the GPS co-ordinates into the CSV file and running the program.Unfortunately, KML files need GPS co-ordinates in Decimal Degrees and all my co-ordinates were in Degrees, Minutes and Seconds.
At this point I could have used any number of web based conversion pages to convert each co-ordinate manually. Instead, I decided to write a JAVA class library to convert co-ordinates between Degrees, Minutes and Seconds and Decimal Degrees.
The code was reasonably simple but as I had not been able to find an equivalent class on the net I decided that I would try to make it as versatile as possible with the aim to releasing it onto the web for anybody to use. It would also be a good learning exercise for me as I have created a Java class library previously.
After a weeks worth of coding I have now got the library to the point that I feel comfortable releasing a alpha version of the library to the net. There is a simple tutorial available and I am currently developing the Javadocs to go with the library.
Eventually, I will also post the source under an open source license to allow others to build or improve the library.
Showing posts with label google earth. Show all posts
Showing posts with label google earth. Show all posts
Thursday, April 8, 2010
Latitude/Longitude Converter Class Library
Labels:
google earth,
gps,
java,
mapping,
open source,
software
Saturday, October 24, 2009
Using JAK and Google Geocoder
In a previous post I mentioned that I would be doing some experimenting with the JAK - Java API for KML. I have now created a simple program that creates a KML file using co-ordinates obtained from calling the Google Geocoder.
If you wish to review the whole program I have made it available here (4mb).
The main parts of the code are as follows:
GeoCoder class
Refer to the Geocoder.java class file in the download for more information on how this works.
Main Class
In the future I will expand on this application to provide more information in the KML.
If you wish to review the whole program I have made it available here (4mb).
The main parts of the code are as follows:
GeoCoder class
- converts a street address into a longitude/latitude point.
- call getLocation method with a string representing the address.
- class uses Google Geocoder.
Refer to the Geocoder.java class file in the download for more information on how this works.
Main Class
- assigns an address from the first command line argument
address = args[0];
- calls the GeoCoder.getLocation method with Address String
location = Geocoder.getLocation(address).toString();
- creates a KML file using the location value returned by the GeoCoder class
final Kml kml = new Kml();
kml.createAndSetPlacemark()
.withName(address)
.withOpen(Boolean.TRUE)
.createAndSetPoint()
.addToCoordinates(location);
try {
kml.marshal(new File("HelloKml.kml"));
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
In the future I will expand on this application to provide more information in the KML.
Labels:
google earth,
jak,
kml,
mapping,
open source
Friday, October 9, 2009
JAK - Java API for KML
In a previous blog post I showed how it was possible to take information recorded by a GPS device and mobile phone and plot the resulting track using Google Maps.
Recently, I found a link to a JAVA API that allows you to interact with the KML files produced by the process using a JAVA application.
The project aims to provide an
Stay tuned...
Recently, I found a link to a JAVA API that allows you to interact with the KML files produced by the process using a JAVA application.
The project aims to provide an
"automatically generated full reference implementation of the KML object model defined by OGC’s KML standard and Google’s GX extensions. It is an object orientated API that enables the convenient and easy use of KML in existing Java environments."Over the next couple of weeks I am going to do some experimentation using this API and try and develop some simple applications to take GPS tracks from Nokia Sports Tracker and my GPS and create interesting KML files.
Stay tuned...
Labels:
google earth,
jak,
kml,
mapping
Sunday, June 21, 2009
GPS Mapping
Over the last 10 years I have ridden many of the trails in the Central Coast area, often more than once. Recently, I have started to map these trails using a GPS with the aim to document them so other riders may enjoy them.
To do the mapping I use the following hardware and software.
Hardware
Software
An example of the embedded map produced by this technique is below. It shows the various information available from the file produced from Nokia Sports Tracker.
View Larger Map
Capturing the Data Points (GPS Track)
To capture the data used for the KML file I use my Nokia mobile phone connected to a bluetooth GPS Module. Nokia have released an application called Nokia Sports Tracker which allows you to record a GPS track. For further information on the use of Nokia Sports Tracker visit the Nokia website.
The Nokia Sports Tracker application has the option to output the file of data points to a variety of formats (GPS, CSV, or KML). We are most interested in KML here because it allows us to import the track into Google Earth or Google Maps.
Viewing the Map
Now that we have a KML file we can open this file directly into Google Earth to check that it looks correct. If you have Google Earth installed, double-clicking the KML file in Windows will open the path and display.
To use the path in Google Maps is a little more involved as you need to host the KML file somewhere on the web. I use a folder on my hosting provider.
Once you have the KML file hosted on the web you can now use it within Google Maps. To use within Google Maps copy/paste the URL into the Google Maps Search Bar and press 'Search' button.

Google Maps will now display the path on the map with some additional information about the path from the KML file.

Embedding the Map
Once you have the map displayed you can now Print, Send, or Link to this map. To embed this map into a blog or another web page use the 'Link' menu and paste the HTML in the second box into your website code.
You can use the 'Customise and preview embedded map' to change the settings of the embedded map.
For more information refer to the examples on the Google Maps site.
To do the mapping I use the following hardware and software.
Hardware
- Bluetooth GPS Module (GlobalSat BT-338)
- Nokia 6120 Phone
Software
An example of the embedded map produced by this technique is below. It shows the various information available from the file produced from Nokia Sports Tracker.
View Larger Map
Capturing the Data Points (GPS Track)
To capture the data used for the KML file I use my Nokia mobile phone connected to a bluetooth GPS Module. Nokia have released an application called Nokia Sports Tracker which allows you to record a GPS track. For further information on the use of Nokia Sports Tracker visit the Nokia website.
The Nokia Sports Tracker application has the option to output the file of data points to a variety of formats (GPS, CSV, or KML). We are most interested in KML here because it allows us to import the track into Google Earth or Google Maps.
Viewing the Map
Now that we have a KML file we can open this file directly into Google Earth to check that it looks correct. If you have Google Earth installed, double-clicking the KML file in Windows will open the path and display.
To use the path in Google Maps is a little more involved as you need to host the KML file somewhere on the web. I use a folder on my hosting provider.
Once you have the KML file hosted on the web you can now use it within Google Maps. To use within Google Maps copy/paste the URL into the Google Maps Search Bar and press 'Search' button.

Google Maps will now display the path on the map with some additional information about the path from the KML file.

Embedding the Map
Once you have the map displayed you can now Print, Send, or Link to this map. To embed this map into a blog or another web page use the 'Link' menu and paste the HTML in the second box into your website code.
You can use the 'Customise and preview embedded map' to change the settings of the embedded map.For more information refer to the examples on the Google Maps site.
Subscribe to:
Posts (Atom)