How to compile gvSIG 2.0

I am proud to share with you the steps to compile gvSIG 2.0, which I discovered thanks to some fellows developers, whom I met thanks to the latests Jornadas GvSIG.

Although you can find a full guide on the official documentation, this simple steps will let you customize and compile your own gvSIG2.0 version without much trouble.

First, you have to install some basic dependencies:

#apt-get install maven2 subversion

Next, we create a folder in which we can work:

$mkdir gvSIG; cd gvSIG

Once we have the basic workspace, we download the source code:

$svn co https://joinup.ec.europa.eu/svn/gvsig-desktop/branches/v2_0_0_prep/build/

Before compiling anything, we prepare a basic configuration file:

$ cat > ~/.gvsig.platform.properties << EOF
native_platform=linux
native_distribution=all
native_compiler=gcc4
native_arch=i386
native_libraryType=dynamic
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType}
EOF

The next code can be written on the .bashrc file of your /home folder, but we can also execute it on the console we are working with.

$if [ -f "${HOME}/.gvsig.platform.properties" ]
then
. ${HOME}/.gvsig.platform.properties
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier} -Dnative-platform=${native_platform}"
else
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m"
fi

Once we have the environment ready, we do the first compilation with maven. Patience, it may take long.

$mvn install

Now that we have our first maven compilation, we proceed to use ant to end up setting up the environment. This command will access to the online repository of gvSIG to download the rest of the source code and will compile and generate gvSIG.

$ant svn.checkout.all

Once we have the environment ready, we proceed to prepare the flavor of gvSIG we are going to use. On his post we will use the standard version of gvSIG:

$cd projects/gvsig-standard
$ant svn.checkout.all

Patience, much more patience.

$mvn install

And it’s done. The application is on the products folder. To execute it, we execute the script gvSIG.sh.

If at the start we get the “command java not found” error, we have to specify the environment variable JAVA_HOME:

$export JAVA_HOME=/usr/lib/jvm...

Now you can use your own customized version.

Soon, I will post about how to create plugins.

Easy map on Java

Sometimes you don’t know where to start when you enter the world of GIS programming. Too many libraries, IDEs, but the truth is, everyone assumes you already have a base and everything become chaos. Something is easy as how to develop a map on Java has scarce documentation.

If you have absolutely no idea of GIS, I would recommend you start by the Free book of Free GIS by Victor Olaya.

For beginners I would recommend that you take a look at a fairly new project aimed at extending Swing (the default graphics java library) with geographical widgets. In this way, add a map to a Java desktop application would be a task as simple as adding a button or text field.

Of course, GIS applications have some complexity, a simple display like this is not enough. But it is a good starting point to get familiar with what a map is and what can a developer do.

We start with a Java project and add SwingX-WS to its dependencies. Then, the following code would show a window with a simple map:

es.emergya.gis.examples package;

import java.awt.BorderLayout;

public class  SwingWS {

  public static void main (String [] args) {
    Form = new JFrame JFrame ("Map");

    JXMapKit JXMapKit jXMapKit1 = new ();
    jXMapKit1.setDefaultProvider (org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
    jXMapKit1.setDataProviderCreditShown (true);
    jXMapKit1.setName ("jXMapKit1") / / NOI18N
    jXMapKit1.setAddressLocation(new GeoPosition(41.881944, 39.627778));

    form.getContentPane().add(jXMapKit1, BorderLayout.CENTER);

    form.pack();
    form.setVisible(true);
  }
}

The tiles of the maps drawn from OpenStreetMap , but is fully configurable for any WMS server.

So now you have your map on java.

en_GBEnglish (UK)