zoukankan      html  css  js  c++  java
  • Proj.4 API 中文参考

    ProjAPI

    https://github.com/OSGeo/proj.4/wiki/ProjAPI

    Tom Kralidis在2015年5月27日编辑此页·修订4

    简介

    执行pj_init()选择并初始化一个由它的参数决定参数的制图投影坐标系。argcargv数组中的元素个数,argv数组每个元素是单个投影的关键字参数(+proj arguments)。该列表中必须包含proj=投影地球半径椭圆参数。如果初始化的投影是有效的,返回一个projPJ结构体的地址,失败返回NULL。

    pj_init_plus()函数的工作方式与pj_init()类似,但将投影参数定义在单个字符串内,且每个参数带有一个+前缀。例如:+proj=utm +zone=11 +ellps=WGS84

    pj_init()的返回值用作投影正算(forward)或者投影逆算(inverse)中的proj参数。投影计算中的参数结构体projUV中的U代表经度或者xV代表维度或者y,经度和维度都是以弧度单位的。如果操作失败,projUV中的两个值都设置为HUGE_VAL(在math.h中定义http://blog.csdn.net/poechant/article/details/7235594)。

    注意:所有投影都有正算(forward)模式,但却不是都有逆算(inverse)模式。如果投影没有逆算模式,那么projPJ中成员inv将设置为NULL

    pj_transform函数用于转换两个坐标系统之间的点。除了投影坐标与地理坐标之间的转换,也可以进行基准面(datum)之间的转换。不同于pj_fwd()pj_inv(),这里也允许坐标系定义参数projPJ*是地理坐标(使用+proj=latlong定义)。xyz数组用于传入计算值,传出计算结果。该函数成功返回0,失败返回错误号(查看inpj_errno)。

    projection(projPJ)关联的内存,可能需要使用pj_free()释放。

    示例

    The following program reads latitude and longitude values in decimal degress, performs Mercator projection with a Clarke 1866 ellipsoid and a 33° latitude of true scale and prints the projected cartesian values in meters:

    下面程序读取十进制的经度和维度值,进行克拉克1866椭球正确范围33°维度的墨卡托投影计算,并打印米单位的笛卡尔坐标值。
    北美大地基准维基百科

    示例

    The following program reads latitude and longitude values in decimal degress, performs Mercator projection with a Clarke 1866 ellipsoid and a 33° latitude of true scale and prints the projected cartesian values in meters:

    下面程序读取十进制的经度和维度值,进行克拉克1866椭球正确范围33°维度的墨卡托投影计算,并打印米单位的笛卡尔坐标值。

    #include <proj_api.h>
    
    main(int argc, char **argv) {
         projPJ pj_merc, pj_latlong;
         double x, y;
    
         if (!(pj_merc = pj_init_plus("+proj=merc +ellps=clrk66 +lat_ts=33")) )
            exit(1);
         if (!(pj_latlong = pj_init_plus("+proj=latlong +ellps=clrk66")) )
            exit(1);
         while (scanf("%lf %lf", &x, &y) == 2) {
            x *= DEG_TO_RAD;
            y *= DEG_TO_RAD;
            p = pj_transform(pj_latlong, pj_merc, 1, 1, &x, &y, NULL );
            printf("%.2f	%.2f
    ", x, y);
         }
         exit(0);
    }
    

    在此程序中,输入-16 20.25将得到结果-1495284.21 1920596.79.

    API函数

    基本API

    int pj_transform( projPJ srcdefn, projPJ dstdefn, long point_count, int point_offset, double *x, double *y, double *z );
    

    转换点x/y/z,从源坐标系统到目标坐标系统(更多信息).

    projPJ pj_init_plus(const char *definition);
    

    从字符串definition创建一个projPJ坐标系统对象(更多信息).

    void pj_free( projPJ pj );
    

    释放与pj关联的所有资源.

    高级函数

    int pj_is_latlong( projPJ pj );
    

    返回TRUE表示是地理坐标系统(proj=latlong).

    int pj_is_geocent( projPJ pj );
    

    返回TRUE表示是地心坐标系统(proj=geocent).

    char *pj_get_def( projPJ pj, int options);
    

    返回PROJ.4初始化字符串,用于pj_init_plus()可产生此坐标系统。但会尽可能多的扩大定义(例如添加:+init= 和 +datum= definitions).

    projPJ pj_latlong_from_proj( projPJ pj_in );
    

    返回一个新的坐标系定义。就是pj_in内部的地理坐标(lat/long)系统.

    环境函数

    void pj_set_finder( const char *(*new_finder)(const char *) );
    

    Install a custom function for finding init and grid shift files.
    安装用于查找initgrid shift(网格转换)文件的自定义函数。

    void pj_set_searchpath ( int count, const char **path );
    

    Set a list of directories to search for init and grid shift files.
    设置一个目录列表去搜索initgrid shift文件。

    void pj_deallocate_grids( void );
    

    Frees all resources associated with loaded and cached datum shift grids.
    释放加载和缓存的基准转换网格关联的所有资源。

    char *pj_strerrno( int );
    

    Returns the error text associated with the passed in error code.
    返回错误代码关联的错误文本。

    int *pj_get_errno_ref( void );
    

    Returns a pointer to the global pj_errno error variable.
    返回全局的pj_errno错误变量地址。

    const char *pj_get_release( void );
    

    Returns an internal string describing the release version.
    返回描述发行版本的内部字符串。

    废弃(过时)函数

    XY pj_fwd( LP lp, PJ *P );
    
    LP pj_inv( XY xy, PJ *P );
    
    projPJ pj_init(int argc, char **argv);
    
  • 相关阅读:
    类的访问级别
    包和静态引入
    数组
    流程控制
    适合初学者的ROS机器人教程(3): ROS下使用Python对UR5机器人建模与控制
    适合初学者的强化学习教程(1): python使用gym实践和注意事项
    适合初学者的ROS机器人教程(1): Ubuntu下ROS创建自己的包和使用github下载的包
    适合初学者的ROS机器人教程(2): Ubuntu下ROS使用Gazebo和Rviz对UR5机器人建模
    spyder使用IPython的ipdb调试
    mysql创建外键
  • 原文地址:https://www.cnblogs.com/oloroso/p/5809884.html
Copyright © 2011-2022 走看看