Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/unittest/src/utils/geom/GeoConvHelperTest.cpp
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GeoConvHelperTest.cpp
15
/// @author Jakob Erdmann
16
/// @author Laura Bieker
17
/// @date 2011-09-23
18
///
19
// Tests the class GeoConvHelper
20
/****************************************************************************/
21
#include <config.h>
22
23
#include <gtest/gtest.h>
24
#include <utils/geom/GeoConvHelper.h>
25
26
/*
27
Tests the class GeoConvHelper
28
*/
29
30
31
/* Test the method 'x2cartesian' */
32
TEST(GeoConvHelper, test_method_x2cartesian) {
33
GeoConvHelper gch(
34
"+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
35
Position(), Boundary(), Boundary(), 1, false);
36
37
Position pos(13.5326994, 52.428098100000007);
38
gch.x2cartesian(pos);
39
40
EXPECT_NEAR(400235.50494557252, pos.x(), 1e-5);
41
EXPECT_NEAR(5809666.826070101, pos.y(), 1e-5);
42
}
43
44
/* Test the method 'cartesian2geo' */
45
TEST(GeoConvHelper, test_method_cartesian2geo) {
46
GeoConvHelper gch(
47
"+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
48
Position(), Boundary(), Boundary(), 1, false);
49
50
// Use the outputs of the `x2cartesian` test - hence making the combination of tests circular: geo -> cartesian -> geo
51
Position cartesian(400235.50494557252, 5809666.826070101);
52
gch.cartesian2geo(cartesian);
53
54
EXPECT_NEAR(13.5326994, cartesian.x(), 1e-5);
55
EXPECT_NEAR(52.428098100000007, cartesian.y(), 1e-5);
56
}
57
58