Tuesday, July 17, 2012

First Impressions with 3DcityDB for PostGIS

Hi.

By some previous work with 3DcityDB and CityGML, and also by an email of a collegue Hugo.L, i was tempted to test both PotsGIS 2.0 and 3DCityDB for PostGIS.

I will skip the installation of Postgres and PostGIS on my MAc and jump straight into the review of the  product.

Impressions:

After following the Tutorial document which required to create a DB using whatever you like and enable it to PostGIS, next steps require additional scripts, however they are created for windows  or at least the
CREATE_DB.bat

which calls

CREATE_DB.SQL

The first one I  tried to UNIXify or macify it :

#/bin/sh                                                                                                                        
echo batchfile that calls CREATE_DB.sql
export PGPORT=5432                                                                                                             
export PGHOST=localhost                                                                                                        
export PGUSER=postgres                                                                                                         
export CITYDB=3dcitydb                                                                                                         
export PGBIN=/usr/local/pgsql/bin                                                                                              
echo  creating the 3D City Database
$PGBIN/psql -d $CITYDB -f CREATE_DB.sql -h $PGHOST -p $PGPORT

however i had no success as I am not hardcore with scripting, 


batchfile that calls CREATE_DB.sql
/psql: No such file or directory/pgsql/bin

however I ran the script by manually like this

$ /usr/local/pgsql/bin/psql -d 3dcitydb -f CREATE_DB.sql -h localhost -p 5432 -U postgres


after which i was prompted for the following

Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin):                28992
Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783):                          urn:ogc:def:crs:28992

28992                                    for the Dutch EPSG or SRS number
urn:ogc:def:crs:28992,       well, I just came with that to see what happens

and after endless SQL functions executed, the following errors appeared


CREATE FUNCTION
psql:PL_pgSQL/GEODB_PKG/MATCHING/MERGE.sql:215: ERROR:  invalid byte sequence for encoding "UTF8": 0xe46e64
psql:PL_pgSQL/GEODB_PKG/MATCHING/MERGE.sql:301: ERROR:  invalid byte sequence for encoding "UTF8": 0xe46e64
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
psql:PL_pgSQL/GEODB_PKG/MATCHING/MERGE.sql:646: ERROR:  invalid byte sequence for encoding "UTF8": 0xe46e64
CREATE FUNCTION
CREATE FUNCTION


I checked my database and is UTF8 encoded so, I checked the sql, and such lines correspond to  extra spaces after the $$ symbol, so maybe as UNIX scripting dislikes spaces i remove them, but no success as that is no unix script.

After some tests with different editors, I tried opening my MERGE.sql with JEdit and after reloading as UTF8 showed a UTF8 ERROR somewhere in line 258 , 159 and 593

    -- building furniture (in rooms) --bei lod r in f ge�ndert

so i removed the offending character and now it ran flawlessly

Future experiences will  follow.

SE ya!





Monday, July 09, 2012

Geoserver ImageMosaic plugin mini troubleshooter

Geoserver Image Mosaic Plugin troubleshooting.

During a recent project, I was challenged to load thousands of images using Geoserver, which is not perfectly suited to this task, due to the high footprint incurred in creating multiple layers and the loading of images and Geoserver itself.

To overcome the situation, the ImageMosaicPlugin offers a nice option to load a folder with images as a single layer where every image should have the following characteristics:

the image
E13B33B.jpg (or TIF or PNG or ...)
the world file
E13B33B.jgw (of TFW or PNW or ...)
and the most important, the projection file
E13B33B.prj

The image file explains by itself, is the raster you want to display.

The world file is a small text file including the size of the pixel in both horizontal and vertical direction, expresed with the first and fourth line. That size is expressed on the same units as the image, which in my case is on decimal degrees.
The last two lines correspond to the center position of pixel in the up left corner


0.00002777777775
0.0
0.0
-2.77777777777778E-05
-104.222208333111
19.4999861110111

And Finally, the PRJ file is the definition of the projection, which I extracted using GDALINFO


GEOGCS["WGS 84", 
  DATUM["World Geodetic System 1984", 
    SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], 
    AUTHORITY["EPSG","6326"]], 
  PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
  UNIT["degree", 0.017453292519943295], 
  AXIS["Geodetic longitude", EAST],
  AXIS["Geodetic latitude", NORTH],  
  AUTHORITY["EPSG","4326"]]




Is important to add this last file because otherwise you will receive the following error:


Could not list layers for this store, an error occurred retrieving them: Unable to acquire a reader for this coverage with format: ImageMosaic


So be sure to have them all.

Now that you have all the files in a folder fulfilling this characteristics and requirements, is possible now to use the ImageMosaicPlugin to load that folder, which will automatically create a shapefile containing the spatial index if the images, and which can be further queried using CQL, which i hope I will explain later.

Hope this helps.

Cheers.
UB

UPDATE:


In case u forgot some of the previous steps. the Plugin will create a shapefile named after the directory, so be sure to delete all created files with .shp and alikes, otherwise  it will fail to create the desired layer.