1

I have already created a raster layer in the postgres default 'public' schema and published it in GeoServer through the ImageMosaic JDBC. This is working fine but I would like to use a new custom schema in PostgreSQL instead of the public schema.

When setting up the raster using public schema, I did not specify schema in the connect.pgraster.xml.inc file and also did not create a datastore.properties file. This worked fine. See below for the original 3 xml config files :

connect.pgraster.xml.inc:

<connect>
  <!-- value DBCP or JNDI -->
  <dstype value="DBCP"/>
  <!--   <jndiReferenceName value=""/>  -->
  <username value="username" />
  <password value="password" />
  <jdbcUrl value="jdbc:postgresql://<host>:5432/dbname" />
  <driverClassName value="org.postgresql.Driver"/>
  <maxActive value="10"/>
  <maxIdle value="0"/>
</connect>

mapping.pgraster.xml.inc

<!-- possible values: universal,postgis,db2,mysql,oracle -->
<spatialExtension name="pgraster"/>
<mapping>
    <masterTable name="mosaic" >
        <coverageNameAttribute name="name"/>
        <tileTableNameAtribute name="tiletable" />
        <maxXAttribute name="maxx"/>
        <maxYAttribute name="maxy"/>
        <minXAttribute name="minx"/>
        <minYAttribute name="miny"/>
        <resXAttribute name="resx"/>
        <resYAttribute name="resy"/>
    </masterTable>
    <tileTable>
        <blobAttributeName name="rast" />
    </tileTable>
</mapping>

coverage_name.pgraster.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ImageMosaicJDBCConfig [
  <!ENTITY mapping PUBLIC "mapping"  "mapping.pgraster.xml.inc">
  <!ENTITY connect PUBLIC "connect"  "connect.pgraster.xml.inc">
]>

<config version="1.0">
  <coverageName name="coverage_name"/>
  <coordsys name="EPSG:3857"/>
  <!-- interpolation 1 = nearest neighbour, 2 = bipolar, 3 = bicubic -->
  <scaleop  interpolation="1"/>
<axisOrder ignore="false"/>
  &mapping;
  &connect;
</config>

When attempting to set up the raster layer in a custom schema, I updated the jdbcUrl value in the connect.pgraster.xml.inc file to specify the custom schema name. I did not change the other config files (mapping.pgraster.xml.inc and coverage_name.pgraster.xml). This did not work. I then created a datastore.properties file where I also set the schema to the custom schema name. This also did not work.

Both times i got this error:

Failed to create reader from file:coverages/coverage_name.pgraster.xml and
hints Hints: LENIENT_DATUM_SHIFT = true COMPARISON_TOLERANCE = 1.0E-8
STYLE_FACTORY = StyleFactoryImpl EXECUTOR_SERVICE =
 java.util.concurrent.ThreadPoolExecutor@19268c7[Running, pool size = 0, active
threads = 0, queued tasks = 0, completed tasks = 0]
FORCE_LONGITUDE_FIRST_AXIS_ORDER = true FORCE_AXIS_ORDER_HONORING = http
FILTER_FACTORY = FilterFactoryImpl GRID_COVERAGE_FACTORY = GridCoverageFactory
TILE_ENCODING = null FEATURE_FACTORY =
org.geotools.feature.LenientFeatureFactoryImpl@1b0cd4d

See below for the updated connect.pgraster.xml.inc, the new datastore.properties file, and mosaic table setup. What else do I need to change to enable use of a custom schema?

connect.pgraster.xml.inc:

<connect>
  <!-- value DBCP or JNDI -->
  <dstype value="DBCP"/>
  <!--   <jndiReferenceName value=""/>  -->
  <username value="username" />
  <password value="password" />
  <jdbcUrl value="jdbc:postgresql://<host>:5432/dbname?currentSchema=custom_schema_name" />
  <driverClassName value="org.postgresql.Driver"/>
  <maxActive value="10"/>
  <maxIdle value="0"/>
</connect>

datastore.properties

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory
host=<host>
port=5432
database=dbname
schema=custom_schema_name
user=username
passwd=password
Loose\ bbox=true
Estimated\ extends=false
validate\ connections=true
Connection\ timeout=10
preparedStatements=true

mosaic table:

name            tiletable            minx  miny  maxx  maxy  resx  resy
coverage_name   raster_table
coverage_name   o_16_raster_table
coverage_name   o_2_raster_table
coverage_name   o_32_raster_table
coverage_name   o_4_raster_table
coverage_name   o_64_raster_table
coverage_name   o_8_raster_table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.