Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 919831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:36:40+00:00 2026-05-15T18:36:40+00:00

So this one is a very difficult one I think, so I’ll try to

  • 0

So this one is a very difficult one I think, so I’ll try to make it as clear as possible.

So basically, I have geographic datas :

Nodes (#ID,lat,lng)
WayNodes (#ID,#node_id,#way_id, sequence)
Ways(#id,name)

And what I want is to get the intersection of two GROUPS of ways.
For example I need to find intersection(s) between the ways called “name1” : {way1, way2, way3} and the ways called “name2” : {way4, way5, way6}

So what I need is to do an equivalent to this :

float x;
float y;

float A1 = Y2-Y1;
float B1 = X1-X2;
float C1 = A1*X1+B1*Y1;

float A2 = Y4-Y3;
float B2 = X3-X4;
float C2 = A2*X3+B2*Y3;

float det = A1*B2 - A2*B1;

if(det == 0){
    //Lines are parallel
    x = 0.0;
    y = 0.0;

}else{
    x = (B2*C1 - B1*C2)/det;
    y = (A1*C2 - A2*C1)/det;
}

BOOL intersection = (x<MAX(X1,X2) && x<MAX(X3,X4) && x>MIN(X1,X2) && x>MIN(X3,X4));

But in SQL !

I kind of think it is possible, my request looks like that :
(F1, F2 and F3 replace two very long functions, which compute X, Y and det, they should be correct.)

SELECT F1(n1.lat,n1.lng,n2.lat,n2.lng,n3.lat,n3.lng,n4.lat,n4.lng) AS x,
F2(n1.lat,n1.lng,n2.lat,n2.lng,n3.lat,n3.lng,n4.lat,n4.lng) AS y,
F3(n1.lat,n1.lng,n2.lat,n2.lng,n3.lat,n3.lng,n4.lat,n4.lng) AS det, 
FROM Nodes n1, Nodes n2, Nodes n3, Nodes n4
JOIN WayNodes wn1 ON n1.id = wn1.node_id
JOIN WayNodes wn2 ON n2.id = wn1.node_id
JOIN WayNodes wn3 ON n3.id = wn1.node_id
JOIN WayNodes wn4 ON n4.id = wn1.node_id
JOIN Way w1 ON wn1.way_id = w1.id AND wn2..way_id = w1.id
JOIN Way w2 ON wn3..way_id = w2.id AND wn4..way_id = w2.id
WHERE det != 0 AND
x < MAX(n1.lng, n2.lng)
AND  x > MIN(n1.lng, n2.lng)
AND x < MAX(n3.lng, n4.lng)
AND  x > MIN(n3.lng, n4.lng)
AND wn1.sequence=wn2.sequence - 1
AND wn3.sequence=wn4.sequence - 1
AND w1.name = "name1"
AND w2.name  = "name2"

Apparently something doesn’t work in the junction… any idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:36:41+00:00Added an answer on May 15, 2026 at 6:36 pm

    Is it that you need…

    JOIN WayNodes wn1 ON n1.id = wn1.node_id
    JOIN WayNodes wn2 ON n2.id = wn2.node_id
    JOIN WayNodes wn3 ON n3.id = wn3.node_id
    JOIN WayNodes wn4 ON n4.id = wn4.node_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this was one of my very first questions here, but I have a
I have a piece of code VERY similar to this one http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching I the
I have lots of vectors like this one below, very sparse, lots of 'NaN'.
This is a very odd one and I'm not sure how to proceed. Basically,
So this one is probably very simple, but I'm having a bit of trouble
I'm generally not a fan of microbenchmarks. But this one has a very interesting
My question popped up a very similar question, this one . But the accepted
for example, in this one, I 'm not very understand about the this pointer,
This post is very similar to my previous one, but the data structures are
This is a very very basic question and I know one way is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.