CN106997355B - Method and device for obtaining distance and determining shortest distance line segment based on Mongodb - Google Patents

Method and device for obtaining distance and determining shortest distance line segment based on Mongodb Download PDF

Info

Publication number
CN106997355B
CN106997355B CN201610046174.0A CN201610046174A CN106997355B CN 106997355 B CN106997355 B CN 106997355B CN 201610046174 A CN201610046174 A CN 201610046174A CN 106997355 B CN106997355 B CN 106997355B
Authority
CN
China
Prior art keywords
line segment
point
distance
shape
points
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610046174.0A
Other languages
Chinese (zh)
Other versions
CN106997355A (en
Inventor
史川
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Navinfo Co Ltd
Original Assignee
Navinfo Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Navinfo Co Ltd filed Critical Navinfo Co Ltd
Priority to CN201610046174.0A priority Critical patent/CN106997355B/en
Publication of CN106997355A publication Critical patent/CN106997355A/en
Application granted granted Critical
Publication of CN106997355B publication Critical patent/CN106997355B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Abstract

The invention provides a method and a device for obtaining a distance and determining a shortest distance line segment based on Mongodb. The method for acquiring the distance comprises the following steps: when the length between two adjacent shape points on the line segment is greater than a preset value, inserting a shape point in the middle position of the two adjacent shape points on the line segment until the length between each two adjacent shape points on the line segment is less than or equal to the preset value, and stopping inserting the shape points; and determining the minimum value of the distance between the selected fixed point outside the line segment and each shape point on the line segment as the distance between the fixed point and the line segment. The distance from the acquisition point to the line obtained by the method is closer to the vertical distance.

Description

Method and device for obtaining distance and determining shortest distance line segment based on Mongodb
Technical Field
The invention relates to the field of computers, in particular to a method and a device for obtaining a distance and determining a shortest distance line segment based on Mongodb.
Background
Mongodb is one of the most popular Nosq1 databases currently, and Mongodb is a database based on distributed file storage. Mongodb supports storage of vector data and space query calculation, a Near function is provided, and a line which takes a certain point as a center and has the shortest distance from the center point in a certain range can be calculated by using the Near function.
The Monogdb's own Near function calculates the distance from a point to a line by calculating the distance from the point to each shape point on the line. A line is composed of a series of coordinate strings, a shape point represents a coordinate position, and since some lines are long and straight and only consist of head and tail end points, the distance from the point to the line is the distance from the point to the nearest end point. As shown in FIG. 1, P1 and P2 are the head and tail points of the line segment P1P2, and P is the point outside the line segment, then d1 is the distance from the point P given by the Near function in Mongodb to the line segment P1P 2. However, the distance from the point P to the line segment P1P2 is actually the vertical distance d from the point P to the line segment P1P2, and therefore, the distance from the point P to the line segment P1P2 obtained by the above method tends to deviate greatly from the actual vertical distance d.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method and a device for obtaining a distance and determining a shortest distance line segment based on Mongodb, which are used for solving the defect that the error of the distance between a point and a line is large in the calculation of a Near function carried by the Mongodb in the prior art.
In order to solve the technical problem, the invention provides a method for obtaining a distance based on Mongodb, which comprises the following steps:
when the length between two adjacent shape points on the line segment is greater than a preset value, inserting a shape point in the middle position of the two adjacent shape points on the line segment until the length between each two adjacent shape points on the line segment is less than or equal to the preset value, and stopping inserting the shape points;
and determining the minimum value of the distance between the selected fixed point outside the line segment and each shape point on the line segment as the distance between the fixed point and the line segment.
In order to implement the method, the invention provides a device for acquiring distance based on Mongodb, which comprises the following steps: a judging module, a processing module and an obtaining module, wherein,
the judging module is used for judging the relationship between the length of two adjacent shape points on the line segment and a preset value;
the processing module is used for inserting a shape point in the middle of two adjacent shape points on the line segment when the length between the two adjacent shape points on the line segment is greater than a preset value, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the preset value;
the acquisition module is used for determining the minimum value of the distance between the fixed point selected outside the line segment and each shape point on the line segment as the distance between the fixed point and the line segment.
The invention also provides a method for determining the shortest distance line segment based on Mongodb, which is characterized by comprising the following steps:
determining a buffer containing a fixed point;
selecting a plurality of line segments in the buffer area;
calculating the distance from the fixed point to each line segment;
determining the line segment with the minimum distance from the fixed point in the buffer area as the nearest line segment of the fixed point;
the calculating the distance from the fixed point to each line segment comprises:
when the length between two adjacent shape points on the line segment is greater than a preset value, inserting a shape point in the middle position of the two adjacent shape points on the line segment until the length between each two adjacent shape points on the line segment is less than or equal to the preset value, and stopping inserting the shape points;
and determining the minimum value of the distance between the fixed point and each shape point on the line segment as the distance between the fixed point and the line segment.
Optionally, the determining a buffer containing a fixed point includes:
determining the fixed point;
and a circular area is defined by taking the fixed point as the circle center and taking the preset value as the radius to serve as the buffer area.
In order to implement the method for determining the shortest distance line segment based on the Mongodb, the invention further provides a device for acquiring the shortest distance line segment based on the Mongodb, which is characterized by comprising the following steps: the device comprises an acquisition module, a selection module, a calculation module, a first processing module, a second processing module and a third processing module; wherein the content of the first and second substances,
the acquisition module is used for determining a buffer area containing a fixed point;
the selection module is used for selecting a plurality of line segments in the buffer area;
the calculation module is used for calculating the distance from the fixed point to each line segment;
the first processing module is configured to determine a line segment in the buffer area with a minimum distance from the fixed point as a closest line segment of the fixed point;
the second processing module is used for inserting a shape point in the middle of two adjacent shape points on the line segment when the length between the two adjacent shape points on the line segment is greater than a preset value, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the preset value;
and the third processing module is used for determining the minimum value of the distance between the fixed point and each shape point on the line segment as the distance between the fixed point and the line segment.
Optionally, the obtaining module includes: a selection unit and a processing unit; wherein the content of the first and second substances,
the selection unit is used for determining the fixed point;
and the processing unit is used for dividing a circular area by taking the fixed point as a circle center and a preset value as a radius to serve as the buffer area.
The invention adopts a difference value calculation method to divide a line segment into a plurality of shape points, and the length between two adjacent shape points is not more than a preset value. The distance from the point P to each shape point on the line segment AB is calculated in sequence by adopting the method, and the minimum value is taken as the distance from the point P to the line segment AB. Compared with the method for obtaining the distance from the point P to the line segment AB in the prior art, the method for calculating the distance from the point P to the line segment AB provided by the embodiment of the invention has the advantages that the distance from the point P to the line segment AB is closer to the vertical distance from the point P to the line segment AB, and the accuracy is higher.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a schematic diagram of the prior art calculation of the distance from a point to a line by a Near function carried by Mongodb;
FIG. 2 is a schematic flow chart of a Mongodb distance acquisition-based method according to an alternative embodiment of the present invention;
FIG. 3 is a schematic diagram of a method for determining a shortest distance line segment based on Mongodb according to an alternative embodiment of the present invention;
FIG. 4 is a schematic diagram of Mongodb based distance acquisition in accordance with an alternative embodiment of the present invention;
FIG. 5 is a schematic flow chart of a method for determining a shortest distance line segment based on Mongodb according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a Mongodb-based distance shortest line segment determination provided in an alternative embodiment of the present invention;
FIG. 7 is a schematic structural diagram of an apparatus for acquiring distance based on Mongodb according to an embodiment of the present invention;
FIG. 8 is a block diagram of an alternative embodiment of the present invention, which provides a device for obtaining the shortest distance line segment based on Mongodb.
Detailed Description
As used in the specification and in the claims, certain terms are used to refer to particular components. As one skilled in the art will appreciate, manufacturers may refer to a component by different names. This specification and claims do not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms "include" and "comprise" are used in an open-ended fashion, and thus should be interpreted to mean "include, but not limited to. "substantially" means within an acceptable error range, and a person skilled in the art can solve the technical problem within a certain error range to substantially achieve the technical effect. The following description is of the preferred embodiment for carrying out the invention, and is made for the purpose of illustrating the general principles of the invention and not for the purpose of limiting the scope of the invention. The scope of the present invention is defined by the appended claims.
In the prior art, for a certain line segment and a point outside the line segment, the distance from a point to the line segment obtained by the calculation of the Near function carried by the Mongodb can be adopted, but the deviation between the distance from the point to the line segment obtained by the method and the actual distance from the point to the line is large, so that the embodiment of the invention provides a method for calculating the distance from the point to the line with higher accuracy.
As shown in fig. 2, a method for obtaining a distance based on Mongodb includes:
step 201, when the length between two adjacent shape points on a line segment is greater than a preset value, inserting a shape point in the middle position of the two adjacent shape points on the line segment, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the preset value;
alternatively, the shape point may be a coordinate point in a rectangular coordinate system, and the shape point may be determined by an abscissa value and an ordinate value.
The total length between the start shape point a and the end shape point B may be determined according to the coordinate position of the shape point a and the coordinate position of the shape point B, that is, may be calculated by using a distance equation between two points (the shape point a and the shape point B) in a planar coordinate system.
The predetermined value may vary depending on the actual requirements, for example the predetermined value may be a few meters, a few decimeters, a few centimeters, a few millimeters, etc.
Optionally, it is determined whether the total length is greater than a predetermined value, and if so, the steps are executed:
a first division point C is inserted at a midpoint position between the start shape point a and the end shape point B, and the first division point C is located on the line segment AB.
The midpoint position may be determined from the midpoint in the rectangular coordinate system, i.e., the midpoint position may be determined from the coordinate positions of shape point a and shape point B.
In a specific example, the above steps can be implemented as follows:
introducing Polyline of the vector into Mongodb, wherein the Polyline is stored in the Mongodb according to a two-dimensional coordinate sequence string, such as: { "__________________": ObjectId ("535884771 dbba31858ad 2101"), "geo: { "type": "Polyline", "Coordinates": [ [ [96.722, 38.755], [97.3482, 38.6922], [97.1674, 38.0752], [96.5474, 38.1383] ] ] } }, and then a two-dimensional index is established.
Traversing each Polyline object, calculating the distance between every two shape points, and performing a difference operation if the distance is less than a preset predetermined value (for example, the predetermined value is 1 meter)
Optionally, the present step includes: it is determined that a first length t1 between the start shape point a and the first division point C is not greater than a predetermined value, and a second length t2 between the end shape point B and the first division point C is not greater than a predetermined value.
t1 and t2 can be calculated by using the distance formula between two points in the plane coordinate system, i.e., t1 can be obtained according to the coordinate values of the start shape point a and the first division point C, and t2 can be obtained according to the coordinate values of the end shape point B and the first division point C.
The first length between the start shape point a and the first division point C may be obtained in a similar manner to step S201, and the second length between the end shape point B and the first division point C may also be obtained in a similar manner to determine the total length between the start shape point a and the end shape point B of the line segment AB.
Step 202, determining the distance from the fixed point to the line segment according to the minimum value of the distance between the fixed point selected outside the line segment and each shape point on the line segment.
Optionally, in this step, a first distance d1 between a fixed point P outside the line segment and the start shape point a, a second distance d2 between the fixed point P and the end shape point B, and a third distance d3 between the fixed point P and the first division point C are obtained.
d1, d2 and d3 can be calculated by the distance formula between two points in the plane coordinate system, i.e. d1 can be obtained from the coordinate value of the fixed point P and the coordinate value of the start shape point a, d2 can be obtained from the coordinate value of the fixed point P and the coordinate value of the end shape point B, and d3 can be obtained from the coordinate value of the fixed point P and the coordinate value of the first division point C.
Optionally, the method includes: the smallest of the first spacing d1, the second spacing d2, and the third spacing d3 is determined as the distance from the fixed point P to the line segment AB.
D1 can be compared with d2 and d3 in turn to find the smallest.
The embodiment of the invention adopts a difference value calculation method to divide the line segment into a plurality of shape points, and the length between two adjacent shape points is not more than a preset value. The distance from the point P to each shape point on the line segment AB is calculated in sequence by adopting the method, and the minimum value is taken as the distance from the point P to the line segment AB. Compared with the method for obtaining the distance from the point P to the line segment AB in the prior art, the method for calculating the distance from the point P to the line segment AB provided by the embodiment of the invention has the advantages that the distance from the point P to the line segment AB is closer to the vertical distance from the point P to the line segment AB, and the accuracy is higher.
Referring to fig. 3, an alternative embodiment of the present invention provides a method for determining a shortest distance line segment based on Mongodb, including the following steps:
step 301, determining a buffer area containing a fixed point;
step 302, selecting a plurality of line segments in the buffer area;
step 303, calculating the distance from the fixed point to each line segment;
step 304, determining the line segment with the minimum distance from the fixed point in the buffer area as the nearest line segment of the fixed point;
wherein the calculating the distance from the fixed point to each line segment comprises:
step 201, when the length between two adjacent shape points on a line segment is greater than a preset value, inserting a shape point in the middle position of the two adjacent shape points on the line segment, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the preset value;
step 202, determining the minimum value of the distance between the fixed point and each shape point on the line segment as the distance between the fixed point and the line segment.
It should be noted that, the method for obtaining the distance from a point to a line segment based on Mongodb according to some other embodiments of the present invention may further include the following steps M1-M5:
step M1: it is determined that a first length t1 between the starting shape point a and the first dividing point C is greater than a predetermined value and a second length t2 between the ending shape point B and the first dividing point C is not greater than a predetermined value.
Step M2: a second division point D is inserted at a second midpoint position between the starting shape point a and the first division point C.
The second midpoint position here can be obtained in a similar manner to the first midpoint position in the above-described embodiment.
According to the above embodiment, if neither the first length between the start shape point a and the first division point C nor the second length t2 between the end shape point B and the first division point C is greater than the predetermined value, the line segment AB is no longer divided, and the division points are added.
Step M3: it is determined that the third length t3 between the start shape point a and the second division point D is not greater than a predetermined value and the fourth length t4 between the second division point D and the first division point C is not greater than a predetermined value.
t3 and t4 can be calculated by using the distance formula between two points in the plane coordinate system, i.e., t3 can be obtained according to the coordinate values of the starting shape point A and the second division point D, and t4 can be obtained according to the coordinate values of the second division point D and the first division point C.
And if the first length between the starting shape point A and the first segmentation point C is larger than the preset value, continuing segmenting the line segment AB and adding segmentation points until the lengths between all the adjacent shape points on the line segment AB are not larger than the preset value.
Step M4: a fourth distance D4 between the fixation point P and the second division point D is obtained.
d4 can be calculated by the distance formula between two points in the plane coordinate system, i.e., d4 can be obtained from the coordinate value of the fixed point P and the coordinate value of the starting shape point a.
Step M5: determining the smallest of the first spacing d1, the second spacing d2, the third spacing d3, and the fourth spacing d4 as the distance from the fixed point P to the line segment AB.
The d4 can be compared with the smallest of d1, d2 and d3 to find the smallest of the four.
In addition, in some other embodiments, the method for obtaining the distance from a point to a line segment based on Mongodb according to the embodiments of the present invention may further include the following steps N1 to N5:
step N1: it is determined that the second length t2 between the ending shape point B and the first dividing point C is not greater than a predetermined value.
Step N2: a third division point E is inserted at a third midpoint position between the trailing shape point B and the first division point C.
The third midpoint position here can be obtained in a similar manner to the first midpoint position in the above-described embodiment.
Step N3: it is determined that the fifth length t5 between the ending shape point B and the third dividing point E is not greater than the predetermined value and the sixth length t6 between the first dividing point C and the third dividing point E is not greater than the predetermined value.
t5 and t6 can be calculated by using a distance formula between two points in a plane coordinate system, that is, t5 can be obtained according to the coordinate values of the ending shape point B and the third dividing point E, and t6 can be obtained according to the coordinate values of the first dividing point C and the third dividing point E.
If the fifth length t5 between the ending shape point B and the third segmentation point E is greater than a predetermined value and/or the sixth length t6 between the first segmentation point C and the third segmentation point E is greater than a predetermined value, the segmentation and the addition of segmentation points to the segment AB are continued until the lengths between all adjacent shape points on the segment AB are not greater than the predetermined value.
Step N4: a fifth spacing d5 between the trailing shape point B and the third cut point E is obtained.
d5 can be calculated by the distance formula between two points in the plane coordinate system, i.e., d5 can be obtained from the coordinate value of the fixed point P and the coordinate value of the starting shape point a.
Step N5: determining the smallest of the first spacing d1, the second spacing d2, the third spacing d3, the fourth spacing d4, and the fifth spacing d5 as the distance from the fixed point P to the line segment AB.
The d5 can be compared with the smallest of d1, d2, d3, d4 to find the smallest of the five.
According to the device for obtaining the distance based on the Mongodb, provided by the embodiment of the invention, the line segment is divided into a plurality of shape points by adopting a difference value calculation method, and the length between two adjacent shape points is not more than a preset value. The distance from the point P to each shape point on the line segment AB is calculated in sequence by adopting the method, and the minimum value is taken as the distance from the point P to the line segment AB. Compared with the method for obtaining the distance from the point P to the line segment AB in the prior art, the method for calculating the distance from the point P to the line segment AB provided by the embodiment of the invention has the advantages that the distance from the point P to the line segment AB is closer to the vertical distance from the point P to the line segment AB, and the accuracy is higher.
In addition, an alternative embodiment of the present invention further provides a method for obtaining a distance based on Mongodb, as shown in fig. 5 and 6, the method may include the following steps:
step S501: a buffer Q containing a fixed point P is determined.
In some embodiments, step S501 may be implemented by the following steps:
first a fixed point P can be determined;
then, a circular area can be defined by taking the fixed point P as a center and taking a preset value as a radius as a buffer area Q.
Step S502: a number of line segments within buffer Q are selected.
In some embodiments, there may be many segments in the buffer Q, all of which may be selected, or some of which may be selected. Wherein none of the selected line segments may pass through the fixed point P.
For example, in FIG. 6, P1-P12 form a plurality of segments, of which segment P1P2 and segment P8P9 can be selected.
Step S503: the distance of the fixed point P to each line segment is calculated.
The distance from the point P to the line segment P1P2 and the distance from the point P to the line segment P8P9 can be calculated by the above-mentioned montodb-based distance acquisition method shown in fig. 2, for example, the distance from the point P to the line segment P1P2 obtained by this method is d1, and the distance from the point P to the line segment P8P9 is d 3.
Step S504: and determining the line segment corresponding to the line segment with the minimum distance as the line segment with the minimum distance to the fixed point P.
If d1 is smaller than d3, P1P2 is the line segment with the shortest distance to the fixed point P; conversely, P8P9 is the line segment with the shortest distance to the fixed point P.
The line segment closest to the fixed point determined by the method is more accurate.
In addition, as shown in fig. 7, an alternative embodiment of the present invention further provides an apparatus for obtaining a distance based on Mongodb, as shown in fig. 4, the apparatus may include: a determining module 701, a processing module 702 and an obtaining module 703, wherein,
the judging module 701 is configured to judge a relationship between a length between two adjacent shape points on a line segment and a predetermined value;
the processing module 702 is configured to insert a shape point at a middle position of two adjacent shape points on a line segment when a length between the two adjacent shape points on the line segment is greater than a predetermined value, and stop inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value;
the obtaining module 703 is configured to determine a minimum value of distances between a fixed point selected outside a line segment and each shape point on the line segment as a distance between the fixed point and the line segment.
In addition, as shown in fig. 8, an alternative embodiment of the present invention provides an apparatus for obtaining the shortest distance line segment based on Mongodb. The device comprises: an obtaining module 801, a selecting module 802, a calculating module 803, a first processing module 804, a second processing module 805 and a third processing module 806; wherein the content of the first and second substances,
the obtaining module 801 is configured to determine a buffer area including a fixed point;
the selecting module 802 is configured to select a plurality of line segments in the buffer;
the calculating module 803 is configured to calculate a distance from the fixed point to each line segment;
the first processing module 804 is configured to determine a line segment in the buffer area with a minimum distance from the fixed point as a nearest line segment of the fixed point;
the second processing module 805 is configured to insert a shape point at a middle position between two adjacent shape points on a line segment when a length between the two adjacent shape points on the line segment is greater than a predetermined value, and stop inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value;
the third processing module 806 is configured to determine a minimum value of distances between the fixed point and each shape point on the line segment as a distance between the fixed point and the line segment.
Optionally, the obtaining module 801 includes: a selection unit 811 and a processing unit 812; wherein the content of the first and second substances,
the selection unit 811 is configured to determine the fixed point;
the processing unit 812 is configured to define a circular area as the buffer area by taking the fixed point as a center and taking a preset value as a radius.
The foregoing description shows and describes several preferred embodiments of the invention, but as aforementioned, it is to be understood that the invention is not limited to the forms disclosed herein, but is not to be construed as excluding other embodiments and is capable of use in various other combinations, modifications, and environments and is capable of changes within the scope of the inventive concept as expressed herein, commensurate with the above teachings, or the skill or knowledge of the relevant art. And that modifications and variations may be effected by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (6)

1. A method for obtaining distance based on Mongodb is characterized by comprising the following steps:
when the length between two adjacent shape points on a line segment is greater than a predetermined value, inserting a shape point in the middle position of the two adjacent shape points on the line segment, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value, specifically comprising: importing Polyline of the vector into Mongodb, storing the Polyline in the Mongodb according to a two-dimensional coordinate sequence string, and then establishing a two-dimensional index; traversing each Polyline object, calculating the distance between every two shape points, judging whether the distance is greater than a preset value or not, if so, carrying out interpolation operation, and drawing a plurality of shape points on the line segment by adopting an interpolation calculation method, wherein the length between every two adjacent shape points is not greater than the preset value; wherein the line segment is composed of a series of coordinate strings, the shape points on the line segment corresponding to coordinate locations in the coordinate strings;
the shape point is a coordinate point in a rectangular coordinate system, and the shape point is determined by an abscissa and an ordinate; the length between the two shape points is calculated by using a distance formula between the two points under a plane coordinate system;
and determining the minimum value of the distance between the selected fixed point outside the line segment and each shape point on the line segment as the distance between the fixed point and the line segment.
2. An apparatus for obtaining distance based on Mongodb, comprising: a judging module, a processing module and an obtaining module, wherein,
the judging module is used for judging the relationship between the length of two adjacent shape points on the line segment and a preset value;
the processing module is configured to insert a shape point at a middle position of two adjacent shape points on a line segment when a length between the two adjacent shape points on the line segment is greater than a predetermined value, and stop inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value, and specifically includes: importing Polyline of the vector into Mongodb, storing the Polyline in the Mongodb according to a two-dimensional coordinate sequence string, and then establishing a two-dimensional index; traversing each Polyline object, calculating the distance between every two shape points, judging whether the distance is greater than a preset value or not, if so, carrying out interpolation operation, and drawing a plurality of shape points on the line segment by adopting an interpolation calculation method, wherein the length between every two adjacent shape points is not greater than the preset value; wherein the line segment is composed of a series of coordinate strings, the shape points on the line segment corresponding to coordinate locations in the coordinate strings;
the shape point is a coordinate point in a rectangular coordinate system, and the shape point is determined by an abscissa and an ordinate; the length between the two shape points is calculated by using a distance formula between the two points under a plane coordinate system;
the acquisition module is used for determining the minimum value of the distance between the fixed point selected outside the line segment and each shape point on the line segment as the distance between the fixed point and the line segment.
3. A method for determining a shortest distance line segment based on Mongodb is characterized by comprising the following steps:
determining a buffer containing a fixed point;
selecting a plurality of line segments in the buffer area;
calculating the distance from the fixed point to each line segment;
determining the line segment with the minimum distance from the fixed point in the buffer area as the nearest line segment of the fixed point;
the calculating the distance from the fixed point to each line segment comprises:
when the length between two adjacent shape points on a line segment is greater than a predetermined value, inserting a shape point in the middle position of the two adjacent shape points on the line segment, and stopping inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value, specifically comprising: importing Polyline of the vector into Mongodb, storing the Polyline in the Mongodb according to a two-dimensional coordinate sequence string, and then establishing a two-dimensional index; traversing each Polyline object, calculating the distance between every two shape points, judging whether the distance is greater than a preset value or not, if so, carrying out interpolation operation, and drawing a plurality of shape points on the line segment by adopting an interpolation calculation method, wherein the length between every two adjacent shape points is not greater than the preset value; wherein the line segment is composed of a series of coordinate strings, the shape points on the line segment corresponding to coordinate locations in the coordinate strings;
the shape point is a coordinate point in a rectangular coordinate system, and the shape point is determined by an abscissa and an ordinate; the length between the two shape points is calculated by using a distance formula between the two points under a plane coordinate system;
and determining the minimum value of the distance between the fixed point and each shape point on the line segment as the distance between the fixed point and the line segment.
4. The method of claim 3, wherein determining a buffer containing a fixed point comprises:
determining the fixed point;
and a circular area is defined by taking the fixed point as the circle center and taking the preset value as the radius to serve as the buffer area.
5. An apparatus for acquiring a shortest distance line segment based on Mongodb, the apparatus comprising: the device comprises an acquisition module, a selection module, a calculation module, a first processing module, a second processing module and a third processing module; wherein the content of the first and second substances,
the acquisition module is used for determining a buffer area containing a fixed point;
the selection module is used for selecting a plurality of line segments in the buffer area;
the calculation module is used for calculating the distance from the fixed point to each line segment;
the first processing module is configured to determine a line segment in the buffer area with a minimum distance from the fixed point as a closest line segment of the fixed point;
the second processing module is configured to insert a shape point at a middle position of two adjacent shape points on a line segment when a length between the two adjacent shape points on the line segment is greater than a predetermined value, and stop inserting the shape point until the length between each two adjacent shape points on the line segment is less than or equal to the predetermined value, and specifically includes: importing Polyline of the vector into Mongodb, storing the Polyline in the Mongodb according to a two-dimensional coordinate sequence string, and then establishing a two-dimensional index; traversing each Polyline object, calculating the distance between every two shape points, judging whether the distance is greater than a preset value or not, if so, carrying out interpolation operation, and drawing a plurality of shape points on the line segment by adopting an interpolation calculation method, wherein the length between every two adjacent shape points is not greater than the preset value; wherein the line segment is composed of a series of coordinate strings, the shape points on the line segment corresponding to coordinate locations in the coordinate strings;
the shape point is a coordinate point in a rectangular coordinate system, and the shape point is determined by an abscissa and an ordinate; the length between the two shape points is calculated by using a distance formula between the two points under a plane coordinate system;
and the third processing module is used for determining the minimum value of the distance between the fixed point and each shape point on the line segment as the distance between the fixed point and the line segment.
6. The apparatus according to claim 5, wherein the acquiring module comprises: a selection unit and a processing unit; wherein the content of the first and second substances,
the selection unit is used for determining the fixed point;
and the processing unit is used for dividing a circular area by taking the fixed point as a circle center and a preset value as a radius to serve as the buffer area.
CN201610046174.0A 2016-01-25 2016-01-25 Method and device for obtaining distance and determining shortest distance line segment based on Mongodb Active CN106997355B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610046174.0A CN106997355B (en) 2016-01-25 2016-01-25 Method and device for obtaining distance and determining shortest distance line segment based on Mongodb

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610046174.0A CN106997355B (en) 2016-01-25 2016-01-25 Method and device for obtaining distance and determining shortest distance line segment based on Mongodb

Publications (2)

Publication Number Publication Date
CN106997355A CN106997355A (en) 2017-08-01
CN106997355B true CN106997355B (en) 2020-06-02

Family

ID=59428649

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610046174.0A Active CN106997355B (en) 2016-01-25 2016-01-25 Method and device for obtaining distance and determining shortest distance line segment based on Mongodb

Country Status (1)

Country Link
CN (1) CN106997355B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108994838A (en) * 2018-08-21 2018-12-14 智久(厦门)机器人科技有限公司上海分公司 The relationship calculation method and system of robot location and planning path
CN109945888B (en) * 2019-03-11 2021-03-16 百度在线网络技术(北京)有限公司 Method and device for generating navigation guide line and computer equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101447947B (en) * 2008-12-26 2011-02-23 北京农业信息技术研究中心 Linear optimal shortest path search method
US8717365B2 (en) * 2010-08-09 2014-05-06 Verizon Patent And Licensing Inc. Polyline vertex reduction
CN104751733B (en) * 2013-12-25 2017-06-16 携程计算机技术(上海)有限公司 The region method for drafting and device of map, path distance sorting technique and system

Also Published As

Publication number Publication date
CN106997355A (en) 2017-08-01

Similar Documents

Publication Publication Date Title
CN106855415B (en) Map matching method and system
CN108801273B (en) Method and device for generating road reference line
CN105444678B (en) Handset size measuring method and system
JP6350251B2 (en) Route information processing apparatus, method, and program
EP2427729A1 (en) Method and system for reducing shape points in a geographic data information system
WO2018090773A1 (en) Method and device thereof for matching track points captured by positioning system to map
WO2022052567A1 (en) Vehicle positioning method and apparatus, vehicle, and storage medium
WO2013182032A1 (en) Method and device for matching public transportation route with road network
CN106997355B (en) Method and device for obtaining distance and determining shortest distance line segment based on Mongodb
CN105719348A (en) Point cloud boundary fitting system and method
JP2015161557A5 (en)
CN111209805B (en) Rapid fusion optimization method for multi-channel segment data of lane line crowdsourcing data
CN110555086A (en) Method and device for attributing resource points in grid
CN111144109A (en) Text similarity determination method and device
CN108776660B (en) ArcGIS-based method for matching road attributes in batches
CN110377681A (en) A kind of method, apparatus of data query, readable storage medium storing program for executing and electronic equipment
US8614703B1 (en) Automatic border alignment of objects in map data
CN103196460B (en) A kind of method and apparatus estimating step-length
US9082045B2 (en) Method and apparatus for matching key pixels, and method and apparatus for matching images
US8199972B2 (en) Methods and systems for fast scan location identification
JP4510792B2 (en) LOCATION ANALYSIS DEVICE, LOCATION ANALYSIS METHOD, ITS PROGRAM, AND RECORDING MEDIUM
CN111858785A (en) Method, device and system for matching discrete elements of map and storage medium
CN110413716B (en) Data storage and data query method and device and electronic equipment
KR101551122B1 (en) Pattern recognition method and apparatus within Terminal
KR20170074418A (en) Apparatus and method for converting k-mer for measuring similarity of sequences

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant