A method, apparatus and electronic device for constructing a map
By extracting and classifying graphic elements from reference maps and constructing target maps using data extraction rules, the problem of low efficiency and insufficient accuracy in manual map construction in existing technologies is solved, and automated, efficient and high-precision map construction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG HUARAY TECH CO LTD
- Filing Date
- 2022-11-21
- Publication Date
- 2026-07-21
AI Technical Summary
Existing map building methods rely on manual labor, which is inefficient and cannot meet high accuracy requirements.
Extract a set of graphic elements from the reference map, classify the graphic elements into N subsets based on their categories, and use the corresponding data extraction rules to obtain the graphic element information to construct the target map.
It enables automated map construction, improves construction efficiency and reduces accuracy errors, especially significantly improving efficiency and accuracy in scenarios involving large-size or large-volume map construction.
Smart Images

Figure CN115761044B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of map drawing technology, and in particular to a method, apparatus and electronic device for constructing maps. Background Technology
[0002] Existing map construction methods mainly rely on manual labor, that is, manual marking of points on reference maps (e.g., planning maps) to construct target maps that meet application requirements.
[0003] However, this manual approach suffers from low construction efficiency, and in some practical scenarios, it is also difficult to meet the requirements for building high-precision target maps.
[0004] Therefore, there is currently a lack of a method for automatically constructing target maps. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for constructing maps.
[0006] In a first aspect, this application provides a method for constructing a map, the method comprising:
[0007] Obtain a set of graphical elements from a reference map for constructing a runnable path; wherein the reference map includes graphical elements for constructing the runnable path and graphical elements not used for constructing the runnable path.
[0008] Based on N preset graphic element categories, the graphic elements in the graphic element set are classified to obtain N subsets; where N is an integer greater than 0, and the graphic elements in the same subset have the same graphic element category;
[0009] For the N subsets, a data extraction rule is determined for each subset based on the graphic element category corresponding to the graphic element in each subset; wherein, the same graphic element category corresponds to the same data extraction rule;
[0010] Using the data extraction rules corresponding to each subset, information is extracted from the graphic elements of each subset to obtain the graphic element information in each subset;
[0011] Based on the graphical element information in each subset, a target map containing the runnable path is constructed.
[0012] Secondly, this application provides an apparatus for constructing a map, the apparatus comprising:
[0013] The acquisition module acquires a set of graphical elements from a reference map for constructing a runnable path; wherein the reference map includes graphical elements for constructing the runnable path and graphical elements not used for constructing the runnable path.
[0014] The classification module classifies the graphic elements in the graphic element set based on N preset graphic element categories, resulting in N subsets; where N is an integer greater than 0, and graphic elements in the same subset have the same graphic element category;
[0015] The determination module, for the N subsets, determines the data extraction rule corresponding to each subset based on the graphic element category corresponding to the graphic element in each subset; wherein, the same graphic element category corresponds to the same data extraction rule;
[0016] The extraction module uses the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset, thereby obtaining the graphic element information in each subset;
[0017] The construction module constructs a target map containing the runnable path based on the graphical element information in each subset.
[0018] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset is specifically used as follows: after determining the first data extraction rule corresponding to the first subset, performing the following operations for each individual graphic element of the first subset: using the first data extraction rule to extract the first point information of the individual graphic element; wherein, the first point information includes at least the head endpoint and tail endpoint of the individual graphic element; determining the first arrangement order of each endpoint in the first point information based on the construction direction of the individual graphic element in the reference map; generating the first graphic element information of the individual graphic element according to the first point information and the first arrangement order; and using the first graphic element information of each graphic element in the first subset as the graphic element information in the first subset.
[0019] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset is specifically used as follows: after determining the second data extraction rules corresponding to the second subset, the following operations are performed on each individual graphic element of the second subset: using the second data extraction rules to extract the second point information of the individual graphic element; wherein, the second point information includes at least the head endpoint, tail endpoint, first control point, and second control point of the individual graphic element; based on the construction direction of the individual graphic element in the reference map, determining the second arrangement order of each endpoint in the second point information; obtaining the second graphic element information of the individual graphic element according to the second point information and the second arrangement order; and using the second graphic element information of each graphic element in the second subset as the graphic element information in the second subset.
[0020] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset is specifically used as follows: after determining the third data extraction rule corresponding to the third subset, the following operations are performed on each individual graphic element of the third subset: using the third data extraction rule to extract the graphic structure information of the individual graphic element; wherein, the graphic structure information includes at least the center endpoint, arc start angle, arc end angle, and arc radius of the individual graphic element; based on the graphic structure information of the individual graphic element, the third point information of the individual graphic element is calculated; wherein, the third point information includes at least the head endpoint, tail endpoint, third control point, and fourth control point of the individual graphic element; according to the third point information and the third arrangement order of each endpoint in the third point information, the third graphic element information of the individual graphic element is obtained; the third graphic element information of each graphic element in the third subset is used as the graphic element information in the third subset.
[0021] In some possible implementations, the extraction module, which calculates the third point information of the single graphic element based on its graphic construction information, is specifically used to: calculate the head endpoint of the single graphic element based on the arc starting angle, the arc radius, and the center endpoint; calculate the tail endpoint of the single graphic element based on the arc ending angle, the arc radius, and the center endpoint; and calculate the third control point of the single graphic element based on the head endpoint, the ingress angle of the single graphic element, and the distance from the head endpoint to the control point; wherein, the ingress angle... The angle is calculated based on the arc's starting angle, and the distance is calculated based on the arc's starting angle and the arc's ending angle. A fourth control point for the single graphic element is calculated based on the tail endpoint, the exit angle of the single graphic element, and the distance from the exit angle to the control point. The exit angle is calculated based on the arc's ending angle, and the distance is calculated based on the arc's starting angle and the arc's ending angle. The calculated head endpoint, tail endpoint, third control point, and fourth control point are used as the third point information for the single graphic element.
[0022] In some possible implementations, the construction module, which constructs a target map containing the runnable path based on the graphical element information in each subset, is specifically configured to: determine a set of point information for constructing the target map based on the graphical element information in each subset; after determining the set of point information, construct points in the target map based on the set of point information, and connect the constructed points according to the graphical element information in each subset to generate a target map containing the runnable path.
[0023] In some possible implementations, the points in the target map are used to segment connected objects in the target map; wherein, the connected objects are objects that are connected over the constructed points.
[0024] Thirdly, this application provides an electronic device, the electronic device comprising:
[0025] Memory, used to store computer programs;
[0026] When a processor executes a computer program stored in the memory, it implements the above-described method steps for constructing a map.
[0027] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method steps for constructing a map.
[0028] For the various aspects of the second to fourth aspects mentioned above, and the technical effects that each aspect may achieve, please refer to the above description of the technical effects that can be achieved for the first aspect or the various possible solutions in the first aspect, which will not be repeated here.
[0029] In this embodiment, a set of graphical elements for constructing runnable paths is first extracted from a reference map. Based on the category of the graphical elements, the set is divided into N subsets, and the same data extraction rules are applied to the same subset to obtain the graphical element information for runnable paths. Then, based on this graphical element information, a target map containing runnable paths is constructed. This method enables automated map construction, improves map construction efficiency, and effectively avoids map accuracy errors caused by manual map construction.
[0030] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0031] Figure 1 A schematic diagram illustrating a possible implementation environment for this application;
[0032] Figure 2 A flowchart of a method for constructing a map provided in this application;
[0033] Figure 3 A schematic diagram of a map-building apparatus provided in this application;
[0034] Figure 4 A schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0036] First, some terms used in the embodiments of this application will be explained to facilitate understanding by those skilled in the art.
[0037] Target Map: A map containing feasible paths that meets the application requirements of smart devices. The aforementioned smart devices can be various intelligent driving devices, without limitation; the aforementioned feasible paths are the drivable routes for smart devices within the target map; the aforementioned application requirements should at least include the file format requirements for smart devices importing the target map.
[0038] Reference map: Contains graphical elements used to construct a workable path, as well as graphical elements not used to construct a workable path. Furthermore, the file format of the reference map may or may not meet the application requirements of smart devices.
[0039] For example, in this embodiment of the application, if the reference map is in DXF format and the target map that meets the application requirements of smart devices is in JSON format, the map construction method provided in this embodiment of the application can be used to construct the target map in JSON format based on the DXF format reference map, so as to achieve automatic construction of the target map.
[0040] It should be noted that this solution can be applied to map building in various application scenarios such as intelligent monitoring, smart cities, autonomous driving, and smartphones. This solution is also suitable for tasks requiring improved efficiency and accuracy in map building.
[0041] The implementation entity of this solution can be a computing terminal, server, or other computing device. By deploying on relevant computing devices and based on the correspondence between image element categories and data extraction rules, appropriate data extraction rules are used to extract graphic element information from the corresponding subset. Based on the extracted graphic element information, the target map is automatically constructed, thereby improving the efficiency and accuracy of map construction. Of course, this is merely an illustrative example of the application entity of this solution and is not specifically limited thereto.
[0042] The design concept of the map construction method provided in the embodiments of this application will be briefly introduced below.
[0043] With the increasing demand for intelligent infrastructure development, more and more smart devices can achieve path planning and autonomous driving by importing operating maps. Examples include driverless cars and autonomous mobile robots (AMRs).
[0044] For example, in some scenarios involving the import of running maps, different smart devices have different application requirements for the file format of the running maps. To adapt to the application requirements of various smart devices for the file format of the running maps, a target map that meets the application requirements needs to be constructed. Currently, the common method is to manually mark points on the map to be converted to complete the file format conversion of the running map.
[0045] For example, in other scenarios involving the import of operational maps, the map to be acquired is a planning map, such as a CAD (Computer Aided Design) map. The planning map contains graphic information about runnable paths and other graphic information; therefore, a target map that meets the application's requirements needs to be reconstructed based on the planning map. To ensure that the target map retains only the runnable paths from the planning map, and to ensure that the target map's file format meets the import requirements of smart devices, manual point labeling is currently commonly used.
[0046] It is evident that, under the relevant technologies, the process of constructing the target map mainly relies on manual labor. Therefore, this method suffers from low construction efficiency and low construction accuracy.
[0047] To improve the efficiency and accuracy of map construction, this application proposes a method for map construction. This method first obtains a set of graphical elements for constructing runnable paths from a reference map. Then, the graphical elements in the set are categorized into N subsets. Next, for each of the N subsets, based on the category of the graphical elements, a data extraction rule is determined for each subset. Using this rule, information is extracted from the graphical elements in each subset to obtain the graphical element information for each subset. Finally, based on the graphical element information in each subset, a target map containing runnable paths is constructed.
[0048] The reference map mentioned above includes: graphical elements used to construct runnable paths, and other graphical elements (i.e., graphical elements not used to construct runnable paths). N is an integer greater than 0. The relationship between the subsets and graphical element categories is as follows: graphical elements within the same subset have the same graphical element category. The relationship between the graphical element categories and data extraction rules is as follows: the same graphical element category corresponds to the same data extraction rule.
[0049] In this embodiment, a set of graphical elements for constructing a workable path is extracted from a reference map. Then, the graphical elements in the set are divided into N subsets based on their categories, and the same data extraction rules are applied to each subset to obtain the graphical element information for the workable path. Based on this graphical element information, a target map containing the workable path is then constructed. This method enables automated map construction, improves map building efficiency, and effectively avoids map accuracy errors caused by manual map construction.
[0050] In addition, the inventors have found in practice that when this method is applied to the construction of large-size maps or a large number of maps, it can achieve more significant improvements in construction efficiency and accuracy, and effectively save the time and labor costs spent on map construction, thereby solving the problem that relying on manual methods cannot meet the efficiency and accuracy requirements of practical applications.
[0051] The map construction method provided in this application embodiment can be applied to... Figure 1 The implementation environment shown may include at least a storage system 10, a computing system 20, and a smart device 30.
[0052] The intelligent device 30 may include intelligent vehicles, smartphones, and autonomous mobile robots. The storage system 10 can store map data, such as reference maps and target maps. The computing system 20 may include servers. The computing system 20 interacts with the storage system 10, retrieving reference maps from it and storing constructed target maps there. Furthermore, the computing system 20 interacts with the intelligent device 30, classifying and extracting information from the graphic elements in the reference map used to construct runnable paths to obtain image element information for constructing the target map, thereby generating the target map. This target map can be imported into the intelligent device 30 and runs normally on it.
[0053] Furthermore, the smart devices 30 (e.g., between 30_1 and 30_2 or 30_N) can communicate with each other via network 40. Network 40 can be a network for information transmission in a broad sense, and may include one or more communication networks, such as wireless communication networks, the Internet, private area networks, local area networks, metropolitan area networks, wide area networks, or cellular data networks.
[0054] It should be noted that the storage system 10, computing system 20, and intelligent device 30 mentioned above are different devices, or any two or three of the storage system 10, computing system 20, and intelligent device 30 can be integrated into the same device. The network 40 mentioned above is not mandatory, and this solution does not impose specific limitations on it.
[0055] The map construction method provided in the embodiments of this application will be described in detail below. (Reference) Figure 2 The method includes steps 201-205, as detailed below.
[0056] Step 201: Obtain the set of graphical elements from the reference map to construct a workable path;
[0057] The reference map is a map that does not meet the application requirements. This reference map includes both graphical elements used to construct a runnable path and graphical elements not used to construct a runnable path. The graphical elements used to construct a runnable path can include at least one or a combination of straight lines, polygons, Bézier curves, and arcs. Therefore, the acquired set of graphical elements can include one or a combination of straight lines, polygons, Bézier curves, and arcs.
[0058] In this embodiment of the application, in order to facilitate reading the graphic elements in the reference map, the graphic element data in the reference map is parsed into key-value pairs, thereby obtaining a set of graphic elements used to construct a runnable path.
[0059] For example, in the above parsing operation, if the reference map is in DXF format, the graphic element data in the original reference map can be converted into key-value pairs using a target plugin (e.g., dxf-parser). Here, the graphic element data in the original reference map can be understood as items piled together in a warehouse (values). To facilitate retrieval, these items need to be categorized and grouped, that is, each item needs to be assigned a unique label (key).
[0060] It should be noted that in the embodiments of this application, all graphic elements can be stored in key-value pair format, which will not be elaborated further below.
[0061] Step 202: Based on the preset N categories of graphic elements, classify the graphic elements in the set of graphic elements to obtain N subsets;
[0062] Where N is an integer greater than 0, and graphic elements in the same subset have the same graphic element category.
[0063] Specifically, straight lines, polygons, Bézier curves, and arcs can be considered as four preset categories of graphic elements. Of course, the number or types of preset graphic element categories are not limited here. Taking the aforementioned four as an example, the graphic elements in the graphic element set obtained in step 201 are classified according to these four categories, that is, elements of the same category are grouped into the same subset, resulting in four corresponding subsets. The four subsets respectively store graphic elements of the four categories: straight lines, polygons, Bézier curves, and arcs.
[0064] Step 203: For the N subsets, based on the graphic element category corresponding to the graphic element in each subset, determine the data extraction rules corresponding to each subset;
[0065] Among them, the same graphic element category corresponds to the same data extraction rule. In other words, the same data extraction rule extracts graphic element information in the same format, and the information length of the graphic element information extracted by the same data extraction rule is also the same. For example, if a graphic element contains 4 data, then its corresponding information length is 4.
[0066] For example, in the embodiments of this application, if four subsets of graphic elements are stored respectively, which are of four graphic element categories: straight line, polygon, Bézier arc, and arc, then the corresponding data extraction rules for each of the four subsets are determined based on the data extraction rules corresponding to each of the four graphic element categories: straight line, polygon, Bézier arc, and arc.
[0067] Step 204: Using the data extraction rules corresponding to each subset, extract information from the graphic elements of each subset to obtain the graphic element information in each subset;
[0068] To illustrate the different extraction logics of different data extraction rules in practical applications, the following is divided into three parts, each corresponding to the extraction logic of a data extraction rule.
[0069] The first part, the first subset, corresponds to the first data extraction rule:
[0070] In this embodiment, after determining the first data extraction rule corresponding to the first subset, the following operations are performed on each graphic element of the first subset. Taking a single image element as an example: First, the first data extraction rule is used to extract the first point information of the single graphic element. This first point information includes at least the head endpoint and tail endpoint of the single graphic element. Then, based on the construction direction of the single graphic element in the reference map, the first arrangement order of each endpoint in the first point information is determined. Finally, based on the first point information and the first arrangement order, the first graphic element information of the single graphic element is generated. Thus, the first graphic element information of each graphic element in the first subset is determined, and the first graphic element information of each graphic element in the first subset is used as the graphic element information of the first subset.
[0071] Specifically, the graphic elements in the first subset mentioned above can be line segments or line segments that form polygons. It should be noted that the line segment is composed of a straight line, a head endpoint, and a tail endpoint.
[0072] The first point information can be represented as a container array, and the first point information contains the horizontal and vertical coordinates of the head endpoint and the tail endpoint in the reference map. Optionally, the horizontal and vertical coordinates are rounded to the nearest integer (or determined according to the accuracy required by the actual application scenario). Therefore, the information length corresponding to the first point information is 4.
[0073] For example, for a graphic element LINE (line segment) in the first subset, firstly, an array is created as a container Arr. Then, the starting endpoint (x0, y0) and ending endpoint (x1, y1) of the LINE in the reference map are traversed, and the values in (x0, y0) and (x1, y1) are rounded down. Two new arrays are added to the container Arr, which are two straight line paths, specifically Arr.push([x0, y0, x1, y1]) and Arr.push([x1, y1, x0, y0]). Here, Arr.push([x0, y0, x1, y1]) represents a straight line segment from (x0, y0) to (x1, y1) in the target map, and Arr.push([x1, y1, x0, y0]) represents a straight line segment from (x1, y1) to (x0, y0) in the target map. Of course, depending on the actual construction situation, if the path where the LINE is located is a one-way street, then one of the above two sets of arrays (paths) can be selected according to its construction direction on the reference map or the indicated direction in the actual scene.
[0074] For example, for a graphic element LWPOLYLINE (polygon) in the first subset, it can be divided into multiple line segments according to its vertices. This is the same idea as the extraction of LINE described above, and will not be repeated here.
[0075] The second part, the second subset, corresponds to the second data extraction rule:
[0076] In this embodiment, after determining the second data extraction rule corresponding to the second subset, the following operations are performed on each graphic element of the second subset. Taking a single image element as an example: using the second data extraction rule, the second point information of the single graphic element is extracted. This second point information includes at least the head endpoint, tail endpoint, first control point, and second control point of the single graphic element. Then, based on the construction direction of the single graphic element in the reference map, the second arrangement order of each endpoint in the second point information is determined. Finally, based on the second point information and the second arrangement order, the second graphic element information of the single graphic element is obtained. Thus, the second graphic element information of each graphic element in the second subset is determined, and the second graphic element information of each graphic element in the second subset is used as the graphic element information of the second subset.
[0077] Specifically, the graphic elements in the second subset mentioned above can be Bézier curves. It should be noted that the line segment is composed of the first endpoint, the last endpoint, and the first and second control points that constitute the curve.
[0078] The aforementioned second point information can be represented as a container array, and the second point information includes the horizontal and vertical coordinates of the head endpoint, tail endpoint, first control point, and second control point in the reference map. Optionally, the horizontal and vertical coordinates can be rounded to the nearest integer (or determined according to the accuracy required by the actual application scenario). Therefore, the information length corresponding to the second point information is 8.
[0079] For example, for a graphic element SPLINE (Bezier curve) in the second subset, firstly, an array is created as a container Arr. Then, the first endpoint (x0, y0), the last endpoint (x3, y3), the first control point (x1, y1), and the second control point (x2, y2) of the SPLINE in the reference map are traversed. The values in (x0, y0), (x1, y1), (x2, y2), and (x3, y3) are rounded down. Two new arrays are added to the container Arr, which are two curve paths. Specifically, Arr.push([x0, y0, x1, y1, x2, y2, x3, y3]) and Arr.push([x3, y3, x2, y2, x1, y1, x0, y0]). Here, `Arr.push([x0,y0,x1,y1,x2,y2,x3,y3])` represents a curve segment in the target map from (x0,y0) to (x3,y3), and `Arr.push([x1,y1,x0,y0])` represents a curve segment in the target map from (x3,y3) to (x0,y0). Of course, depending on the actual construction situation, if the path where the SPLINE is located is a one-way street, then one of the above two sets of arrays (paths) can be selected based on its construction direction in the reference map or its indicated direction in the actual scene.
[0080] The third part, the third subset, corresponds to the third data extraction rule:
[0081] In this embodiment, after determining the third data extraction rule corresponding to the third subset, the following operations are performed on each graphic element of the third subset, taking a single image element as an example: First, the third data extraction rule is used to extract the graphic construction information of the single graphic element. This graphic construction information includes at least the center endpoint, arc start angle, arc end angle, and arc radius of the single graphic element. Then, based on the graphic construction information of the single graphic element, the third point information of the single graphic element is calculated. This third point information includes at least the head endpoint, tail endpoint, third control point, and fourth control point of the single graphic element. Finally, based on the third point information and the third arrangement order of each endpoint in the third point information, i.e., the third arrangement order of each endpoint in the third point information determined based on the construction direction of the single graphic element in the reference map, the third graphic element information of the single graphic element is obtained. Thus, the third graphic element information of each graphic element in the third subset is determined, and the third graphic element information of each graphic element in the third subset is used as the graphic element information of the third subset.
[0082] Specifically, the graphic elements in the third subset mentioned above can be arcs. It should be noted that the graphic construction information of the arc includes: the endpoint of the center of the circle containing the arc, the starting angle of the arc, the ending angle of the arc, and the radius of the arc.
[0083] The aforementioned third point information can be represented as a container array, and the third point information includes the horizontal and vertical coordinates of the first endpoint, the last endpoint, the third control point, and the fourth control point in the reference map. Optionally, the horizontal and vertical coordinates can be rounded to the nearest integer (or determined according to the accuracy required by the actual application scenario). Therefore, the information length corresponding to the first point information is 8.
[0084] For example, for a graphic element ARC (arc) in the first subset, if the graphic construction information of ABC is determined as follows: center endpoint (x,y), arc start angle startAngle, arc end angle endAngle, and arc radius radius, then the above-mentioned third point information can be generated based on the above graphic construction information, as follows.
[0085] Based on the arc's starting angle (startAngle), arc radius (radius), and center endpoint (x, y), the starting endpoint (startX, startY) of a single graphic element's ARC is calculated using one formula:
[0086] startX=Math.cos(startAngle)*radius+x;
[0087] startY=Math.sin(startAngle)*radius+y.
[0088] Based on the arc termination angle (endAngle), arc radius (radius), and center endpoint (x, y), the tail endpoint (endX, endY) of a single graphic element ARC can be calculated using one formula:
[0089] endX=Math.cos(endAngle)*radius+x;
[0090] endY=Math.sin(endAngle)*radius+y.
[0091] Based on the head endpoints (startX, startY), the ingress angle sa of a single graphic element ARC, and the distance rr from the head endpoints to the control points, the third control point (c1x, c1y) of a single graphic element ARC is calculated. One formula for this calculation is as follows:
[0092] c1x=Math.cos(sa)*rr+startX;
[0093] c1y=Math.sin(sa)*rr+startY.
[0094] Based on the tail endpoints (endX, endY), the exit angle ea of a single graphic element ARC, and the distance rr from the exit angle to the control point, the fourth control point (c2x, c2y) of a single graphic element ARC is calculated. One formula for this calculation is as follows:
[0095] c2x = Math.cos(ea)*rr + endX;
[0096] c2y = Math.sin(ea)*rr + endY.
[0097] The parameters required for calculating the third control point (c1x, c1y) and the fourth control point (c2x, c2y) include: the ingress angle sa, the outgress angle ea, the difference between the ingress and outgress angles R, and the distance rr, as detailed below.
[0098] The inclination angle *sa* is calculated based on the starting angle *startAngle* of the arc, and one formula for its calculation is as follows:
[0099] sa = startAngle + Math.PI / 2;
[0100] The exit angle ea is calculated based on the arc termination angle endAngle, and one of its calculation formulas can be expressed as:
[0101] ea = endAngle - Math.PI / 2;
[0102] The difference between the entry and exit angles R (taking acute angles) is calculated based on the entry angle sa and the exit angle ea. One formula for its calculation is as follows:
[0103] R = getAnlge(sa,ea);
[0104] The distance rr is calculated based on the arc's starting angle startAngle and ending angle endAngle. One formula for its calculation is as follows:
[0105] rr = R / Math.PI*radius.
[0106] After calculating the first endpoint (startX, startY), the last endpoint (endX, endY), the third control point (c1x, c1y), and the fourth control point (c2x, c2y), these values can be rounded down. Two new arrays, which are two circular paths, can be added to the container Arr. Specifically, Arr.push([startX, startY, c1x, c1y, c2x, cy2, endX, endY]) and Arr.push([endX, endY, cx2, cy2, c1x, c1y, startX, startY]). In this context, `Arr.push([startX,startY,c1x,c1y,c2x,cy2,endX,endY])` represents an arc segment in the target map from (startX,startY) to (endX,endY), and `Arr.push([endX,endY,cx2,cy2,c1x,c1y,startX,startY])` represents another arc segment in the target map from (endX,endY) to (startX,startY). Of course, depending on the actual construction situation, if the path where ARC is located is a one-way street, then one of the above two sets of arrays (paths) can be selected based on its construction direction in the reference map or its indicated direction in the actual scene.
[0107] After introducing the extraction logic of different data extraction rules, it should be noted that the terms "first," "second," and "third" used in the above three parts are for descriptive purposes only and should not be interpreted as indicating or implying relative importance or order. Furthermore, in practical applications, the above three parts can be used individually or in combination according to actual needs; this solution does not impose any restrictions on this.
[0108] Step 205: Based on the graphical element information in each subset, construct a target map containing the runnable path.
[0109] After determining the graphic element information in each subset, the target map can be constructed in two steps: establishing points and connecting lines.
[0110] Point creation: The aforementioned graphic element information mainly includes the location information of points used to construct straight, curved, or circular paths. For example, the first endpoint of a single unidirectional path is designated as the last endpoint. Therefore, a set of point information for constructing the target map can be determined. Optionally, this set may only contain the first endpoint of a single unidirectional path designated as the last endpoint. Then, based on the endpoint coordinates in the point information set, the corresponding points are constructed on the canvas or coordinate system where the target map is located.
[0111] Optionally, during the point construction process, a point index can be simultaneously established to support the rapid retrieval of corresponding points on the constructed target map. Accordingly, the specific retrieval method can be as follows: traverse all points in the target map, establish and sort the set of all y-values corresponding to the x-coordinate of each point. During the search, first find the set of y-values corresponding to the x-value; if not found, return false; otherwise, return the set of y-values and perform a binary search. If found, return true; otherwise, return false, thus improving the retrieval speed and reducing coupling.
[0112] Connections: The aforementioned graphic element information also includes the relevant point information for reconstructing straight, curved, or circular paths. For example, a graphic element with a length of 4 indicates a straight path, while a graphic element with a length of 8 indicates a curved or circular path through its two control endpoints. Therefore, based on the information length of the graphic element and its included control endpoints, points constructed in the target map can be connected. The resulting path is a runnable path, which together constitute the target map.
[0113] Optionally, during the connection process, the graphic element information with a length of 4 can be traversed first to establish the connectivity of all straight paths, and then the graphic element information with a length of 8 can be traversed to construct the connectivity of curved paths or arc paths.
[0114] Furthermore, points in the target map can also be used to segment connected objects in the target map, that is, objects connected by the constructed points, such as lines.
[0115] For example, iterate through all connected lines in the target map and search for intersections between lines or points on the lines. If so, automatically split the map at the corresponding intersection or point. It should be noted that if splitting is based on intersections, the corresponding intersections need to be recorded as points.
[0116] Furthermore, it should be noted that the method provided in this application embodiment is mainly used to automate the conversion of graphic elements of runnable paths in a reference map to generate a target map that meets application requirements. Therefore, regarding the horizontal and vertical coordinates involved in this application embodiment, those skilled in the art will understand that the point coordinates in the target map do not need to be completely consistent with the point coordinates in the reference map. That is, the coordinate information in the reference map can be mapped to the target map through conversion, but the relative positions between graphic elements in the target map and the relative positions between graphic elements in the reference map need to be consistent.
[0117] Based on the same inventive concept, this application also provides a map-building apparatus, for use in, see [link to relevant documentation] Figure 3 The device includes:
[0118] The acquisition module 301 acquires a set of graphical elements for constructing a runnable path from a reference map; wherein the reference map includes: graphical elements for constructing the runnable path and graphical elements not used for constructing the runnable path;
[0119] The classification module 302 classifies the graphic elements in the graphic element set based on N preset graphic element categories to obtain N subsets; where N is an integer greater than 0, and the graphic elements in the same subset have the same graphic element category;
[0120] The determining module 303, for the N subsets, determines the data extraction rule corresponding to each subset based on the graphic element category corresponding to the graphic element in each subset; wherein, the same graphic element category corresponds to the same data extraction rule;
[0121] The extraction module 304 uses the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset, thereby obtaining the graphic element information in each subset;
[0122] The construction module 305 constructs a target map containing the runnable path based on the graphic element information in each subset.
[0123] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset, the extraction module 304 is specifically used to: after determining the first data extraction rule corresponding to the first subset, perform the following operations for each individual graphic element of the first subset: using the first data extraction rule to extract the first point information of the individual graphic element; wherein, the first point information includes at least the head endpoint and tail endpoint of the individual graphic element; based on the construction direction of the individual graphic element in the reference map, determine the first arrangement order of each endpoint in the first point information; generate the first graphic element information of the individual graphic element according to the first point information and the first arrangement order; and use the first graphic element information of each graphic element in the first subset as the graphic element information in the first subset.
[0124] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset, the extraction module 304 is specifically used to: after determining the second data extraction rules corresponding to the second subset, perform the following operations for each individual graphic element of the second subset: using the second data extraction rules to extract the second point information of the individual graphic element; wherein, the second point information includes at least the head endpoint, tail endpoint, first control point, and second control point of the individual graphic element; based on the construction direction of the individual graphic element in the reference map, determine the second arrangement order of each endpoint in the second point information; obtain the second graphic element information of the individual graphic element according to the second point information and the second arrangement order; and use the second graphic element information of each graphic element in the second subset as the graphic element information in the second subset.
[0125] In some possible implementations, the step of using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset to obtain graphic element information in each subset, the extraction module 304 is specifically used to: after determining the third data extraction rule corresponding to the third subset, perform the following operations for each individual graphic element of the third subset: using the third data extraction rule to extract the graphic structure information of the individual graphic element; wherein, the graphic structure information includes at least the center endpoint, arc start angle, arc end angle, and arc radius of the individual graphic element; based on the graphic structure information of the individual graphic element, calculate the third point information of the individual graphic element; wherein, the third point information includes at least the head endpoint, tail endpoint, third control point, and fourth control point of the individual graphic element; according to the third point information and the third arrangement order of each endpoint in the third point information, obtain the third graphic element information of the individual graphic element; and use the third graphic element information of each graphic element in the third subset as the graphic element information in the third subset.
[0126] In some possible implementations, the extraction module 304, specifically used to calculate the third point information of the single graphic element based on its graphic construction information, is configured to: calculate the head endpoint of the single graphic element based on the arc start angle, the arc radius, and the center endpoint; calculate the tail endpoint of the single graphic element based on the arc end angle, the arc radius, and the center endpoint; and calculate the third control point of the single graphic element based on the head endpoint, the ingress angle of the single graphic element, and the distance from the head endpoint to the control point; wherein, the... The entry angle is calculated based on the arc's starting angle, and the distance is calculated based on the arc's starting angle and the arc's ending angle. A fourth control point for the single graphic element is calculated based on the tail endpoint, the exit angle of the single graphic element, and the distance from the exit angle to the control point. The exit angle is calculated based on the arc's ending angle, and the distance is calculated based on the arc's starting angle and the arc's ending angle. The calculated head endpoint, tail endpoint, third control point, and fourth control point are used as the third point information for the single graphic element.
[0127] In some possible implementations, the construction module 305, which constructs a target map containing the runnable path based on the graphical element information in each subset, is specifically used to: determine a set of point information for constructing the target map based on the graphical element information in each subset; after determining the set of point information, construct points in the target map based on the set of point information, and connect the constructed points according to the graphical element information in each subset to generate a target map containing the runnable path.
[0128] In some possible implementations, the points in the target map are used to segment connected objects in the target map; wherein, the connected objects are objects that are connected over the constructed points.
[0129] Based on the same inventive concept, this application also provides an electronic device that can perform the functions of the aforementioned map-building device. (Refer to...) Figure 4 The electronic device includes:
[0130] At least one processor 401 and a memory 402 connected to at least one processor 401. In this embodiment, the specific connection medium between the processor 401 and the memory 402 is not limited. Figure 4 The example shown is the connection between processor 401 and memory 402 via bus 400. Bus 400 is... Figure 4 The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. The 400 bus can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 4 The term is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, processor 401 can also be called a controller; there is no restriction on the name.
[0131] In this embodiment, memory 402 stores instructions executable by at least one processor 401. By executing the instructions stored in memory 402, at least one processor 401 can perform the map construction method described above. Processor 401 can implement... Figure 3 The functions of each module in the device / system shown.
[0132] The processor 401 is the control center of the device / system. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 402 and calling data stored in memory 402, it can monitor the various functions and data processing of the device / system as a whole.
[0133] In one possible design, processor 401 may include one or more processing units. Processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 401. In some embodiments, processor 401 and memory 402 may be implemented on the same chip; in some embodiments, they may also be implemented separately on separate chips.
[0134] Processor 401 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the map construction method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0135] Memory 402, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 402 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 402 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 402 can also be a circuit or any other device / system capable of implementing storage functions for storing program instructions and / or data.
[0136] By designing and programming the processor 401, the code corresponding to the map construction method described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute it during runtime. Figure 2The steps of the map construction method in the illustrated embodiment are as follows. How to design and program the processor 401 is a technique well-known to those skilled in the art and will not be described further here.
[0137] Based on the same inventive concept, embodiments of this application also provide a storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the map construction method described above.
[0138] In some possible implementations, various aspects of the map-building method provided in this application may also be implemented in the form of a program product, which includes program code that, when the program product is run on a device, causes the control device to perform the steps in the map-building method according to the various exemplary embodiments of this application described above.
[0139] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus / systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0140] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0141] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0142] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0143] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for constructing a map, characterized in that, The method includes: Obtain a set of graphical elements from a reference map for constructing a runnable path; wherein the reference map includes graphical elements for constructing the runnable path and graphical elements not used for constructing the runnable path. Based on N preset graphic element categories, the graphic elements in the graphic element set are classified to obtain N subsets; where N is an integer greater than 0, and the graphic elements in the same subset have the same graphic element category; For the N subsets, a data extraction rule is determined for each subset based on the graphic element category corresponding to the graphic element in each subset; wherein, the same graphic element category corresponds to the same data extraction rule; Using the data extraction rules corresponding to each subset, information is extracted from the graphic elements of each subset to obtain the graphic element information in each subset, including: After determining the third data extraction rule corresponding to the third subset, the following operations are performed on each individual graphic element of the third subset: The third data extraction rule is used to extract the graphic structure information of the individual graphic element; wherein, the graphic structure information includes at least the center endpoint, arc start angle, arc end angle, and arc radius of the individual graphic element. Based on the graphic construction information of the single graphic element, the third point information of the single graphic element is calculated; wherein, the third point information includes at least the head endpoint, tail endpoint, third control point and fourth control point of the single graphic element. Based on the third point information and the third arrangement order of each endpoint in the third point information, the third graphic element information of the single graphic element is obtained; The third graphic element information of each graphic element in the third subset is used as the graphic element information in the third subset; Based on the graphical element information in each subset, a target map containing the runnable path is constructed.
2. The method as described in claim 1, characterized in that, The step involves using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset, thereby obtaining the graphic element information in each subset, including: After determining the first data extraction rule corresponding to the first subset, the following operations are performed on each individual graphic element of the first subset: Using the first data extraction rule, the first point information of the single graphic element is extracted; wherein, the first point information includes at least the head endpoint and the tail endpoint of the single graphic element; Based on the construction direction of the single graphic element in the reference map, the first arrangement order of each endpoint in the first point information is determined. Based on the first point information and the first arrangement order, generate the first graphic element information of the single graphic element; The first graphic element information of each graphic element in the first subset is used as the graphic element information in the first subset.
3. The method as described in claim 1, characterized in that, The step involves using the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset, thereby obtaining the graphic element information in each subset, including: After determining the second data extraction rule corresponding to the second subset, the following operations are performed on each individual graphic element of the second subset: Using the second data extraction rule, the second point information of the single graphic element is extracted; wherein, the second point information includes at least the head endpoint, tail endpoint, first control point, and second control point of the single graphic element; Based on the construction direction of the single graphic element in the reference map, the second arrangement order of each endpoint in the second point information is determined; Based on the second point information and the second arrangement order, the second graphic element information of the single graphic element is obtained; The second graphic element information of each graphic element in the second subset is used as the graphic element information in the second subset.
4. The method as described in claim 1, characterized in that, The calculation of the third point information of the single graphic element based on the graphic construction information of the single graphic element includes: Based on the arc starting angle, the arc radius, and the center endpoint, calculate the head endpoint of the individual graphic element; Based on the arc termination angle, the arc radius, and the center endpoint, calculate the tail endpoint of the individual graphic element; The third control point of the single graphic element is calculated based on the head endpoint, the ingress angle of the single graphic element, and the distance from the head endpoint to the control point; wherein the ingress angle is calculated based on the arc start angle, and the distance is calculated based on the arc start angle and the arc end angle. Based on the tail endpoint, the exit angle of the individual graphic element, and the distance from the exit angle to the control point, the fourth control point of the individual graphic element is calculated; wherein, the exit angle is calculated based on the arc termination angle, and the distance is calculated based on the arc start angle and the arc termination angle; The calculated head endpoint, tail endpoint, third control point, and fourth control point are used as the third point information of the single graphic element.
5. The method as described in claim 1, characterized in that, The construction of a target map containing the runnable path based on the graphical element information in each subset includes: Based on the graphic element information in each subset, a set of point information for constructing the target map is determined; After determining the set of point information, points in the target map are constructed based on the set of point information, and the constructed points are connected according to the graphic element information in each subset to generate a target map containing the runnable path.
6. The method as described in claim 5, characterized in that, The points in the target map are used to segment connected objects in the target map; wherein, the connected objects are objects that are connected based on the constructed points.
7. An apparatus for constructing a map, characterized in that, The device includes: The acquisition module acquires a set of graphical elements from a reference map for constructing a runnable path; wherein the reference map includes graphical elements for constructing the runnable path and graphical elements not used for constructing the runnable path. The classification module classifies the graphic elements in the graphic element set based on N preset graphic element categories, resulting in N subsets; where N is an integer greater than 0, and graphic elements in the same subset have the same graphic element category; The determination module, for the N subsets, determines the data extraction rule corresponding to each subset based on the graphic element category corresponding to the graphic element in each subset; wherein, the same graphic element category corresponds to the same data extraction rule; The extraction module uses the data extraction rules corresponding to each subset to extract information from the graphic elements of each subset, obtaining graphic element information in each subset, including: After determining the third data extraction rule corresponding to the third subset, the following operations are performed on each individual graphic element of the third subset: The third data extraction rule is used to extract the graphic structure information of the individual graphic element; wherein, the graphic structure information includes at least the center endpoint, arc start angle, arc end angle, and arc radius of the individual graphic element. Based on the graphic construction information of the single graphic element, the third point information of the single graphic element is calculated; wherein, the third point information includes at least the head endpoint, tail endpoint, third control point and fourth control point of the single graphic element. Based on the third point information and the third arrangement order of each endpoint in the third point information, the third graphic element information of the single graphic element is obtained; The third graphic element information of each graphic element in the third subset is used as the graphic element information in the third subset; The construction module constructs a target map containing the runnable path based on the graphical element information in each subset.
8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a computer program stored in the memory, implements the method steps of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-6.