It's very easy since there is limited ability for trains to change tracks, so the location history of the train is a strong indicator of which track it is on. Even Google Maps can tell you which lane you are in since god knows when, and cars can freely change lanes. And that's just consumer software. For something commercial like a train they could trivially solve this problem with something more robust. But I'm not familiar with the Spanish system; how much of the engineering did they do?
Yes, it can tell you. How perfectly, though? Perfectly enough to bet 60 lives on?
When Google Maps gets wrong what lane I'm in, nobody dies. It can be right 99% of the time, that's good enough. It's not good enough for a train system, though - at least, I suspect it's not. I'd want a lot more than "it works in my car" before I trusted it.
HN does railway safety... The Dunning-Kruger level in this thread is ridiculous.
As a passenger, I'm very glad software engineers haven't (fully) taken over aviation and railway safety yet.
Google maps gives me the directions for the express lanes when I'm in the normal lanes and vice versa like 50% of the time, and that's an order of magnitude greater error in distance than the distance between adjacent train tracks. And several orders of magnitude greater failure rate than is acceptable for a safety system.
There are switches that move trains between tracks. Now you need every switch to report, keep a history of that. Many trains also separate and combine. Trains sometimes go backwards to be switched.
It's not impossible. But handwaving GPS placement of trains at the correct location, direction, and track deserves more than a handwave as trivial.