本文整理汇总了C++中pj_init函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_init函数的具体用法?C++ pj_init怎么用?C++ pj_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fmucs2geo
/*
* NAME:
* fmucs2geo
*
* PURPOSE:
* Computes geographical latitude, longitude from UCS northings, eastings.
*
* REQUIREMENTS:
*
* INPUT:
*
* OUTPUT:
*
* NOTES:
*
* BUGS:
*
* AUTHOR:
* Øystein Godøy, met.no/FOU, 10.01.2005
*
* MODIFIED:
* NA
*/
fmgeopos fmucs2geo(fmucspos xy, fmprojspec myproj) {
fmgeopos ll;
PJ *ref;
projUV cnat;
/*
* Select predefined projection, and initialize interface to PROJ
*/
if (myproj == MI) {
if (!(ref=pj_init(sizeof(miproj)/sizeof(char *), miproj))) {
fprintf(stderr,"ERROR: PROJ initialization failed.\n");
}
} else if (myproj == MEOS) {
if (!(ref=pj_init(sizeof(meosproj)/sizeof(char *), meosproj))) {
fprintf(stderr,"ERROR: PROJ initialization failed.\n");
}
} else {
fprintf(stdout,"ERROR: Projection not supported\n");
}
/*
* Estimate ll
*/
cnat.u = xy.eastings;
cnat.v = xy.northings;
cnat = pj_inv(cnat,ref);
ll.lon = cnat.u*RAD_TO_DEG;
ll.lat = cnat.v*RAD_TO_DEG;
if (cnat.u == HUGE_VAL) {
fprintf(stderr, "ERROR: pj_inv conversion\n");
}
pj_free(ref);
return(ll);
}
示例2: main
int main(){
// char *pr1[] = {"+proj=latlong", "+ellps=WGS84"};
char *pr1[] = {"+proj=tmerc", "+ellps=WGS84", "+lon_0=39",
"+scale=1", "+lat_0=0", "+x_0=500000"};
char *pr2[] = {"+proj=tmerc", "+ellps=krass", "+lon_0=39",
"+scale=1", "+lat_0=0", "+x_0=500000"};
projPJ P1 = pj_init(6, pr1);
projPJ P2 = pj_init(6, pr2);
if (!P1) {
fprintf(stderr, "can't create projection 1\n");
exit(1);
}
if (!P2) {
fprintf(stderr, "can't create projection 2\n");
exit(1);
}
double x=39*M_PI/180 + ((double)rand()/RAND_MAX - 0.5) * M_PI/30; // 36..42
double y=((double)rand()/RAND_MAX - 0.5) * M_PI; // -90..+90
double z=((double)rand()/RAND_MAX - 0.5) * 6000; // +/- 3000m
printf("%.12f %.12f %f\n",x*180/M_PI,y*180/M_PI,z);
int i;
for (i=0; i<1000000; i++){
// z=0;
int j = pj_transform(P1,P2, 1, 1, &x, &y, &z);
if (j) {
fprintf(stderr, "can't do transform\n");
exit(1);
}
// z=0;
j = pj_transform(P2,P1, 1, 1, &x, &y, &z);
if (j) {
fprintf(stderr, "can't do transform\n");
exit(1);
}
}
printf("%.12f %.12f %f\n",x*180/M_PI,y*180/M_PI,z);
pj_free(P1);
pj_free(P2);
}
示例3: new
/**Creates a new projection object. See the intro for details.
call-seq: new(String) -> Proj4::Projection
new(Array) -> Proj4::Projection
new(Hash) -> Proj4::Projection
*/
static VALUE proj_initialize(VALUE self, VALUE params){
_wrap_pj* wpj;
VALUE proj_params = rb_funcall(cProjection, idParseInitParameters, 1, params);
int size = RARRAY_LEN(proj_params);
char** c_params = (char **) malloc(size*sizeof(char *));
int i;
for (i=0; i < size; i++)
{
VALUE item = rb_ary_entry(proj_params, i);
c_params[i]= StringValuePtr(item);
}
Data_Get_Struct(self,_wrap_pj,wpj);
wpj->pj = pj_init(size,c_params);
free(c_params);
if(wpj->pj == 0) {
int pj_errno_ref = *pj_get_errno_ref();
if (pj_errno_ref > 0) {
rb_raise(rb_eSystemCallError, "Unknown system call error");
} else {
raise_error(pj_errno_ref);
}
}
return self;
}
示例4: init_stack
static pj_status_t init_stack()
{
pj_sockaddr addr;
pjsip_inv_callback inv_cb;
pj_status_t status;
pj_log_set_level(5);
status = pj_init();
CHECK_STATUS();
pj_log_set_level(3);
status = pjlib_util_init();
CHECK_STATUS();
pj_caching_pool_init(&app.cp, NULL, 0);
app.pool = pj_pool_create( &app.cp.factory, "sipecho", 512, 512, 0);
status = pjsip_endpt_create(&app.cp.factory, NULL, &app.sip_endpt);
CHECK_STATUS();
pj_log_set_level(4);
pj_sockaddr_init(AF, &addr, NULL, (pj_uint16_t)SIP_PORT);
if (AF == pj_AF_INET()) {
status = pjsip_udp_transport_start( app.sip_endpt, &addr.ipv4, NULL,
1, NULL);
} else if (AF == pj_AF_INET6()) {
status = pjsip_udp_transport_start6(app.sip_endpt, &addr.ipv6, NULL,
1, NULL);
} else {
status = PJ_EAFNOTSUP;
}
pj_log_set_level(3);
CHECK_STATUS();
status = pjsip_tsx_layer_init_module(app.sip_endpt) ||
pjsip_ua_init_module( app.sip_endpt, NULL );
CHECK_STATUS();
pj_bzero(&inv_cb, sizeof(inv_cb));
inv_cb.on_state_changed = &call_on_state_changed;
inv_cb.on_new_session = &call_on_forked;
inv_cb.on_media_update = &call_on_media_update;
inv_cb.on_rx_offer = &call_on_rx_offer;
status = pjsip_inv_usage_init(app.sip_endpt, &inv_cb) ||
pjsip_100rel_init_module(app.sip_endpt) ||
pjsip_endpt_register_module( app.sip_endpt, &mod_sipecho) ||
pjsip_endpt_register_module( app.sip_endpt, &msg_logger) ||
//pjmedia_endpt_create(&app.cp.factory,
// pjsip_endpt_get_ioqueue(app.sip_endpt),
// 0, &app.med_endpt) ||
pj_thread_create(app.pool, "sipecho", &worker_proc, NULL, 0, 0,
&app.worker_thread);
CHECK_STATUS();
return PJ_SUCCESS;
}
示例5: main
int main(int argc, char *argv[])
{
if (argc < 2) {
usage(argv[0]);
return 1;
}
pj_init();
init();
if (stricmp(argv[1], "record")==0) {
record_file("FILE.PCM");
} else if (stricmp(argv[1], "play")==0) {
play_file("FILE.PCM");
} else if (stricmp(argv[1], "send")==0) {
create_ses_by_remote_sdp(4002, listener_sdp);
} else if (stricmp(argv[1], "recv")==0) {
create_ses_by_remote_sdp(4000, talker_sdp);
} else {
usage(argv[0]);
}
deinit();
return 0;
}
示例6: SetUpTestCase
static void SetUpTestCase()
{
pj_init();
pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
pjsip_endpt_create(&caching_pool.factory, NULL, &endpt);
pool = pj_pool_create(&caching_pool.factory, "contact-filtering-test", 4000, 4000, NULL);
};
示例7: main
/*
* main()
*/
int main(int argc, char *argv[])
{
pj_caching_pool cp;
pj_status_t status;
if (argc < 2 || argc > 3) {
puts("Usage: httpdemo URL [output-filename]");
return 1;
}
pj_log_set_level(5);
pj_init();
pj_caching_pool_init(&cp, NULL, 0);
mem = &cp.factory;
pjlib_util_init();
if (argc > 2)
f = fopen(argv[2], "wb");
else
f = stdout;
status = getURL(argv[1]);
if (status != PJ_SUCCESS) {
PJ_PERROR(1, (THIS_FILE, status, "Error"));
}
if (f != stdout)
fclose(f);
pj_caching_pool_destroy(&cp);
pj_shutdown();
return 0;
}
示例8: main
int main() {
pj_caching_pool cp;
pj_pool_t *pool;
pjmedia_endpt *ep;
pjmedia_conf *conf;
pjmedia_port *fp, *mp;
pjmedia_snd_port *sp;
pjmedia_snd_port *mic;
unsigned slot;
pj_init();
pj_srand(12345);
pj_caching_pool_init(&cp, NULL, 1024);
pool = pj_pool_create(&cp.factory, "pool1", 1024, 1024, NULL);
pjmedia_endpt_create(&cp.factory, NULL, 1, &ep);
pjmedia_conf_create(pool, 3, 8000, 1,
8000 * 1 * 20 / 1000, // Sample per frame = # of samples in 20 ms
16, PJMEDIA_CONF_NO_DEVICE, &conf);
mp = pjmedia_conf_get_master_port(conf);
CHECK(__FILE__, pjmedia_snd_port_create_player(pool, 1, 8000, 1, 160, 16, 0, &sp));
printf("sp=%p - mp=%p\n", sp, mp);
pjmedia_snd_port_connect(sp, mp);
pjmedia_snd_port_create_rec(pool, 0, 8000, 1, 160, 16, 0, &mic);
pjmedia_wav_player_port_create(pool, "NHP-mono-pcm-s16le.wav", 0, 0, 0, &fp);
//pjmedia_wav_writer_port_create(pool, "vnt.wav", 8000, 1, 160, 16, 0, 0, &fp);
fp = pjmedia_snd_port_get_port(mic);
pjmedia_conf_add_port(conf, pool, fp, NULL, &slot);
pjmedia_conf_connect_port(conf, slot, 0, 0);
while (1) sleep(2);
}
示例9: mericd_init
static int mericd_init(struct gpsnav *gpsnav, struct gps_map_provider *prov)
{
struct mericd_data *data;
char *projc[3];
PJ *pj;
data = malloc(sizeof(*data));
if (data == NULL)
return -ENOMEM;
memset(data, 0, sizeof(*data));
projc[0] = "ellps=WGS84";
projc[1] = "proj=merc";
projc[2] = "no_defs";
pj = pj_init(3, projc);
if (pj == NULL) {
gps_error("Unable to initialize projection");
free(data);
return -1;
}
data->proj = pj;
prov->data = data;
return 0;
}
示例10: main
/*
* main()
*/
int main(int argc, char *argv[])
{
pj_caching_pool cp;
pjmedia_endpt *med_ept;
pjsip_endpoint *sip_ept;
char errmsg[PJ_ERR_MSG_SIZE];
pj_status_t code;
if (argc != 2) {
puts("Usage: strerror ERRNUM");
return 1;
}
pj_log_set_level(3);
pj_init();
pj_caching_pool_init(&cp, NULL, 0);
pjlib_util_init();
pjnath_init();
pjmedia_endpt_create(&cp.factory, NULL, 0, &med_ept);
pjsip_endpt_create(&cp.factory, "localhost", &sip_ept);
pjsip_evsub_init_module(sip_ept);
code = atoi(argv[1]);
pj_strerror(code, errmsg, sizeof(errmsg));
printf("Status %d: %s\n", code, errmsg);
pj_shutdown();
return 0;
}
示例11: main
int main(int argc, char *argv[])
{
ics_stream_t stream_data;
char tmp[10];
pj_status_t status;
pj_caching_pool cp;
pj_pool_t *pool;
status = pj_init();
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
pool = pj_pool_create(&cp.factory, "app", 4000, 4000, NULL);
ics_stream_init(&stream_data, &cp, pool);
ics_stream_create(&stream_data, 4321, "127.0.0.1:1234", "sink");
ics_stream_connect_with_snd_sink(&stream_data);
ics_stream_start(&stream_data);
for (;;) {
if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
puts("EOF while reading stdin, will quit now..");
break;
}
if (tmp[0] == 'q')
break;
}
//Destroy and clean`
ics_stream_clean(&stream_data);
return 0;
}
示例12: main
int main() {
pj_sock_t sock;
pj_sockaddr_in to_addr;
char *s = "Cong hoa xa hoi chu nghia VietNam";
char buffer[100];
pj_ssize_t len;
struct timeval tv_begin, tv_end, tv_diff;
pj_log_set_level(3);
CHECK(__FILE__, pj_init());
pj_bzero(buffer, sizeof(buffer));
CHECK_R( __FILE__, pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock) );
//udp_socket(12345, &sock);
setup_addr_with_host_and_port(&to_addr, "127.0.0.1", 33333);
len = strlen(s);
gettimeofday(&tv_begin, NULL);
pj_sock_sendto(sock, s, &len, 0, &to_addr, sizeof(to_addr));
PJ_LOG(3, (__FILE__, "Sent: %s", s));
len = 100;
pj_sock_recv(sock, buffer, &len, 0);
gettimeofday(&tv_end, NULL);
int diff = timeval_subtract(&tv_diff, &tv_end, &tv_begin);
PJ_LOG(3, (__FILE__, "Received: %s %0.2f msec", buffer, diff*1.0/1000));
pj_shutdown();
return 0;
}
示例13: test_main
int test_main(void)
{
int rc = 0;
pj_caching_pool caching_pool;
pj_init();
pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
pj_log_set_decor(PJ_LOG_HAS_NEWLINE);
pj_log_set_level(3);
mem = &caching_pool.factory;
DO_TEST(sdp_neg_test());
//DO_TEST(sdp_test (&caching_pool.factory));
//DO_TEST(rtp_test(&caching_pool.factory));
//DO_TEST(session_test (&caching_pool.factory));
DO_TEST(jbuf_main());
DO_TEST(mips_test());
DO_TEST(codec_test_vectors());
PJ_LOG(3,(THIS_FILE," "));
on_return:
if (rc != 0) {
PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!"));
} else {
PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!"));
}
pj_caching_pool_destroy(&caching_pool);
return rc;
}
示例14: create_app
/*
* Create app
*/
static pj_status_t create_app(void)
{
pj_status_t status;
status = pj_init();
if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Error initializing pjlib", status);
return status;
}
/* init PJLIB-UTIL: */
status = pjlib_util_init();
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
/* Must create a pool factory before we can allocate any memory. */
pj_caching_pool_init(&app.cp, &pj_pool_factory_default_policy,
CACHING_POOL_SIZE);
/* Create application pool for misc. */
app.pool = pj_pool_create(&app.cp.factory, "app", 1000, 1000, NULL);
/* Create the endpoint: */
status = pjsip_endpt_create(&app.cp.factory, pj_gethostname()->ptr,
&app.sip_endpt);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
return status;
}
示例15: TransformTiffCorner
static bool TransformTiffCorner(GTIF * gtif, GTIFDefn * defn, double x, double y, double& outLon, double& outLat)
{
/* Try to transform the coordinate into PCS space */
if( !GTIFImageToPCS( gtif, &x, &y ) )
return false;
if( defn->Model == ModelTypeGeographic )
{
outLon = x;
outLat = y;
return true;
}
else
{
if( GTIFProj4ToLatLong( defn, 1, &x, &y ) )
{
outLon = x;
outLat = y;
return true;
}
int size = 0;
tagtype_t type = TYPE_UNKNOWN;
int key_count = GTIFKeyInfo(gtif, GTCitationGeoKey, &size, &type);
if(key_count > 0 && key_count < 1024 && type == TYPE_ASCII && size == 1)
{
vector<char> ascii(key_count);
int r = GTIFKeyGet(gtif, GTCitationGeoKey, &ascii[0], 0, key_count);
if(r == key_count)
{
DebugAssert(ascii.back() == 0);
string citation = string(&ascii[0]);
if(citation == "PCS Name = WGS_1984_Web_Mercator_Auxiliary_Sphere")
{
char ** args = CSLTokenizeStringComplex("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m [email protected] +wktext +no_defs", " +", TRUE, FALSE);
PJ * psPJ = pj_init( CSLCount(args), args );
CSLDestroy(args);
if(psPJ)
{
projUV sUV;
sUV.u = x;
sUV.v = y;
sUV = pj_inv( sUV, psPJ );
outLon = sUV.u * RAD_TO_DEG;
outLat = sUV.v * RAD_TO_DEG;
pj_free(psPJ);
return true;
}
}
}
}
}
return false;
}