Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/geom/GeomConvHelper.h
169678 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 GeomConvHelper.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Sept 2003
19
///
20
// Some helping functions for geometry parsing
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <utils/geom/PositionVector.h>
27
#include <utils/geom/Boundary.h>
28
29
30
// ===========================================================================
31
// class definitions
32
// ===========================================================================
33
/**
34
* @class GeomConvHelper
35
* This class holds some helping functions for the parsing of geometries
36
*/
37
class GeomConvHelper {
38
public:
39
/** @brief Builds a PositionVector from a string representation, reporting occurred errors
40
*
41
* It is assumed, the vector is stored as "x,y[ x,y]*" where x and y are doubles.
42
* @param[in] shpdef The shape definition to parse
43
* @param[in] objecttype The name of the parsed object type; used for error message generation
44
* @param[in] objectid The name of the parsed object; used for error message generation
45
* @param[out] ok Whether the value could be read
46
* @param[in] allowEmpty Whether an empty shape definition is valid
47
* @param[in] report Whether errors shall be written to msg handler's error instance
48
* @return The parsed position vector
49
*/
50
static PositionVector parseShapeReporting(const std::string& shpdef, const std::string& objecttype,
51
const char* objectid, bool& ok, bool allowEmpty, bool report = true);
52
53
54
/** @brief Builds a boundary from its string representation, reporting occurred errors
55
*
56
* It is assumed that the boundary is stored as a quadruple of double, divided by ','.
57
* @param[in] def The boundary definition to parse
58
* @param[in] objecttype The name of the parsed object type; used for error message generation
59
* @param[in] objectid The name of the parsed object; used for error message generation
60
* @param[out] ok Whether the value could be read
61
* @param[in] report Whether errors shall be written to msg handler's error instance
62
* @param[in] offsets Whether inverted values (i.e. xmin > xmax) shall be kept rather than corrected
63
* @return The parsed boundary
64
*/
65
static Boundary parseBoundaryReporting(const std::string& def, const std::string& objecttype,
66
const char* objectid, bool& ok, bool report = true, bool offsets = false);
67
68
69
private:
70
/** @brief Writes an error message into the MessageHandler
71
* @param[in] report Whether errors shall be written to msg handler's error instance
72
* @param[in] what Name of the parsed object ("Shape", or "Boundary")
73
* @param[in] objecttype The name of the parsed object type the error occurred at
74
* @param[in] objectid The name of the parsed object type the error occurred at
75
* @param[out] desc Error description
76
*/
77
static void emitError(bool report, const std::string& what, const std::string& objecttype,
78
const char* objectid, const std::string& desc);
79
80
81
};
82
83