Answer the question
In order to leave comments, you need to log in
How to check coordinate hit?
Hello.
There is a certain page A, which plays the role of an entry point into the application.
It tracks changes in the user's coordinates via
navigator.geolocation.watchPosition(callback, error);
When the coordinates change, the user's coordinates are sent to the socket server (Node.JS + SOCKET.IO + Express) ss1.example.com:3000, from where the coordinates are further sent to other users inside the room, and new coordinates of the corners of the map are sent there. our user.
From there, ss1.example.com transmits, if necessary (for example, if disonnected is called), data about the last location of the user to the geodb.example.com server, which first saves them in the system geoobject database, and also transfers them to the Backup server. The database servers receive the data last, because they are the slowest of all, and firstly there is an exchange of location with other users of the room - let them calmly dig with the incoming data :)
Question:
We transfer the coordinates of the corners of the map and the coordinates of the user.
How to send these coordinates (socket.emit) only to those users who have our sender in the "visibility zone" (that is, not outside the boundaries of the map)?
Answer the question
In order to leave comments, you need to log in
Problem solved.
(Bx - Ax) * (Py - Ay) - (By - Ay) * (Px - Ax)
- our point, Px - latitude, Py - longitude
A - one of the angles, xy respectively
B - the opposite angle to A.
Negative value: hit
Positive: not hit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question