New devices are able to determine not only what building you and your phone are in but also which floor you’re on. (Bigstock)

Cellphones long have doubled as tracking devices, capable of revealing your location to police, paramedics, even grocery stores looking to deliver coupons to nearby customers. But there’s a measurement cellphones once struggled to make: altitude.

No more.

Cellphone tracking is about to go vertical as the location-services industry, prodded by the U.S. government, solves the riddle of what experts call “the z vector.” Soon it will be possible to determine not only what building you and your phone are in but also whether you are on the first or 15th floor.

One key is the rapid spread of barometric-pressure sensors, which have become standard features in Apple’s iPhone 6 and several Android devices. More than 100 million of these smartphones already are in the hands of consumers, capable of making air-pressure readings that can be used to estimate a user’s altitude, to within a few feet.

The systems, though now used mainly for apps that users control, are part of a new generation of location technology that could collect altitude data from smartphones and use it to, for example, help rescue crews find people trapped in an office-tower fire. But privacy advocates warn that detectives, intelligence agencies and maybe hackers could gain the ability to map the three-dimensional movements of cellphone users with startling new detail.

Sensors in smartphones that measure air pressure can now determine the callers’s altitude.

An early glimpse at this tension is playing out at the Federal Communications Commission, which is updating its requirements for how wireless carriers handle 911 calls, 70 percent of which now come from cellphones rather than land lines. In a proposal that could be adopted as soon as January, the FCC would require wireless carriers to build more-precise location systems capable of finding callers anywhere, even in a multistory building.

The proposal has triggered a lobbying fight, with some public-safety groups supporting strict FCC rules and wireless carriers pushing for slower implementation and different technology. The outcome of that struggle is likely to determine the precision of the next generation of cellphone tracking and how quickly it arrives.

“This puts those of us in the civil-liberties community in a difficult position of opposing the creation of location services for emergency services, because we know the FBI will ask for it later and we don’t have the power to stop them when they ask for it later,” said Christopher Soghoian, principal technologist for the American Civil Liberties Union.

The FBI declined to comment on the location rules under consideration by the FCC, but the bureau’s own investigative guidelines say it can seek access to any information supplied to other government agencies. Previous generations of FCC location rules, though created for 911 services, eventually led to the FBI quietly gaining an expanded ability to track cellphone users.

The potential goes far beyond government uses, said Manlio Allegra­, chief executive of Polaris Wireless, one of the location-services­ companies experimenting with altitude measurements. Malls could use altitude tracking to monitor crowd flows and send coupons to the phones of customers walking past a shoe shop on the top floor. Multilevel casinos could monitor gamblers for security purposes. Companies could better keep tabs on the movements of their employees, especially those handling expensive products.

“It’s like a tidal wave,” Allegra said of the potential for three-dimensional­ tracking. “You upgrade the network, every performance [capability] on the network gets upgraded.”

From air to ‘z’

The technology works on a simple principle: Air molecules concentrate more densely at low altitudes than at high ones, causing measurable variations that follow predictable patterns. Even if overall barometric pressure at a certain location is shifting — say, as a hurricane approaches — the bottom floor of an office building will have higher pressure than the top one.

The air-pressure sensors built into the latest smartphones have sparked the development of a range of apps. Some help forecast the arrival of storms; others claim to alert anglers to when fish — which are said to prefer high, stable pressure — are biting.

The iPhone 6 includes a health app that uses changes in air pressure to estimate how many stairs a user climbs each day. Apps that help hikers navigate peaks and glider pilots track flights are increasingly using barometric sensors to measure altitude, something that GPS tracking technology struggles to do as quickly and accurately.

Australian glider pilot Peter Rundle built an Android app called GlideMate that maps longitude and latitude — the “x” and “y” vectors — while also showing the “z” vector of altitude based on air-pressure readings made by the smartphone.

GlideMate also tracks rates of ascent or descent, mimicking a device called a variometer and allowing him to leave some bulky gear behind when he flies. “It’s easier to just have one instrument that does everything,” Rundle said.

The Polaris Wireless altitude sensors work roughly the same way. During a demonstration for government officials on the seventh floor of FCC headquarters in September, amid the cluster of drab office buildings south of the Mall in Washington, a company employee carried a Samsung Galaxy S3 smartphone down several flights of stairs, said Allegra, the Polaris CEO.

Using software the company designed, the Samsung device measured the pressure shifts and relayed them to a server at the company’s Silicon Valley headquarters. The server then compared the readings with an atmospheric model of the area and reported the shifting altitude estimates to another device, as Allegra and the FCC officials looked on.

The proposed FCC rules would not endorse a particular location technology, but any new standards are likely to spur innovation as companies compete for the lucrative business of helping wireless carriers comply.

“We are committed to both improving public safety and protecting consumer privacy,” David Simpson, chief of the FCC’s public-safety and homeland-security bureau, said in a statement. “The goal of this proceeding is to use technological advancements in the marketplace to help first responders better locate 911 callers. We’ve sought public comment on our proposals, including any privacy implications, and will consider all input as we move forward.”

The four largest wireless carriers reached an agreement with two major public-safety groups last week, endorsing standards and a timetable less stringent than proposed by the FCC and relying on a different technology — using maps of WiFi and Bluetooth signals, as some commercial location services now do — for determining the address and altitude of a 911 caller.

Other groups are still pushing for air-pressure technology, arguing that it is more reliable and precise and could be implemented more quickly. “The [wireless] industry is basically trying to slow the train down,” said Harold Schaitberger, general president of the International Association of Fire Fighters. “That’s very troubling to us.”

Beyond GPS

A 911 call is unlike any other: A person dialing the number typically is seeking help from authorities to report a crime, fire or medical emergency. The dispatcher needs to know the location of the caller to direct the appropriate responders to the right place, even if the caller cannot or will not provide that information.

Several technologies, operating under existing FCC rules, already are capable of finding 911 callers based on data that flows through cellular networks, such as what cell towers phones are using and how quickly signals are reaching them. Increasingly, though, carriers also are activating the GPS chips in smartphones to determine the locations of callers and sending the results to dispatchers.

Yet some in the location-services industry, backed by coalitions of emergency workers, have argued that existing systems are flawed and imprecise. GPS tracking, for example, needs a clear line of sight to satellites, making them all but useless when somebody inside a building makes a 911 call.

“There needs to be privacy protections, but right now, for all the networks, that’s not the challenge,” said Jamie Barnett, a former top FCC official now lobbying for one of the location-services companies, TruePosition, and also for a coalition of emergency workers that the company is funding. “The question is, can the networks even find you?”

Many privacy advocates support the idea — in concept — of better location tracking for 911 calls but fear government overreach. The last time the FCC updated its location requirements for wireless carriers, several later agreed to provide that same data to the FBI.

The increasing use of GPS tracking, the privacy advocates say, offers a cautionary tale. Even if callers have turned off the capability on their smartphones, 911 systems are capable of remotely activating GPS functions and extracting precise locations.

This may cause little concern since somebody calling authorities typically wants to be found. But if smartphones are designed to include the ability to have their GPS tools activated remotely, there is no guarantee that others will not secretly take advantage of that feature. Users making 911 calls typically do not get notification that their smartphones have activated the GPS functions and reported the location to authorities.

Jim Dempsey, senior counsel to the Center for Democracy & Technology and a veteran of debates over FCC location rules, said privacy concerns could be lessened by requiring wireless carriers to build systems capable of transmitting altitude measurements only during 911 calls. “It’s not like the FCC is forcing anyone to design a mass surveillance tool of the future,” Dempsey said.

But Rundle, the Australian glider pilot and app developer, said location data generated for 911 calls will inevitably be collected by the government — and perhaps others — to track cellphone users.

“It’s the dilemma of today’s technology. You can’t make it hack-proof,” he said. “If somebody can program it, someone else can re-purpose it.”

Brian Fung contributed to this report.

Follow The Post’s tech blog, The Switch, where technology and policy connect.