[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] WKB to native geometry using BULK COPY
From:       David Blasby <dblasby () refractions ! net>
Date:       2004-03-24 17:38:15
Message-ID: 4061C787.80501 () refractions ! net
[Download RAW message or body]

Ryan Proulx wrote:

> Any thoughts on this yet? Or is this just a really stupid question? I am open to \
> suggestions on how to make transfering data in and out of PostGIS easier. 
> Regards,
> ryan
> 
> -----Original Message-----
> From: Ryan Proulx 
> Sent: March 4, 2004 16:02
> To: PostGISUserGroup (E-mail)
> Subject: [postgis-users] WKB to native geometry using BULK COPY
> 
> 
> Greetings,
> 
> I am curious how I can use the COPY commands to insert literal geometry data. \
> Currently this works with WKT by specifying the geometry as:  
> 'srid=<srid>;<the_geometry_as_wkt>'. 
> 
> However, I would like to do the same thing using WKB. Any ideas on how that might \
> successfully be done?  
> It seems I will have to get an SRID and a WKB geometry, in hex preferably, and \
> combine the two to form a single hex literal to be inserted directly into a column \
> of type GEOMETRY. 
> When I am using single INSERT statements instead of the COPY commands I use the \
> 'geomfromwkb' function to combine the SRID and WKB hex string, so I guess what I \
> really need to know is how this is accomplished and likely what the native \
> underlying geometry looks like.

Dont try to directly create a GEOMETRY object outside the database - 
you're almost certainly going to give yourself nightmares!

Currently, postgis allows the "srid=<srid>;<wkt>" for input to the 
"normal" creation function ("geometry_in()").

You could modify the PostGIS geometry_in() function so that it could 
tell the difference between "srid=<srid>;<wkt>" and say 
"srid=<srid>;<hex WKB>".

IF <isWKB>
    get SRID (-1 if not present)
    grab the hex WKB portion of the input string
    convert hex WKB string to an actual WKB type (WKB_in())
    convert the WKB to GEOMETRY (geometry_from_wkb())
    set the SRID on the new GEOMETRY (setSRID())
    return the GEOMETRY;
ELSE <is WKT>
    ... as before ...
END


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic