I have a structure something like this:
A veiculo
table where I store the id
and the placa
of the vehicle.
A estacionamento
table where I store nome do estacionamento
, id
, and area
of it (a polygon using postgis .
A ponto de interesse
table where I capture the localização atual
of my vehicle. (such data will be entered in the hand via a Webservice .
When I send ponto de interesse
to the database, I need to create a function that checks if the point is inside a parking lot, and if I return true
, it is necessary to open a command and save the date of entry.
My difficulty consists of the following:
I'm capturing points from the car, and I need to compare the current point with the previous point, to see if it's still in the parking lot or has already left, for example.
- If he was out and still out, he did nothing.
- If he was outside and entered, he opened a command.
- If he was inside and still inside he does nothing.
- If it was inside and now it is out, close the command.
To check if you're in, I'm using St_within
of postgis , but I was not able to think about how to compare the previous point with the current one effectively.
Can anyone tell me some north so I can follow?