Spatial search with ravenDB

I have a rather specific spatial search that I need to do. Basically, you have an object (allowing calling obj1) with two locations, allows you to call them point A and point B.

Then I have a set of objects (allows you to call each of obj2), each with its own points A and B.

I want to return the top 10 objects from a collection sorted by:

(distance from obj1 A to obj2A) + (distance from obj1B to obj2B)

Any ideas? Thanks Nick

Update: Here are some more details about the documents and how I want to compare them.

Domain Model:

Listing: ListId int Title bar Price double Place of origin Destination

Location: Post / Zipcode String Decimal Point Width Decimal Longitude

What I want to do is take a list object (not in the database) and compare it with the collection of lists in the database. I want the query to return the top 12 (or x) number of lists sorted by distance from the source, plus a crow, flying from the destination.

I don’t care about the distance from the source to the destination - only about the distance from the place of origin to the destination, plus the destination to the destination.

I mainly try to find lists where the start and end locations are close.

Please let me know if I can clarify more. Thank!

+3
source share
4 answers

I don’t think you found the solution right out of the box.

, . http://en.wikipedia.org/wiki/Bounding_sphere

     C = ( A + B)/2 and R = distance(A,B) /2

, . .

, C , 3D quadtree, 2D. http://en.wikipedia.org/wiki/Quadtree

, , . 3D- 2D, .

, , .

, " " " ". (x ) .

0

​​

mysql 4.1 &

mysql 5.

mysql 4.1 , . , , .

, , obj1, obj2 .

0

, , , .

, , :

public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
{
    double deltaLat = DegreesToRadians(lat2 - lat1);
    double deltaLong = DegreesToRadians(lng2 - lng1);

    double a = Math.Pow(Math.Sin(deltaLat / 2), 2) +
        Math.Cos(DegreesToRadians(lat1))
        * Math.Cos(DegreesToRadians(lat2))
        * Math.Pow(Math.Sin(deltaLong / 2), 2);

    return earthMeanRadiusMiles * (2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)));
}
0

, - rideshare.:)

, , . , : MySQL OpenGIS ( ) PostgreSQL PostGIS. , ravenDB: http://ravendb.net/documentation/indexes/sptial

, . , A, .

- A , . , .

, (). , db, . " " . ; 10. , , 1 1 ( 60 60 ) . , , lng = 43,5,86.5. db - SELECT COUNT (*) FROM WHERE (lat > 43 AND lat < 44) AND (lng > 86 AND lng < 87). lat/lng, .

- 10 . , " ". 5 , . 100 , . 3 , 50% ( 100%) , , 10.

, .

!

0

Source: https://habr.com/ru/post/1782051/


All Articles