Skip to content
Browse files

Adapt PG raster online test

  • Loading branch information...
1 parent b35d130 commit 17b97fe68de9055a133d71584fc6f0159a786bda Christian Mueller committed Aug 12, 2012
View
9 docs/user/library/coverage/pgraster.rst
@@ -24,17 +24,10 @@ This plugin expects the following table layout:
Of course, it is possible to use sql views instead of tables for
creating the best physical table layout for the local deployment
-.. warning::
-
- At the time of developing this module, Postgis 2.0 was not a final version.
- The support for OUT-DB rasters is not working, IN-DB rasters work fine.
-
Prepare the tiles and overviews using the gdal tool box http://www.gdal.org.
A good candidate is http://www.gdal.org/gdal_retile.html.
-The utility for importing the tiles is described here
-http://postgis.refractions.net/documentation/manual-svn/RT_reference.html#RT_Loading_Rasters
-and is included in Postgis 2.0
+The utility for importing the tiles is described here http://postgis.refractions.net/docs/using_raster.xml.html and is included in Postgis 2.0.
An example setup assumes the existense of 3 tables, **rtable1**, **rtable2** **rtable3**. **rtable1** is populated with the tiles from the base image,
View
3 modules/plugin/imagemosaic-jdbc/pom.xml
@@ -145,7 +145,8 @@
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <!-- The version number is specified in the parent POM. -->
+ <!-- Overriding version number from parent POM. -->
+ <version>9.1-901-1.jdbc4</version>
<scope>test</scope>
</dependency>
View
75 ...osaic-jdbc/src/test/java/org/geotools/gce/imagemosaic/jdbc/custom/PGRasterOnlineTest.java
@@ -22,12 +22,14 @@
import java.io.Reader;
import java.net.URL;
import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.util.StringTokenizer;
import org.geotools.gce.imagemosaic.jdbc.AbstractTest;
import org.geotools.gce.imagemosaic.jdbc.Config;
import org.geotools.gce.imagemosaic.jdbc.DBDialect;
+
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -173,9 +175,18 @@ void executeCreate(java.sql.Connection con,String[] scriptNames, boolean outdb)
ps.setString(2, "rtable3");
ps.execute();
+ con.prepareStatement(
+ "CREATE TABLE \"public\".\"rtable1\" (\"rid\" serial PRIMARY KEY,\"rast\" raster,\"filename\" text)").execute();
+ con.prepareStatement(
+ "CREATE TABLE \"public\".\"rtable2\" (\"rid\" serial PRIMARY KEY,\"rast\" raster,\"filename\" text)").execute();
+ con.prepareStatement(
+ "CREATE TABLE \"public\".\"rtable3\" (\"rid\" serial PRIMARY KEY,\"rast\" raster,\"filename\" text)").execute();
+
+/*
con.prepareStatement(
"CREATE TABLE \"public\".\"rtable1\" (rid serial PRIMARY KEY, \"filename\" text)").execute();
+
con.prepareStatement(
"SELECT AddRasterColumn('public','rtable1','rast',4326, ARRAY['8BUI','8BUI','8BUI','8BUI'], "+outdb+
@@ -194,6 +205,7 @@ void executeCreate(java.sql.Connection con,String[] scriptNames, boolean outdb)
con.prepareStatement(
"SELECT AddRasterColumn('public','rtable3','rast',4326, ARRAY['8BUI','8BUI','8BUI','8BUI'], "+outdb+
", false, null, 0.030188679245283, -0.020408163265306, null, null, null)").execute();
+*/
// con.prepareStatement("alter table raster1 drop constraint enforce_srid_rast").execute();
// con.prepareStatement("alter table raster2 drop constraint enforce_srid_rast").execute();
@@ -222,11 +234,25 @@ void executeCreate(java.sql.Connection con,String[] scriptNames, boolean outdb)
con.prepareStatement(
"CREATE INDEX \"rtable1_rast_gist_idx\" ON \"public\".\"rtable1\" USING GIST (st_convexhull(rast))").execute();
con.prepareStatement(
- "CREATE INDEX \"rtable2_rast_gist_idx\" ON \"public\".\"rtable2\" USING GIST (st_convexhull(rast))").execute();
+ "ANALYZE \"public\".\"rtable1\"").execute();
con.prepareStatement(
- "CREATE INDEX \"rtable3_rast_gist_idx\" ON \"public\".\"rtable3\" USING GIST (st_convexhull(rast))").execute();
-
+ "SELECT AddRasterConstraints('public','rtable1','rast',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE)").execute();
+
+ con.prepareStatement(
+ "CREATE INDEX \"rtable2_rast_gist_idx\" ON \"public\".\"rtable2\" USING GIST (st_convexhull(rast))").execute();
+ con.prepareStatement(
+ "ANALYZE \"public\".\"rtable2\"").execute();
+ con.prepareStatement(
+ "SELECT AddRasterConstraints('public','rtable2','rast',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE)").execute();
+
+ con.prepareStatement(
+ "CREATE INDEX \"rtable3_rast_gist_idx\" ON \"public\".\"rtable3\" USING GIST (st_convexhull(rast))").execute();
+ con.prepareStatement(
+ "ANALYZE \"public\".\"rtable3\"").execute();
+ con.prepareStatement(
+ "SELECT AddRasterConstraints('public','rtable3','rast',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE)").execute();
+
con.commit();
//con.close();
} catch (Exception e) {
@@ -243,44 +269,19 @@ public void testDrop() {
java.sql.Connection con = null;
try {
con = getDBDialect().getConnection();
+ con.prepareStatement("DROP TABLE if exists MOSAIC").execute();
+ con.prepareStatement("DROP TABLE IF EXISTS \"public\".\"rtable1\"").execute();
+ con.prepareStatement("DROP TABLE IF EXISTS \"public\".\"rtable2\"").execute();
+ con.prepareStatement("DROP TABLE IF EXISTS \"public\".\"rtable3\"").execute();
+ con.commit();
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
- }
- try {
- con.prepareStatement("DROP TABLE MOSAIC").execute();
- con.commit();
- } catch (Exception e) {}
- try {
- con.prepareStatement("SELECT DropRasterColumn ('public','rtable1','rast')").execute();
- con.commit();
- } catch (Exception e) {}
- try {
- con.prepareStatement("DROP TABLE rtable1").execute();
- con.commit();
- } catch (Exception e) {}
- try {
- con.prepareStatement("SELECT DropRasterColumn ('public','rtable2','rast')").execute();
- con.commit();
- } catch (Exception e) {}
-
- try {
- con.prepareStatement("DROP TABLE rtable2").execute();
- con.commit();
- } catch (Exception e) {}
- try {
- con.prepareStatement("SELECT DropRasterColumn ('public','rtable3','rast')").execute();
- con.commit();
- } catch (Exception e) {}
- try {
- con.prepareStatement("DROP TABLE rtable3").execute();
- con.commit();
- } catch (Exception e) {}
-
- try {
- con.close();
- } catch (Exception e) {}
+ } finally {
+ try { if (con!=null) con.close(); } catch (SQLException ex) {};
+ }
}
+
protected String[] getTileTableNames() {
return new String[] { "rtable1", "rtable2", "rtable3" };
View
BIN modules/plugin/imagemosaic-jdbc/src/test/resources/resources.zip
Binary file not shown.

0 comments on commit 17b97fe

Please sign in to comment.
Something went wrong with that request. Please try again.