[postgis-users] Convert/cast bytea to raster
dustymugs
dustymugs at gmail.com
Thu Jun 27 10:45:49 PDT 2013
Daniel,
Is it safe to assume that the OutOfMemoryException exception is coming
from NHibernate? It doesn't look like something PostgreSQL or PostGIS
would emit.
How big is the source raster file that is causing that error?
It doesn't look like there is the capability to import the WKB. Can you
file a ticket? I'll see about getting it done for 2.2.
-bborie
On 06/26/2013 02:40 AM, Hedén Daniel wrote:
> Hi,
>
> I am working on a program that stores GIS data in a PostgreSQL database, the program is using NHibernate (C#, Npgsql and NpgsqlParameter bound to columns) to map database objects to entities in the program.
> My problem is with saving raster data to the database I convert the raster file to a byte array with the format of described in: http://trac.osgeo.org/postgis/browser/trunk/raster/doc/RFC2-WellKnownBinaryFormat, (using raster2pgsql.exe and extracting the hex string from the generated SQL).
> And I can't use the SQL from raster2pgsql.exe to insert/update the database directly I have to do it by a NpgsqlParameter in an INSERT or UPDATE statement because there are more tables that are updated in the same transaction and objects cached and many clients work against the same server.
>
> The problem is with inserting/updating the raster column from this data.
>
> The SQL used to update/set the raster column looks like this:
> UPDATE "GeoObject" SET "the_geom" = :p0, "the_raster" = :p1, "MetaId" = :p2, "SymbolId" = :p3 WHERE "ObjectId" = :p4
>
> It works to set the raster column from a hex string if I add a cast of the raster parameter like this:
> UPDATE "GeoObject" SET "the_geom" = :p0, "the_raster" = :p1::raster, "MetaId" = :p2, "SymbolId" = :p3 WHERE "ObjectId" = :p4
>
> I can insert smaller raster files like this, but if the file is to big I get an OutOfMemoryException because it can't allocate a string big enough to hold the hex string.
> And if I try to use a bytea parameter I can't convert that to raster and I get the error "cannot cast type bytea to raster".
>
> Is there a way to insert raster data from the binary equivalence of the hex string raster2pgsql generates ? (A function that takes bytea and returns raster, a reverse of ST_AsBinary)
>
>
> Regards
>
> Daniel Hedén
> Sweco Position, Falun Sweden
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
More information about the postgis-users
mailing list