Month: August 2012

A quiz about Apple, the shameless company.

Posted by – Saturday 2012-08-25

I have a question, for you, smart readers of this humble blog. Maybe one of you can help me.

On August 24th, 2012 a jury in a federal court in California, United States of America, ruled that the South Korean company Samsung violated some of Apple Inc’s patents. Among the violated patents, some of them are as absurd like a rectangle with round corners.

However, in 1994 Steve Jobs, Apple’s CEO, claimed that «… we have been always shameless about stealing great ideas.»

So the question is: how can you claim that stealing is great and years later sue a competitor for doing the same you «shameless» did some years ago?

More…

GeoServer SQL views.

Posted by – Monday 2012-08-20

In this post we will see a simple example of how GeoServer’s SQL views [note 1] can be used to derive multiple layers from a single SQL table.

1. The arena.

I had a table in a PostGIS database that stores the geometries of all roads in the province of Lugo. Each road has a geometry and a set of attributes. One of these attributes is ‘owner’, which stores the road owner: a municipality, a province, a regional government or the central government.

From this table I needed to generate four WMS layers: roads owned by municipalities, roads owned by the the province, and so on.

More…

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…