RFC 7459
Representation of Uncertainty and Confidence in the Presence Information Data Format Location Object (PIDF-LO)
RFC 7459 ๐ Representation of Uncertainty and Confidence in the Presence Information Data Format Location Object (PIDF-LO)
Okay bestie, let's get into it! ๐ This one is RFC 7459, published in February 2015 and written by M. Thomson (at Mozilla) and J. Winterbottom (unaffiliated). The title block says it's a Standards Track doc with ISSN 2070-1721. It updates RFCs 3693, 4119, and 5491, and the title block doesn't list anything it obsoletes ๐ฆ
Abstract โจ
So the vibe is this: the doc defines the key concepts of uncertainty and confidence as they apply to location information, and it outlines how you can manipulate location estimates that carry uncertainty info ๐บ๏ธ
It also normatively updates the definition of location information representations from RFCs 4119 and 5491. And it deprecates some related terminology from RFC 3693 ๐
Status of This Memo ๐
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.
Info about the current status of this document, any errata, and how to send feedback can be found at http://www.rfc-editor.org/info/rfc7459 ๐
Copyright Notice ยฉ๏ธ
Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
Table of Contents ๐
1. Introduction ....................................................4
1.1. Conventions and Terminology ................................4
2. A General Definition of Uncertainty .............................5
2.1. Uncertainty as a Probability Distribution ..................6
2.2. Deprecation of the Terms "Precision" and "Resolution" ......8
2.3. Accuracy as a Qualitative Concept ..........................9
3. Uncertainty in Location .........................................9
3.1. Targets as Points in Space .................................9
3.2. Representation of Uncertainty and Confidence in PIDF-LO ...10
3.3. Uncertainty and Confidence for Civic Addresses ............10
3.4. DHCP Location Configuration Information and Uncertainty ...11
4. Representation of Confidence in PIDF-LO ........................12
4.1. The "confidence" Element ..................................13
4.2. Generating Locations with Confidence ......................13
4.3. Consuming and Presenting Confidence .......................13
5. Manipulation of Uncertainty ....................................14
5.1. Reduction of a Location Estimate to a Point ...............15
5.1.1. Centroid Calculation ...............................16
5.1.1.1. Arc-Band Centroid .........................16
5.1.1.2. Polygon Centroid ..........................16
5.2. Conversion to Circle or Sphere ............................19
5.3. Conversion from Three-Dimensional to Two-Dimensional ......20
5.4. Increasing and Decreasing Uncertainty and Confidence ......20
5.4.1. Rectangular Distributions ..........................21
5.4.2. Normal Distributions ...............................21
5.5. Determining Whether a Location Is within a Given Region ...22
5.5.1. Determining the Area of Overlap for Two Circles ....24
5.5.2. Determining the Area of Overlap for Two Polygons ...25
6. Examples .......................................................25
6.1. Reduction to a Point or Circle ............................25
6.2. Increasing and Decreasing Confidence ......................29
6.3. Matching Location Estimates to Regions of Interest ........29
6.4. PIDF-LO with Confidence Example ...........................30
7. Confidence Schema ..............................................31
8. IANA Considerations ............................................32
8.1. URN Sub-Namespace Registration for ........................32
8.2. XML Schema Registration ...................................33
9. Security Considerations ........................................33
10. References ....................................................34
10.1. Normative References .....................................34
10.2. Informative References ...................................35
Appendix A. Conversion between Cartesian and Geodetic
Coordinates in WGS84 ..................................36
Appendix B. Calculating the Upward Normal of a Polygon ............37
B.1. Checking That a Polygon Upward Normal Points Up ...........38
Acknowledgements ..................................................39
Authors' Addresses ................................................39
1. Introduction ๐ฆ
Location info is basically an estimate of where a Target is [RFC6280]. Ideally, the estimate exactly matches where the Target actually is. But for automated systems that figure out location, there are a bunch of factors that bring errors into the measurements used to build those estimates ๐ญ
How the measurements get combined into a location estimate is outside IETF scope. BUT the results still get carried in IETF data formats and protocols, so this doc explains how uncertainty (and its buddy, confidence) gets expressed and interpreted โจ
It also gives everyone a shared vocabulary for talking about uncertainty and confidence in location info ๐ง
Then there's the practical stuff: how to manage location info that includes uncertainty. The doc describes methods for expanding or reducing uncertainty to hit a required level of confidence, and methods for working out the probability that a Target sits inside a specified region based on its location estimate. These methods are simplified by making certain assumptions about the estimate, and they're designed for location estimates in a relatively small geographic area ๐ธ
Last but not least, a confidence extension for the Presence Information Data Format - Location Object (PIDF-LO) [RFC4119] is described. These methods work alongside automatically determined location info, and they're statistically based ๐
1.1. Conventions and Terminology ๐
Okay this is the important bit! The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].
The doc assumes you already get the basics of mathematics, especially statistics and geometry ๐ค
Some terminology is borrowed from [RFC3693] and [RFC6280], in particular "Target".
Math notation time! The operators are add +, subtract -, multiply *, divide /, power ^, and absolute value |x|. Precedence follows the usual rules: power operations come before multiply and divide, multiply and divide come before add and subtract, and parentheses group operations that are applied together. The functions use common abbreviations: square root sqrt(x), sine sin(x), cosine cos(x), inverse cosine acos(x), tangent tan(x), inverse tangent atan(x), two-argument inverse tangent atan2(y,x), error function erf(x), and inverse error function erfinv(x) ๐งฎ
2. A General Definition of Uncertainty ๐ฅ
Uncertainty comes from the limits of measurement. When you measure any observable quantity, errors from a range of sources affect the result. Uncertainty is basically a quantification of what we know about the observed quantity, either through those measurement limits or through the quantity's own inherent variability ๐
Uncertainty is most completely described by a probability distribution, and a probability distribution assigns a probability to possible values for the quantity ๐
Real talk: a probability distribution describing a measured quantity can be arbitrarily complex, so it's really useful to find a simplified model. One common approach is to reduce the probability distribution to a confidence interval. Lots of other models get used in other areas, but studying those isn't the focus of this doc ๐
Beyond the central estimate of the observed quantity, a confidence interval is succinctly described by two values: an error range and a confidence. The error range describes an interval, and the confidence describes an estimated upper bound on the probability that a "true" value is found within the extents defined by the error ๐ฏ
Here's an example where a measurement of a length is shown as a nominal value, plus an error range (0.0043 meters) and a confidence (95%) ๐
e.g., x = 1.00742 +/- 0.0043 meters at 95% confidence
This result means the value of "x" is between 1.00312 and 1.01172 meters with 95% probability. That's it. It does NOT assert that x is 1.00742 ๐ โโ๏ธ
Uncertainty and confidence for location estimates can be derived in a bunch of ways, and this doc doesn't try to list every method for determining uncertainty. [ISO.GUM] and [NIST.TN1297] give a set of general guidelines for determining and manipulating measurement uncertainty, and this doc applies that general guidance to consumers of location information ๐ซถ
Here's a cute detail: uncertainty values are statistical measures, found from information in the aggregate across numerous individual estimates. An individual estimate might be "correct" (say, if a survey validates the result) without invalidating the statistical assertion ๐ฆ
That's why asserting a confidence of 100%, which might seem intuitively correct, is rarely advisable. Main character energy is not the vibe here ๐
2.1. Uncertainty as a Probability Distribution โจ
Okay bestie, so the Probability Density Function (PDF) is what tells you how likely the "true" value is to be at any single point ๐ฏ. The shape of that distribution can change depending on how the result was figured out ๐ง. This doc looks at the two PDFs that matter most for location info ๐ :
- The normal PDF (also called a Gaussian PDF) is used where a large number of small random factors contribute to errors. The error range for a normal PDF is tied to the standard deviation of the distribution ๐.
- A rectangular PDF is used where the errors are known to be consistent across a limited range ๐งฑ. It can show up when one error source, like a rounding error, is way bigger than the other errors. A rectangular PDF is usually described by its half-width, which is half the width of the distribution ๐ซถ.
Each of these PDFs can be described by its center point (the mean) and its width ๐ธ. For a normal distribution, uncertainty and confidence are both connected to the standard deviation of the function (see Section 5.4) ๐. For a rectangular distribution, we use the half-width instead โจ.
Figure 1 shows a normal and a rectangular PDF, with the mean (m) and standard deviation (s) labeled. The half-width (h) of the rectangular distribution is marked too ๐ฆ.
***** *** Normal PDF
** : ** --- Rectangular PDF
** : **
** : **
.---------*---------------*---------.
| ** : ** |
| ** : ** |
| * <-- s -->: * |
| * : : : * |
| ** : ** |
| * : : : * |
| * : * |
|** : : : **|
** : **
*** | : : : | ***
***** | :<------ h ------>| *****
.****-------+.......:.........:.........:.......+-------*****.
m
Figure 1: Normal and Rectangular Probability Density Functions
For any given PDF, the value of the PDF tells you the probability that the "true" value is at that point ๐. Confidence for any interval is the total probability that the "true" value is somewhere in that range, and it's defined as the integral of the PDF over the interval ๐.
The probability that the "true" value falls between two points is found by looking at the area under the curve between those points (that's the integral of the curve between them) ๐. For any PDF, the area under the curve across the whole range, from negative infinity to positive infinity, is 1, or (100%) ๐ฏ. So the confidence over any interval of uncertainty is always less than 100% ๐.
Figure 2 shows how confidence works out for a normal distribution. The shaded area gives the confidence (c) for the interval between "m-u" and "m+u" ๐.
*****
**:::::**
**:::::::::**
**:::::::::::**
*:::::::::::::::*
**:::::::::::::::**
**:::::::::::::::::**
*:::::::::::::::::::::*
*:::::::::::::::::::::::*
**:::::::::::::::::::::::**
*:::::::::::: c ::::::::::::*
*:::::::::::::::::::::::::::::*
**|:::::::::::::::::::::::::::::|**
** |:::::::::::::::::::::::::::::| **
*** |:::::::::::::::::::::::::::::| ***
***** |:::::::::::::::::::::::::::::| *****
.****..........!:::::::::::::::::::::::::::::!..........*****.
| | |
(m-u) m (m+u)
Figure 2: Confidence as the Integral of a PDF
Section 5.4 covers methods for manipulating uncertainty when the shape of the PDF is known ๐ง.
2.2. Deprecation of the Terms "Precision" and "Resolution" ๐ โโ๏ธ
Okay so "Precision" and "Resolution" are defined in RFC 3693 [RFC3693] ๐. Those definitions were meant to give everyone a shared vocab for talking about uncertainty ๐ซ . BUT these exact words are used in a bunch of other fields with totally different meanings, so the definitions aren't enough to stop the confusion ๐. These terms are unsuitable when you're talking about quantitative stuff, like uncertainty and confidence for location information ๐ซ.
2.3. Accuracy as a Qualitative Concept ๐
Uncertainty is a quantitative concept, but "accuracy" is a useful word for describing the general, qualitative side of location info ๐ฅฐ. Accuracy is generally helpful when you're describing qualitative aspects of location estimates ๐. It's not a suitable term for a quantitative context though ๐ โโ๏ธ.
For example, it could be fair to say that a location estimate with uncertainty "X" is more accurate than a location estimate with uncertainty "2X" at the same confidence ๐. It's not okay to assign a number to "accuracy", and it's not okay to call any part of uncertainty or confidence "accuracy" either ๐ค. So saying the "accuracy" of the first location estimate is "X" would be an erroneous use of this term โ.
3. Uncertainty in Location ๐
A "location estimate" is the result of location determination ๐บ๏ธ. Like any other observation, a location estimate is subject to uncertainty ๐ซถ. But unlike a simple measure of a one-dimensional property, like length, a location estimate is specified in two or three dimensions ๐.
Uncertainty in two- or three-dimensional locations can be described with confidence intervals ๐ . The confidence interval for a location estimate in two- or three-dimensional space is expressed as a subset of that space โจ. This doc uses the term "region of uncertainty" for the area or volume that describes the confidence interval ๐ซง.
Areas or volumes that describe regions of uncertainty can be built by combining two or three one-dimensional ranges ๐งฉ. Or you can describe more complex shapes, like the ones in [RFC5491] ๐ท.
3.1. Targets as Points in Space ๐
This doc makes a simplifying assumption: the Target of the PIDF-LO takes up just a single point in space ๐ซ . Yeah, that's clearly false in basically every real scenario ๐ญ, but it's often a reasonable simplification to make ๐.
How valid this is really depends on how big the Target is compared to the region of uncertainty ๐. When you're locating a personal device with today's location techniques, the space the device takes up is proportionally pretty tiny compared to the uncertainty ๐ฑ. Even if that device stands in for a person, the proportions don't change much ๐.
This assumption gets less useful as uncertainty becomes small relative to the size of the Target of the PIDF-LO (or the other way around, when uncertainty gets small compared to the Target) ๐ฅบ. For example, describing the location of a football stadium or a small country would include a region of uncertainty that's only a bit bigger than the Target itself ๐๏ธ. In those cases, a lot of the guidance in this doc doesn't apply ๐. And honestly, as location determination tech gets more accurate, the advice in this doc could become less relevant by the same measure ๐.
3.2. Representation of Uncertainty and Confidence in PIDF-LO ๐ง
A set of shapes that work for expressing uncertainty in location estimates in the PIDF-LO is described in [GeoShape] ๐ถ. These shapes are the recommended form for representing uncertainty in [RFC4119] PIDF-LO documents ๐.
The PIDF-LO can contain uncertainty, but it doesn't include an indication of confidence ๐คทโโ๏ธ. [RFC5491] defines a fixed value of 95% ๐ฏ. Similarly, the PIDF-LO format doesn't give you any indication of the shape of the PDF ๐ถ. Section 4 defines elements to convey that information in PIDF-LO ๐ง.
Not having uncertainty info in a PIDF-LO document does not mean there's no uncertainty in the location estimate ๐จ. Maybe uncertainty was never calculated for the estimate, or it may have been withheld for privacy purposes ๐.
If the Point shape is used, confidence and uncertainty are unknown ๐ซฅ. A receiver can either assume a confidence of 0% or infinite uncertainty ๐ค. The same principle applies on the altitude axis for two-dimensional shapes, like the Circle ๐ฆ.
3.3. Uncertainty and Confidence for Civic Addresses ๐
Automatically determined civic addresses [RFC5139] inherently include uncertainty ๐ซถ. That uncertainty is based on the area of the most precise element that is specified ๐ฏ. So in this case, uncertainty is basically described by which elements are present or absent ๐. To the recipient of location information, elements that are not present are uncertain ๐ซ๏ธ.
To apply the concept of uncertainty to civic addresses, it helps to unify the conceptual models of civic address and geodetic location information ๐ง . This is especially useful when you're looking at civic addresses determined through reverse geocoding (that's the process of translating geodetic information into civic addresses) ๐.
In the unified view, a civic address defines a series of spatial partitions, and they can be sometimes non-orthogonal ๐งฉ. The first is the implicit partition that identifies the surface of the earth and the space near the surface ๐. The second is the country ๐ณ๏ธ. Each label in a civic address gives information about a different set of spatial partitions ๐ท๏ธ. Some partitions need slight adjustments from a standard interpretation ๐. For instance, a road includes all properties that adjoin the street ๐ก. And each label might need to be read together with other values to give it context ๐.
As each value at a level is interpreted, one or more spatial partitions at that level are selected, and all the other partitions of that type are excluded โ๏ธ. For non-orthogonal partitions, only the part of the partition that fits within the existing space gets selected ๐ซง. This is what tells King Street in Sydney apart from King Street in Melbourne ๐ฆ๐บ. Each defined element selects a partition of space, and the resulting location is the intersection of all the selected spaces ๐.
The resulting spatial partition can be considered a region of uncertainty ๐ธ.
Note: This view is a potential perspective on the process of geocoding, which is the translation of a civic address to a geodetic location ๐ก.
Uncertainty in civic addresses can be increased by removing elements ๐. But that doesn't increase confidence unless additional information is used ๐ โโ๏ธ. Similarly, arbitrarily increasing uncertainty in a geodetic location does not increase confidence either ๐ซ .
3.4. DHCP Location Configuration Information and Uncertainty ๐บ๏ธโจ
Okay so location info is usually measured in two or three dimensions, and expressing uncertainty in just one dimension is rare, honestly ๐. The "resolution" parameters in [RFC6225] give you an indication of how many bits of a number are valid, which you could read as an expression of uncertainty in one dimension ๐ค.
[RFC6225] defines a way to represent uncertainty, but it doesn't specify a value for confidence ๐. A default value of 95% confidence should be assumed for the combination of the uncertainty on each axis. This matches up with how those forms get turned into the uncertainty representations from [RFC5491]. So the confidence of the resulting rectangular Polygon or Prism is assumed to be 95% ๐.
4. Representation of Confidence in PIDF-LO ๐
On the whole, a fixed definition for confidence is preferable, primarily because it ensures consistency between implementations ๐ซถ. Location generators that are aware of this constraint can generate location information at the required confidence. Location recipients are able to make sensible assumptions about the quality of the information that they receive. It's giving organized ๐.
In some circumstances (particularly with preexisting systems), location generators might be unable to provide location information with consistent confidence ๐ฌ. Existing systems sometimes specify confidence at 38%, 67%, or 90%. Existing forms of expressing location information, such as that defined in [TS-3GPP-23_032], contain elements that express the confidence in the result.
The addition of a confidence element provides information that was previously unavailable to recipients of location information ๐ฅ. Without this information, a location server or generator that has access to location information with a confidence lower than 95% has two options:
- The location server can scale regions of uncertainty in an attempt to achieve 95% confidence. This scaling process significantly degrades the quality of the information, because the location server might not have the necessary information to scale appropriately. The location server is forced to make assumptions that are likely to result in either an overly conservative estimate with high uncertainty or an overestimate of confidence ๐.
- The location server can ignore the confidence entirely, which results in giving the recipient a false impression of its quality ๐.
Both of these choices degrade the quality of the information provided ๐ญ.
The addition of a confidence element avoids this problem entirely if a location recipient supports and understands the element ๐. A recipient that does not understand (and, hence, ignores) the confidence element is in no worse a position than if the location server ignored confidence.
4.1. The "confidence" Element ๐
The "confidence" element MAY be added to the "location-info" element of the PIDF-LO [RFC4119] document. This element expresses the confidence in the associated location information as a percentage. A special "unknown" value is reserved to indicate that confidence is supported, but not known to the Location Generator.
The "confidence" element optionally includes an attribute that indicates the shape of the PDF of the associated region of uncertainty. Three values are possible: unknown, normal, and rectangular.
Indicating a particular PDF only indicates that the distribution approximately fits the given shape, based on the methods used to generate the location information. The PDF is normal if there are a large number of small, independent sources of error. It is rectangular if all points within the area have roughly equal probability of being the actual location of the Target. Otherwise, the PDF MUST either be set to unknown or omitted. ๐ง
If a PIDF-LO does not include the confidence element, the confidence of the location estimate is 95%, as defined in [RFC5491] โจ.
A Point shape does not have uncertainty (or it has infinite uncertainty), so confidence is meaningless for a Point. Therefore, this element MUST be omitted if only a Point is provided ๐.
4.2. Generating Locations with Confidence ๐ธ
Location generators SHOULD attempt to ensure that confidence is equal in each dimension when generating location information. This restriction, while not always practical, allows for more accurate scaling, if scaling is necessary ๐ง.
A confidence element MUST be included with all location information that includes uncertainty (that is, all forms other than a Point). A special "unknown" is used if confidence is not known ๐ซถ.
4.3. Consuming and Presenting Confidence ๐
The inclusion of confidence that is anything other than 95% presents a potentially difficult usability problem for applications that use location information. Effectively communicating the probability that a location is incorrect to a user can be difficult ๐ตโ๐ซ.
It is inadvisable to simply display locations of any confidence, or to display confidence in a separate or non-obvious fashion. If locations with different confidence levels are displayed such that the distinction is subtle or easy to overlook (such as using fine graduations of color or transparency for graphical uncertainty regions, or displaying uncertainty graphically but providing confidence as supplementary text), a user could fail to notice a difference in the quality of the location information that might be significant ๐.
Depending on the circumstances, different ways of handling confidence might be appropriate. Section 5 describes techniques that could be appropriate for consumers that use automated processing ๐ค.
Providing that the full implications of any choice for the application are understood, some amount of automated processing could be appropriate. In a simple example, applications could choose to discard or suppress the display of location information if confidence does not meet a predetermined threshold ๐๏ธ.
In settings where there is an opportunity for user training, some of these problems might be mitigated by defining different operational procedures for handling location information at different confidence levels ๐.
5. Manipulation of Uncertainty ๐ฆ
This section deals with manipulation of location information that contains uncertainty.
The following rules generally apply when manipulating location information:
- Where calculations are performed on coordinate information, these should be performed in Cartesian space and the results converted back to latitude, longitude, and altitude. A method for converting to and from Cartesian coordinates is included in Appendix A.
While some approximation methods are useful in simplifying calculations, treating latitude and longitude as Cartesian axes is never advisable. The two axes are not orthogonal. Errors can arise from the curvature of the earth and from the convergence of longitude lines ๐.
- Normal rounding rules do not apply when rounding uncertainty. When rounding, the region of uncertainty always increases (that is, errors are rounded up) and confidence is always rounded down (see [NIST.TN1297]). This means that any manipulation of uncertainty is a non-reversible operation; each manipulation can result in the loss of some information ๐.
5.1. Reduction of a Location Estimate to a Point ๐
Manipulating location estimates that include uncertainty information requires additional complexity in systems. In some cases, systems only operate on definitive values, that is, a single point ๐ฏ.
This section describes algorithms for reducing location estimates to a simple form without uncertainty information. Having a consistent means for reducing location estimates allows for interaction between applications that are able to use uncertainty information and those that cannot ๐.
Note: Reduction of a location estimate to a point constitutes a reduction in information. Removing uncertainty information can degrade results in some applications. Also, there is a natural tendency to misinterpret a Point location as representing a location without uncertainty. This could lead to more serious errors. Therefore, these algorithms should only be applied where necessary. โ ๏ธ
Several different approaches can be taken when reducing a location estimate to a point. Different methods each make a set of assumptions about the properties of the PDF and the selected point; no one method is more "correct" than any other. For any given region of uncertainty, selecting an arbitrary point within the area could be considered valid. However, given the aforementioned problems with Point locations, a more rigorous approach is appropriate ๐ง.
Given a result with a known distribution, selecting the point within the area that has the highest probability is a more rigorous method. Alternatively, a point could be selected that minimizes the overall error; that is, it minimizes the expected value of the difference between the selected point and the "true" value.
If a rectangular distribution is assumed, the centroid of the area or volume minimizes the overall error. Minimizing the error for a normal distribution is mathematically complex. Therefore, this document opts to select the centroid of the region of uncertainty when selecting a point ๐ .
5.1.1. Centroid Calculation ๐
For regular shapes, such as Circle, Sphere, Ellipse, and Ellipsoid, this approach equates to the center point of the region. For regions of uncertainty that are expressed as regular Polygons and Prisms, the center point is also the most appropriate selection ๐ซ.
For the Arc-Band shape and non-regular Polygons and Prisms, selecting the centroid of the area or volume minimizes the overall error. This assumes that the PDF is rectangular.
Note: The centroid of a concave Polygon or Arc-Band shape is not necessarily within the region of uncertainty. ๐
5.1.1.1. Arc-Band Centroid ๐
The centroid of the Arc-Band shape is found along a line that bisects the arc. The centroid can be found at the following distance from the starting point of the arc-band (assuming an arc-band with an inner radius of "r", outer radius "R", start angle "a", and opening angle "o"):
d = 4 * sin(o/2) * (R*R + R*r + r*r) / (3*o*(R + r))
This point can be found along the line that bisects the arc; that is, the line at an angle of a + (o/2) ๐งโโ๏ธ.
5.1.1.2. Polygon Centroid โจ
okay so polygons and prisms are where centroid math gets spicy ๐ถ๏ธ. polygons defined with geodetic coordinates are not necessarily coplanar (they don't all sit on one flat plane ๐ญ). so for any polygon that doesn't have an altitude, pick a value for altitude before you start. an altitude of 0 is fine bestie ๐ซถ
The method described in this section is simplified by assuming that the surface of the earth is locally flat. This method degrades as polygons become larger; see [GeoShape] for recommendations on polygon size.
the trick is to translate the polygon into a new coordinate system whose x-y plane is roughly parallel to the polygon. then you can drop the z-axis values and calculate the centroid using only x and y ๐ . this only works if you know the upward normal for the polygon.
to translate the polygon coordinates, use the process in Appendix B to find the normal vector "N = [Nx,Ny,Nz]". make this a unit vector so the transformation matrix is a special orthogonal matrix ๐ฆ. then pick two vectors that are perpendicular to it and combine them into a transformation matrix.
if "Nx" and "Ny" are both non-zero, you can use the matrices in Figure 3, where "p = sqrt(Nx^2 + Ny^2)". there are more transformations later in this section for when "Nx" or "Ny" are zero ๐
[ -Ny/p Nx/p 0 ] [ -Ny/p -Nx*Nz/p Nx ]
T = [ -Nx*Nz/p -Ny*Nz/p p ] T' = [ Nx/p -Ny*Nz/p Ny ]
[ Nx Ny Nz ] [ 0 p Nz ]
(Transform) (Reverse Transform)
Figure 3: Recommended Transformation Matrices
to transform every point in the polygon, make a matrix out of the Cartesian Earth-Centered, Earth-Fixed (ECEF) coordinates and multiply it by the transform to get the translated coordinates โจ
[ -Ny/p Nx/p 0 ] [ x[1] x[2] x[3] ... x[n] ]
[ -Nx*Nz/p -Ny*Nz/p p ] * [ y[1] y[2] y[3] ... y[n] ]
[ Nx Ny Nz ] [ z[1] z[2] z[3] ... z[n] ]
[ x'[1] x'[2] x'[3] ... x'[n] ]
= [ y'[1] y'[2] y'[3] ... y'[n] ]
[ z'[1] z'[2] z'[3] ... z'[n] ]
Figure 4: Transformation
or you can skip the matrix and multiply directly, which gives the same result ๐ธ
x'[i] = -Ny * x[i] / p + Nx * y[i] / p
y'[i] = -Nx * Nz * x[i] / p - Ny * Nz * y[i] / p + p * z[i]
z'[i] = Nx * x[i] + Ny * y[i] + Nz * z[i]
the first and second rows ("x'" and "y'") are what you use to calculate the centroid of the polygon. first, find the area with:
A = sum from i=1..n of (x'[i]*y'[i+1]-x'[i+1]*y'[i]) / 2
for these formulae, treat each set of coordinates as circular, so "x'[0] == x'[n]" and "x'[n+1] == x'[1]" ๐. once you have the area, the centroid along each axis is:
Cx' = sum (x'[i]+x'[i+1]) * (x'[i]*y'[i+1]-x'[i+1]*y'[i]) / (6*A)
Cy' = sum (y'[i]+y'[i+1]) * (x'[i]*y'[i+1]-x'[i+1]*y'[i]) / (6*A)
Note: The formula for the area of a polygon will return a negative value if the polygon is specified in a clockwise direction. This can be used to determine the orientation of the polygon.
the third row is a distance from a plane parallel to the polygon. if the polygon is coplanar, the values for "z'" are all identical ๐. realistically though, the constraints recommended in [RFC5491] mean this is rarely the case, so to find "Cz'", you average them:
Cz' = sum z'[i] / n
once you know the centroid in the transformed coordinates, you can transform it back to the original coordinate system with the reverse transformation in Figure 5 ๐
[ -Ny/p -Nx*Nz/p Nx ] [ Cx' ] [ Cx ]
[ Nx/p -Ny*Nz/p Ny ] * [ Cy' ] = [ Cy ]
[ 0 p Nz ] [ sum of z'[i] / n ] [ Cz ]
Figure 5: Reverse Transformation
you can also apply the reverse transformation directly:
Cx = -Ny * Cx' / p - Nx * Nz * Cy' / p + Nx * Cz'
Cy = Nx * Cx' / p - Ny * Nz * Cy' / p + Ny * Cz'
Cz = p * Cy' + Nz * Cz'
the ECEF value "[Cx,Cy,Cz]" can then be converted back to geodetic coordinates. if a polygon is defined with no altitude, or with equal altitudes for each point, the altitude of the result can either be ignored or reset after converting back to a geodetic value ๐
for the Prism shape, find the centroid of the base polygon and raise that point by half the height of the prism. you can add this to the altitude of the final result, or add it to "Cz'" instead. adding it to "Cz'" makes sure a negative height is applied correctly for polygons defined in a clockwise direction ๐ง
the recommended transforms only apply if "Nx" and "Ny" are non-zero. if the normal vector is "[0,0,1]" (along the z-axis), you don't need a transform at all ๐. if the normal vector is "[0,1,0]" or "[1,0,0]", skip the transformation and use the x and z coordinates, or the y and z coordinates (respectively), in the centroid calculation. if either "Nx" or "Ny" is zero, you can use the alternative transform matrices in Figure 6. the reverse transform is the transpose of this matrix.
if Nx == 0: | if Ny == 0:
[ 0 -Nz Ny ] [ 0 1 0 ] | [ -Nz 0 Nx ]
T = [ 1 0 0 ] T' = [ -Nz 0 Ny ] | T = T' = [ 0 1 0 ]
[ 0 Ny Nz ] [ Ny 0 Nz ] | [ Nx 0 Nz ]
Figure 6: Alternative Transformation Matrices
5.2. Conversion to Circle or Sphere โญ
circles and spheres are simple shapes that suit a bunch of applications ๐. they hold fewer units of data, which makes operations on location estimates way easier to handle ๐
the simplest way to turn a location estimate into a Circle or Sphere is to find the centroid, then find the longest distance from it to any point in the region of uncertainty. how you measure that distance depends on the shape type:
- Circle/Sphere: No conversion necessary.
- Ellipse/Ellipsoid: The greater of either semi-major axis or altitude uncertainty.
- Polygon/Prism: The distance to the farthest vertex of the Polygon (for a Prism, it is only necessary to check points on the base).
- Arc-Band: The farthest length from the centroid to the points where the inner and outer arc end. This distance can be calculated by finding the larger of the two following formulae:
X = sqrt( d*d + R*R - 2*d*R*cos(o/2) )
x = sqrt( d*d + r*r - 2*d*r*cos(o/2) )
once you have the Circle or Sphere shape, the associated confidence can go up if the result is known to follow a normal distribution. ngl though, that's complicated and gives limited benefit ๐. it also often breaks the rule that confidence in each dimension be the same. so confidence should be left unchanged when you do this conversion ๐
two-dimensional shapes become a Circle, and three-dimensional shapes become a Sphere โจ
5.3. Conversion from Three-Dimensional to Two-Dimensional ๐
a three-dimensional shape is super easy to turn into a two-dimensional one: you just remove the altitude component ๐ฆ. a Sphere becomes a Circle, a Prism becomes a Polygon, and an Ellipsoid becomes an Ellipse. each conversion only needs those altitude-related elements taken out.
the altitude is unspecified for a two-dimensional shape, so it has unlimited uncertainty along the vertical axis. that means the confidence for the two-dimensional shape is higher than for the three-dimensional one ๐ญ. assuming equal confidence on each axis, you can increase the confidence of the Circle with this approximate formula:
C[2d] >= C[3d] ^ (2/3)
"C[2d]" is the confidence of the two-dimensional shape and "C[3d]" is the confidence of the three-dimensional shape. for example, a Sphere with a confidence of 95% can be simplified to a Circle of equal radius with a confidence of 96.6% ๐
5.4. Increasing and Decreasing Uncertainty and Confidence ๐
uncertainty and confidence together tell you a lot about the data being measured ๐ง . if you know the uncertainty, the confidence, and the PDF, you can extrapolate some info. in particular, the uncertainty can be scaled to hit a desired confidence, or the confidence for a particular region of uncertainty can be found.
in general, confidence goes down as the region of uncertainty gets smaller, and goes up as it gets bigger. but it depends on the PDF ๐. expanding the region of uncertainty for a rectangular distribution has no effect on confidence without extra information. and if the region of uncertainty gets increased during obfuscation (see [RFC6772]), the confidence cannot be increased.
a region of uncertainty that gets reduced in size always has a lower confidence ๐
a region of uncertainty with an unknown PDF shape can't be reduced reliably. it can be expanded, but only if confidence doesn't go up ๐ซถ
This section makes the simplifying assumption that location information is symmetrically and evenly distributed in each dimension. This is not necessarily true in practice. If better information is available, alternative methods might produce better results.
5.4.1. Rectangular Distributions ๐ฌ
uncertainty that follows a rectangular distribution can only be decreased in size ๐. increasing it has no value, since it has no effect on confidence. because the PDF is constant over the region of uncertainty, the resulting confidence comes from this formula:
Cr = Co * Ur / Uo
where "Uo" and "Ur" are the sizes of the original and reduced regions of uncertainty (either the area or the volume of the region), and "Co" and "Cr" are the confidence values associated with each region ๐ธ
heads up though: decreasing the region of uncertainty for a rectangular distribution loses information ๐ฌ. once it's reduced in size, the uncertainty region cannot be increased in size again ๐
5.4.2. Normal Distributions โจ
okay so normal distributions are a whole mood ๐ you can increase AND decrease uncertainty and confidence for them, and the math depends on how many dimensions the uncertainty region has ๐
for a normal distribution, uncertainty and confidence are tied to the standard deviation of the function. this is the relationship along a single axis ๐
S[x] = U[x] / ( sqrt(2) * erfinv(C[x]) )
where S[x] is the standard deviation, U[x] is the uncertainty, and C[x] is the confidence along a single axis. erfinv is the inverse error function ๐ง
scaling a normal distribution in two dimensions takes a few assumptions ๐ซถ first, the distribution along each axis is independent. second, the confidence for each axis is assumed to be the same. so the confidence along each axis can be assumed to be:
C[x] = Co ^ (1/n)
where C[x] is the confidence along a single axis, Co is the overall confidence, and n is the number of dimensions in the uncertainty.
so to find the uncertainty for each axis at a desired confidence, Cd, apply this formula ๐ฆ
Ud[x] <= U[x] * (erfinv(Cd ^ (1/n)) / erfinv(Co ^ (1/n)))
for regular shapes, this formula can be applied as a scaling factor in each dimension to reach a required confidence ๐
5.5. Determining Whether a Location Is within a Given Region ๐ฆ
a bunch of applications need to decide whether a Target is inside a given region of interest ๐ and with a location estimate that has uncertainty, that judgment can be kinda tricky. a location estimate represents a probability distribution, and the true location of the Target can never be definitively known. so the judgment actually relies on figuring out the probability that the Target is within the region ๐ธ
the probability that the Target is within a particular region is found by integrating the PDF over that region. for a normal distribution, there are no analytical methods that can find the integral of the two- or three-dimensional PDF over an arbitrary region ๐ญ the numerical methods are also too complex to be useful in many applications. for example, finding the integral of the PDF in two or three dimensions across the overlap between the uncertainty region and the target region is a lot. if the PDF is unknown, no determination can be made without a simplifying assumption ๐
so when judging whether a location is within a given region, this document assumes that uncertainties are rectangular. yes, this introduces errors, but it simplifies the calculations significantly โจ before applying this assumption, confidence should be scaled to 95%.
Note: The selection of confidence has a significant impact on the final result. Only use a different confidence if an uncertainty value for 95% confidence cannot be found.
given the rectangular distribution assumption, the probability that a Target is found within a given region is found by first finding the area (or volume) of overlap between the uncertainty region and the region of interest. you then multiply that by the confidence of the location estimate to get the probability ๐ฅ figure 7 shows an example of finding the area of overlap between the region of uncertainty and the region of interest ๐
_.-""""-._
.' `. _ Region of
/ \ / Uncertainty
..+-"""--.. |
.-' | :::::: `-. |
,' | :: Ao ::: `. |
/ \ :::::::::: \ /
/ `._ :::::: _.X
| `-....-' |
| |
| |
\ /
`. .' \_ Region of
`._ _.' Interest
`--..___..--'
Figure 7: Area of Overlap between Two Circular Regions
once the area of overlap, Ao, is known, the probability that the Target is within the region of interest, Pi, is ๐
Pi = Co * Ao / Au
given that the area of the region of uncertainty is Au and the confidence is Co.
this probability is often fed into a decision process that has a limited set of outcomes, so a threshold value needs to be selected ๐ depending on the application, different threshold probabilities might be picked. a probability of 50% or greater is recommended before deciding that an uncertain value is within a given region. if the decision process selects between two or more regions, as is required by [RFC5222], then the region with the highest probability can be selected ๐ซถ
5.5.1. Determining the Area of Overlap for Two Circles ๐
figuring out the area of overlap between two arbitrary shapes is a non-trivial process ๐ but reducing areas to circles (see Section 5.2) lets you use the following process, which is way easier ๐ฆ
given the radius of the first circle r, the radius of the second circle R, and the distance between their center points d, the following set of formulae gives you the area of overlap Ao.
- If the circles don't overlap, that is
d >= r+R,Aois zero. - If one of the two circles is entirely within the other, that is
d <= |r-R|, the area of overlap is the area of the smaller circle. - Otherwise, if the circles partially overlap, that is
d < r+Randd > |r-R|, findAousing:
a = (r^2 - R^2 + d^2)/(2*d)
Ao = r^2*acos(a/r) + R^2*acos((d - a)/R) - d*sqrt(r^2 - a^2)
a value for d can be determined by converting the center points to Cartesian coordinates and calculating the distance between the two center points ๐
d = sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)
5.5.2. Determining the Area of Overlap for Two Polygons ๐
a calculation of overlap based on polygons can give better results than the circle-based method ๐ however, efficiently calculating the overlapping area is non-trivial. algorithms such as Vatti's clipping algorithm [Vatti92] can be used ๐ง
for large polygonal areas, geodesic interpolation might be used. in these cases, altitude is also frequently omitted when describing the polygon ๐ธ for such shapes, a planar projection can still give a good approximation of the area of overlap if the larger area polygon is projected onto the local tangent plane of the smaller one. this only works if the only area of interest is the area contained within the smaller polygon. where the entire area of the larger polygon is of interest, geodesic interpolation is necessary โจ
6. Examples ๐ง
this section presents some examples of how to apply the methods described in Section 5 ๐
6.1. Reduction to a Point or Circle
okay so Alice gets a location estimate from her Location Information Server (LIS) that has an ellipsoidal region of uncertainty ๐ this info comes at 19% confidence with a normal PDF. a PIDF-LO extract for it is shown in Figure 8 ๐
<gp:geopriv>
<gp:location-info>
<gs:Ellipsoid srsName="urn:ogc:def:crs:EPSG::4979">
<gml:pos>-34.407242 150.882518 34</gml:pos>
<gs:semiMajorAxis uom="urn:ogc:def:uom:EPSG::9001">
7.7156
</gs:semiMajorAxis>
<gs:semiMinorAxis uom="urn:ogc:def:uom:EPSG::9001">
3.31
</gs:semiMinorAxis>
<gs:verticalAxis uom="urn:ogc:def:uom:EPSG::9001">
28.7
</gs:verticalAxis>
<gs:orientation uom="urn:ogc:def:uom:EPSG::9102">
43
</gs:orientation>
</gs:Ellipsoid>
<con:confidence pdf="normal">95</con:confidence>
</gp:location-info>
<gp:usage-rules/>
</gp:geopriv>
Figure 8: Alice's Ellipsoid Location
this info can be reduced to a point just by pulling out the center point, which is [-34.407242, 150.882518, 34] ๐ธ
if some limited uncertainty is needed, the estimate can be converted into a circle or sphere ๐ฆ to convert to a sphere, the radius is the largest of the semi-major, semi-minor and vertical axes. in this case, that's 28.7 meters โจ
but if only a circle is required, the altitude can be dropped, and so can the altitude uncertainty (the vertical axis of the ellipsoid). that gives you a circle at [-34.407242, 150.882518] with a radius of 7.7156 meters ๐
Bob gets a location estimate with a Polygon shape (which roughly matches the location of the Sydney Opera House ๐). this info is shown in Figure 9 ๐
<gml:Polygon srsName="urn:ogc:def:crs:EPSG::4326">
<gml:exterior>
<gml:LinearRing>
<gml:posList>
-33.856625 151.215906 -33.856299 151.215343
-33.856326 151.214731 -33.857533 151.214495
-33.857720 151.214613 -33.857369 151.215375
-33.856625 151.215906
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
Figure 9: Bob's Polygon Location
to convert this to a polygon, each point is first assigned an altitude of zero and converted to ECEF coordinates (see Appendix A) ๐ง then, a normal vector for this polygon is found (see Appendix B). the result of each of these stages is shown in Figure 10 ๐ note that the numbers shown in this document are rounded only for formatting reasons. the actual calculations don't include rounding, because that would generate significant errors in the final values ๐ญ
Polygon in ECEF coordinate space
(repeated point omitted and transposed to fit):
[ -4.6470e+06 2.5530e+06 -3.5333e+06 ]
[ -4.6470e+06 2.5531e+06 -3.5332e+06 ]
pecef = [ -4.6470e+06 2.5531e+06 -3.5332e+06 ]
[ -4.6469e+06 2.5531e+06 -3.5333e+06 ]
[ -4.6469e+06 2.5531e+06 -3.5334e+06 ]
[ -4.6469e+06 2.5531e+06 -3.5333e+06 ]
Normal Vector: n = [ -0.72782 0.39987 -0.55712 ]
Transformation Matrix:
[ -0.48152 -0.87643 0.00000 ]
t = [ -0.48828 0.26827 0.83043 ]
[ -0.72782 0.39987 -0.55712 ]
Transformed Coordinates:
[ 8.3206e+01 1.9809e+04 6.3715e+06 ]
[ 3.1107e+01 1.9845e+04 6.3715e+06 ]
pecef' = [ -2.5528e+01 1.9842e+04 6.3715e+06 ]
[ -4.7367e+01 1.9708e+04 6.3715e+06 ]
[ -3.6447e+01 1.9687e+04 6.3715e+06 ]
[ 3.4068e+01 1.9726e+04 6.3715e+06 ]
Two dimensional polygon area: A = 12600 m^2
Two-dimensional polygon centroid: C' = [ 8.8184e+00 1.9775e+04 ]
Average of pecef' z coordinates: 6.3715e+06
Reverse Transformation Matrix:
[ -0.48152 -0.48828 -0.72782 ]
t' = [ -0.87643 0.26827 0.39987 ]
[ 0.00000 0.83043 -0.55712 ]
Polygon centroid (ECEF): C = [ -4.6470e+06 2.5531e+06 -3.5333e+06 ]
Polygon centroid (Geo): Cg = [ -33.856926 151.215102 -4.9537e-04 ]
Figure 10: Calculation of Polygon Centroid
the point conversion for the polygon uses the final result, Cg, and ignores the altitude since the original shape didn't include altitude ๐
to convert this to a circle, take the maximum distance in ECEF coordinates from the center point to each of the points. that gives you a radius of 99.1 meters. confidence is unchanged ๐ซถ
6.2. Increasing and Decreasing Confidence ๐
Okay so, assume the confidence for Alice's location info is 19%. That's a super typical number for a 3D ellipsoid uncertainty where the normal distribution's standard deviation is used directly for uncertainty in each dimension ๐ซถ. Honestly, 19% is pretty low for a lot of apps ๐ญ. Since the estimate follows a normal distribution, we can use the method from Section 5.4.2 โจ. Each axis gets scaled by:
scale = erfinv(0.95^(1/3)) / erfinv(0.19^(1/3)) = 2.9937
Rounding always goes in the direction that increases uncertainty, so the location estimate at 95% has a semi-major axis of 23.1, a semi-minor axis of 10, and a vertical axis of 86 ๐ฅ.
Now Bob ๐ง. His location estimate from the previous example covers about 12600 square meters. If the estimate follows a rectangular distribution, we can shrink the region of uncertainty. Here we figure out the confidence that Bob is inside the smaller area of the Concert Hall ๐. For the Concert Hall, we use the polygon [-33.856473, 151.215257; -33.856322, 151.214973; -33.856424, 151.21471; -33.857248, 151.214753; -33.857413, 151.214941; -33.857311, 151.215128]. To work with this new region, we find its area using the same translation method from Section 5.1.1.2, and it comes out to 4566.2 square meters. The Concert Hall is completely inside Bob's original estimate, so the confidence for the smaller area is 95% * 4566.2 / 12600 = 34%. Main character energy for that smaller region ๐.
6.3. Matching Location Estimates to Regions of Interest ๐ฆ
Say we define a circular area centered at [-33.872754, 151.20683] with a radius of 1950 meters. To figure out whether Bob is inside it, given that Bob is at [-34.407242, 150.882518] with an uncertainty radius of 7.7156 meters, we apply the method from Section 5.5 ๐. Using the converted Circle shape for Bob's location, the distance between the points is 1915.26 meters. The area of overlap between Bob's location estimate and the region of interest is therefore 2209 square meters, and the area of Bob's location estimate is 30853 square meters. So the estimated probability that Bob is less than 1950 meters from the selected point is 67.8% โจ.
Note that if we pick 1920 meters for the distance from the selected point instead, the area of overlap drops to 16196 square meters and the confidence is 49.8%. So it's marginally more likely that Bob is outside the region of interest, even though the center point of his location estimate is inside it ๐ญ. Lowkey wild.
6.4. PIDF-LO with Confidence Example ๐
The PIDF-LO document in Figure 11 represents uncertainty as a circular area ๐. The confidence element (on the line marked with a comment) says the confidence is 67% and that it follows a normal distribution.
<pidf:presence
xmlns:pidf="urn:ietf:params:xml:ns:pidf"
xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
xmlns:gs="http://www.opengis.net/pidflo/1.0"
xmlns:gml="http://www.opengis.net/gml"
xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
entity="pres:alice@example.com">
<dm:device id="sg89ab">
<gp:geopriv>
<gp:location-info>
<gs:Circle srsName="urn:ogc:def:crs:EPSG::4326">
<gml:pos>42.5463 -73.2512</gml:pos>
<gs:radius uom="urn:ogc:def:uom:EPSG::9001">
850.24
</gs:radius>
</gs:Circle>
<!--c--> <con:confidence pdf="normal">67</con:confidence>
</gp:location-info>
<gp:usage-rules/>
</gp:geopriv>
<dm:deviceID>mac:010203040506</dm:deviceID>
</dm:device>
</pidf:presence>
Figure 11: Example PIDF-LO with Confidence
7. Confidence Schema โจ
Here's the schema for the confidence element ๐:
<?xml version="1.0"?>
<xs:schema
xmlns:conf="urn:ietf:params:xml:ns:geopriv:conf"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:ietf:params:xml:ns:geopriv:conf"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:annotation>
<xs:appinfo
source="urn:ietf:params:xml:schema:geopriv:conf">
PIDF-LO Confidence
</xs:appinfo>
<xs:documentation
source="http://www.rfc-editor.org/rfc/rfc7459.txt">
This schema defines an element that is used for indicating
confidence in PIDF-LO documents.
</xs:documentation>
</xs:annotation>
<xs:element name="confidence" type="conf:confidenceType"/>
<xs:complexType name="confidenceType">
<xs:simpleContent>
<xs:extension base="conf:confidenceBase">
<xs:attribute name="pdf" type="conf:pdfType"
default="unknown"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="confidenceBase">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0.0"/>
<xs:maxExclusive value="100.0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="unknown"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="pdfType">
<xs:restriction base="xs:token">
<xs:enumeration value="unknown"/>
<xs:enumeration value="normal"/>
<xs:enumeration value="rectangular"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
8. IANA Considerations ๐
8.1. URN Sub-Namespace Registration for urn:ietf:params:xml:ns:geopriv:conf ๐ธ
A new XML namespace, "urn:ietf:params:xml:ns:geopriv:conf", has been registered, as per the guidelines in [RFC3688].
- URI:
urn:ietf:params:xml:ns:geopriv:conf - Registrant Contact: IETF GEOPRIV working group (geopriv@ietf.org), Martin Thomson (martin.thomson@gmail.com).
- XML:
BEGIN
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>PIDF-LO Confidence Attribute</title>
</head>
<body>
<h1>Namespace for PIDF-LO Confidence Attribute</h1>
<h2>urn:ietf:params:xml:ns:geopriv:conf</h2>
<p>See <a href="http://www.rfc-editor.org/rfc/rfc7459.txt">
RFC 7459</a>.</p>
</body>
</html>
END
8.2. XML Schema Registration ๐ฆ
An XML schema has been registered, as per the guidelines in [RFC3688].
- URI:
urn:ietf:params:xml:schema:geopriv:conf - Registrant Contact: IETF GEOPRIV working group (geopriv@ietf.org), Martin Thomson (martin.thomson@gmail.com).
- Schema: The XML for this schema can be found as the entirety of Section 7 of this document.
9. Security Considerations ๐จ
This part is serious, bestie. Read it carefully ๐ญ.
This document describes methods for managing and manipulating uncertainty in location. No specific security concerns arise from most of the information provided. The considerations of [RFC4119] all apply.
A thorough treatment of the privacy implications of describing location information is discussed in [RFC6280]. Including uncertainty information increases the amount of information available, and altering uncertainty is not an effective privacy mechanism ๐.
Providing uncertainty and confidence information can reveal information about the process by which location information is generated. For instance, it might reveal information that could be used to infer that a user is using a mobile device with a GPS, or that a user is acquiring location information from a particular network-based service. A Rule Maker might choose to remove uncertainty-related fields from a location object in order to protect this information. Note, however, that information might not be perfectly protected due to difficulties associated with location obfuscation, as described in Section 13.5 of [RFC6772]. In particular, increasing uncertainty does not necessarily result in a reduction of the information conveyed by the location object ๐.
Adding confidence to location information risks misinterpretation by consumers of location that do not understand the element. This could be exploited, particularly when reducing confidence, since the resulting uncertainty region might include locations that are less likely to contain the Target than the recipient expects. Since this sort of error is always a possibility, the impact of this is low ๐ซถ.
10. References ๐
10.1. Normative References ๐ฅ
- [RFC2119]: Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>. - [RFC3688]: Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, January 2004,
<http://www.rfc-editor.org/info/rfc3688>. - [RFC3693]: Cuellar, J., Morris, J., Mulligan, D., Peterson, J., and J. Polk, "Geopriv Requirements", RFC 3693, February 2004,
<http://www.rfc-editor.org/info/rfc3693>. - [RFC4119]: Peterson, J., "A Presence-based GEOPRIV Location Object Format", RFC 4119, December 2005,
<http://www.rfc-editor.org/info/rfc4119>. - [RFC5139]: Thomson, M. and J. Winterbottom, "Revised Civic Location Format for Presence Information Data Format Location Object (PIDF-LO)", RFC 5139, February 2008,
<http://www.rfc-editor.org/info/rfc5139>. - [RFC5491]: Winterbottom, J., Thomson, M., and H. Tschofenig, "GEOPRIV Presence Information Data Format Location Object (PIDF-LO) Usage Clarification, Considerations, and Recommendations", RFC 5491, March 2009,
<http://www.rfc-editor.org/info/rfc5491>. - [RFC6225]: Polk, J., Linsner, M., Thomson, M., and B. Aboba, Ed., "Dynamic Host Configuration Protocol Options for Coordinate-Based Location Configuration Information", RFC 6225, July 2011,
<http://www.rfc-editor.org/info/rfc6225>. - [RFC6280]: Barnes, R., Lepinski, M., Cooper, A., Morris, J., Tschofenig, H., and H. Schulzrinne, "An Architecture for Location and Location Privacy in Internet Applications", BCP 160, RFC 6280, July 2011,
<http://www.rfc-editor.org/info/rfc6280>.
10.2. Informative References โจ
Here are the bonus reads, the ones that aren't strictly required but are seriously worth bookmarking ๐
- [Convert] Burtch, R., "A Comparison of Methods Used in Rectangular to Geodetic Coordinate Transformations", April 2006.
- [GeoShape] Thomson, M. and C. Reed, "GML 3.1.1 PIDF-LO Shape Application Schema for use by the Internet Engineering Task Force (IETF)", Candidate OpenGIS Implementation Specification 06-142r1, Version: 1.0, April 2007.
- [ISO.GUM] ISO/IEC, "Guide to the expression of uncertainty in measurement (GUM)", Guide 98:1995, 1995.
- [NIST.TN1297] Taylor, B. and C. Kuyatt, "Guidelines for Evaluating and Expressing the Uncertainty of NIST Measurement Results", Technical Note 1297, September 1994.
- [RFC5222] Hardie, T., Newton, A., Schulzrinne, H., and H. Tschofenig, "LoST: A Location-to-Service Translation Protocol", RFC 5222, August 2008,
http://www.rfc-editor.org/info/rfc5222. - [RFC6772] Schulzrinne, H., Ed., Tschofenig, H., Ed., Cuellar, J., Polk, J., Morris, J., and M. Thomson, "Geolocation Policy: A Document Format for Expressing Privacy Preferences for Location Information", RFC 6772, January 2013,
http://www.rfc-editor.org/info/rfc6772. - [Sunday02] Sunday, D., "Fast polygon area and Newell normal computation", Journal of Graphics Tools JGT, 7(2):9-13, 2002.
- [TS-3GPP-23_032] 3GPP, "Universal Geographical Area Description (GAD)", 3GPP TS 23.032 12.0.0, September 2014.
- [Vatti92] Vatti, B., "A generic solution to polygon clipping", Communications of the ACM Volume 35, Issue 7, pages 56-63, July 1992,
http://portal.acm.org/citation.cfm?id=129906. - [WGS84] US National Imagery and Mapping Agency, "Department of Defense (DoD) World Geodetic System 1984 (WGS 84), Third Edition", NIMA TR8350.2, January 2000.
Appendix A. Conversion between Cartesian and Geodetic Coordinates in WGS84 ๐
Going from geodetic coordinates (latitude, longitude, and altitude) to ECEF Cartesian coordinates is the easy direction, bestie ๐
This appendix uses the following constants and derived values from the definition of WGS84 [WGS84]:
{radius of ellipsoid} R = 6378137 meters
{inverse flattening} 1/f = 298.257223563
{first eccentricity squared} e^2 = f * (2 - f)
{second eccentricity squared} e'^2 = e^2 * (1 - e^2)
To convert geodetic coordinates (latitude, longitude, altitude) to ECEF coordinates (X, Y, Z), use these relationships:
N = R / sqrt(1 - e^2 * sin(latitude)^2)
X = (N + altitude) * cos(latitude) * cos(longitude)
Y = (N + altitude) * cos(latitude) * sin(longitude)
Z = (N*(1 - e^2) + altitude) * sin(latitude)
The reverse conversion is where things get messy ๐ญ Most methods introduce some error in latitude and altitude. You can find a range of techniques in [Convert]. A variant of the method originally proposed by Bowring gives an acceptably small error, and it looks like this:
p = sqrt(X^2 + Y^2)
r = sqrt(X^2 + Y^2 + Z^2)
u = atan((1-f) * Z * (1 + e'^2 * (1-f) * R / r) / p)
latitude = atan((Z + e'^2 * (1-f) * R * sin(u)^3)
/ (p - e^2 * R * cos(u)^3))
longitude = atan2(Y, X)
altitude = sqrt((p - R * cos(u))^2 + (Z - (1-f) * R * sin(u))^2)
Heads up for anyone near the poles: if "p < 1", the altitude this method produces is unstable ๐ For a point in that spot, a simpler method for determining altitude is:
altitude = |Z| - R * (1 - f)
Appendix B. Calculating the Upward Normal of a Polygon ๐บ
For a polygon that is guaranteed to be convex and coplanar, you can find the upward normal by taking the vector cross product of adjacent edges.
For more general cases, you can use the Newell method of approximation described in [Sunday02]. This method works even when the points are only approximately coplanar, and it also handles non-convex polygons. Iconic ๐
This process needs a Cartesian coordinate system, so first convert the geodetic coordinates of the polygon to Cartesian ECEF coordinates (Appendix A). If no altitude is specified, assume an altitude of zero.
The method condenses down to this set of equations:
Nx = sum from i=1..n of (y[i] * (z[i+1] - z[i-1]))
Ny = sum from i=1..n of (z[i] * (x[i+1] - x[i-1]))
Nz = sum from i=1..n of (x[i] * (y[i+1] - y[i-1]))
In these formulae, the polygon is made of points "(x[1], y[1], z[1])" through "(x[n], y[n], x[n])". Each array is treated as circular, meaning "x[0] == x[n]" and "x[n+1] == x[1]" ๐
To turn this into a unit vector, divide each component by the length of the vector:
Nx' = Nx / sqrt(Nx^2 + Ny^2 + Nz^2)
Ny' = Ny / sqrt(Nx^2 + Ny^2 + Nz^2)
Nz' = Nz / sqrt(Nx^2 + Ny^2 + Nz^2)
B.1. Checking That a Polygon Upward Normal Points Up ๐งญ
[RFC5491] stipulates that the Polygon shape be presented in counterclockwise direction, so that the upward normal points in an upward direction. Accidentally reversing the points can flip this vector, and that error is sneaky. It's hard to spot just by looking at the series of coordinates that form the polygon ๐ฌ
Here's the check: calculate the dot product of the polygon's upward normal (Appendix B) and any vector that points away from the center of the earth from the location of the polygon. If this product is positive, the polygon's upward normal also points away from the center of the earth.
The inverse cosine of this value gives the angle between the horizontal plane and the approximate plane of the polygon.
A unit vector for the upward direction at any point can be found from the latitude (lat) and longitude (lng) of that point, like so:
Up = [ cos(lat) * cos(lng) ; cos(lat) * sin(lng) ; sin(lat) ]
For polygons that span less than half the globe, any point in the polygon, including the centroid, can be selected to generate an approximate up vector for comparison with the upward normal ๐ธ
Acknowledgements ๐ซถ
Peter Rhodes helped with some of the mathematical groundwork on this document. Dan Cornford gave a detailed review and many terminology corrections, which is the real MVP energy ๐
Authors' Addresses ๐
Martin Thomson Mozilla 331 E Evelyn Street Mountain View, CA 94041 United States
EMail: martin.thomson@gmail.com
James Winterbottom Unaffiliated Australia
EMail: a.james.winterbottom@gmail.com
๐ฆ where this page comes from
- ietf: rfc7459 2015-02
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms