Map segmentation method and device, equipment and storage medium
By receiving user segmentation commands, the position and shape of the segmentation lines are automatically adjusted, solving the problems of insufficient flexibility and user experience in existing map segmentation methods, and realizing flexible region segmentation and efficient user interaction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LETV INFORMATION TECH BEIJING
- Filing Date
- 2025-12-23
- Publication Date
- 2026-04-24
AI Technical Summary
Existing map segmentation methods are insufficient in terms of flexibility and user experience. The segmentation parameter method is simple to operate but has low flexibility, while the custom drawing method is highly professional and complex to operate.
A map segmentation method is provided, which receives a user's segmentation command, determines the type of the segmentation command, and adds, moves, or rotates the segmentation lines. The segmentation lines are automatically stretched or shortened according to the edges of the graphic to achieve flexible region segmentation.
Users can easily add, move, and rotate dividing lines, which automatically and tightly fit with the edges, enabling flexible segmentation of different areas and improving user experience and segmentation flexibility.
Smart Images

Figure CN121921331A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing, and more particularly to the field of computer geometric segmentation technology, specifically to a map segmentation method, apparatus, device, and storage medium. Background Technology
[0002] Modern map segmentation software allows users to customize the division of areas on a map. For example, users can freely create areas of varying sizes and shapes, such as circles and rectangles, according to their needs.
[0003] Currently, the main methods for segmenting maps to form customized regions include the following: The method of generating tile maps by segmenting maps based on cutting parameters can cut maps into tile maps, which is suitable for various map customization scenarios. Users only need to upload local images and set cutting parameters to generate tile maps. The operation is simple and intuitive, suitable for personal projects and professional needs. However, it has low flexibility in map segmentation and poor user experience. It allows users to customize the way business areas are divided on a map, providing business area management functions. Users can customize the drawing of business areas and perform operations such as merging, splitting by line, and splitting by area. After drawing, users can also assign attribute values to the area and save it. The drawn area can also be made into a thematic map, such as a segmented color map. However, it is highly professional and not easy to operate in practice. Summary of the Invention
[0004] This disclosure provides a map segmentation method, apparatus, device, and storage medium.
[0005] According to a first aspect of this disclosure, a map segmentation method is provided. The method includes: Display electronic map; Receive the user's split command; Determine the type of the segmentation command to add or adjust the segmentation line, and segment the electronic map into regions based on the position of the added or adjusted segmentation line; The segmentation command includes: The Single Add Divider command adds a single dividing line that extends along the edge of the closed region until it intersects the edge of the closed region. The "Add Divider Line Multiple Times" command is used to repeatedly add divider lines, ensuring that the divider lines are added according to the center position of the current largest area. The Move Divider command is used to move dividers and extend them to the edge of closed regions during the movement. After the divider movement is complete, other dividers that do not form closed regions are deleted. The Rotate Divider command is used to rotate the dividing line and extend it to the edge of the closed area during the rotation.
[0006] In addition to the aspects and any possible implementations described above, a further implementation is provided in which adding a dividing line such that the dividing line extends along the edge of the closed region until it intersects with the edge of the closed region includes: Add a dividing line, and starting from the midpoint of the dividing line, extend the dividing line towards the edge of the closed region according to the line segment vectors of the front and back halves of the dividing line, until it intersects with it; Determine the intersection point at the edge of the enclosed area; Calculate the vector required to extend the distance from the starting point to the intersection point in the direction of the endpoint.
[0007] In addition to the aspects and any possible implementations described above, a further implementation is provided in which the moving dividing line, and extending to the edge of the closed region during the moving of the dividing line, comprises: Determine the dividing line to be moved; When the user's movement point is within the map area, respond to the user's movement point, and starting from the user's movement point, redraw the dividing line and extend it to the edge of the closed area according to the line segment vectors of the front and back halves of the dividing line to be moved, until it intersects with it.
[0008] In addition to the aspects and any possible implementations described above, a further implementation is provided in which deleting other dividing lines that do not form a closed region after the dividing line movement is completed includes: After the dividing line is moved, traverse all line segments and keep only the line segments whose ends are on other line segments.
[0009] As described above and in any possible implementation, a further implementation is provided in which the rotating dividing line, and extending to the edge of the closed region during the rotation of the dividing line, comprises: Determine the dividing line to be rotated and the rotation angle; Based on the rotation angle, the dividing line to be rotated is rotated around its midpoint, and with the midpoint of the dividing line as the starting point, the dividing line is redrawn and extended towards the edge of the closed region according to the line segment vectors of the front and back halves of the rotated line segment until it intersects with it.
[0010] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the method further includes: When two dividing lines intersect, starting from the intersection point, the dividing lines are redrawn according to the line segment vectors of each dividing line and extend towards the edge of the closed region until they intersect.
[0011] In addition to the aspects described above and any possible implementations, a further implementation is provided in which the edge of the enclosed region includes a map edge or an obstacle edge.
[0012] According to a second aspect of this disclosure, a map segmentation apparatus is provided. The apparatus includes: The display module is used to display electronic maps; The receiving module is used to receive the user's segmentation command; The segmentation module is used to determine the type of the segmentation command, add or adjust the segmentation lines, and segment the electronic map into regions based on the position of the added or adjusted segmentation lines. The segmentation commands include: a single add segmentation line command, used to add a segmentation line that extends along the edge of the closed region until it intersects with the edge of the closed region; a multiple add segmentation line command, used to repeatedly add segmentation lines that are added at the center position of the current largest region; a move segmentation line command, used to move the segmentation line and extend it to the edge of the closed region during the movement, and delete other segmentation lines that have not formed a closed region after the movement is completed; and a rotate segmentation line command, used to rotate the segmentation line and extend it to the edge of the closed region during the rotation.
[0013] According to a third aspect of this disclosure, an electronic device is provided. The electronic device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the program to implement the method described above.
[0014] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0015] This application provides a map segmentation method that can receive segmentation commands from users; determine the type of segmentation command to add or adjust segmentation lines; and segment the map into regions based on the positions of the added or adjusted segmentation lines. The segmentation commands include: a single add segmentation line command, used to add a single segmentation line that extends along the edge of a closed region until it intersects the edge of the closed region; a multiple add segmentation line command, used to repeatedly add segmentation lines that are added at the center position of the current largest region; a move segmentation line command, used to move the segmentation line and extend it to the edge of the closed region during the movement, and delete other segmentation lines that do not form closed regions after the movement is complete; and a rotate segmentation line command, used to rotate the segmentation line and extend it to the edge of the closed region during the rotation. Based on this, users can easily add, move, and rotate segmentation lines with simple operations. The segmentation lines automatically stretch or shorten according to the edges of the graphic to achieve a tight fit with the edges, thereby segmenting the graphic into different regions based on the position of the segmentation lines.
[0016] It should be understood that the description in the Summary of the Invention is not intended to limit the key or essential features of the embodiments of this disclosure, nor is it intended to restrict the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0017] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. The drawings are provided for a better understanding of the invention and are not intended to limit the scope of this disclosure. In the drawings, the same or similar reference numerals denote the same or similar elements, wherein: Figure 1 A flowchart of a map segmentation method according to an embodiment of the present disclosure is shown; Figure 2 A schematic diagram of an added dividing line page according to an embodiment of the present disclosure is shown; Figure 3 A schematic diagram is shown showing how, according to an embodiment of the present disclosure, when dividing lines intersect, the original dividing line is automatically cut into two new dividing lines. Figure 4 A schematic diagram illustrating an embodiment of the present disclosure is shown, which can be arbitrarily divided into different segments; Figure 5 A block diagram of a map segmentation apparatus according to an embodiment of the present disclosure is shown; Figure 6 A block diagram of an exemplary electronic device capable of implementing embodiments of the present disclosure is shown. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0019] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0020] In this disclosure, users can easily add, move, and rotate dividing lines with simple operations. The dividing lines will automatically stretch or shorten according to the edges of the graphic to achieve a close fit with the edges, thereby dividing the graphic into different regions according to the position of the dividing lines.
[0021] Figure 1 A flowchart of a map segmentation method 100 according to an embodiment of the present disclosure is shown.
[0022] Box 110 displays an electronic map; In some embodiments, the electronic map may be a map displayed by application software such as drone flight path display, architectural design space display, and robot vacuum cleaner execution path display.
[0023] In box 120, the user's split command is received.
[0024] In some embodiments, the segmentation command can be adaptively adjusted and set according to the user's actual needs, so that in response to the user's segmentation command, the map can be segmented into regions according to the position of the segmentation line.
[0025] In box 130, the type of the segmentation command is determined to add or adjust the segmentation line, and the electronic map is segmented into regions according to the position of the added or adjusted segmentation line; The splitting commands include: The Single Add Divider command adds a single dividing line that extends along the edge of the closed region until it intersects the edge of the closed region. The "Add Divider Line Multiple Times" command is used to repeatedly add divider lines, ensuring that the divider lines are added according to the center position of the current largest area. The Move Divider command is used to move dividers and extend them to the edge of closed regions during the movement. After the divider movement is complete, other dividers that do not form closed regions are deleted. The Rotate Divider command is used to rotate the dividing line and extend it to the edge of the closed area during the rotation.
[0026] In some embodiments, the segmentation commands, including the single-add-segmentation-line command, the multiple-add-segmentation-line command, the move-segmentation-line command, and the rotate-segmentation-line command, can be directly visualized on the user's map creation page, so that the user can segment regions of different sizes and shapes according to their needs during the map creation process.
[0027] In some embodiments, after adding a dividing line, the user can move the dividing line at will. The dividing line will automatically stretch or shorten according to the edge of the graphic, dividing the graphic into different areas according to the position of the dividing line. When it encounters other dividing lines, it will automatically cut the other dividing lines again, cutting the graphic into areas of different shapes and sizes according to the user's needs.
[0028] In some embodiments, the edge of the enclosed area includes the edge of the map or the edge of an obstacle. The determination of an obstacle can be based on an editable area, such as fixed walls when creating a map.
[0029] In some embodiments, adding a dividing line such that the dividing line extends along the edge of the closed region until it intersects with the edge of the closed region includes: Add a dividing line, and starting from the midpoint of the dividing line, extend the dividing line towards the edge of the closed region according to the line segment vectors of the front and back halves of the dividing line, until it intersects with it; Determine the intersection point at the edge of the enclosed area; Calculate the vector required to extend the distance from the starting point to the intersection point in the direction of the endpoint.
[0030] like Figure 2 As shown, to facilitate easy and flexible operation for users, in response to a single command to add a dividing line, once a dividing line is added, the dividing line will automatically extend along the edge of the region until it intersects with the edge of the closed region.
[0031] In some embodiments, the code snippet executed in response to a single add separator command may be as follows: / / / The line extends towards the [frame] boundary until it intersects the boundary. bool _extendToBoundary(RLine handleLine, List <mappoint>frame, bool needInsert) { MapPoint? newStart, newEnd; / / Get the vector of the first half of the line segment RLine cStart = RLine(handleLine.start.copy(), handleLine.center.copy()); / / Get the vector of the second half of the line segment RLine cEnd = RLine(handleLine.center.copy(), handleLine.end.copy()); / / Calculate the vector required to extend the first half of the line segment by a certain length var vectorStart = _extendPoint(handleLine.end, handleLine.start,1.5); / / Calculate the vector required to extend the latter half of the line segment by a certain length var vector = _extendPoint(handleLine.start, handleLine.end, 1.5); / / For the two line segments, the first and second halves, find a new intersection point on the edge of the partition. newStart = _findPointOnEdge(cStart, vectorStart, needInsert,frame, true); if(newStart == null) { logD(tag, 'newStart ext. long'); return false; } newEnd = _findPointOnEdge(cEnd, vector, needInsert, frame,false); if(newEnd == null) { logD(tag, 'newEnd super long'); return false; } / / Update the position of the intersection point of the line segments handleLine.updateStartWithMP(newStart); handleLine.updateEndWithMP(newEnd); return true; } / / / Find the intersection point on the partition edge MapPoint? _findPointOnEdge(RLine cPoint, MapPoint vector, bool needInsert, List <mappoint>frame, bool isStart) { bool isFirstFind = true; MapPoint? newPoint; while (newPoint == null) { Finding the intersection point here involves two steps. / / Step 1: Extend the line by 10 times the length of the vector each time until it intersects with the edge. The first intersection point is found, but at this point it is uncertain how many intersection points there are; there could be multiple. / / Step 2: Return the length before finding the intersection point, and then extend the length of the vector each time to find the first intersection point. if(isFirstFind) { / / This is the line segment passed in, which is extended by a factor of 10 based on the vector to speed up the search for intersection points. isStart ? cPoint.updateStartWithMP(cPoint.start + vector *10) : cPoint.updateEndWithMP(cPoint.end + vector * 10); } else { isStart ? cPoint.updateStartWithMP(cPoint.start + vector) : cPoint.updateEndWithMP(cPoint.end + vector); } / / Find the intersection point of the current left and right line segments on the dividing line. if(!needInsert) { for(int a = 0; a < zoneLines.length; a++) { if (a == selectLineIndex) { continue? } / / Find the intersection point when the current line segment intersects the dividing line. MapPoint? point = cPoint.checkIntersectionWithMe(zoneLines[a]); if (point != null) { if(isFirstFind) { / / This is the line segment passed in, which is extended by a factor of 10 based on the vector to speed up the search for intersection points. isStart ? cPoint.updateStartWithMP(cPoint.start -vector * 10) :cPoint.updateEndWithMP(cPoint.end - vector * 10); isFirstFind = false; } else { newPoint = point; } break } if(newPoint != null) { break } } } / / Find the intersection point on the edge of the partition var pointMap = cPoint.checkIntersectionWithFrame(frame); if(pointMap != null) { if(isFirstFind) { / / This is the line segment passed in, which is extended by a factor of 10 based on the vector to speed up the search for intersection points. isStart ? cPoint.updateStartWithMP(cPoint.start - vector *10) :cPoint.updateEndWithMP(cPoint.end - vector * 10); isFirstFind = false; } else { / / Return the length before finding the intersection point, then extend the vector length each time to find the first intersection point. int index = pointMap.keys.first; int insertIndex = index; newPoint = pointMap[index]; if(needInsert && insertIndex >= 0) { frame.insert(insertIndex, newPoint!); } break; } } / / If the line segment length exceeds 500, it is considered out of bounds and return to the previous step if(cPoint.distance() > 500) { logD(tag, 'translateLine newPoint is too long'); backLast(); break; } } return newPoint; } / / / Calculate the vector required to extend the length of length in the direction from point start to point end MapPoint _extendPoint(MapPoint start, MapPoint end, double len) { / / Calculate the line segment vector final MapPoint vector = end - start; / / Normalize the vector final double length = vector.distance; final Offset normalized = Offset(vector.x / length, vector.y / length); / / Calculate the extended vector final double extensionLength = len; final MapPoint extension = MapPoint(normalized.dx *extensionLength, normalized.dy * extensionLength); / / Calculate the new endpoints after extending in both directions / / final MapPoint extendedStart1 = start - extension; / / final MapPoint extendedEnd1 = end + extension; / / final MapPoint extendedStart2 = start + extension; / / final MapPoint extendedEnd2 = end - extension; return extension.toRoundDouble(); }
[0032] In some embodiments, when adding dividing lines repeatedly, the default position of the dividing line can be based on the center position of the current largest area. After determining the addition position, adding dividing lines multiple times according to the user's actual needs, following the method described above for adding a single dividing line.
[0033] In some embodiments, the above-mentioned moving dividing line, and extending to the edge of the closed region during the moving dividing line process, includes: Determine the dividing line to be moved; When the user's movement point is within the map area, respond to the user's movement point, and starting from the user's movement point, redraw the dividing line and extend it to the edge of the closed area according to the line segment vectors of the front and back halves of the dividing line to be moved, until it intersects with it.
[0034] In some embodiments, deleting other dividing lines that do not form a closed region after the dividing line movement is completed includes: After the dividing line is moved, traverse all line segments and keep only the line segments whose ends are on other line segments.
[0035] In some embodiments, during the process of moving the dividing line, the dividing line will automatically extend to the edge of the map or the edge of the obstacle. After the dividing line is moved, other dividing lines that have not formed a closed area will be automatically deleted.
[0036] In some embodiments, the code snippet executed in response to the move separator command may be as follows: / / / Translation line void translateLine(MapPoint touchPoint) { if (!canMoveLine) { return; } / / Get the currently selected line var line = zoneLines[selectLineIndex]; / / Get map outline var points = mapBean.frame; / / Check if the finger's landing point is within the map area. Path path = Path(); path.moveTo(points![0].x, points[0].y); for (final element in points) { path.lineTo(element.x, element.y); } path.close(); if(!path.contains(touchPoint.toOffSet())) { logD(tag, 'out of range'); return; } / / logD(tag, 'lineCenter ${touchPoint}'); / / Draw a new line based on the finger's landing point MapPoint ve = (line.end - line.start) / 2; / / Vector RLine handleLine = RLine(touchPoint - ve, touchPoint + ve); / / Shorten the line List <mappoint>? frame = mapBean.frame; / / Calculate the length of the line segment double d = handleLine.distance() / 2; / / Calculate the vector required to extend the vector from point start to point end in the direction of length. var len = _extendPoint(handleLine.start, handleLine.end, 0 - d +2); / / Update the start and end coordinates of the line segment handleLine.updateStartWithMP(handleLine.start - len); handleLine.updateEndWithMP(handleLine.end + len); / / handleLine.translate(details.focalPointDelta); / / Extend the shortened line towards the edge var success = _extendToBoundary(handleLine, frame!, false); if(success) { / / Update the start and end coordinates of the line segment line.updateStartWithMP(handleLine.start); line.updateEndWithMP(handleLine.end); line.rotateCenter = line.center.copy(); } }
[0037] In some embodiments, the above-described rotating dividing line, extending to the edge of the closed region during the rotating dividing line process, includes: Determine the dividing line to be rotated and the rotation angle; Based on the rotation angle, the dividing line to be rotated is rotated around its midpoint, and with the midpoint of the dividing line as the starting point, the dividing line is redrawn and extended towards the edge of the closed region according to the line segment vectors of the front and back halves of the rotated line segment until it intersects with it.
[0038] In some embodiments, during the map creation process, the dividing lines can be moved and rotated at will, and the map area can also be zoomed in, zoomed out, and rotated for better observation and division of the area.
[0039] In some embodiments, the code snippet executed in response to the rotate dividing line command may be as follows: / / / Rotating line void rotateLine(double angle) { / / Get the currently selected line var line = zoneLines[selectLineIndex]; / / Get map outline List <mappoint>? frame = mapBean.frame; / / Select the line segment and rotate it by the angle. line.rotate(angle); / / Copy a line segment for later use. RLine handleLine = line.copy(); / / Shorten the line to get the length of the vector (handleLine.rotateCenter: the point around which the line segment rotates) var disStart = (handleLine.rotateCenter - handleLine.start).distance; var disEnd = (handleLine.end - handleLine.rotateCenter).distance; / / Calculate the vector required to extend the vector from point start to point end in the direction of length. var vStart = _extendPoint(handleLine.rotateCenter, handleLine.start,0 - disStart + 2); var vEnd = _extendPoint(handleLine.rotateCenter, handleLine.end, 0 - disEnd + 2); / / Update the start and end coordinates of the line segment handleLine.updateStartWithMP(handleLine.start + vStart); handleLine.updateEndWithMP(handleLine.end + vEnd); / / Extend the line to the boundary to obtain the rotated line. bool success = _extendToBoundary(handleLine, frame!, false); if(success) { / / Update the start and end coordinates of the line segment line.updateStartWithMP(handleLine.start); line.updateEndWithMP(handleLine.end); } } / / / Rotation [angle] degrees void rotate(double angle) { / / Object conversion var c = rotateCenter.toOffSet(); / / Rotate the start and end points around the center point by an angle. var newStart = _rotate(rotateStart.toOffSet(), c, angle); var newEnd = _rotate(rotateEnd.toOffSet(), c, angle); / / Update start and end positions start.updateWithOffSet(newStart); end.updateWithOffSet(newEnd); center = MapPoint(((start + end) / 2).x, ((start + end) / 2).y); } / / / Rotate [point] around [center] degrees by [angle] degrees Offset _rotate(Offset point, Offset center, double angle) { double cosTheta = cos(angle); double sinTheta = sin(angle); double dx = (point.dx - center.dx); double dy = (point.dy - center.dy); var x = cosTheta * dx - sinTheta * dy; var y = sinTheta * dx + cosTheta * dy; return Offset(((x + center.dx) * 100).roundToDouble() / 100, ((y + center.dy) * 100).roundToDouble() / 100); } / / / Update coordinates void updateWithOffSet(Offset point) { _x = point.dx; _y = point.dy; }
[0040] In some embodiments, the above method further includes: When two dividing lines intersect, starting from the intersection point, the dividing lines are redrawn according to the line segment vectors of each dividing line and extend towards the edge of the closed region until they intersect.
[0041] like Figure 3 As shown, when two dividing lines intersect, a complete dividing line can be automatically cut into two dividing lines according to the intersection point, and each line can be moved and edited separately.
[0042] In some embodiments, the code snippet executed when the above-mentioned dividing lines intersect can be as follows: / / / Split intersecting partition lines void splitZoneLine() { / / Get the currently selected line var selectLine = zoneLines[_selectLineIndex]; / / Index of the dismantled line List <rline>beiChaiByStart = []; List <rline>beiChaiByEnd = []; / / Iterate through all line segments and find the segment that has been split. for(int b = 0; b < zoneLines.length; b++) { if(selectLineIndex == b) continue; var lineB = zoneLines[b]; / / Find which lines have been split, based on whether the start or end point of the selected line lies on another line segment and is not equal to the endpoint of that line segment. if(lineB.isPointOnLine(selectLine.start) && !lineB.start.equal(selectLine.start) && !lineB.end.equal(selectLine.start)) { / / Record the split lines beiChaiByStart.add(lineB); } else if(lineB.isPointOnLine(selectLine.end) && !lineB.start.equal(selectLine.end) && !lineB.end.equal(selectLine.end)) { / / Record the split lines beiChaiByEnd.add(lineB); } } if(beiChaiByStart.isNotEmpty) { / / Split the line segment based on the intersection point of the line segment and the starting point of the edited line segment. _splitLine(beiChaiByStart, selectLine.start); } if (beiChaiByEnd.isNotEmpty) { / / Split the line segment based on the intersection point of the line segment and the end point of the edited line segment. _splitLine(beiChaiByEnd, selectLine.end); } / / Update the index of the selected line _selectLineIndex = zoneLines.indexOf(selectLine); } / / / Determine if a point is on the line bool isPointOnLine(MapPoint point) { var d = (point - start).distance + (end - point).distance; return d <= (end - start).distance + 0.2; } / / Split the line segments based on the passed-in list of line segments and the insertion point. void _splitLine(List <rline>beiChai, MapPoint insert) { / / Sort by the distance from the insertion point to the line segment, and select the closest line segment for splitting. beiChai.sort((a, b) { / / Compare the perpendicular distance from the insertion point to the line return a.pointToLineDistance(insert) < b.pointToLineDistance(insert) ? -1 : 1; }); / / Select the nearest line segment for splitting var beiChaiLine = beiChai[0]; RLine newLine1, newLine2; newLine1 = RLine(beiChaiLine.start.copy(), insert.copy()); newLine2 = RLine(insert.copy(), beiChaiLine.end.copy()); / / Find which partition contains the split line. Add some to the partition. if(!insertPointIntoFrame(newLine1, insert)) return; if(!insertPointIntoFrame(newLine2, insert)) return; if(!insertPointIntoFrame(beiChaiLine, insert)) return; var indexOf = zoneLines.indexOf(beiChaiLine); zoneLines.remove(beiChaiLine); zoneLines.insert(indexOf, newLine2); zoneLines.insert(indexOf, newLine1); } / / / Perpendicular distance from point to line double pointToLineDistance(MapPoint point) { return ((end.x - start.x) * (start.y - point.y) - (start.x - point.x) * (end.y - start.y)).abs() / sqrt(pow(end.x - start.x, 2) + pow(end.y - start.y, 2)); } / / / Add points to the region containing the line bool insertPointIntoFrame(RLine line, MapPoint insert) { int zoneIndex = -1, insertIndex = -1; / / Find which partition contains this line zoneBeans: partition under editing for(int a = 0; a < zoneBeans.length; a++) { / / Get region outline coordinates var frame = zoneBeans[a].zoneFrame; var length = frame!.length; / / Find a line segment that is equal to the input line segment. if(RLine(frame[length - 1], frame[0]).equal(line)){ zoneIndex = a; insertIndex = 0; } else { / / Traverse the region's outline coordinates and find the line segment that matches the input line segment. for(int d = 0; d < length; d++) { var point = frame[d]; var next = frame[(d + 1) % length]; var nextNext = frame[(d + 2) % length]; if(RLine(point, next).equal(line)) { zoneIndex = a; insertIndex = (d + 1) % length; break } else if(RLine(point, nextNext).equal(line) && next.equal(insert)) { zoneIndex = a; insertIndex = (d + 1) % length; break } } } if(zoneIndex != -1) { break } } if(zoneIndex == -1) { / / No partition containing this line found, rollback operation backLast(); return false; } / / Insert a point in the found partition zoneBeans[zoneIndex].zoneFrame!.insert(insertIndex, insert.copy().insert()); return true; }
[0043] like Figure 4 As shown, based on the above map segmentation method, after adding the segmentation line, the segmentation line can be rotated and moved at will. The segmentation line will automatically extend or shorten the line segment length according to the map edge and obstacles to achieve a close fit with the edge. After the segmentation lines intersect, the line segments can be divided according to the intersection point to achieve the purpose of arbitrarily controlling the segmented area.
[0044] According to the embodiments of this disclosure, the following technical effects are achieved: This system can divide a map into regions based on the position of dividing lines, responding to user commands. These commands include: a single add dividing line command, which adds a single dividing line that extends along the edge of a closed region until it intersects the edge; a multiple add dividing line command, which repeatedly adds dividing lines, placing them at the center of the largest region; a move dividing line command, which moves a dividing line and extends it to the edge of a closed region during the movement, deleting any other dividing lines that do not form closed regions after the movement is complete; and a rotate dividing line command, which rotates a dividing line and extends it to the edge of a closed region during the rotation. Based on this, users can easily add, move, and rotate dividing lines with simple operations. The dividing lines automatically stretch or shorten according to the edges of the graphic to achieve a tight fit, thus dividing the graphic into different regions based on the position of the dividing lines.
[0045] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, because according to this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.
[0046] The above is an introduction to the method embodiments. The following describes the solution described in this disclosure further through device embodiments.
[0047] Figure 5 A block diagram of a map segmentation apparatus 500 according to an embodiment of the present disclosure is shown. Figure 5 As shown, the device 500 includes: Display module 510 is used to display electronic maps; Receiver module 520 is used to receive the user's segmentation command. The segmentation module 530 is used to determine the type of segmentation command, add or adjust segmentation lines, and segment the electronic map into regions based on the position of the added or adjusted segmentation lines. The segmentation commands include: a single add segmentation line command, which adds a single segmentation line that extends along the edge of the closed region until it intersects the edge of the closed region; a multiple add segmentation line command, which repeatedly adds segmentation lines, adding them along the center position of the current largest region; a move segmentation line command, which moves a segmentation line and extends it to the edge of the closed region during the movement, and deletes any other segmentation lines that do not form a closed region after the movement is complete; and a rotate segmentation line command, which rotates a segmentation line and extends it to the edge of the closed region during the rotation.
[0048] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the described module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0049] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0050] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0051] Figure 6 A block diagram of an exemplary electronic device 600 capable of implementing embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0052] Electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in ROM 602 or a computer program loaded into RAM 603 from storage unit 608. RAM 603 may also store various programs and data required for the operation of electronic device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. I / O interface 605 is also connected to bus 604.
[0053] Multiple components in electronic device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of displays, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows electronic device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0054] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as method 100. For example, in some embodiments, method 100 may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608.
[0055] In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of method 100 described above may be performed. Alternatively, in other embodiments, computing unit 601 may be configured to perform method 100 by any other suitable means (e.g., by means of firmware).
[0056] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0057] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0058] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0059] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including voice input, speech input, or tactile input).
[0060] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0061] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0062] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0063] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.< / rline> < / rline> < / rline> < / mappoint> < / mappoint> < / mappoint> < / mappoint>
Claims
1. A map segmentation method, characterized in that, include: Display electronic map; Receive the user's split command; Determine the type of the segmentation command to add or adjust the segmentation line, and segment the electronic map into regions based on the position of the added or adjusted segmentation line; The segmentation command includes: The Single Add Divider command adds a single dividing line that extends along the edge of the closed region until it intersects the edge of the closed region. The "Add Divider Line Multiple Times" command is used to repeatedly add divider lines, ensuring that the divider lines are added according to the center position of the current largest area. The Move Divider command is used to move dividers and extend them to the edge of closed regions during the movement. After the divider movement is complete, other dividers that do not form closed regions are deleted. The Rotate Divider command is used to rotate the dividing line and extend it to the edge of the closed area during the rotation.
2. The method according to claim 1, characterized in that, Adding a dividing line, extending along the edge of the closed region until it intersects with the edge of the closed region, includes: Add a dividing line, and starting from the midpoint of the dividing line, extend the dividing line towards the edge of the closed region according to the line segment vectors of the front and back halves of the dividing line, until it intersects with it; Determine the intersection point at the edge of the enclosed area; Calculate the vector required to extend the distance from the starting point to the intersection point in the direction of the endpoint.
3. The method according to claim 1, characterized in that, The moving dividing line, extending to the edge of the closed area during the moving dividing line process, includes: Determine the dividing line to be moved; When the user's movement point is within the map area, respond to the user's movement point, and starting from the user's movement point, redraw the dividing line and extend it to the edge of the closed area according to the line segment vectors of the front and back halves of the dividing line to be moved, until it intersects with it.
4. The method according to claim 3, characterized in that, The step of deleting other dividing lines that did not form a closed region after the dividing line movement is completed includes: After the dividing line is moved, traverse all line segments and keep only the line segments whose ends are on other line segments.
5. The method according to claim 1, characterized in that, The rotating dividing line, extending to the edge of the closed region during the rotating dividing line process, includes: Determine the dividing line to be rotated and the rotation angle; Based on the rotation angle, the dividing line to be rotated is rotated around its midpoint, and with the midpoint of the dividing line as the starting point, the dividing line is redrawn and extended towards the edge of the closed region according to the line segment vectors of the front and back halves of the rotated line segment until it intersects with it.
6. The method according to claim 1, characterized in that, The method further includes: When two dividing lines intersect, starting from the intersection point, the dividing lines are redrawn according to the line segment vectors of each dividing line and extend towards the edge of the closed region until they intersect.
7. The method according to any one of claims 1 to 6, characterized in that, The edges of the enclosed area include map edges or obstacle edges.
8. A map segmentation device, characterized in that, include: The display module is used to display electronic maps; The receiving module is used to receive the user's segmentation command; The segmentation module is used to determine the type of the segmentation command, add or adjust the segmentation lines, and segment the electronic map into regions based on the position of the added or adjusted segmentation lines. The segmentation commands include: a single add segmentation line command, used to add a segmentation line that extends along the edge of the closed region until it intersects with the edge of the closed region; a multiple add segmentation line command, used to repeatedly add segmentation lines that are added at the center position of the current largest region; a move segmentation line command, used to move the segmentation line and extend it to the edge of the closed region during the movement, and delete other segmentation lines that have not formed a closed region after the movement is completed; and a rotate segmentation line command, used to rotate the segmentation line and extend it to the edge of the closed region during the rotation.
9. An electronic device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.