I am college student and I have beginner level experience of web development(NodeJS, MongoDB) I am developing a website for student attendance if a student is present in classroom in given time and he/she fill attendance by pressing a button then his/her attendance should be marked as present.
I am doing it by accessing location of user...
I am using geolocation API to access location of user :https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation
it returns value like :
Latitude: 20.7819165
Longitude: 22.5789159
but many times it gives different values for the same point of location(varying last four digits) and I can't find any criteria to differentiate user who is inside the classroom and outside the classroom
Almost same value of for both points in above image
I think I need to apply some math, but I don't know what exactly I should do ?
Please give any suggestion....
Is it possible or not ?
Is there any other way(other than use of location) to do it ?
Locally, the Earth surface is flat. Assuming that you far enough from poles and classroom is small, the equation for straight lines is approximately
a*longitude + b*latitude + c = 0
so if you can find (a,b,c) that describe the walls of the classroom, you can derive 4 checks
a_i*longitude + b_i*latitude + c_i >= 0? i=1,2,3,4
that have to be satisfied for a person to be inside the rectangle.
Of course, we also assume that you get person's and classroom's location with sufficient accuracy.