Comparison of geographical points in postgres

Asked

Viewed 137 times

1

I have a structure like this:

A table veiculo where I store the id and the placa of the vehicle.

A table estacionamento where I store the nome do estacionamento, the id and the area of him (a polygon using the postgis.

A table ponto de interesse where I capture the localização atual of my vehicle. (this data will be entered into the hand through a Webservice.

When I send a ponto de interesse for the bank, I need to create a function that checks if the point is inside a parking lot, and if it returns true, it is necessary to open a command and record the date of entry.

My difficulty lies in the following:

I am capturing points of the car, and I need to compare the current point with the previous one, to know if it is still inside the parking lot or has already left, example.

  • If he was out and still out, does nothing.
  • If he was out and came in, open a command.
  • If he was in and he’s still in it does nothing.
  • If he was in and now he’s out, close the remote.

To check if you’re inside, I’m using the St_within of postgis, but I couldn’t think of how to compare the previous point with the current one effectively.

Can someone tell me some north so I can follow?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.