What is IGGGIS ?


teaser01
Fig.1 - Roads in Bonn queried from a postgis database.
teaser02
Fig.2 - Building footprints with minimal bounding circle.

IGGGIS is a simple java application to display geoinformation data. It is designed for educational purposes for usage alongside lectures in the topic of geoinformation science.

Source on Github API Download Pagelatest version: 1.1

Setup

Setting up IGGGIS is straight forward:

IGGGIS uses three main libraries: the JTS Topology Suite for planar geometry, GeoTools for importing and exporting to ESRI Shapefiles and Postgis for importing from PostgreSQL databases.

On the Download Page you find compiled jar-files for these three libraries as well as the current version of IGGGIS.

Download all these files and put them into the classpath of your Java application. You should be ready to start coding your own mapping application!

Code Examples

The example data used in the following listings can be found here: example data

Listing 1: A minimalist example to read POIs from an ESRI shapefile and displaying them as point features in a map frame.

public static void main(String[] args) {
	try {
		List features = FeatureReader.readFeaturesFromShapefile(new File("data/pois-bonn.shp"));
					
		ListLayer myLayer = new ListLayer(SymbolFactory.DEFAULT_FACTORY);
		for (Feature f : features)
			myLayer.add(f);
										
		MapPanel panel = new MapPanel();
		panel.getMap().addLayer(myLayer, 1);

		JFrame frame = new JFrame("POIs in Bonn");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(panel);
		Dimension size = new Dimension(640, 480);
		frame.setSize(size);
		frame.setPreferredSize(size);
		frame.setVisible(true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}					
Listing 1 - result
Fig.3 - Result for the minimalist example: all POIs are drawn as a black dot.

Listing 2: The way the points are displayed on the map is controlled by the SymbolFactory. The following listing is an example for a more advanced SymbolFactory, that displays POIs colored according to their category.

public class CategorizedSymbolFactory implements SymbolFactory {
	private Color defaultColor;
	private String categoryColName;
	private TreeMap categories;
		
	public CategorizedSymbolFactory(Color c, String s) {
		this.defaultColor = c;
		this.categoryColName = s;
		this.categories = new TreeMap();
	}
	
	public void addCategory(String name, Color c) {
		this.categories.put(name, c);
	}
	
	@Override
	public Symbol createSymbol(Feature f) {
		Color c = categories.get(f.getAttribute(categoryColName));
		if (c == null) c = defaultColor;
		return new PointSymbol(f, c);
	}
}					
Listing 2 - example result
Fig.4 - Restaurants in red, cafes in green and bars in blue. The default color is set to black.

Listing 3: IGGGIS supports postgis databases as data source for geometry layers. The following listing is a minimal example for a connection to such a database. The DatabaseLayer queries the geometry features on demand meaning that only the features in the current view frame are loaded and updated dynamically on map state change.

public static void main(String[] args) {
	// add server adress and user credentials
	PGSimpleDataSource dataSource = new PGSimpleDataSource();
	dataSource.setServerNames(new String[] { ... });
	dataSource.setPortNumbers(new int[] { ... });
	dataSource.setDatabaseName(...);
	dataSource.setUser(...);
	dataSource.setPassword(...); // better: use JPasswordField to avoid
								 // setting password in plain text

	// create DatabaseLayer that queries DB on demand
	DatabaseLayer dbl = null;
	try {
		dbl = new DatabaseLayer(dataSource.getConnection().createStatement(), 
								SymbolFactory.DEFAULT_FACTORY, "lines", "geom");
								// "lines" is the table name, "geom" the geometry column name
	} catch (SQLException e) {
		e.printStackTrace();
		System.exit(1); // connection failed --> exit
	}

	// define map panel with specific view point
	MapPanel panel = new MapPanel();
	panel.getMap().setAutoFitToDisplay(false);
	panel.getMap().addLayer(dbl, 1, false);
	double xM = 365600;
	double yM = 5620900;
	panel.getMap().fitBoxToDisplay(new Envelope(xM - 500, xM + 500, yM - 500, yM + 500));

	// create main frame
	JFrame frame = new JFrame("Roads NRW");
	Dimension size = new Dimension(640, 480);
	frame.add(panel);
	frame.setSize(size);
	frame.setPreferredSize(size);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
}
Listing 3 - database layer
Fig.5 - Roads in Bonn queried from a postgis database.

Contact

IGGGIS is being developed by the Working Group Geoinformation at the Institute for Geodesy and Geoinformation at University Bonn.

For questions or problems regarding the application please turn to Axel Forsch or Viktor Stroh, {familyname}@igg.uni-bonn.de