Tag: Java

Quick and dirty coordinate transforming using GeoTools.

Posted by – Monday 2012-08-13

In this post we will how to transform 2D coordinates from one coordinate reference system (CRS) to another one using the open source, Java library GeoTools.

In the first section a code snippet is shown, and in the second one the list of needed jars is given.

1. The code.

The following Java code snippet transforms a set of coordinates (x, y) expressed in the ETRS 89, UTM zone 29N (EPSG code 25829) coordinate system to WGS84 (EPSG code 4326). The source coordinates are stored in the variables x and y, and the result is left in the variables transX and transY.

import org.geotools.geometry.DirectPosition2D;

import org.geotools.referencing.CRS;

import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.opengis.referencing.operation.MathTransform;

...

CoordinateReferenceSystem sourceCrs = CRS.decode("EPSG:25829");
CoordinateReferenceSystem targetCrs = CRS.decode("EPSG:4326");

double x = (double) 636497.59434;
double y = (double) 4778964.017375;

boolean lenient = true;
MathTransform mathTransform 
    = CRS.findMathTransform(sourceCrs, targetCrs, lenient);

DirectPosition2D srcDirectPosition2D 
    = new DirectPosition2D(sourceCrs, x, y);
DirectPosition2D destDirectPosition2D 
    = new DirectPosition2D();
mathTransform.transform(srcDirectPostion2D, destDirectPosition2D);

double transX = destDirectPosition2D.x;
double transY = destDirectPosition2D.y;

More…

A short note about setting Apache Tomcat 7 environment variables under Debian 6.

Posted by – Sunday 2012-04-22

In this post we will see a way of setting Apache Tomcat, version 7, environment variables when running under Debian 6.

Let’s suposse that Apache Tomcat – Tomcat for short – has been installed in the directory TOMCAT_DIR and that we want to set the used Java virtual machine and the amount of used RAM memory.

More…

Profiling application LLC cache misses under Linux using Perf Events.

Posted by – Wednesday 2011-11-30

In this post we will see how to do some profiling under Ubuntu Linux using Perf Events, present in the kernel since version 2.6.31 [1, 2]. In particular, we will estimate the rate of Last Level Cache (LLC) misses that a Java application has.

There are GIS applications that are computing power hungry; among them applications processing LiDAR data are an example, because the volume of the input data is usually huge. The efficient usage of the processor caches can boost execution time. Given the high penalty processor cache misses have, identifying application areas causing too much cache misses is very important.

1. Installation of Perf Events

Fortunately, Ubuntu Linux offers Perf Events (PE) in the form of binary packages. By using the command apt-get, installation is straighforward:

$ sudo apt-get install linux-tools-common linux-tools-2.6.38-13

Two notes about installation. First, before attempting installation check that the kernel you are using is recent enough: Perf Events [note 1] is available since Linux version 2.6.31. Second, install a version of the package linux-tools matching your kernel version.

More…

Java: how many threads are in a cached thread pool?

Posted by – Sunday 2011-07-17

The advent of multicore processors and the good thread support that Java has, have made this platform a good choice for parallel computing.

When distributing the workload among the created threads, questions like the optimum number and when to create and destroy them are important. Usually the answers to these questions are not obvious.

More…

Getting the Well-Known Binary representation of geometries using the JTS Topology Suite.

Posted by – Thursday 2010-11-25

In this post we will see how to get the Well-Known Binary[1] (WKB) representation of geometries using the Java library JTS Topology Suite. WKB is a binary, serialized form of the Well-Known Text (WKT) representation of geometries.

In the first section a sample program getting the WKB representation of two simple geometries is shown. The second section covers potential issues related with endiannesss.

1. Simple Java code

JTS Topology Suite package com.vividsolutions.jts.io provides classes to get both WKB and WKT representations of geometries. Let’s see how to get the WKB representation of a point and a polygon using them; the key class is WKBWriter.

More…