zoukankan      html  css  js  c++  java
  • 翻译Lanlet2

    1. Here is more information on the basic primitives that make up a Lanelet2 map.
    2. Read here for a primer on the software architecture of lanelet2.
    3. There is also some documentation on the geometry calculations you can do with lanelet2 primitives.
    4. If you are interested in Lanelet2's projections, you will find more here.
    5. To get more information on how to create valid maps, see here.

    1.

    https://github.com/changhexingchen/Lanelet2/blob/master/lanelet2_core/doc/RegulatoryElementTagging.md

    Lanelet2/lanelet2_core/doc/RegulatoryElementTagging.md

    Tagging Regulatory Elements

    Regulatory Elements are divided into categories. The most common ones are TrafficLightTrafficSignSpeedLimit and RightOfWay, which are already included in the core library, but there are many more ways to model restrictions on lanelets and areas. More might be added in the future and also users are able to add own regulatory elements by inheriting from the generic RegulatoryElement class and registering the new type using the RegisterRegulatoryElement class.

    This document describes the generic layout of a Regulatory Element and shows how the common Regulatory Elements are structured.

    本文件描述了交通规则元素的一般布局,并展示了那些普通的交通规则元素(如:交通灯,交通标志,限速标志)是如何被结构化的。

    Tags

    Regulatory Elements always have type=regulatory_element. If this tag is not present, Lanelet2 will add it when writing to an .osm file.

    交通规则元素总是有这个键值对:type=regulatory_element。如果这个标签不存在,Lanelet2将在写入.osm格式的文件时添加它。

    Subtype

    The subtype tag helps Lanelet2 to distinguish between the different regulatory elements. For the basic Regulatory Elements this would be:

    • traffic_light
    • traffic_sign
    • speed_limit
    • right_of_way

    子类型标记帮助Lanelet2区分不同的交通规则。对于基本的交通规则来说,这将是:

    • 红绿灯
    • 指示牌
    • 车速限制
    • 路权

    Other, Optional Tags

    The following tags can be used to add more information to a Regulatory Element (of course you can add you own to enhance your map and implement a new TrafficRule object that implements them). The default values for the tag are highlighted.

    • dynamic (yes/no): Indicates that this Regulatory Element might change its meaning based on a condition. Examples would be a road that is closed on weekends. Or a speed limit that is only in action if the road is wet. By default, Lanelet2 cannot handle dynamic Regulatory Elements and will ignore them. Specialized traffic rule classes could be implemented that use background information (such as the current time) to resolve dynamic Regulatory Elements.
    • fallback (yes/no): Indicates that this Regulatory Element has a lower priority than another Regulatory Element. Examples are right of way regulations that become valid if the traffic lights of an intersection are out of order.

    其他的可选标签

    以下标签被用来向交通规则添加更多信息(当然,您可以添加自己的标签来增强你的地图并新建TrafficRule对象实施与你的地图)。标签的默认值被突出显示(高亮显示)。

    • 动态(的)(yes/no):指示此交通规则可能根据某种情况更改其含义。例如,一条道路在周末关闭。或者只有在路面潮湿的情况下才会起作用的限速。默认情况下,Lanelet2无法处理动态交通规则,所以将忽略它们。可以实现专门化的交通规则类,这些类使用背景信息(例如当前时间)来解析动态交通规则。
    • 后退(yes/no):指示此交通规则的优先级低于另一个交通规则。例如,当交叉路口的交通灯出现故障时,通行(权)规则就会生效。

    Basic Regulatory Elements

    一些基本的交通规则

    Traffic Sign

     

    A traffic sign generically expresses a restriction that is expressed by a traffic sign. The refers part refers to traffic signs that form the rule. The cancels parameter then refers to traffic signs that mark the end of the restriction expressed by the sign (e.g. the end of no-overtaking section). The ref_line and cancel_line parameters can then be used to define the exact start and end points of the rule. The LineStrings referenced by that must not have an intersection with the referencing lanelet or Area. If they do, the rule is valid from/to this intersection point. If not, the rule is valid for the whole lanelet/area.

    交通标志

    一般情况下,一种交通标志表达一种限制。参考部分是指构成规则的交通标志。cancels参数则是指解除限制(如禁止超车路段结束)。用ref_line和cancel_line参数定义规则的确切起点和终点。它引用的线串不能与引用的小lanelet或Area有交叉。如果他们这样做了,规则从/到这个交点是有效的。如果不是,则该规则适用于整个lanelet/area。

    Speed Limit

    Speed limits work very similar to traffic signs. If they are put up by a traffic sign, they simply reference this traffic sign. Similar for the ref_line and the cancels role. The TrafficRules class then takes care of interpreting the speed limit from the subtype of the referenced traffic sign.

    Alternatively, if the speed limit does not originate from a traffic sign, a sign_type tag can be used to define the speed limit. The value should contain the unit, eg "50 km/h". mph or mps or similar units are possible as well. If no unit is given, km/h is assumed.

    限速

    限速工作原理与交通标志非常相似。如果他们被一个交通标志提供,他们只是简单地引用这个交通标志。类似于ref_line和cancels角色。然后,traffic rules类负责从引用的交通标志的子类型(subtype)解释速度限制。

    或者,如果速度限制不是来自交通标志,可以使用sign_type标记来定义速度限制。数值应包含单位,如“50km /h”。英里每小时或mps或类似的单位也是可能的。如果没有给出单位,则默认是km/h。

    Traffic Light

    Traffic lights are also similar to traffic signs. Instead of a sign, the light itself is referenced as refers parameter. The cancels and cancels_line role have no meaning for traffic lights. The ref_line can reference the respective stop line. If they are not present, the stop line is implicitly at the end of the lanelet or Area.

    交通灯

    交通灯也类似于其他交通标志。并不是一个符号,灯本身被引用作为参数。cancels和cancels_line角色对于交通灯没有意义。ref_line可以引用各自的停止线。如果它们不存在,则停止线隐含地位于lanelet或Area的末尾。

    Right of Way

    By default, intersecting lanelets are treated as a "first come first served" situation, meaning that the vehicle that arrives first at the intersection point has right of way. The RightOfWay Regulatory Element changes this. It has three roles:

    • yield: References the lanelets that have to yield
    • right_of_way: the lanelets that have the right of way over the yielding ones
    • ref_line: The lines where vehicles that are crossing a yield lanelet have to stop at. If not set, this is the end of the yieldlanelet.

    Only one lanelet of a chain of lanelets that belong to the same lane have to be referenced. Generally this is the last lanelet that can be undoubtedly assigned to one specific intersection arm (i.e. the last lanelet before the intersection begins). All lanelets that are mentioned by the right of way Regulatory Element also have to reference the regulatory element.

    路权

    默认情况下,相交的lanelets被视为“先到先得”的情况,这意味着首先到达交叉点(或者翻译成冲突点)的车辆拥有优先通行权。路权的概念改变了这一点。它承担三个角色:

    • 屈服/让步:引用具有路权的Lanelets
    • 路权:具有先行权的lanelets
    • ref_line:车辆需要停在那里的停止线。如果不设置,就相当于具有路权并且不需要让行。

    只需引用属于同一lane的一个lanelets链中的一个lanelet。一般来说,这是最后一个可以毫无疑问地分配给一个特定交臂的lanelet(即交点开始前的最后一个lanelet)。所有被指定路权的lanelets也要引用基本的交通规则。


    2.

    https://github.com/changhexingchen/Lanelet2/blob/master/lanelet2_core/doc/Architecture.md

    Lanelet2/lanelet2_core/doc/Architecture.md

    Architecture

    This file describes the technical architectural architecture of Lanelet2. For information on the representation of lanelet and its primitives, please read first here.

    架构

    这个文件描述了Lanelet2的技术架构。有关lanelet及其基本组成的信息,请先在这里阅读。

    Principles

    原则

    Data sharing

    数据分享

    In lanelet two, everything that has an id is unique across the whole map. Because multiple primitives can reference the same element, it is therefore not possible to duplicate/copy the information of a lanelet primitive. If that was possible, modifying the information would leave the map in an invalid state, because other elements that reference it would not be notified of the change.

    在lanelet 2中,所有事物都拥有唯一的id。由于许多的地图基本组成可以引用同一个元素,因此不可能复制/复制一个lanelet的基本组成之信息。如果可能的话,修改信息将使地图处于无效状态,因为引用它的其他元素不会被通知那个更改。

    To solve this issue, Lanelet2's primitive do not actually store data. Instead, they hold a pointer to the real, uncopyable data object. This means they only provide a view on the underlying map data. This means that Lanelet2 primitives can be copied without regret, because all copies still point to the same underlying data object. If the data is modified through one of the primtives, all other copies can observe the change.

    为了解决这个问题,Lanelet2的基本组成元素实际上不存储数据。相反,它们持有一个指向真实的、不可复制的数据对象的指针。这意味着它们只提供底层地图数据的视图。这意味着可以毫无遗憾地复制Lanelet2基本组成元素,因为所有副本仍然指向相同的底层数据对象。如果通过其中一个基本组成元素修改了数据,则所有其他副本可以观察到这个更改。

    This gives some interesting properties. Firstly, primitives can be copied extremely fast, because only the pointer is copied, not the data. Secondly, this means that we can provide different views on the data. One example is that we can give you a 2D view and a 3D view on the data, e.g. a Point2d that returns x and y coordinates but not the z coordinate. You can convert this point back to Point3d without losing information, because in the underlying data, the z-coordinate was always there. Linestrings behave similar. A LineString3d returns Point3d, a LineString2d gives you Point2d.

    这给出了一些有趣的性质。首先,基本组成元素的复制速度非常快,因为只复制指针,而不复制数据。其次,这意味着我们可以对数据提供不同的观测视角。例如,我们可以在数据上提供2D视图和3D视图,例如返回x和y坐标但不返回z坐标的Point2d。您可以在不丢失信息的情况下将这个点转换回Point3d,因为在底层数据中,z坐标始终存在。线串具有相似的表现。LineString3d返回Point3d, LineString2d返回Point2d。

    We can also easily invert Linestrings and Lanelets with this technique. An inverted Linestring simply returns the underlying data in reversed order. You will not even notice it is inverted, because it still behaves in the same way as a non-inverted one. The effort of creating the inverted Linestring is - you guessed it - just the effort of copying a pointer!

    我们还可以使用这种技术轻松地反转线串和Lanelets。一个翻转的线串以相反的顺序返回底层数据。你甚至不会注意到它是倒置的,因为它的行为方式和非倒置的是一样的。创建反向Linestring的工作—您猜对了—就是复制一个指针的工作!

    Like this we can make sure that modifying the map is alwas consistent. All primitives will observe the change. However there are two exceptions to this, and they are related to caching: The centerline of a lanelet is calculated based on the left and right bound at the time it was first requested. If the points of a left or right bounds were modified, the Lanelet can not notice the change and still returns the now wrong centerline. You have to reset the centerline of the lanelet yourself. The second issue is within the laneletMap itself. It holds some precalculated Tree structures to efficiently query closest points or usages of a point. If one of the points is modified, the query will still run on the old tree structure. So the general message is: When you plan to modify the map, know what you are doing!

    这样我们就可以确保地图的修改始终是一致和连贯的。所有地图的基本组成元素都能观察到这种改变。但是有两个例外,它们与缓存有关:一个lanelet的中心线是根据第一次请求时的左右边界计算的。如果修改了左边界或右边界的点,则Lanelet无法注意到更改,仍然返回错误的中心线。你必须自己重新设置lanelet的中心线。第二个问题是laneletMap本身。它包含一些预先计算的树结构,以有效地查询最近点或点的使用。如果修改了其中一个点,查询仍将在旧的树结构上运行。因此,总的信息是:当您计划修改地图时,要知道您在做什么!

    Composability

    可组合性

    Since Lanelet2's primitives, especially Lanelets represent an atomic section of the map, it is often important to compose these atomic parts together to create compound objects. These compound primitives behave in the same way as the primitives they are composed of, but internally access their data. This is also driven by the pointer-based concept introduced above: The compound objects simply hold a list of pointers instead of a single one. As an example, you can compose multiple Linestring3d to one CompoundLineString3d. It behaves like a single linestring, gives you its size() in points acces to the individual points while still internally accessing the data of the actual linestrings. You can also compose Polygons from Linestrings, LaneletSet from Lanelets, and so on.

    由于Lanelet2的基本组成元素,尤其是Lanelets表示地图的微小的不可分割的部分,因此将这些微小部分组合在一起以创建复合对象通常非常重要。这些复合对象的行为方式与组成它们的那些基本元素的行为方式相同,但在内部访问它们的数据。这也是由上面介绍的基于指针的概念驱动:复合对象只包含一个指针列表,而不是单个指针。例如,您可以将多个Linestring3d组合为一个CompoundLineString3d。它的行为类似于一个linestring线串,它的大小()以点表示,在访问各个点的同时仍然在内部访问实际linestring的数据。您还可以从linestrings组合多边形,从Lanelets组合Lanelet集,等等。

    Const correctness

    常量正确性

    Since modifying the map can make cached data invalid, and since modification affects the whole map, Lanelet2 offers some protection against unwanted modification. This is related to const correctness: If an object is passed to a function as const, not only the data of the object itself is immutable, but also the data derived from it and all the copies that you make.

    E.g. if a function accepts a Linestring as const Linestring3d, its data is immutable. If you access a point of the linestring, you get a ConstPoint3d, that allows you to access its data, but not modify it. It is not possible to convert a ConstPoint3d back to a Point3d. This means, if you call a function that accepts a const LineString3d or even a ConstLineString3d, you can be 100% sure that you map data will not be modified.

    由于修改地图会使缓存的数据无效,而且修改会影响整个地图,所以Lanelet2提供了一些保护,防止不必要的修改。这与常量正确性有关:如果一个对象以常量的形式传递给一个函数,那么不仅对象本身的数据是不可变的,它派生的数据以及您创建的所有副本也是不可变的。

    例如,如果一个函数接受一个Linestring作为const Linestring3d,那么它的数据是不可变的。如果您访问linestring的一个点,您将得到ConstPoint3d,它允许您访问它的数据,但不修改它。将ConstPoint3d转换回Point3d是不可能的。这意味着,如果调用一个接受const LineString3d甚至ConstLineString3d的函数,您可以100%确定映地图数据不会被修改。

    Modularity

    模块化

    We are aware of the fact that roads can be very different in different countries and different places. Some things can be hard to squeeze into the typical map format. Also, the requirements on the map can be very different. To account for this, we tried to make Lanelet2 as flexible as possible by adding customization points where you can plugin your customized solution. Also the modularity of Lanelet2 aims to make it as simple as possible to add new functionality in the future.

    Part of the flexibility concept is that the tags that are used on objects can be extended without any limits. This way you can easily add more specific information to your maps that you are missing. New, custom Regulatory Elements can be added to accout for difficult traffic situations. Also Lanelet2 can be extended for different countries and different road participants by adding new TrafficRules objects which are used by Lanelet2 to interpret the map data. New parsers and writers for new map formats can be added and registered while still using the same good old load/write function.

    我们意识到,在不同的国家和不同的地方,道路可能是非常不同的。有些东西很难硬塞进典型的地图格式中。此外,地图上的需求可能非常不同。为了解决这个问题,我们试图通过添加定制点,使Lanelet2尽可能灵活,您可以在定制的解决方案中插入定制点。此外,Lanelet2的模块化的目标是使它在未来尽可能简单地添加新功能。

    灵活性概念的一部分是,对象上使用的标签可以无限制地扩展。通过这种方式,您可以轻松地向您丢失的地图添加更多特定的信息。新的,自定义的交通规则可以被添加以解释复杂的交通情况。此外,Lanelet2还可以扩展到不同的国家和不同的道路参与者,添加新的交通规则对象,Lanelet2使用这些对象来解释地图数据。可以为新的地图格式添加和注册解析器和写入器,同时仍然使用相同的旧的加载/写入功能。

    Geometry calculations

    几何计算

    Lanelet2's objects meant to be directly usable for geometry calculations. They are all registered with boost::geometry, meaning the follwing is easily possible: double d = boost::geometry::distance(laneletPoint1, laneletPoint2). If laneletPoint1/2 is a 2D point, you will get the result in 2D, else in 3D.

    However, there are limitations to this that originate from the fact that the ConstCorrectness concept and boost::geometry do not play well with each other, because boost::geometry gets confused by the different point types used when things are used in a const and a non-const context. If you want to know more how to solve this problem and avoid pages and pages of compiler errors from boost's feared template code, read our Geometry Primer on this.

    Lanelet2的对象意味着可以直接用于几何计算。它们都注册了boost::geometry,这意味着下面的操作很容易实现:double d = boost::geometry::distance(laneletPoint1, laneletPoint2)。如果laneletPoint1/2是一个二维点,你将得到二维的结果,否则是三维的。

    然而,由于const和非const环境中使用的内容使用的点类型不同(?),因此const常量正确性概念和boost::geometry不能很好地相互配合,因此存在一些限制。如果您想知道更多如何解决这个问题,并避免boost的模板代码中编译器的错误,请阅读我们的几何入门教程。

    Overview and Interaction

    概述和交互

    If you don't know Lanelet2's basic primitives yet, better read here first!

    如果你还不知道Lanelet2的基本的组成部分,你最好先阅读 一下这里!

    Here, we want to introduce the basic terms and object that you will be confronted with when using Lanelet2 and how they interact:

    这里,我们想介绍你使用Llanelet2的时候将遇到的基本术语和对象,以及它们是如何相互作用的。

    • Primitive any Lanelet2 primitive and their derivates (LaneletConstLaneletLineString2d, etc)
    • 一切Lanelet2组成和它们的衍生品(LaneletConstLaneletLineString2d, 等)
    • LaneletMap a laneletMap is the basic storage container for primitives. It is separated in layers, one for each primitive type and offers different ways to access its data (by a BoundingBox, by id, by nearest point, etc). It does not provide routing functionality.
    • LaneletMap laneMap是lanelet的基本组件的最基本的存储容器。它是分层的,每一层存储一个基本类型,并提供了不同的方法来访问它的数据(通过一个BoundingBox,通过id,通过最近的点,等等)。它不提供路线规划功能。
    • TrafficRules a traffic rules object interprets the map. E.g. it reports if a lanelet isPassable, or if lane changes are possible between two lanelets. A traffic rule object interprets the map from the perspective of one road participant type. A vehicle TrafficRule object will therefore give completely different results on a specific lanelet than a pedestrian TrafficRule object.
    • 交通规则:一个交通规则对象解释地图。例如,它报告一个lanelet是否是可通行的,或者两个lanelets之间是否可变道。交通规则对象从道路参与者类型的角度解释地图。因此,车辆交通规则对象在特定的lanelet上给出的结果与行人交通规则对象完全不同。
    • RoutingCost these classes are used by the routing graph to determine costs when driving from one Lanelet/Area to another one. It could be by travelled distance, by travel time but there are no limits for more advanced routing cost functions. You can also choose the cost of lane changes so that routes with few, preferably long lane changes are preferred.
    • 路线成本:这些类被用来确定从一个Lanelet/Area到另一个Lanelet/Area的最小成本。它可以通过旅行距离,旅行时间来实现,但是对于更高级的路线成本函数没有限制。您还可以选择车道更改的成本,以便选择较少、最好是较长的车道更改的路线。
    • RoutingGraph a routing graph is built from a LaneletMap, TrafficRules and RoutingCost objects. One routing graph is only for one single participant: The one that the TrafficRules belong to. With the routing graph, you can make all kinds of queries to determine where you or someone else can go/drive.
    • 路线图:路线图是根据LaneletMap、交通规则和路线成本对象构建的。一个路由图只针对一个交通参与者:即交通规则所属的参与者。使用路线图,您可以进行各种查询来确定您或其他人可以去/驾驶的位置。
    • Route a route is something returned by the graph when you query a route from A to B. It contains a structure of all the lanelets that you can use on the way with the lowest routing cost, including all possible lane changes.
    • 路线:一条路线是在查询从a到b的路路线时由路线图返回的内容。它包含一个你在路上所使用的所有lanelets,您可以在路线成本最低的情况下使用这些lanelets,包括所有可能的变道。
    • LaneletPath or Path in general is a sequence of lanelets returned by the RoutingGraph that are directly adjacent and have the lowest routing cost to the destination. "Adjacent" means that they can also be connected by a lane change, not only by following the lanelet in a straight direction.
    • 路径:LaneletPath或Path通常是由路线图返回的直接相邻且到目的地路线成本最低的lanelets序列。“相邻”意味着它们也可以通过变道连接,而不仅仅在直线方向上沿着lanelet行驶。
    • LaneletSequence a list of directly succeeding lanelets that can be reached without lane changes. A LaneletSequence is the special case of a LaneletPath where no lane change is necessary.
    • Lanelet序列:无需更改车道即可到达的连续的lanelets的列表。一个Lanelet序列是不需要改变车道的Lanelet路径的特殊情况。
    • Projector projectors are used by the IO module to convert between maps that store date in the WGS84 (lat/lon) format and the local coordinates used by Lanelet2. There are many different projections that all have different properties, so you should choose the one that fits best to you. If in doubt, use UTM.
    • 投影:IO模块使用投影在存储数据格式为WGS84 (lat/lon)格式的地图和Lanelet2使用的本地坐标之间进行转换。有很多不同的投影都有不同的性质,所以你应该选择最适合你的投影。如果有疑问,请使用UTM。

     3.

    https://github.com/changhexingchen/Lanelet2/blob/master/lanelet2_core/doc/GeometryPrimer.md

    Geometry Calculations With Lanelet2

    用Lanelet2进行几何计算

    Lanelet2 primitives interface with Boost.Geometry. Boost.Geometry offers almost all common geometry calculations and is very fast. One downside is that not all algorithms work well with normal Lanelet2 primitives (see below). Another downside is that Boost.Geometry is compile-time heavy and is thus not included in the normal lanelet2 headers. To use geometry calculations, include the respective geometry header, e.g. geometry/LineString.h.

    Lanelet2基本组件与Boost.Geometry接口。Boost.Geometry提供了几乎所有常见的几何计算,而且非常快。一个缺点是,并不是所有的算法都能很好地与普通的Lanelet2组件一起工作(见下文)。另一个不利因素是Boost.Geometry编译时费时和繁重的,因此不包括在普通的lanelet2头文件中。若要使用几何计算,请包含相应的头文件,例如:geometry/LineString.h。

    Thanks to boost, all common geometry algorithms are available out of the box. E.g. you can compute distances between points, linestrings, polygons, etc in all combinations in (mostly) all dimensions.

    多亏了boost,所有常见的几何算法都是开箱即用的。例如,你可以计算点与点之间的距离,线串,多边形等,在几乎所有的维度上所有的组合。

    There are usually two different kinds of algorithms: The one that Boost implements (like distance) and the one that Lanelet2 implements (mostly on top of Boost), like boundingBox2d. When using the first kind, you should read the lines below, while the second kind can be used without further reading.

    通常有两种不同的算法:一种是Boost实现的(比如距离),另一种是Lanelet2实现的(主要建立在Boost之上),比如boundingBox2d。在使用第一种方法时,您应该阅读下面的代码行,而第二种方法无需进一步阅读就可以使用。

    For a list of algorithms that are available, please refer too Boost's documentation or look through lanelet's geometry headers (or doxygen). All algorithms there have a small description.

    有关可用算法的列表,请参考Boost的文档或查看lanelet的几何头文件(或doxygen)。所有的算法都有一个小的描述。

    Using Lanelet Primitives in Boost.Geometry

    在Boost.Geometry中使用Lanelet基本组件

    Lanelet2 offers every geometrical primitive in three flavors, each for 2D and 3D. Because they are just pointers to the actual data, they can be converted without actually copying data:

    Lanelet2提供了三种形式的几何元素,分别用于2D和3D。因为它们只是指向实际数据的指针,可以在不复制数据的情况下进行转换:

    • Mutable (e.g. LineString2d): Are mutable, returned members are mutable (unless the object is const, then they are also immutable)
    • Const (e.g. ConstLineString2d): These are immutable, returned members (e.g. points of linestring) are also immutable
    • Hybrid (e.g. ConstHybridLineString2d): Also immutable, returned members are not lanelet primitives (e.g. BasicPoint2d). If in doubt, use this one.

    Let us consider these types one by one. The first one (mutable) has the property that it behaves differently (i.e. returns different types) when used const or non-const. This is an issue for some of Boost.Geometry algorithms, because they sometimes accept const and sometimes non-const objects and therefore get the type wrong. Even if they get the type right, Boost is not fully compatible with the concept that copied primitives still refer to the same data and might therefore accidentally modify the wrong data. Therefore algorithms that modify the input (e.g. correct) are possible, but there is no 100% guarantee they work as expected (across all versions of Boost).

    让我们逐一考虑这些类型。第一个变量(可变)的属性是,当使用const或non-const时,它的行为是不同的(即返回不同的类型)。这是Boost.Geometry算法的问题,因为它们有时接受const对象,有时接受非const对象,因此得到错误的类型。即使类型正确,Boost也不完全兼容,复制的元素仍然引用相同数据的概念,因此可能会意外修改错误的数据。因此,修改输入(例如,正确)的算法是可能的,但是不能100%保证它们能正常工作(在Boost的所有版本中)。

    The const version does not have the risk of accidentally modifying the wrong data (because they are always immutable), however some algorithms that should not modify the data still try to instanciate templates in which the data can be modified. This results in longish compiler errors (and this might change from Boost version to Boost version). Algorithms that modify the input data (such as correct) can not be used because of the constness.

    const版本没有意外修改错误数据的风险(因为它们总是不可变的),但是一些不应该修改数据的算法仍然试图实例化可以修改数据的模板。这会导致较长时间的编译器错误(这可能会在不同的Boost版本之间发生变化)。不能使用修改输入数据(如correct)的算法,由于常量。

    The hybrid version returns non-lanelet objects (BasicPoint2d/3d), which are fully compatible with Boost. This is the best solution for almost all geometry calculations. However, algorithms that mutate the primitive itself (such as correct) are not possible because the hybrid versions themselves are immutable (no points can be deleted or added).

    混合版本返回与Boost完全兼容的非lanelet对象(BasicPoint2d/3d)。这是几乎所有几何计算的最佳解决方案。然而,改变基本元素本身(如correct)的算法是不可能的,因为混合版本本身是不可变的(不能删除或添加任何点)。

    In summary:

    TypeFor exampleUse for Boost.Geometry
    Mutable LineString2d Only for mutating algorithms, but use with care
    Const ConstLineString2d No
    Hybrid ConstHybridLineString2d Yes, safe to use if they compile

    Understanding Boost Geometry's Errors

    Boost geometry is known for outputting endless lines of compiler errors when used in the wrong way. Here are some hints to find out what you did wrong (sometimes you have to look closely for the actual error in many lines of instanciated templates). They are related to GCC's error messages, but other compilers will output similar stuff:

    • Something about "no member named 'set' in boost::geometry::traits::access [...]: You used a const primitive (or you used a mutable primitive and Boost converted it into a const by a mistake). Try using the hybrid version.
    • Some error including "NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE" together with some *no matching function for call to assertion failed": This is a very generic error and the error message may be misleading. One reason could be that you forgot to include some lanelet2_core/geometry headers. Other reasons could be that you used the function on a primitive it was not implemented for (refer to Boosts documentation for that) or that it was not implemented for this particular dimension. Especially 3D operations are often not implemented in boost::geometry.
    • Something with "You mixed matrices of different sizes". This is actually an error from Eigen. It means you passed a BasicPoint3d where a BasicPoint2d was expected (or vice versa).
    • Something with "no matching member function for call to '_init1'", also from Eigen: You passed a wrong type where a BasicPoint2d/3d was expected.
    • Some error in boost::assert_dimension_equal: You passed a 2d primitive to Boost where a 3d primitive was expected (or vice versa).
  • 相关阅读:
    学习
    2018年看书计划(40本)
    java快排(两种方法)
    max-points-on-a-line
    Angular不同版本对应的Bootstrap组件
    AngularCLI介绍及配置文件主要参数含义解析
    D3——Updates, Transitions, and Motion
    SVG中的元素属性
    D3——Axes
    Angular2.0知识架构图
  • 原文地址:https://www.cnblogs.com/yibeimingyue/p/10397041.html
Copyright © 2011-2022 走看看