<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Location Query</title>
  <abstract>This specification defines an XMPP protocol extension for querying a compliant server or service for information about the geographical or physical location of an entity.</abstract>
  &LEGALNOTICE;
  <number>0255</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  <author>
    <firstname>Helge</firstname>
    <surname>Timenes</surname>
    <email>helge@buddycloud.com</email>
    <jid>helge@buddycloud.com</jid>
  </author>
  <author>
    <firstname>Simon</firstname>
    <surname>Tennant</surname>
    <email>simon@buddycloud.com</email>
    <jid>simon@buddycloud.com</jid>
  </author>
  <author>
    <firstname>Ross</firstname>
    <surname>Savage</surname>
    <email>ross@buddycloud.com</email>
    <jid>ross@buddycloud.com</jid>
  </author>
  <revision>
    <version>0.6</version>
    <date>2009-04-09</date>
    <initials>psa</initials>
    <remark><p>Defined registry; added nic type from list discussion.</p></remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2009-03-13</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Added example with IP address</li>
        <li>Corrected closing &lt;/iq&gt; tags in examples</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2009-02-17</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Added IP address to the type of beacons</li>
        <li>Changed the nomenclature from 'beacons' to 'references' as they may not always be active transmitters (as in the case of IP address)</li>
        <li>Corrected &lt;latitude/&gt; and &lt;longitude/&gt; and tags in example 1 to &lt;lat/&gt; and &lt;lon/&gt;</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2008-12-20</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Corrected name-space in section 10.1.</li>
        <li>Removed extra 's in example 7 </li>
        <li>Made time-stamp optional</li>
        <li>Added optional time-stamp to beacon element</li>
        <li>Added comment reflecting that query time-stamp applies to GPS coordinates if beacons provide own time-stamps</li>
        <li>Updated schema to reflect changes.</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2008-12-17</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Updated examples to be conform with XEP-0080 (use lat and lon instead of latitude and longitude).</li>
        <li>Fixed wrong closing tag for &lt;type&gt; in examples.</li>
        <li>Added signal strength to beacon data.</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2008-11-13</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2008-11-07</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Removed &lt;error/&gt; child of geoloc element (arc minutes).</li>
        <li>Added &lt;accuracy/&gt; (meters).</li>
        <li>Updated notes on GPS data submitted in location query.</li>
        <li>Replaced language encoding 'en-UK' with 'en-US' to avoid UK/GB confusion.</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2008-11-03</date>
    <initials>ht</initials>
    <remark>
      <ul>
        <li>Corrected XML namespace.</li>
        <li>Added country code reference.</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2008-10-28</date>
    <initials>ht/st/rs</initials>
    <remark><p>First draft.</p></remark>
  </revision>

</header>

<section1 topic='Introduction' anchor='intro'>
  <p>This document defines a format for querying a location server for information about an entity's geographical location.  The query must contain some location characteristics that the server can process to derive this information. These can be in the form of geodetic coordinates (from GPS receivers or other positioning equipment), in which case the server will perform "reversed geocoding" to derive the information. Alternatively, the location can be characterized by a geographically assigned IP address or a list of cellular telephone towers, wireless network access points, Bluetooth devices, RFID tags, network addresses, or other information observable from this location (from here on called 'location references', or just 'references'). In this case the location server must match the supplied characteristics with stored knowledge about the location references to derive the submitting entity's location.  Client implementers are encouraged to supply both kinds of characteristics when available, as this can be utilized by self-learning location servers. The location information returned by the location server is structured according to &xep0080;, ensuring compatibility with systems using this standard for location information publishing.</p>
  <p>The location query is designed to be used as a one-shot request or as a continuous query-result dialogue. The latter form will allow location servers to analyze changes with time, which in most cases yields improved fidelity and the possibility to derive motion state information.</p>
</section1>

<section1 topic='Requirements' anchor='reqs'>
  <p>The format defined herein was designed to address the following requirements:</p>
  <ul>

   <li>It shall be usable on devices with no support for GPS or other geodetic positioning systems</li>
   <li>It shall be usable on devices with support for GPS or other geodetic positioning systems</li>
   <li>It shall be compatible with place-referencing systems</li>
   <li>It shall support self-learning location servers</li>
   <li>The result format shall be expressed as natural language location description</li>
   <li>The result format shall be compatible with XEP-0080</li>

</ul>
</section1>

<section1 topic='How It Works' anchor='examples'>
  <p>The basic principle behind this XMPP extension is as follows: An XMPP clients collects characteristics about its current location that is not directly suitable for presentation to a human user, but from which human readable location information can be derived. The client sends this information to a location server that derives this information and returns it to the querying client. Here "location server" means a XMPP server application that supports the &lt;locationquery/&gt; payload defined in this document. It can either be an integral part of the XMPP server, or run as a component on the same or a different machine from the XMPP server itself.</p>

  <example caption='Entity queries server with GPS coordinates'><![CDATA[
<iq from='hamlet@shakespeare.lit/phone' 
    id='q01' 
    to='location.shakespear.lit' 
    type='get' 
    xml:lang='en-US'>
  <locationquery xmlns='urn:xmpp:locationquery:0'>
    <lat>57.0501862</lat>
    <lon>9.9188746</lon>
    <accuracy>35.6</accuracy>
  </locationquery>
</iq>
  ]]></example>

  <example caption='Server responds with location info'><![CDATA[
<iq from='location.shakespeare.lit' 
    id='q01' 
    to='hamlet@shakespeare.lit/phone' 
    type='result' 
    xml:lang='en-US'>
  <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
    <timestamp>1599-10-23T01:56:05Z</timestamp>
    <lat>57.0501862</lat>
    <lon>9.9188746</lon>
    <accuracy>35.6</accuracy>
    <street>Jomfru Ane Gade 13</street>
    <locality>Aalborg</locality>
    <country>Denmark</country>
    <uri>http://shakespeare.lit/places/kings_head_pub_aalborg</uri>
    <text>Near King's Head Pub</text>
  </geoloc>
</iq>
  ]]></example>

  <example caption='Entity queries server with IP address'><![CDATA[
<iq from='hamlet@shakespeare.lit/phone' 
    id='q02' 
    to='location.shakespear.lit' 
    type='get' 
    xml:lang='en-US'>
  <locationquery xmlns='urn:xmpp:locationquery:0'>
    <reference>
      <id>80.2.47.198</id>
      <type>ip</type>
    </reference>
  </locationquery>
</iq>
  ]]></example>

  <example caption='Server responds with location info'><![CDATA[
<iq from='location.shakespeare.lit' 
    id='q02' 
    to='hamlet@shakespeare.lit/phone' 
    type='result' 
    xml:lang='en-US'>
  <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
    <timestamp>1599-10-23T01:56:05Z</timestamp>
    <lat>56.8</lat>
    <lon>9.9</lon>
    <accuracy>100000</accuracy>
    <locality>Aalborg</locality>
    <country>Denmark</country>
  </geoloc>
</iq>
  ]]></example>

  <example caption='Entity queries server with cell tower and wifi access point IDs'><![CDATA[
<iq from='hamlet@shakespeare.lit/phone' 
    id='q03' 
    to='location.shakespear.lit' 
    type='get' 
    xml:lang='en-US'>
  <locationquery xmlns='urn:xmpp:locationquery:0'>
    <reference>
      <id>238:02:34775:50880</id>
      <type>cell</type>
    </reference>
    <reference>
      <id>00:0F:3D:42:92:2A</id>
      <type>wifi</type>
    </reference>
    <reference>
      <id>00:19:CB:45:50:4A</id>
      <type>wifi</type>
    </reference>
  </locationquery>
</iq>
  ]]></example>

  <example caption='Server responds with location info'><![CDATA[
<iq from='location.shakespeare.lit' 
    id='q03' 
    to='hamlet@shakespeare.lit/phone' 
    type='result' 
    xml:lang='en-US'>
  <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
    <timestamp>1599-10-23T01:56:05Z</timestamp>
    <lat>57.050122</lat>
    <lon>9.918833</lon>
    <locality>Aalborg</locality>
    <street>Jomfru Ane Gade 13</street>
    <country>Denmark</country>
    <accuracy>20</accuracy>
    <uri>http://shakespeare.lit/places/kings_head_pub_aalborg</uri>
    <text>King's Head Pub</text>
  </geoloc>
</iq>
  ]]></example>

  <example caption='Entity queries server with reference info from multiple cell tower and wifi accespoint scans and specifies that results should be published'><![CDATA[
<iq from='hamlet@shakespeare.lit/phone' 
    id='q04' 
    to='location.shakespear.lit' 
    type='get' 
    xml:lang='en-US'>
  <locationquery xmlns='urn:xmpp:locationquery:0'>
    <timestamp>1599-10-23T01:55:21Z</timestamp>
    <lat>57.0501862</lat>
    <lon>9.918874</lon>
    <accuracy>33.56</accuracy>
    <publish>true</publish>
    <reference>
      <id>238:02:34775:50880</id>
      <type>cell</type>
      <signalstrength>-88</signalstrength>
      <timestamp>1599-10-23T01:55:21Z</timestamp>
    </reference>
    <reference>
      <id>238:02:34775:48770</id>
      <type>cell</type>
      <signalstrength>-76</signalstrength>
      <timestamp>1599-10-23T01:52:34Z</timestamp>
    </reference>
    <reference>
      <id>00:0F:3D:42:92:2A</id>
      <type>wifi</type>
      <signalstrength>-64</signalstrength>
      <timestamp>1599-10-23T01:55:21Z</timestamp>
    </reference>
    <reference>
      <id>238:02:34775:50880</id>
      <type>cell</type>
      <signalstrength>-88</signalstrength>
      <timestamp>1599-10-23T01:55:21Z</timestamp>
    </reference>
    <reference>
      <id>00:19:CB:45:50:4A</id>
      <type>wifi</type>
      <signalstrength>-82</signalstrength>
      <timestamp>1599-10-23T01:52:24Z</timestamp>
    </reference>
    <reference>
      <id>00:18:42:E6:71:51</id>
      <type>bluetooth</type>
    </reference>
  </locationquery>
</iq>
  ]]></example>

  <example caption='Server responds with empty IQ-result...'><![CDATA[
<iq from='location.shakespeare.lit' 
    id='q04' 
    to='hamlet@shakespeare.lit/phone' 
    type='result' 
    xml:lang='en-US' />
  ]]></example>

  <example caption='...and publishes result to the entity&apos;s geoloc pubsub node...'><![CDATA[
<iq from='hamlet@shakespeare.lit/phone' 
    id='q04' 
    to='hamlet@shakespeare.lit/phone' 
    type='set' 
    xml:lang='en-US'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish>
      <node xmlns='http://jabber.org/protocol/geoloc'>
        <item>
          <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
            <timestamp>1599-10-23T01:56:05Z</timestamp>
            <lat>57.0501862</lat>
            <lon>9.918874</lon>
            <street>Jomfru Ane Gade 13</street>
            <locality>Aalborg</locality>
            <country>Denmark</country>
            <accuracy>20</accuracy>
            <uri>http://shakespeare.lit/places/kings_head_pub_aalborg</uri>
            <text>King's Head Pub</text>
          </geoloc>
        </item>
      </node>
    </publish>
  </pubsub>
</iq>
  ]]></example>

  <example caption='...which is delivered to everyone subscribing to it'><![CDATA[
<message from='hamlet@shakespeare.lit' to='hamlet@shakespeare.lit/phone'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='http://jabber.org/protocol/geoloc'>
      <item id='4C940F61C13A0'>
        <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
          <timestamp>1599-10-23T01:56:05Z</timestamp>
          <lat>57.0501862</lat>
          <lon>9.918874</lon>
          <street>Jomfru Ane Gade 13</street>
          <locality>Aalborg</locality>
          <country>Denmark</country>
          <accuracy>20</accuracy>
          <uri>http://shakespeare.lit/places/kings_head_pub_aalborg</uri>
          <text>King's Head Pub</text>
        </geoloc>
      </item>
    </items>
  </event>
</message>

<message from='hamlet@shakespeare.lit' to='horatio@shakespeare.lit/pda'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='http://jabber.org/protocol/geoloc'>
      <item id='4C940F61C13A0'>
        <geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
          <timestamp>1599-10-23T01:56:05Z</timestamp>
          <lat>57.0501862</lat>
          <lon>9.918874</lon>
          <street>Jomfru Ane Gade 13</street>
          <locality>Aalborg</locality>
          <country>Denmark</country>
          <accuracy>20</accuracy>
          <uri>http://shakespeare.lit/places/kings_head_pub_aalborg</uri>
          <text>King's Head Pub</text>
        </geoloc>
      </item>
    </items>
  </event>
</message>
  ]]></example>

</section1>

<section1 topic='Data Format' anchor='format'>
  <p>Information about location references in the entity's surrounding, and, if available, the entity's own geodetic coordinates, are provided by the entity and propagated on the network by the entity's associated application (usually a client). The information is structured by means of a &lt;locationquery/&gt; element that is qualified by the 'urn:xmpp:locationquery:0' namespace and nested with in a &lt;iq&gt; element with type set to <i>get</i>.  The location result is provided by the location server and returned to the client in a &lt;iq&gt; element with type set to <i>result</i>.  The location result is structured by means of a &lt;geoloc/&gt; element that is qualified by  the 'http://jabber.org/protocol/geoloc' namespace (see <a href="../xep-0080.html">XEP-0080</a>).</p>

    <table caption='Location Query Child Elements'>
      <tr class="body">
         <th>Element Name</th>
         <th>Datatype</th>
         <th>Definition</th>
         <th>Example</th>

         <th>Notes</th>
      </tr>
      <tr class="body">
         <td>timestamp</td>
         <td>xs:datetime</td>
         <td>UTC time-stamp (MUST conform to the DateTime profile of &xep0082;). </td>
         <td>2004-02-19T21:12Z</td>
         <td>Optional. If individual location references contain own timing information, this time-stamp shall represent GPS time only, otherwise it shall represent all provided info in the query. If not set, the server may assume current time.</td>
      </tr>
      <tr class="body">
         <td>publish</td>
         <td>xs:boolean</td>
         <td>A flag specifying whether or not the server should publish the location result to subscribers of the submitting user's XEP-0080 compatible geoloc pub-sub node instead of returning it directly to the submitting user.</td>
         <td>true</td>
         <td>Optional. If present and "true", the server shall publish the entity's location details whenever it changes (suitable for periodic queries) and respond to the query with an empty &lt;iq&gt; stanza with type set to "result". If not specified or "false" the server shall return the location results to the submitting user in the form of a geoloc stanza (XEP-0080) embedded in a &lt;iq&gt; with type set to "result". Default is "false"</td>
      </tr>
      <tr class="body">
         <td>lat</td>
         <td>xs:decimal</td>
         <td>Latitude in decimal degrees
         North.</td>
         <td>39.75</td>
         <td>Required if no location references present, otherwise optional. If present, this shall also be present in the result stanza.  If not present, the location server SHOULD estimate a value based on submitted reference data and return with result stanza. The location server is free to decide if the value of this field should be piped directly through to result, or if it should be modified based on reference data or time history information. For instance: if the entity is indoors, the GPS signal will be inaccurate and unstable over time. If wifi references are submitted, the location server may decide that the entity is inside a known building, and return the latitude of this instead.</td>
      </tr>
      <tr class="body">
         <td>lon</td>
         <td>xs:decimal</td>
         <td>Longitude in decimal degrees East</td>
         <td>-104.99</td>
         <td>See notes for <i>lat</i></td>
      </tr>
      <tr class="body">
         <td>alt</td>
         <td>xs:decimal</td>
         <td>Altitude in meters above or below sea level</td>
         <td>1609</td>
         <td>Optional. If present, this shall also be present in the result stanza with identical value.</td>
      </tr>

      <tr class="body">
         <td>bearing</td>
         <td>xs:decimal</td>
         <td>GPS bearing (direction in which the entity is heading to reach its next waypoint), measured in decimal degrees relative to true north</td>
         <td> </td>
         <td>See notes for <i>alt</i></td>

      </tr>
      <tr class="body">
         <td>datum</td>
         <td>xs:string</td>
         <td>GPS datum (See XEP-0080)</td>
         <td> </td>
         <td>See notes for <i>alt</i></td>

      </tr>
      <tr class="body">
         <td>accuracy</td>
         <td>xs:decimal</td>
         <td>Horizontal GPS accuracy in meters</td>
         <td>10</td>
         <td>See notes for <i>lat</i></td>

      </tr>
      <tr class="body">
         <td>speed</td>
         <td>xs:decimal</td>
         <td>The speed at which the entity is moving, in meters per second</td>
         <td>52.69</td>
         <td>See notes for <i>alt</i></td>
      </tr>
      <tr class="body">
         <td>references</td>
         <td>locationquery:reference</td>
         <td>A list of identifiable location references observed by the entity</td>
         <td> </td>
         <td>Required if no <i>lat</i> and <i>lon</i> values specified, otherwise optional. See Table 2 for type definition.</td>
      </tr>
    </table>

    <table caption='Reference Child Elements'>
      <tr class="body">
         <th>Element Name</th>
         <th>Datatype</th>
         <th>Definition</th>
         <th>Example</th>
         <th>Notes</th>

      </tr>
      <tr class="body">
         <td>id</td>
         <td>xs:string</td>
         <td>A world-wide unique reference identifier. This SHALL be composed as follows: <br/><br/>For cell towers: "MCC:MNC:LAC:CID" where MCC is the mobile country code <note>Values of Mobile Country Codes (MCC) are specified by <link url="http://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.212A-2007-PDF-E.pdf">Annex to ITU Operational Bulletin No. 897 – 1.XII.2007</link>.</note>), MNC is the network carrier code, LAC is the area code and CID is the cell ID.<br/><br/>For wireless access points and Bluetooth devices: The device MAC address.<br/><br/>For IP addresses: the IP address itself (either IPv4 or IPv6).</td>
         <td>207:02:12643:78596</td>
         <td>Required</td>
      </tr>
      <tr class="body">
         <td>type</td>
         <td>xs:string</td>
         <td>Reference type as maintained in the registry specified under <link url='#registrar-reftypes'>Reference Types Registry</link></td>
         <td>"cell"</td>
         <td>Required.</td>
      </tr>
      <tr class="body">
         <td>signalstrength</td>
         <td>xs:int</td>
         <td>Reference signal strength in dBM. Only appliccable to actively transmitting references (cell towers, wifi access points, Bluetooth devices)</td>
         <td>-64</td>
         <td>Optional.</td>
      </tr>
      <tr class="body">
         <td>timestamp</td>
         <td>xs:datetime</td>
         <td>UTC time-stamp (MUST conform to the DateTime profile of &xep0082;). </td>
         <td>2004-02-19T21:12Z</td>
         <td>Optional. If query contains info from multiple location reference scans, specifying the timestamp for each reference may lead to improved temporal analysis (movement state etc).</td>
      </tr>
    </table>

    <table caption='Location Result Child Elements (Copied from XEP-0080 with notes added)'>
      <tr class="body">
         <th>Element Name</th>
         <th>Datatype</th>
         <th>Definition</th>
         <th>Example</th>
         <th>Notes</th>
      </tr>
      <tr class="body">
         <td>alt</td>
         <td>xs:decimal</td>
         <td>Altitude in meters above or below sea level</td>
         <td>1609</td>
         <td>Piped directly through from query <i>alt</i> field if set.</td>
      </tr>

      <tr class="body">
         <td>area</td>
         <td>xs:string</td>
         <td>A named area such as a campus or neighborhood</td>
         <td>Central Park</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>bearing</td>
         <td>xs:decimal</td>
         <td>GPS bearing (direction in which the entity is heading to reach its next waypoint), measured in decimal degrees relative to true north</td>
         <td> </td>
         <td>Piped directly through from query <i>bearing</i> field if set.</td>

      </tr>
      <tr class="body">
         <td>building</td>
         <td>xs:string</td>
         <td>A specific building on a street or in an area</td>
         <td>The Empire State Building</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>country</td>
         <td>xs:string</td>
         <td>The nation where the user is located</td>
         <td>USA</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>datum</td>
         <td>xs:string</td>
         <td>GPS datum (See notes for XEP-0080)</td>
         <td></td>
         <td>Piped directly through from query <i>datum</i> field if set.</td>
      </tr>
      <tr class="body">
         <td>description</td>
         <td>xs:string</td>
         <td>A natural-language name for or description of the location</td>
         <td>Bill's house</td>
         <td>If location is mapped to a place in a place oriented service, this should hold the place description.</td>

      </tr>
      <tr class="body">
         <td>accuracy</td>
         <td>xs:decimal</td>
         <td>Horizontal GPS accuracy in meters</td>
         <td>10</td>
         <td>Piped directly through from query <i>accuracy</i> field or estimated by location server using based on the other information in query and, if possible, differences between several queries over time.</td>

      </tr>
      <tr class="body">
         <td>floor</td>
         <td>xs:string</td>
         <td>A particular floor in a building</td>
         <td>102</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>lat</td>
         <td>xs:decimal</td>
         <td>Latitude in decimal degrees
         North</td>
         <td>39.75</td>
         <td>Piped directly through from query <i>lat</i> field or estimated by location server based on the other information in query and, if possible, differences between several queries over time.</td>

      </tr>
      <tr class="body">
         <td>locality</td>
         <td>xs:string</td>
         <td>A locality within the administrative region, such as a town or city</td>
         <td>New York City</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>lon</td>
         <td>xs:decimal</td>
         <td>Longitude in decimal degrees East</td>
         <td>-104.99</td>
         <td>Piped directly through from query <i>lon</i> or estimated by location server based on the other information in query and, if possible, differences between several queries over time.</td>

      </tr>
      <tr class="body">
         <td>postalcode</td>
         <td>xs:string</td>
         <td>A code used for postal delivery</td>
         <td>10027</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>region</td>
         <td>xs:string</td>
         <td>An administrative region of the nation, such as a state or province</td>
         <td>New York</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>room</td>
         <td>xs:string</td>
         <td>A particular room in a building</td>
         <td>Observatory</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>speed</td>
         <td>The speed at which the entity is moving, in meters per second</td>
         <td>52.69</td>
         <td>xs:decimal</td>
         <td>Piped directly through from query <i>speed</i> field or estimated by location server based on the other information in query and, if possible, differences between several queries over time.</td>

      </tr>
      <tr class="body">
         <td>street</td>
         <td>xs:string</td>
         <td>A thoroughfare within the locality, or a crossing of two thoroughfares</td>
         <td>34th and Broadway</td>
         <td> </td>

      </tr>
      <tr class="body">
         <td>text</td>
         <td>xs:string</td>
         <td>A catch-all element that captures any other information about the location</td>
         <td>Northwest corner of the lobby</td>
         <td>Best practice tip: This field can be used by the server to combine several fields in a natural language style, suitable for simple one-line location presence text. Example: "Near Bob's place" (description + accuracy), "On the road in New York" (locality + speed)</td>

      </tr>
      <tr class="body">
         <td>timestamp</td>
         <td>xs:datetime</td>
         <td>UTC timestamp specifying the moment when the reading was taken (MUST conform to the DateTime profile of <cite>XEP-0082</cite>)</td>
         <td>2004-02-19T21:12Z</td>

         <td>Piped directly through from query <i>timestamp</i> field.</td>
      </tr>
      <tr class="body">
         <td>uri</td>
         <td>A URI or URL pointing to
         information about the location</td>
         <td>http://beta.plazes.com/plazes/1940:jabber_inc</td>

         <td>xs:anyURI</td>
         <td>Only applicable to place-oriented services</td>
      </tr>
    </table>

    <p>NOTE: The datatypes specified above are defined in &w3xmlschema2;.</p>
   
</section1>

<section1 topic='Recommended Transport' anchor='transport'>
  <p>The location results SHOULD be distributed means of &xep0060; or the subset thereof specified in &xep0163;. This can be done automatically  by requesting the "publish" location query result format, in which case the location server will publish the results on the user's behalf. Alternatively the it can be done client side as outlined in <cite>XEP-0080</cite>.</p>
</section1>

<section1 topic='Implementation Notes' anchor='impl'>

  <section2 topic='Server Implementation Notes' anchor='server_impl'>
    <p>The does not have to determine a value for all fields of the &lt;geoloc&gt; stanza, but it SHOULD determine values for as many as possible.  At the very least a value for 'country' should be set.</p>

    <p>If no GPS coordinate and accuracy information is submitted in the query, and the server determines location coordinates from submitted reference data, a value for the returned geoloc 'accuracy' field SHOULD be returned. The magnitude of this should be derived based on the ranges of the location references used to determine the location, if known. </p>
    <p>The server should make no assumptions about how often a entity submits a query. It should support occasional manually triggered queries as well as periodic automated queries. In the latter case it should analyze changes over time, as this can greatly increase the fidelity of the result. </p>
    <p>Furthermore, no assumptions should be made about the number and types of location references being logged in each query. Some handset manufacturers limit the access programmers have to cell tower and access point information. Some may only offer the currently connected cell ID, such that even if the handset can "see" many cell towers, only the one to which the handset is connected at the moment can be read. In this case the cell tower readings may not be constant, even if the querying entity is not moving. Rather it may jump round-robin style to each visible cell with variable time spent on each.  The location server should account for this to avoid yielding results indicating that a user is running around in cell-sized circles when he is in fact stationary. Again, analysis of variation of submitted queries over time is recommended.</p>
    <p>As no guarantees can be made that a given location reference stays at one fixed physical location throughout it's lifetime, the server should implement means to detect this. Generally it can be assumed that cell towers seldom move (could happen when a network operator changes the way it allocates cell IDs or when a tower is physically moved to a different location). Wireless access points move a bit more frequently (for instance when their owners move, or if they are installed in moving vehicles such as busses or trains). Bluetooth devices can generally be assumed to be mobile and should, unless specific knowledge to the contrary exists, not be used to locate an entity to a specific physical location. Rather, Bluetooth devices (and other mobile references) can be used to co-locate entities to other entities for which a physical location is known. An example: Entity A submits query with GPS coordinates and the ID of some Bluetooth device. It is located based on its submitted coordinates. Entity B submits a query with the same Bluetooth device ID, but no GPS coordinates. Given this, and the fact that Bluetooth transmitters have a very limited range, the server can then derive that A and B are at the same physical location (it may add 10-20 m to the accuracy of the location of B to account for the Bluetooth range).</p>
    <p>The "radio landscape" is by no means constant. New cells and access points are added continuously, and old ones are phased out. A location server will have to adapt to this shifting landscape, either by means of operator-supplied databases (in case of cell towers) or by means of user generated information. This standard was written with the latter in mind, and it is recommended that location servers utilize any queries with both GPS coordinates and location references to "learn" the approximate physical location of the provided references. For server implementation that rely on user generated information only, it is also recommended to supply additional means for the users to feed back location context in cases where the client does not have any GPS access, or when the server produces the wrong results. One way to do this would be to let the users define "placemarks" (a name, street, city etc) that can be associated with the references seen by this user at the time of definition. This is however beyond the scope of this XEP. </p>
  </section2>

  <section2 topic='Client Implementation Notes' anchor='client_impl'>
    <p>For the reasons mentioned above, it is recommended that the client supply both GPS coordinates as well as nearby location references when possible. Also it is recommended that the client submit queries frequently enough to allow the server to analyze changes over time (or lack thereof) to obtain a better result. When possible, the client should include wifi access points in the queries, as these yield much more precise results than cell towers alone (due to the much more limited range). This must however all be weighted against the increased power consumption resulting from keeping network sockets open, scanning for access points and driving a GPS receiver.<br/><br/> For optimal results, clients SHOULD post a location query any time when the set of observed location references change (e.g. a new cell tower is seen or an old one is not seen any more)</p>
  </section2>
</section1>

<section1 topic='Internationalization Considerations' anchor='i18n'>
  <p>Because the character data contained in the location results is intended to be readable by humans, the location query SHOULD possess an 'xml:lang' attribute specifying the natural language of such character data &rfc4646;. If so, the server SHOULD equip the &lt;geoloc/&gt; element, of the result stanza with an identical attribute </p>

</section1>

<section1 topic='Security Considerations' anchor='security'>
  <p>It is imperative to control access to location information, at least by default. Imagine that a stalker got unauthorized access to this information, with enough accuracy and timeliness to be able to find the target person. This scenario could lead to loss of life, so please take access control checks seriously. If an error is deliberately added to a location, the error SHOULD be the same for all receivers, to minimize the likelihood of triangulation. In the case of deliberate error, the &lt;accuracy/&gt; element SHOULD NOT be included.</p>

</section1>

<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with the <span class="ref" style=""><a href="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</a></span> [<a href="notes_iana">7</a>].</p>

</section1>

<section1 topic='XMPP Registrar Considerations' anchor='registrar'>

  <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <p>This specification defines the following XML namespace:</p>
    <ul>
      <li>urn:xmpp:locationquery:0</li>
    </ul>
    <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespaces to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  </section2>

  <section2 topic='Protocol Versioning' anchor='registrar-versioning'>
    &NSVER;
  </section2>

  <section2 topic='Reference Types Registry' anchor='registrar-reftypes'>
    <section3 topic='Process' anchor='registrar-reftypes-process'>
      <p>The XMPP Registrar shall maintain a registry of values for the &lt;type/&gt; child of the &lt;reference/&gt; element when qualified by the 'urn:xmpp:locationquery:0' namespace.</p>
      &REGPROCESS;
      <code><![CDATA[
<reftype>
  <name>the machine-readable name for the reference type</name>
  <description>a natural-language description of the reference type</description>
</reftype>
      ]]></code>
      <p>The registrant can register more than one reference type at a time, each contained in a separate &lt;reftype/&gt; element.</p>
    </section3>
    <section3 topic='Initial Submission' anchor='registrar-reftypes-init'>
      <p>As part of this document, the following reference types are registered:</p>
      <code><![CDATA[
<reftype>
  <name>bluetooth</name>
  <description>
    The device address as determined by Bluetooth technologies as defined in
    the IEEE 802.15.1 standards.
  </description>
</reftype>
<reftype>
  <name>cell</name>
  <description>
    A cell tower address, formatted as "MCC:MNC:LAC:CID" (where MCC is 
    the mobile country code, MNC is the network carrier code, LAC is the 
    area code, and CID is the cell ID).
  </description>
</reftype>
<reftype>
  <name>ip</name>
  <description>
    An Internet Protocol (IP) address possessed by or assigned to the 
    client.
  </description>
</reftype>
<reftype>
  <name>nic</name>
  <description>
    The link layer (Media Access Control) address of one of the Network 
    Interface Controllers (NICs) associated with the client sending the 
    request. Most commonly, this will take the form of a 48-bit Ethernet 
    address formatted in six colon-separated groups of two hexadecimal 
    digits, in transmission order. Some location servers might be able to 
    use this information to query network elements through which the client 
    is connected to deduce location data.
  </description>
</reftype>
<reftype>
  <name>rfid</name>
  <description>
    The device address as determined by Radio Frequency Identification
    technologies.
  </description>
</reftype>
<reftype>
  <name>wifi</name>
  <description>
    The device address as determined by WiFi technologies as defined in
    the IEEE 802.11 standards.
  </description>
</reftype>
<reftype>
  <name>wimax</name>
  <description>
    The device address as determined by Worldwide Inter-operability for 
    Microwave Access technologies.
  </description>
</reftype>
      ]]></code>
    </section3>
  </section2>

</section1>

<section1 topic='XML Schema' anchor='schema'>
  <code><![CDATA[
<xs:schema 
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:locationquery:0' 
    xmlns='urn:xmpp:locationquery:0'
    elementFormDefault='qualified'>

  <xs:element name='locationquery'>
    <xs:complexType>
      <xs:sequence minOccurs='1' maxOccurs='1'>
        <xs:element name='timestamp' 
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:datetime'/>
        <xs:element name='publish'   
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:bolean'/>
        <xs:element name='lat'       
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='lon'       
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='alt'       
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='bearing'   
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='speed'     
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='datum'     
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:string'/>
        <xs:element name='accuracy'     
                    minOccurs='0' 
                    maxOccurs='1' 
                    type='xs:decimal'/>
        <xs:element name='references'   
                    minOccurs='0' 
                    maxOccurs='unbounded'
                    type='referenceType'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:complexType name='referenceType'>
    <xs:sequence minOccurs='1' maxOccurs='1'>
      <xs:element name='id'
                  minOccurs='1'
                  maxOccurs='1'
                  type='xs:string'/>
      <xs:element name='type'
                  minOccurs='1'
                  maxOccurs='1'
                  type='xs:string'/>
      <xs:element name='signalstrength'
                  minOccurs='0'
                  maxOccurs='1'
                  type='xs:int'/>
      <xs:element name='timestamp'
                  minOccurs='0'
                  maxOccurs='1'
                  type='xs:datetime'/>
    </xs:sequence>
  </xs:complexType>

</xs:schema>
  ]]></code>
  <p>Note: the schema for the location results is given by <cite>XEP-0080</cite>.</p>
</section1>

</xep>
