[SERVER-23197] Distance calculation for multiple lat and long error Created: 17/Mar/16  Updated: 29/Mar/16  Resolved: 28/Mar/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: shibimukesh Assignee: Kelsey Schubert
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-23300 Linestring point calculation error in... Closed
Operating System: ALL
Participants:

 Description   

how to calculate distance for multiple points its error in mongodb
"loc" :

{ "type" : "LineString", "coordinates" : [ [-73.958, 40.8003 ], [ -73.9498, 40.7968], [ -73.9737, 40.7648], [ -73.9814, 40.7681]]}

 Comments   
Comment by shibimukesh [ 29/Mar/16 ]

thank you,
shall i run this java script in mongoshell

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

On Tue, Mar 29, 2016 at 3:29 AM, Thomas Schubert (JIRA) <jira@mongodb.org>

Comment by Kelsey Schubert [ 28/Mar/16 ]

Hi shibish,

This operation to find the length of a lineString would be best handled by your application. As I mentioned in my previous comment, an implementation of the haversine formula for MongoDB is presented here.

Determining the best solution for your particular use case would involve more discussion, and I would recommend that you consider posting your question on the mongodb-users group for MongoDB-related support.

Kind regards,
Thomas

Comment by shibimukesh [ 24/Mar/16 ]

Hi Thomas,

Thankyou for your response exactly thats the result am expecting..
For example if an Passenger picks an taxi for start and destination point
there will be number of lat and long we need to calculate the lat and long
for finding the distance..
0.7924 km + 4.088 km + 0.7451 km = 5.6255 kilometers.
in mysql we use haversine formula and how to do this in mongo

With regards,
M.shibi

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

On Thu, Mar 24, 2016 at 5:25 AM, Thomas Schubert (JIRA) <jira@mongodb.org>

Comment by Kelsey Schubert [ 23/Mar/16 ]

Hi shibish,

Thank you for the additional details.

My understanding is that you are looking for an operation in MongoDB to provide a sum of the distance between each adjacent position in the lineString. As an example, using the coordinates that you have provided, the distance would be 0.7924 km + 4.088 km + 0.7451 km = 5.6255 kilometers. Is this the output that you would expect? If not can you please explain how you would like the distance to be calculated?

You may benefit from reviewing this blog post which includes a function, haversine, to compute the distance between two positions. The complete code solution to the problem described in the blog post can be found here. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag.

Kind regards,
Thomas

Comment by shibimukesh [ 19/Mar/16 ]

how to calculate the distance for this multipoint of lat and long

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

Comment by shibimukesh [ 19/Mar/16 ]

collection name: driver location history
{
"_id" : 1299,
"location_hid" : 1,
"trip_id" : 865,
"free_record" : "",
"status" : "A",
"createdate" : "2015-09-08 20:20:07",
"loc" :

{ "type" : "MultiPoint", "coordinates" : [ [ 76.9165522, 11.0214407 ], [ 76.9165544, 11.0214409 ], [ 76.9165543, 11.0214429 ], [ 76.9165556, 11.0214428 ], [ 76.9165562, 11.0214429 ], [ 76.916555, 11.0214432 ], ] }

}

and my query is

db.d.find({
loc: {
$geoIntersects: {
$geometry:

{ type: "LineString", coordinates: [[ 76.9165522, 11.0214407],[76.9165544, 11.0214409],[76.9165543, 11.0214429],[ 76.9165556,11.0214429],[76.916555,11.0214432]] }

}
}
})

and my output is its simply returns the document i need the output of total
distance traveled

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

On Fri, Mar 18, 2016 at 8:06 PM, Thomas Schubert (JIRA) <jira@mongodb.org>

Comment by Kelsey Schubert [ 18/Mar/16 ]

Hi shibish,

Sorry for the confusion, please help by answering the following questions:

  1. Can you attach a shell script that shows the existing behavior that you describe?
  2. Can you please provide an example of the behavior you would like to see? Please include:
    1. sample data
    2. MongoDB commands
    3. sample output

Thank you,
Thomas

Comment by shibimukesh [ 18/Mar/16 ]

Hi
For calculating distance using double lat and long mongodb supports and its
giving exact distance...and my issue is for calculating distance on
multiple lat and long there is no option for calculating distance instead
its showing the particular document in a collection

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

On Fri, Mar 18, 2016 at 12:22 AM, Thomas Schubert (JIRA) <jira@mongodb.org>

Comment by Kelsey Schubert [ 17/Mar/16 ]

Hi shibish,

If I am understanding correctly, I believe this is a duplicate of the feature request described in SERVER-14948. Please feel free to vote for it and watch it for updates.

Thank you,
Thomas

Generated at Thu Feb 08 04:02:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.