mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 09:02:37 +00:00
1dfa144781
Fix cross-linking between encoded polyline in/out funx Add link to encoded polyline algorithm format git-svn-id: http://svn.osgeo.org/postgis/trunk@12751 b70326c6-7e19-0410-871a-916f4a2858ee
1300 lines
51 KiB
XML
1300 lines
51 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<sect1 id="Geometry_Outputs">
|
|
<title>Geometry Outputs</title>
|
|
<refentry id="ST_AsBinary">
|
|
<refnamediv>
|
|
<refname>ST_AsBinary</refname>
|
|
<refpurpose>Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>text </type><parameter>NDR_or_XDR</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>text </type><parameter>NDR_or_XDR</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the Well-Known Binary representation of the geometry. There are 2 variants of the function. The first
|
|
variant takes no endian encoding parameter and defaults to server machine endian. The second variant takes a second argument
|
|
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</para>
|
|
<para>This is useful in binary cursors to pull data out of the
|
|
database without converting it to a string representation.</para>
|
|
|
|
<note>
|
|
<para>The WKB spec does not include the SRID. To get the WKB with SRID format use ST_AsEWKB</para>
|
|
</note>
|
|
<note>
|
|
<para>ST_AsBinary is the reverse of <xref linkend="ST_GeomFromWKB" /> for geometry. Use <xref linkend="ST_GeomFromWKB" /> to convert to a postgis geometry from ST_AsBinary representation.</para>
|
|
</note>
|
|
|
|
<note>
|
|
<para>The default behavior in PostgreSQL 9.0 has been changed to output bytea in hex encoding. ST_AsBinary is the reverse of <xref linkend="ST_GeomFromWKB" /> for geometry. If your GUI tools
|
|
require the old behavior, then SET bytea_output='escape' in your database.</para>
|
|
</note>
|
|
|
|
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
|
|
<para>Enhanced: 2.0.0 support for higher coordinate dimensions was introduced.</para>
|
|
<para>Enhanced: 2.0.0 support for specifying endian with geography was introduced.</para>
|
|
<para>Availability: 1.5.0 geography support was introduced.</para>
|
|
<para>Changed: 2.0.0 Inputs to this function can not be unknown -- must be geometry. Constructs such as <code>ST_AsBinary('POINT(1 2)')</code> are no longer valid and you will get an <code>n st_asbinary(unknown) is not unique error</code>. Code like that
|
|
needs to be changed to <code>ST_AsBinary('POINT(1 2)'::geometry);</code>. If that is not possible, then install <filename>legacy.sql</filename>.</para>
|
|
<para>&sfs_compliant; s2.1.1.1</para>
|
|
<para>&sqlmm_compliant; SQL-MM 3: 5.1.37</para>
|
|
<para>&curve_support;</para>
|
|
<para>&P_support;</para>
|
|
<para>&T_support;</para>
|
|
<para>&Z_support;</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
|
|
st_asbinary
|
|
--------------------------------
|
|
\001\003\000\000\000\001\000\000\000\005
|
|
\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\360?\000\000\000\000\000\000
|
|
\360?\000\000\000\000\000\000\360?\000\000
|
|
\000\000\000\000\360?\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000
|
|
(1 row)</programlisting>
|
|
<programlisting>SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
|
|
st_asbinary
|
|
--------------------------------
|
|
\000\000\000\000\003\000\000\000\001\000\000\000\005\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
\000?\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000
|
|
\000\000\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
(1 row)</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para>
|
|
<xref linkend="ST_GeomFromWKB" />
|
|
<xref linkend="ST_AsEWKB" />,
|
|
<xref linkend="ST_AsText" />,
|
|
</para>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="ST_AsEWKB">
|
|
<refnamediv>
|
|
<refname>ST_AsEWKB</refname>
|
|
<refpurpose>Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsEWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsEWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>text </type><parameter>NDR_or_XDR</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
<para>Returns the Well-Known Binary representation of the geometry with SRID metadata. There are 2 variants of the function. The first
|
|
variant takes no endian encoding parameter and defaults to little endian. The second variant takes a second argument
|
|
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</para>
|
|
<para>This is useful in binary cursors to pull data out of the
|
|
database without converting it to a string representation.</para>
|
|
<note>
|
|
<para>The WKB spec does not include the SRID. To get the OGC WKB format use ST_AsBinary</para>
|
|
</note>
|
|
<note>
|
|
<para>ST_AsEWKB is the reverse of ST_GeomFromEWKB. Use ST_GeomFromEWKB to convert to a postgis geometry from ST_AsEWKB representation.</para>
|
|
</note>
|
|
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
|
|
<para>&Z_support;</para>
|
|
<para>&curve_support;</para>
|
|
<para>&P_support;</para>
|
|
<para>&T_support;</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
|
|
st_asewkb
|
|
--------------------------------
|
|
\001\003\000\000 \346\020\000\000\001\000
|
|
\000\000\005\000\000\000\000
|
|
\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\360?\000\000\000\000\000\000\360?
|
|
\000\000\000\000\000\000\360?\000\000\000\000\000
|
|
\000\360?\000\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
(1 row)</programlisting>
|
|
<programlisting>
|
|
SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
|
|
st_asewkb
|
|
--------------------------------
|
|
\000 \000\000\003\000\000\020\346\000\000\000\001\000\000\000\005\000\000\000\000\
|
|
000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000?
|
|
\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000\000\000
|
|
\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_SRID" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="ST_AsEWKT">
|
|
<refnamediv>
|
|
<refname>ST_AsEWKT</refname>
|
|
<refpurpose>Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsEWKT</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsEWKT</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the Well-Known Text representation of the geometry prefixed with the SRID.</para>
|
|
|
|
<note>
|
|
<para>The WKT spec does not include the SRID. To get the OGC WKT format use ST_AsText</para>
|
|
</note>
|
|
<para><inlinegraphic fileref="images/warning.png" />
|
|
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
|
|
</para>
|
|
<note>
|
|
<para>ST_AsEWKT is the reverse of <xref linkend="ST_GeomFromEWKT" />. Use <xref linkend="ST_GeomFromEWKT" /> to convert to a postgis geometry from ST_AsEWKT representation.</para>
|
|
</note>
|
|
<para>Enhanced: 2.0.0 support for Geography, Polyhedral surfaces, Triangles and TIN was introduced.</para>
|
|
<para>&Z_support;</para>
|
|
<para>&curve_support;</para>
|
|
<para>&P_support;</para>
|
|
<para>&T_support;</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_AsEWKT('0103000020E61000000100000005000000000000
|
|
000000000000000000000000000000000000000000000000000000
|
|
F03F000000000000F03F000000000000F03F000000000000F03
|
|
F000000000000000000000000000000000000000000000000'::geometry);
|
|
|
|
st_asewkt
|
|
--------------------------------
|
|
SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))
|
|
(1 row)
|
|
|
|
SELECT ST_AsEWKT('0108000080030000000000000060E30A4100000000785C0241000000000000F03F0000000018
|
|
E20A4100000000485F024100000000000000400000000018
|
|
E20A4100000000305C02410000000000000840')
|
|
|
|
--st_asewkt---
|
|
CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_AsBinary" /><xref linkend="ST_AsEWKB" /><xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromEWKT" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="ST_AsGeoJSON">
|
|
<refnamediv>
|
|
<refname>ST_AsGeoJSON</refname>
|
|
|
|
<refpurpose>Return the geometry as a GeoJSON element.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the geometry as a Geometry Javascript Object Notation (GeoJSON) element. (Cf <ulink
|
|
url="http://geojson.org/geojson-spec.html">GeoJSON
|
|
specifications 1.0</ulink>). 2D and 3D Geometries are both
|
|
supported. GeoJSON only support SFS 1.1 geometry type (no curve
|
|
support for example).</para>
|
|
|
|
<para>The gj_version parameter is the major version of the GeoJSON spec. If specified, must be 1. This represents the spec version of GeoJSON.</para>
|
|
|
|
<para>The third argument may be used to reduce the maximum number
|
|
of decimal places used in output (defaults to 15).</para>
|
|
|
|
<para>The last 'options' argument could be used to add Bbox or Crs
|
|
in GeoJSON output:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>0: means no option (default value)</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>1: GeoJSON Bbox</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>2: GeoJSON Short CRS (e.g EPSG:4326)</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>4: GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>Version 1: ST_AsGeoJSON(geom) / precision=15 version=1 options=0</para>
|
|
<para>Version 2: ST_AsGeoJSON(geom, precision) / version=1 options=0</para>
|
|
<para>Version 3: ST_AsGeoJSON(geom, precision, options) / version=1</para>
|
|
<para>Version 4: ST_AsGeoJSON(gj_version, geom) / precision=15 options=0</para>
|
|
<para>Version 5: ST_AsGeoJSON(gj_version, geom, precision) /options=0</para>
|
|
<para>Version 6: ST_AsGeoJSON(gj_version, geom, precision,options)</para>
|
|
|
|
<para>Availability: 1.3.4</para>
|
|
<para>Availability: 1.5.0 geography support was introduced.</para>
|
|
<para>Changed: 2.0.0 support default args and named args.</para>
|
|
<para>&Z_support;</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<para>GeoJSON format is generally more efficient than other formats for use in ajax mapping.
|
|
One popular javascript client that supports this is Open Layers.
|
|
Example of its use is <ulink
|
|
url="http://openlayers.org/dev/examples/vector-formats.html">OpenLayers GeoJSON Example</ulink>
|
|
</para>
|
|
<programlisting>SELECT ST_AsGeoJSON(the_geom) from fe_edges limit 1;
|
|
st_asgeojson
|
|
-----------------------------------------------------------------------------------------------------------
|
|
|
|
{"type":"MultiLineString","coordinates":[[[-89.734634999999997,31.492072000000000],
|
|
[-89.734955999999997,31.492237999999997]]]}
|
|
(1 row)
|
|
--3d point
|
|
SELECT ST_AsGeoJSON('LINESTRING(1 2 3, 4 5 6)');
|
|
|
|
st_asgeojson
|
|
-----------------------------------------------------------------------------------------
|
|
{"type":"LineString","coordinates":[[1,2,3],[4,5,6]]}
|
|
|
|
</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="ST_AsGML">
|
|
<refnamediv>
|
|
<refname>ST_AsGML</refname>
|
|
<refpurpose>Return the geometry as a GML version 2 or 3 element.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<!--
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGML</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGML</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
-->
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGML</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>nprefix=null</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>id=null</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsGML</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>nprefix=null</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>id=null</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the geometry as a Geography Markup Language (GML) element. The version parameter,
|
|
if specified, may be either 2 or 3. If no version parameter is
|
|
specified then the default is assumed to be 2. The precision argument
|
|
may be used to reduce the maximum number of decimal places (<varname>maxdecimaldigits</varname>)
|
|
used in output (defaults to 15).</para>
|
|
<para>GML 2 refer to 2.1.2 version, GML 3 to 3.1.1 version</para>
|
|
<para>The 'options' argument is a bitfield. It could be used to define CRS output type
|
|
in GML output, and to declare data as lat/lon:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>0: GML Short CRS (e.g EPSG:4326), default value</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>1: GML Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>2: For GML 3 only, remove srsDimension attribute from output.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>4: For GML 3 only, use <LineString> rather than <Curve> tag for lines.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>16: Declare that datas are lat/lon (e.g srid=4326). Default is to assume that data are planars.
|
|
This option is useful for GML 3.1.1 output only, related to axis order. So if you set it, it will swap the coordinates
|
|
so order is lat lon instead of database lon lat.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>32: Output the box of the geometry (envelope).</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<para>The 'namespace prefix' argument may be used to specify a custom
|
|
namespace prefix or no prefix (if empty). If null or omitted 'gml' prefix is used</para>
|
|
|
|
|
|
<para>Availability: 1.3.2</para>
|
|
<para>Availability: 1.5.0 geography support was introduced.</para>
|
|
<para>Enhanced: 2.0.0 prefix support was introduced. Option 4 for GML3 was introduced to allow using LineString instead of Curve tag for lines. GML3 Support for Polyhedral surfaces and TINS was introduced. Option 32 was introduced to output the box.</para>
|
|
<para>Changed: 2.0.0 use default named args</para>
|
|
<para>Enhanced: 2.1.0 id support was introduced, for GML 3.</para>
|
|
|
|
<note><para>Only version 3+ of ST_AsGML supports Polyhedral Surfaces and TINS.</para></note>
|
|
<para>&Z_support;</para>
|
|
<para>&P_support;</para>
|
|
<para>&T_support;</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples: Version 2</title>
|
|
<programlisting><![CDATA[SELECT ST_AsGML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
st_asgml
|
|
--------
|
|
<gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 0,1 1,1 1,0 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>]]>
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>Examples: Version 3</title>
|
|
<programlisting>-- Flip coordinates and output extended EPSG (16 | 1)--
|
|
<![CDATA[SELECT ST_AsGML(3, ST_GeomFromText('POINT(5.234234233242 6.34534534534)',4326), 5, 17);
|
|
st_asgml
|
|
--------
|
|
<gml:Point srsName="urn:ogc:def:crs:EPSG::4326"><gml:pos>6.34535 5.23423</gml:pos></gml:Point>]]>
|
|
</programlisting>
|
|
<programlisting>-- Output the envelope (32) --
|
|
<![CDATA[SELECT ST_AsGML(3, ST_GeomFromText('LINESTRING(1 2, 3 4, 10 20)',4326), 5, 32);
|
|
st_asgml
|
|
--------
|
|
<gml:Envelope srsName="EPSG:4326">
|
|
<gml:lowerCorner>1 2</gml:lowerCorner>
|
|
<gml:upperCorner>10 20</gml:upperCorner>
|
|
</gml:Envelope>]]>
|
|
</programlisting>
|
|
|
|
<programlisting>-- Output the envelope (32) , reverse (lat lon instead of lon lat) (16), long srs (1)= 32 | 16 | 1 = 49 --
|
|
<![CDATA[SELECT ST_AsGML(3, ST_GeomFromText('LINESTRING(1 2, 3 4, 10 20)',4326), 5, 49);
|
|
st_asgml
|
|
--------
|
|
<gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326">
|
|
<gml:lowerCorner>2 1</gml:lowerCorner>
|
|
<gml:upperCorner>20 10</gml:upperCorner>
|
|
</gml:Envelope>]]>
|
|
</programlisting>
|
|
|
|
<programlisting>-- Polyhedral Example --
|
|
SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
|
|
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
|
|
((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
|
|
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )'));
|
|
st_asgml
|
|
--------
|
|
<![CDATA[ <gml:PolyhedralSurface>
|
|
<gml:polygonPatches>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">0 0 0 0 0 1 0 1 1 0 1 0 0 0 0</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">0 0 0 0 1 0 1 1 0 1 0 0 0 0 0</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">0 0 0 1 0 0 1 0 1 0 0 1 0 0 0</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">1 1 0 1 1 1 1 0 1 1 0 0 1 1 0</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">0 1 0 0 1 1 1 1 1 1 1 0 0 1 0</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
<gml:PolygonPatch>
|
|
<gml:exterior>
|
|
<gml:LinearRing>
|
|
<gml:posList srsDimension="3">0 0 1 1 0 1 1 1 1 0 1 1 0 0 1</gml:posList>
|
|
</gml:LinearRing>
|
|
</gml:exterior>
|
|
</gml:PolygonPatch>
|
|
</gml:polygonPatches>
|
|
</gml:PolyhedralSurface>]]>
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="ST_GeomFromGML" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="ST_AsHEXEWKB">
|
|
<refnamediv>
|
|
<refname>ST_AsHEXEWKB</refname>
|
|
|
|
<refpurpose>Returns a Geometry in HEXEWKB format (as text) using either
|
|
little-endian (NDR) or big-endian (XDR) encoding.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsHEXEWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>NDRorXDR</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsHEXEWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns a Geometry in HEXEWKB format (as text) using either
|
|
little-endian (NDR) or big-endian (XDR) encoding. If no encoding is specified, then NDR is used.</para>
|
|
|
|
<note>
|
|
<para>Availability: 1.2.2</para>
|
|
</note>
|
|
<para>&Z_support;</para>
|
|
<para>&curve_support;</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>SELECT ST_AsHEXEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
which gives same answer as
|
|
|
|
SELECT ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326)::text;
|
|
|
|
st_ashexewkb
|
|
--------
|
|
0103000020E6100000010000000500
|
|
00000000000000000000000000000000
|
|
00000000000000000000000000000000F03F
|
|
000000000000F03F000000000000F03F000000000000F03
|
|
F000000000000000000000000000000000000000000000000</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsKML">
|
|
<refnamediv>
|
|
<refname>ST_AsKML</refname>
|
|
|
|
<refpurpose>Return the geometry as a KML element. Several variants. Default version=2, default precision=15</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsKML</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsKML</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsKML</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>nprefix=NULL</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsKML</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>text </type> <parameter>nprefix=NULL</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the geometry as a Keyhole Markup Language (KML) element. There are several variants of this function.
|
|
maximum number of decimal places used in
|
|
output (defaults to 15), version default to 2 and default namespace is no prefix.</para>
|
|
|
|
<para>Version 1: ST_AsKML(geom_or_geog, maxdecimaldigits) / version=2 / maxdecimaldigits=15 </para>
|
|
<para>Version 2: ST_AsKML(version, geom_or_geog, maxdecimaldigits, nprefix) maxdecimaldigits=15 / nprefix=NULL </para>
|
|
|
|
<note>
|
|
<para>Requires PostGIS be compiled with Proj support. Use <xref linkend="PostGIS_Full_Version" /> to confirm you have proj support compiled in.</para>
|
|
</note>
|
|
|
|
<note>
|
|
<para>Availability: 1.2.2 - later variants that include version param came in 1.3.2</para>
|
|
</note>
|
|
<note>
|
|
<para>Enhanced: 2.0.0 - Add prefix namespace. Default is no prefix</para>
|
|
</note>
|
|
<note>
|
|
<para>Changed: 2.0.0 - uses default args and supports named args</para>
|
|
</note>
|
|
|
|
<note>
|
|
<para>AsKML output will not work with geometries that do not have an SRID</para>
|
|
</note>
|
|
|
|
<para>&Z_support;</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting><![CDATA[SELECT ST_AsKML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
|
|
st_askml
|
|
--------
|
|
<Polygon><outerBoundaryIs><LinearRing><coordinates>0,0 0,1 1,1 1,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>
|
|
|
|
--3d linestring
|
|
SELECT ST_AsKML('SRID=4326;LINESTRING(1 2 3, 4 5 6)');
|
|
<LineString><coordinates>1,2,3 4,5,6</coordinates></LineString>
|
|
]]>
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="ST_AsSVG" />, <xref linkend="ST_AsGML" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="ST_AsSVG">
|
|
<refnamediv>
|
|
<refname>ST_AsSVG</refname>
|
|
|
|
<refpurpose>Returns a Geometry in SVG path data given a geometry or geography object.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsSVG</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>rel=0</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsSVG</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>geog</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>rel=0</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the geometry as Scalar Vector Graphics (SVG) path data. Use 1 as second
|
|
argument to have the path data implemented in terms of relative
|
|
moves, the default (or 0) uses absolute moves. Third argument may
|
|
be used to reduce the maximum number of decimal digits used in
|
|
output (defaults to 15). Point geometries will be rendered as
|
|
cx/cy when 'rel' arg is 0, x/y when 'rel' is 1. Multipoint
|
|
geometries are delimited by commas (","), GeometryCollection
|
|
geometries are delimited by semicolons (";").</para>
|
|
|
|
<note>
|
|
<para>Availability: 1.2.2. Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to <ulink
|
|
url="http://www.w3.org/TR/SVG/paths.html#PathDataBNF">http://www.w3.org/TR/SVG/paths.html#PathDataBNF</ulink></para>
|
|
</note>
|
|
<para>Changed: 2.0.0 to use default args and support named args</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>SELECT ST_AsSVG(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
|
|
|
|
st_assvg
|
|
--------
|
|
M 0 0 L 0 -1 1 -1 1 0 Z</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsX3D">
|
|
<refnamediv>
|
|
<refname>ST_AsX3D</refname>
|
|
|
|
<refpurpose>Returns a Geometry in X3D xml node element format: ISO-IEC-19776-1.2-X3DEncodings-XML</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsX3D</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns a geometry as an X3D xml formatted node element <ulink url="http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html">http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html</ulink>. If <varname>maxdecimaldigits</varname> (precision) is not specified then defaults to 15. </para>
|
|
<note>
|
|
<para>There are various options for translating PostGIS geometries to X3D since X3D geometry types don't map directly to PostGIS geometry types and some newer X3D types that might be better mappings we ahve avoided since most rendering tools don't currently support them.
|
|
These are the mappings we have settled on. Feel free to post a bug ticket if you have thoughts on the idea or ways we can allow people to denote their preferred mappings.</para>
|
|
<para>Below is how we currently map PostGIS 2D/3D types to X3D types</para>
|
|
</note>
|
|
|
|
<informaltable>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>PostGIS Type</entry>
|
|
<entry>2D X3D Type</entry>
|
|
<entry>3D X3D Type</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>LINESTRING</entry>
|
|
<entry>not yet implemented - will be PolyLine2D</entry>
|
|
<entry>LineSet</entry>
|
|
</row>
|
|
<row>
|
|
<entry>MULTILINESTRING</entry>
|
|
<entry>not yet implemented - will be PolyLine2D</entry>
|
|
<entry>IndexedLineSet</entry>
|
|
</row>
|
|
<row>
|
|
<entry>MULTIPOINT</entry>
|
|
<entry>Polypoint2D</entry>
|
|
<entry>PointSet</entry>
|
|
</row>
|
|
<row>
|
|
<entry>POINT</entry>
|
|
<entry>outputs the space delimited coordinates</entry>
|
|
<entry>outputs the space delimited coordinates</entry>
|
|
</row>
|
|
<row>
|
|
<entry>(MULTI) POLYGON, POLYHEDRALSURFACE</entry>
|
|
<entry>Invalid X3D markup</entry>
|
|
<entry>IndexedFaceSet (inner rings currently output as another faceset)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>TIN</entry>
|
|
<entry>TriangleSet2D (Not Yet Implemented)</entry>
|
|
<entry>IndexedTriangleSet</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<note><para>2D geometry support not yet complete. Inner rings currently just drawn as separate polygons. We are working on these.</para></note>
|
|
<para>Lots of advancements happening in 3D space particularly with <ulink url="http://www.web3d.org/x3d/wiki/index.php/X3D_and_HTML5#Goals:_X3D_and_HTML5">X3D Integration with HTML5</ulink></para>
|
|
<para>There is also a nice open source X3D viewer you can use to view rendered geometries. Free Wrl <ulink url="http://freewrl.sourceforge.net/">http://freewrl.sourceforge.net/</ulink> binaries available for Mac, Linux, and Windows. Use the FreeWRL_Launcher packaged to view the geometries.</para>
|
|
<para>Availability: 2.0.0: ISO-IEC-19776-1.2-X3DEncodings-XML</para>
|
|
<!-- Optionally mention 3d support -->
|
|
<para>&Z_support;</para>
|
|
<!-- Optionally mention supports Polyhedral Surface -->
|
|
<para>&P_support;</para>
|
|
|
|
<!-- Optionally mention support for Triangles and TINS -->
|
|
<para>&T_support;</para>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Example: Create a fully functional X3D document - This will generate a cube that is viewable in FreeWrl and other X3D viewers.</title>
|
|
<programlisting><![CDATA[SELECT '<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
|
|
<X3D>
|
|
<Scene>
|
|
<Transform>
|
|
<Shape>
|
|
<Appearance>
|
|
<Material emissiveColor=''0 0 1''/>
|
|
</Appearance> ' ||
|
|
ST_AsX3D( ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
|
|
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
|
|
((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
|
|
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )')) ||
|
|
'</Shape>
|
|
</Transform>
|
|
</Scene>
|
|
</X3D>' As x3ddoc;]]>
|
|
|
|
x3ddoc
|
|
--------
|
|
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
|
|
<X3D>
|
|
<Scene>
|
|
<Transform>
|
|
<Shape>
|
|
<Appearance>
|
|
<Material emissiveColor='0 0 1'/>
|
|
</Appearance>
|
|
<IndexedFaceSet coordIndex='0 1 2 3 -1 4 5 6 7 -1 8 9 10 11 -1 12 13 14 15 -1 16 17 18 19 -1 20 21 22 23'>
|
|
<Coordinate point='0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1' />
|
|
</IndexedFaceSet>
|
|
</Shape>
|
|
</Transform>
|
|
</Scene>
|
|
</X3D>]]></programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>Example: An Octagon elevated 3 Units and decimal precision of 6</title>
|
|
<programlisting>SELECT ST_AsX3D(
|
|
ST_Translate(
|
|
ST_Force_3d(
|
|
ST_Buffer(ST_Point(10,10),5, 'quad_segs=2')), 0,0,
|
|
3)
|
|
,6) As x3dfrag;
|
|
|
|
x3dfrag
|
|
--------
|
|
<![CDATA[<IndexedFaceSet coordIndex="0 1 2 3 4 5 6 7">
|
|
<Coordinate point="15 10 3 13.535534 6.464466 3 10 5 3 6.464466 6.464466 3 5 10 3 6.464466 13.535534 3 10 15 3 13.535534 13.535534 3 " />
|
|
</IndexedFaceSet>]]></programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>Example: TIN</title>
|
|
<programlisting><![CDATA[SELECT ST_AsX3D(ST_GeomFromEWKT('TIN (((
|
|
0 0 0,
|
|
0 0 1,
|
|
0 1 0,
|
|
0 0 0
|
|
)), ((
|
|
0 0 0,
|
|
0 1 0,
|
|
1 1 0,
|
|
0 0 0
|
|
))
|
|
)')) As x3dfrag;]]>
|
|
|
|
x3dfrag
|
|
--------
|
|
<![CDATA[<IndexedTriangleSet index='0 1 2 3 4 5'><Coordinate point='0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 1 0'/></IndexedTriangleSet>]]></programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>Example: Closed multilinestring (the boundary of a polygon with holes)</title>
|
|
<programlisting><![CDATA[SELECT ST_AsX3D(
|
|
ST_GeomFromEWKT('MULTILINESTRING((20 0 10,16 -12 10,0 -16 10,-12 -12 10,-20 0 10,-12 16 10,0 24 10,16 16 10,20 0 10),
|
|
(12 0 10,8 8 10,0 12 10,-8 8 10,-8 0 10,-8 -4 10,0 -8 10,8 -4 10,12 0 10))')
|
|
) As x3dfrag;]]>
|
|
|
|
x3dfrag
|
|
--------
|
|
<![CDATA[<IndexedLineSet coordIndex='0 1 2 3 4 5 6 7 0 -1 8 9 10 11 12 13 14 15 8'>
|
|
<Coordinate point='20 0 10 16 -12 10 0 -16 10 -12 -12 10 -20 0 10 -12 16 10 0 24 10 16 16 10 12 0 10 8 8 10 0 12 10 -8 8 10 -8 0 10 -8 -4 10 0 -8 10 8 -4 10 ' />
|
|
</IndexedLineSet>]]></programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_GeoHash">
|
|
<refnamediv>
|
|
<refname>ST_GeoHash</refname>
|
|
|
|
<refpurpose>Return a GeoHash representation of the geometry.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_GeoHash</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>maxchars=full_precision_of_point</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return a GeoHash representation (<ulink url="http://en.wikipedia.org/wiki/Geohash">http://en.wikipedia.org/wiki/Geohash</ulink>) of the geometry. A GeoHash encodes a point into a text form that is sortable and searchable based on prefixing. A shorter GeoHash is a less precise representation of a point. It can also be thought of as a box, that contains the actual point.</para>
|
|
|
|
<para>If no <varname>maxchars</varname> is specficified ST_GeoHash returns a GeoHash based on full precision of the input geometry type. Points return a GeoHash with 20 characters of precision (about enough to hold the full double precision of the input). Other types return a GeoHash with a variable amount of precision, based on the size of the feature. Larger features are represented with less precision, smaller features with more precision. The idea is that the box implied by the GeoHash will always contain the input feature.</para>
|
|
|
|
<para>If <varname>maxchars</varname> is specified ST_GeoHash returns a GeoHash with at most that many characters so a possibly lower precision representation of the input geometry. For non-points, the starting point of the calculation is the center of the bounding box of the geometry.</para>
|
|
|
|
<para>Availability: 1.4.0</para>
|
|
|
|
<note>
|
|
<para>ST_GeoHash will not work with geometries that are not in geographic (lon/lat) coordinates.</para>
|
|
</note>
|
|
|
|
<para>&curve_support;</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting><![CDATA[SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326));
|
|
|
|
st_geohash
|
|
----------------------
|
|
c0w3hf1s70w3hf1s70w3
|
|
|
|
SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326),5);
|
|
|
|
st_geohash
|
|
------------
|
|
c0w3h
|
|
]]>
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="ST_GeomFromGeoHash" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsText">
|
|
<refnamediv>
|
|
<refname>ST_AsText</refname>
|
|
<refpurpose>Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsText</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsText</function></funcdef>
|
|
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the Well-Known Text representation of the geometry/geography.</para>
|
|
|
|
<note>
|
|
<para>The WKT spec does not include the SRID. To get the SRID as part of the data, use the non-standard
|
|
PostGIS <xref linkend="ST_AsEWKT" /></para>
|
|
</note>
|
|
<para><inlinegraphic fileref="images/warning.png" />
|
|
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
|
|
</para>
|
|
<note>
|
|
<para>ST_AsText is the reverse of <xref linkend="ST_GeomFromText" />. Use <xref linkend="ST_GeomFromText" /> to convert to a postgis geometry from ST_AsText representation.</para>
|
|
</note>
|
|
|
|
<para>Availability: 1.5 - support for geography was introduced.</para>
|
|
<para>&sfs_compliant; s2.1.1.1</para>
|
|
<para>&sqlmm_compliant; SQL-MM 3: 5.1.25</para>
|
|
<para>&curve_support;</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_AsText('01030000000100000005000000000000000000
|
|
000000000000000000000000000000000000000000000000
|
|
F03F000000000000F03F000000000000F03F000000000000F03
|
|
F000000000000000000000000000000000000000000000000');
|
|
|
|
st_astext
|
|
--------------------------------
|
|
POLYGON((0 0,0 1,1 1,1 0,0 0))
|
|
(1 row)</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKB" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_GeomFromText" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="ST_AsLatLonText">
|
|
<refnamediv>
|
|
<refname>ST_AsLatLonText</refname>
|
|
<refpurpose>Return the Degrees, Minutes, Seconds representation of the given point.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsLatLonText</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_AsLatLonText</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>format</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the Degrees, Minutes, Seconds representation of the point.</para>
|
|
|
|
<note>
|
|
<para>It is assumed the point is in a lat/lon projection. The X (lon) and Y (lat) coordinates are normalized in the output
|
|
to the "normal" range (-180 to +180 for lon, -90 to +90 for lat).</para>
|
|
</note>
|
|
<para>
|
|
The text parameter is a format string containing the format for the resulting text, similar to a date format string. Valid tokens
|
|
are "D" for degrees, "M" for minutes, "S" for seconds, and "C" for cardinal direction (NSEW). DMS tokens may be repeated to indicate
|
|
desired width and precision ("SSS.SSSS" means " 1.0023").
|
|
</para>
|
|
<para>
|
|
"M", "S", and "C" are optional. If "C" is omitted, degrees are
|
|
shown with a "-" sign if south or west. If "S" is omitted, minutes will be shown as decimal with as many digits of precision
|
|
as you specify. If "M" is also omitted, degrees are shown as decimal with as many digits precision as you specify.
|
|
</para>
|
|
<para>
|
|
If the format string is omitted (or zero-length) a default format will be used.
|
|
</para>
|
|
<para>
|
|
</para>
|
|
|
|
<para>Availability: 2.0</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<para>Default format.</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)'));
|
|
st_aslatlontext
|
|
----------------------------
|
|
2°19'29.928"S 3°14'3.243"W
|
|
</programlisting>
|
|
<para>Providing a format (same as the default).</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D°M''S.SSS"C'));
|
|
st_aslatlontext
|
|
----------------------------
|
|
2°19'29.928"S 3°14'3.243"W
|
|
</programlisting>
|
|
<para>Characters other than D, M, S, C and . are just passed through.</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D degrees, M minutes, S seconds to the C'));
|
|
st_aslatlontext
|
|
--------------------------------------------------------------------------------------
|
|
2 degrees, 19 minutes, 30 seconds to the S 3 degrees, 14 minutes, 3 seconds to the W
|
|
</programlisting>
|
|
<para>Signed degrees instead of cardinal directions.</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D°M''S.SSS"'));
|
|
st_aslatlontext
|
|
----------------------------
|
|
-2°19'29.928" -3°14'3.243"
|
|
</programlisting>
|
|
<para>Decimal degrees.</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-3.2342342 -2.32498)', 'D.DDDD degrees C'));
|
|
st_aslatlontext
|
|
-----------------------------------
|
|
2.3250 degrees S 3.2342 degrees W
|
|
</programlisting>
|
|
<para>Excessively large values are normalized.</para>
|
|
<programlisting>
|
|
SELECT (ST_AsLatLonText('POINT (-302.2342342 -792.32498)'));
|
|
st_aslatlontext
|
|
-------------------------------
|
|
72°19'29.928"S 57°45'56.757"E
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsTWKB">
|
|
<refnamediv>
|
|
<refname>ST_AsTWKB</refname>
|
|
<refpurpose>Returns the geometry as TWKB, Tiny WKB</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsTWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>decimaldigits</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsTWKB</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>decimaldigits</parameter></paramdef>
|
|
<paramdef><type>int8 </type> <parameter>geometryID</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
<para>Returns the geometry in TWKB format. TWKB is a new compressed binary format. </para>
|
|
<para>The second parameter is an integer used to define the number of coordinate decimals in the output.</para>
|
|
<para>The third parameter is optional. It is used to give each TWKB-geometry an unique ID</para>
|
|
<note>
|
|
<para>TWKB is still a moving target. The format is described <ulink url="https://github.com/nicklasaven/TWKB">here</ulink> , and code for building a client can be found <ulink url="https://github.com/nicklasaven/twkb_web">here</ulink></para>
|
|
</note>
|
|
|
|
|
|
<para>Availability: 2.2.0</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
SELECT ST_AsTWKB('LINESTRING(1 1,5 5)'::geometry,0,1);
|
|
st_astwkb
|
|
--------------------------------------------
|
|
\x0342010202020808
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_AsTWKBAgg" />, <xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKB" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_GeomFromText" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsTWKBAgg">
|
|
<refnamediv>
|
|
<refname>ST_AsTWKBAgg</refname>
|
|
<refpurpose>Aggregates the geometries and returns as TWKB</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsTWKBAgg</function></funcdef>
|
|
<paramdef><type>geometry set</type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>decimaldigits</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsTWKBAgg</function></funcdef>
|
|
<paramdef><type>geometry set</type> <parameter>g1</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>decimaldigits</parameter></paramdef>
|
|
<paramdef><type>int8 </type> <parameter>geometryID</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the geometry in TWKB format. TWKB is a new compressed binary format. </para>
|
|
<para>This is the aggregate version of ST_AsTWKB. It aggregates and returns the geometry in TWKB-format. In the resulting TWKB-geometry each individual ID of the input geometries is stored. </para>
|
|
<para>The second parameter is an integer used to define the number of coordinate decimals in the output.</para>
|
|
<para>The third parameter is optional. It is used to give each TWKB-geometry an unique ID</para>
|
|
<note>
|
|
<para>TWKB is still a moving target. The format is described <ulink url="https://github.com/nicklasaven/TWKB">here</ulink> , and code for building a client can be found <ulink url="https://github.com/nicklasaven/twkb_web">here</ulink></para>
|
|
</note>
|
|
|
|
|
|
<para>Availability: 2.2.0</para>
|
|
</refsection>
|
|
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
SELECT ST_AsTWKBAgg(geom,0,id) FROM
|
|
(SELECT 'LINESTRING(1 1,5 5)'::geometry geom, 1 AS id
|
|
UNION ALL
|
|
SELECT 'LINESTRING(6 5, 1 7)'::geometry AS geom, 2 AS id) foo;
|
|
st_astwkbagg
|
|
----------------------------------------------------------------------------
|
|
\x035602010202020808020202000904
|
|
</programlisting>
|
|
</refsection>
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_AsTWKB" />, <xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKB" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_GeomFromText" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="ST_AsEncodedPolyline">
|
|
<refnamediv>
|
|
<refname>ST_AsEncodedPolyline</refname>
|
|
<refpurpose>Returns an Encoded Polyline from a LineString geometry.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>test <function>ST_AsEncodedPolyline</function></funcdef>
|
|
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
|
|
<paramdef choice="opt"><type>integer </type> <parameter>precision=5</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the geometry as an Encoded Polyline.</para>
|
|
|
|
|
|
<para>Availability: 2.2.0</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
ST_AsEncodedPolyline(GeomFromEWKT('SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)'));
|
|
--result--
|
|
|_p~iF~ps|U_ulLnnqC_mqNvxq`@
|
|
</programlisting>
|
|
</refsection>
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_LineFromEncodedPolyline" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|