zoukankan      html  css  js  c++  java
  • PostGIS之路——几何对象输出函数

    (1)ST_AsBinary

          ST_AsBinary返回一个表示 Well-Known Binary (WKB)格式表示的没有SRID改变的几何对象或地理要素。这个函数有两种形式。第一种:不接受尾数法编码参数和默认服务器机器尾数法。第二种:需要第二个参数表示,使用little - endian编码(NDR)或大端法(XDR)编码。这个函数经常用于二进制游标把数据从没有将它转换为一个字符串表示数据库导出。

    函数:

    bytea ST_AsBinary(geometry g1);
    bytea ST_AsBinary(geometry g1, text NDR_or_XDR);
    bytea ST_AsBinary(geography g1);
    bytea ST_AsBinary(geography g1, text NDR_or_XDR);

    注意:a.WKB规范中不包括SRID,需要获得SRID请使用ST_AsEWKB函数。

            b.ST_AsBinary 是ST_GeomFromWKB 为几何对象提供的反向方法。

            c.默认在PostgreSQL 9.0输出bytea在十六进制编码,如果您的GUI工具需要旧的版本,请设置bytea_output =’escape’在你的数据库中。

            d.2.0.0版本支持多面、三角网、TIN数据输出, 更高坐标尺寸,空间地理类型。

    实例SQL:

    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)

    (2)ST_AsEWKB

         ST_AsEWKB返回一个表示 Well-Known Binary (WKB)格式有SRID的几何对象或地理要素。这个函数有两种形式。第一种:不接受尾数法编码参数和默认服务器机器尾数法。第二种:需要第二个参数表示,使用little - endian编码(NDR)或大端法(XDR)编码。这个函数经常用于二进制游标把数据从没有将它转换为一个字符串表示数据库导出。

    函数:

    bytea ST_AsEWKB(geometry g1);
    bytea ST_AsEWKB(geometry g1, text NDR_or_XDR);

    实例SQL: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)

    注意事项:同上。

    其他类似函数有:(使用技巧可参考PostGIS帮助文档)

    ST_AsEWKT  

    text ST_AsEWKT(geometry g1);
    text ST_AsEWKT(geography g1);

    ST_AsGeoJSON

    text ST_AsGeoJSON(geometry geom, integer maxdecimaldigits=15, integer options=0);
    text ST_AsGeoJSON(geography geog, integer maxdecimaldigits=15, integer options=0);
    text ST_AsGeoJSON(integer gj_version, geometry geom, integer maxdecimaldigits=15, integer options=0);
    text ST_AsGeoJSON(integer gj_version, geography geog, integer maxdecimaldigits=15, integer options=0);

     ST_AsGML

    text ST_AsGML(geometry geom, integer maxdecimaldigits=15, integer options=0);
    text ST_AsGML(geography geog, integer maxdecimaldigits=15, integer options=0);
    text ST_AsGML(integer version, geometry geom, integer maxdecimaldigits=15, integer options=0, text nprefix=null);
    text ST_AsGML(integer version, geography geog, integer maxdecimaldigits=15, integer options=0, text nprefix=null);

    ST_AsHEXEWKB

    text ST_AsHEXEWKB(geometry g1, text NDRorXDR);
    text ST_AsHEXEWKB(geometry g1);

    ST_AsKML

    text ST_AsKML(geometry geom, integer maxdecimaldigits=15);
    text ST_AsKML(geography geog, integer maxdecimaldigits=15);
    text ST_AsKML(integer version, geometry geom, integer maxdecimaldigits=15, text nprefix=NULL);
    text ST_AsKML(integer version, geography geog, integer maxdecimaldigits=15, text nprefix=NULL);

    ST_AsSVG

    text ST_AsSVG(geometry geom, integer rel=0, integer maxdecimaldigits=15);
    text ST_AsSVG(geography geog, integer rel=0, integer maxdecimaldigits=15);

    ST_AsX3D

    text ST_AsX3D(geometry g1, integer maxdecimaldigits=15, integer options=0);

    ST_GeoHash

    text ST_GeoHash(geometry geom, integer maxchars=full_precision_of_point);

    ST_AsText

    text ST_AsText(geometry g1);
    text ST_AsText(geography g1);

    ST_AsLatLonText

    text ST_AsLatLonText(geometry pt);
    text ST_AsLatLonText(geometry pt, text format);

  • 相关阅读:
    通过SSIS监控远程服务器Windows服务并发送邮件报警!
    通过SSIS监控远程服务器磁盘空间并发送邮件报警!
    Jquery和雅虎的YQL服务实现天气预报功能!
    表字段或表名出现Mysql关键字或保留字导致问题 Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have
    Mybatis对象关系映射 one2one,one2many,many2many
    事务的传播属性及隔离级别 Spring
    正整数的二进制表示中1的个数计算(使用移位或者n&(n-1))
    char类型及ASCII码之间比较
    数据表记录包含表索引和数值(int范围的整数),请对表索引相同的记录进行合并,即将相同索引的数值进行求和运算,输出按照key值升序进行输出
    写出一个程序,接受一个十六进制的数,输出该数值的十进制表示。(多组同时输入 )
  • 原文地址:https://www.cnblogs.com/LCGIS/p/2953289.html
Copyright © 2011-2022 走看看