Wednesday, October 27, 2010
Monday, October 25, 2010
Java mysql database connectivity
http://www.kitebird.com/articles/jdbc.html
http://www.kitebird.com/articles/jdbc.html
Sunday, October 24, 2010
Best resource on AIS ever found on internet
Have written an AISparser to automaically decode the AIS data message.
http://www.aishub.net/
AIS is the mariner's most significant development in navigation safety since the introduction of radar. The system was originally developed as a collision avoidance tool to enable commercial vessels to ‘see' each other more clearly in all conditions and improve the helmsman's information about his surrounding environment. AIS does this by continuously transmitting a vessels identity, position, speed and course, along with other relevant information to all other AIS equipped vessels within range. Combined with a shore station, this system also offers port authorities and maritime safety bodies the ability to manage maritime traffic and reduce the hazards of marine navigation.
http://gpsd.berlios.de/AIVDM.html
Thursday, October 21, 2010
web site
Decode AIS data= AIS parser
In Order:
!AIVDM: The NMEA message type
1 Number of Sentences (some messages need more then one)
1 Sentence Number (1 unless it's a multi-sentence message)
The blank is the Sequential Message ID (for multi-sentence messages)
A The AIS Channel (A or B)
14eG;... The Encoded AIS Data
0* End of Data
7D NMEA Checksum
AIS Data Encoding
In the NMEA encoding for AIS - each ASCII character corresponds to 6 binary bits (unlike normal ASCII which uses 8 bits) so you need to step through each character and subtract 48 from the ASCII - then if it's still a decimal number > 40 subtract another 8 - then convert to binary: this guarantees a 6 bit number. Looking at our data (just the first few characters)14eG
1 = 000001
4 = 000100
e = 101101
G = 010111
and so on...
The complete data string decoded looks like this when strung back together.
000001 000100 101101 010111 011100 001010 010000 000000 000000 000000 110111 001000 110111 100001 101000 011100 011101 110010 011111 101011 110000 110101 010111 010000 000000 001000 011000 011011
Now you start grabbing sets of bits from this and converting to decimal. Here are the key pieces of information assuming the first character is a '1' (the message type):
MMSI Number - starting from bit 8 for 30 bits
= 010010110101011101110000101001 = 316005417
HDG - bit 128 for 9 bits
COG - bit 116 for 12 bits (and divide by 10)
SOG - bit 50 for 10 bits (and divide by 10)
Lat - bit 89 for 27 bits (a signed binary number, divide by 600000)
Lon - bit 61 for 28 bits (a signed binary number, divide by 600000)
import java.util.StringTokenizer;
public class AISDecoder {
public static void main(String[] args) {
String s = "!AIVDM,1,1,,A,14eG;o@034o8sd
StringTokenizer stok = new StringTokenizer(s, ",");
String tokens[] = new String[stok.countTokens()];
for (int i = 0;i< stok.countTokens()+5;i++) {
tokens[i] = stok.nextToken().trim();
}
//System.out.println(tokens[4]);
String msg = tokens[4];
String binarystr = "";
String full = "";
for (int i = 0; i < msg.length(); i++) {
int j = (int) msg.charAt(i);
//System.out.println(j);
j = j - 48;
//System.out.println(j);
if (j > 40) {
j = j - 8;
}
//System.out.println(j);
//System.out.println();
binarystr = Integer.toBinaryString(j);
int len = binarystr.length();
switch (len) {
case 1:
binarystr = "00000" + binarystr;
break;
case 2:
binarystr = "0000" + binarystr;
break;
case 3:
binarystr = "000" + binarystr;
break;
case 4:
binarystr = "00" + binarystr;
break;
case 5:
binarystr = "0" + binarystr;
break;
case 6:
binarystr = "" + binarystr;
break;
}
// System.out.println(binarystr);
// System.out.println("");
full = full.concat(binarystr).trim();
}
System.out.println(full);
//System.out.println(full.length());
String msgtype = full.substring(0, 6);
System.out.println(msgtype);
System.out.println(Integer.parseInt(msgtype,2));
String repind = full.substring(6, 8);
System.out.println(repind);
System.out.println(Integer.parseInt(repind,2));
String mmsi = full.substring(8, 38);
System.out.println("mm"+mmsi.length());
System.out.println(Integer.parseInt(mmsi,2));
String aisversion = full.substring(38,40);
System.out.println(Integer.parseInt(aisversion,2));
String imonum = full.substring(40,70);
System.out.println(Integer.parseInt(imonum,2));
String lon = full.substring(61, 88);
System.out.println("len" + lon.length());
int lonint = Integer.parseInt(lon,2);
float lonflo = (float)lonint/600000;
System.out.println(lonflo);
String lat = full.substring(89,117);
int latint = Integer.parseInt(lat,2);
float latflo = (float)latint/600000;
System.out.println(latflo);
// String callsign = full.substring(70,112);
// System.out.println(callsign.length());
//System.out.println(Double.parseDouble(ca));
// System.out.println(mmsi);
// System.out.println(Integer.parseInt(mmsi,2));
}
}
Monday, October 18, 2010
PoStGiS
installed on top of Postgresql
http://postgis.refractions.net/download/windows/
NMEA 083 is the format for AIS string.
AIS database design
installing the db- embeded java database
this needs knowledge of hibernate, so have to learn hibernate
--------------------------------------------------------------
deadend
Sunday, October 17, 2010
Find out AIS data receiving format
design AIS data storage database
Finding and longitude from AIS data string.
Try out mouse position tracking from AIS data
Tuesday, October 12, 2010
AIS database design-1
AIS Database Powered by GIS Technology for Maritime Safety and Security
|
|
Abstract
The Automatic Identification System (AIS) is an efficient tool to exchange positioning data among participating naval units and land control centres. It was developed primarily as an advanced tool for assistance to sailors during navigation and for the safety of the life at sea. Maritime security has become a major concern for all coastal nations, especially after September 11, 2001. The fundamental requirement is maritime domain awareness via identification, tracking and monitoring of vessels within their waters and this is exactly what an AIS could bring. This paper will be focused on how the AIS-derived information could be used for coastal security, maritime traffic management, vessel tracking and monitoring with the help of GIS technology. The AIS data used in this paper was collected by the Canadian national aerial surveillance program.
Key Words:Automatic Identification System; Geographic Information System; Marine Security; Aerial Surveillance
got an idea of how the AIS really function in nava
Monday, October 11, 2010
Found MapMouseEvent method
getMapPosition
public DirectPosition2D getMapPosition()
- Get the position, in map (world) coordinates of this mouse event
- Returns:
- a new DirectPosition2D object for the world coordinates
- //////////////////////////////////////
- this should work?
get mouse position
Friday, October 8, 2010
offline repository
Maven Alternative¶
The alternative to using Maven to download and manage jars for you is to manually install them. To start with we will obtain GeoTools from the website:
Download the GeoTools binary release from http://sourceforge.net/projects/geotools/files
Extract the geotools-2.6.0-bin.zip file to C:javageotools-2.6.0 folder.
If you open up the folder and have a look you will see GeoTools and all of the other jars that it uses including those from other libraries such as GeoAPI and JTS.
We can now set up GeoTools as a library in NetBeans:
From the menu bar choose Tools > Libraries to open the Library Manager.
From the Library Manager press the New Library button.
Enter “GeoTools” for the Library Name and press OK
You can now press the Add JAR/Folder button and add in all the jars from C:javaGeoTools-2.7-M2
GeoTools includes a copy of the “EPSG” map projections database; but also allows you to hook up your own copy of the EPSG database as an option. However, only one copy can be used at a time so we will need to remove the following jars from the Library Manager:
EPSG
The EPSG databaes is distributed as an Access database and has been converted into the pure java database HSQL for our use.
- gt-epsg-h2
- gt-epsg-oracle
- gt-epsg-postgresql
- gt-epsg-wkt-2.6
GeoTools allows you to work with many different databases; however to make them work you will need to download jdbc drivers from the manufacturer.
For now remove the following plugins from the Library Manager:
- gt-arcsde
- gt-arcsde-common
- gt-db2
- gt-jdbc-db2
- gt-oracle-spatial
- gt-jdbc-oracle
We are now ready to proceed with creating an example project. Select File > New Project
Choose the default “Java Application”
Fill in “Tutorial” as the project name; and our initial Main class will be called “Quickstart”.
Open up Example in the Projects window, right click on Libraries and select Add Libraries. Choose GeoTools from the Add Library dialog.
Congratulations ! You can now return to Quickstart or any of the other tutorials
Thursday, October 7, 2010
Tried new geotools tutorial
CachingFeatureSource cache = new CachingFeatureSource(featureSource);
added to the quick start
with the
import org.geotools.data.CachingFeatureSource;
Configure and install geotools to my new laptop from beginning
The GeoTools development community uses the build tool Maven which is integrated into the latest releases of NetBeans.
The advantages of using Maven are:
- You only download as much of GeoTools as your application requires Jars are downloaded to a single location in your home directory (in a hidden folder called .m2/repository)
- Source code and javadocs are automatically downloaded and hooked up
Although Maven is a build tool it works by describing the contents of a project. This is a different approach then used by the Make or Ant tools which list the steps required to build.
what is a POM file
Part of the description of a project is the required jars and a repository on the internet where they can be downloaded from. We will be using these facilities to bring GeoTools jars as needed into our project.
The pom.xml file is used to describe the care and feeding of your maven project; we are going to focus on the dependencies needed for your project
PLATFORM | LOCAL REPOSITORY |
---|---|
Windows XP: | C:\Documents and Settings\Jody\.m2\repository |
Windows: | C:\Users\Jody\.m2\repository |
Linux and Mac: | ~/.m2/repository |
finally some thing to work with
> 1. How do I get the world-coordinates when clicking with the mouse?
> When adding a normal MouseListener, it only returns the coordinates on
> the screen, but I would like to know the position on the map.
[solved]
Using org.geotools.renderer.j2d.GeoMouseEvent.getMapCoordinate();
> 2. How do I change the behaviour of the mouse on a map? When clicking
> and draging the mouse, it generates a zoom-pane with the selected
> area. I want to change this behaviour to pan the map. So, when moving
> the mouse, the map also moves, but doesn't zoom or anything else. Is
> this possible?
>
> And another question: As already mentioned, I'm using the methods as
> in the Spearfish Sample, which uses J2D-renderer. I experienced
> OutOfMemoryExceptions when dealing with larger shapefiles (3x 30 MB).
> Is there a possibility to avoid that?
I would still appreciate some suggestions ;)
Bernhard
Wednesday, October 6, 2010
Learning Java and geo tools documentation
8/30 to 1.pm read the book Head first java
afternoon i refer the Geotools documentation.
Monday, October 4, 2010
Initial Presentation- Navy Command Elecronics work shop west wing Rangala
Finding out how to write a mouse listener in GeoTools.
Displaying a shape file
finally downloaded the jar files necessary for displaying a shape file.
\\\\\\\\\\\\\\\code for display shape file
// docs start source
/*
* GeoTools - The Open Source Java GIS Tookit
* http://geotools.org
*
* (C) 2006-2008, Open Source Geospatial Foundation (OSGeo)
*
* This file is hereby placed into the Public Domain. This means anyone is
* free to do whatever they wish with this file. Use it well and enjoy!
*/
package org.geotools.demo;
import java.io.File;
import org.geotools.data.CachingFeatureSource;
import org.geotools.data.FeatureSource;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.map.DefaultMapContext;
import org.geotools.map.MapContext;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;
/**
* GeoTools Quickstart demo application. Prompts the user for a shapefile
* and displays its contents on the screen in a map frame
*
* @source $URL$
*/
public class Quickstart {
/**
* GeoTools Quickstart demo application. Prompts the user for a shapefile
* and displays its contents on the screen in a map frame
*/
public static void main(String[] args) throws Exception {
// display a data store file chooser dialog for shapefiles
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if (file == null) {
return;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
FeatureSource featureSource = store.getFeatureSource();
// Create a map context and add our shapefile to it
MapContext map = new DefaultMapContext();
map.setTitle("Quickstart");
map.addLayer(featureSource, null);
// Now display the map
JMapFrame.showMap(map);
}
// docs end main
// docs start cache
/**
* This method demonstrates using a memory-based cache to speed up
* the display (e.g. when zooming in and out).
*
* There is just one line extra compared to the main method, where
* we create an instance of CachingFeatureStore.
*
* @throws Exception
*/
public void usingFeatureCaching() throws Exception {
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if (file == null) {
return;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
FeatureSource featureSource = store.getFeatureSource();
CachingFeatureSource cache = new CachingFeatureSource(featureSource);
// Create a map context and add our shapefile to it
MapContext map = new DefaultMapContext();
map.setTitle("Using cached features");
map.addLayer(cache, null);
// Now display the map
JMapFrame.showMap(map);
}
}
// docs end source
///////////////pom file////////
/////////////////////////////////////////////