Apollo
11.0
自动驾驶开放平台
pj_transformer.cc
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2019 The Apollo Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*****************************************************************************/
16
#include "
modules/map/tools/map_datachecker/server/pj_transformer.h
"
17
18
#include <iostream>
19
#include <sstream>
20
21
#include "
cyber/cyber.h
"
22
23
namespace
apollo
{
24
namespace
hdmap {
25
26
PJTransformer::PJTransformer
(
int
zone_id) {
27
// init projPJ
28
std::stringstream stream;
29
stream <<
"+proj=utm +zone="
<< zone_id <<
" +ellps=WGS84"
<< std::endl;
30
pj_utm_ = pj_init_plus(stream.str().c_str());
31
if
(pj_utm_ ==
nullptr
) {
32
AERROR
<<
"proj4 init failed!"
<< stream.str() << std::endl;
33
return
;
34
}
35
pj_latlong_ = pj_init_plus(
"+proj=latlong +ellps=WGS84"
);
36
if
(pj_latlong_ ==
nullptr
) {
37
AERROR
<<
"proj4 pj_latlong init failed!"
;
38
return
;
39
}
40
AINFO
<<
"proj4 init success"
<< std::endl;
41
}
42
43
PJTransformer::~PJTransformer
() {
44
if
(pj_latlong_) {
45
pj_free(pj_latlong_);
46
pj_latlong_ =
nullptr
;
47
}
48
if
(pj_utm_) {
49
pj_free(pj_utm_);
50
pj_utm_ =
nullptr
;
51
}
52
}
53
int
PJTransformer::LatlongToUtm
(int64_t point_count,
int
point_offset,
54
double
*x,
double
*y,
double
*z) {
55
if
(!pj_latlong_ || !pj_utm_) {
56
AERROR
<<
"pj_latlong_:"
<< pj_latlong_ <<
"pj_utm_:"
<< pj_utm_
57
<< std::endl;
58
return
-1;
59
}
60
return
pj_transform(pj_latlong_, pj_utm_, point_count, point_offset, x, y, z);
61
}
62
63
}
// namespace hdmap
64
}
// namespace apollo
apollo::hdmap::PJTransformer::LatlongToUtm
int LatlongToUtm(int64_t point_count, int point_offset, double *x, double *y, double *z)
Definition
pj_transformer.cc:53
apollo::hdmap::PJTransformer::PJTransformer
PJTransformer(int zone_id=50)
Definition
pj_transformer.cc:26
apollo::hdmap::PJTransformer::~PJTransformer
~PJTransformer()
Definition
pj_transformer.cc:43
cyber.h
AERROR
#define AERROR
Definition
log.h:44
AINFO
#define AINFO
Definition
log.h:42
apollo
class register implement
Definition
arena_queue.h:37
pj_transformer.h
modules
map
tools
map_datachecker
server
pj_transformer.cc