postgresql - What's the "E" before a Postgres string? -


i reading postgres/postgis statement this:

select st_asbinary( st_geomfromwkb(   e'\\001\\001\\000\\000\\000\\321\\256b\\312o\\304q\\300\\347\\030\\220\\275\\336%e@',   4326   ) ); 

the above creates known binary (wkb). haven't seen specific way of quoting here string single quoted e preceding beginning quote.

what format called? , formatting rules this? e.g. 336%e@ @ end special or binary value?

this postgres9.3/9.4; postgis 2.1.

as per postgresql documentation http://www.postgresql.org/docs/9.0/static/sql-syntax-lexical.html (emphasis mine)

postgresql accepts "escape" string constants, extension sql standard. an escape string constant specified writing letter e (upper or lower case) before opening single quote, e.g., e'foo'. (when continuing escape string constant across lines, write e before first opening quote.) within escape string, backslash character () begins c-like backslash escape sequence, in combination of backslash , following character(s) represent special byte value

the use of \\ in string means it's escaping escape sequence, safe in transit , storage in .sql file. verbatim string passed st_geomfromwkb function be:

\001\001\000\000\000\321\256b\312o\304q\300\347\030\220\275\336%e@ 

these sequences of 3 or 4 characters between slashes interpreted st_geofromwkb directly.

the documentation st_geofromwkb ( http://postgis.org/docs/st_geomfromwkb.html ) states:

the st_geomfromwkb function, takes well-known binary representation of geometry , spatial reference system id (srid) , creates instance of appropriate geometry type. function plays role of geometry factory in sql. alternate name st_wkbtosql.

unfortunately doesn't state format, exactly, "well-known binary representation" is.

it turns out content of string depends on coordinate system you're using, specified srid parameter. in case 4326 corresponds wgs84: https://en.wikipedia.org/wiki/world_geodetic_system#wgs84

you'll need further reading , research untangle that.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -