<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
  <header>
    <title>Data Forms Geolocation Element</title>
    <abstract>This specification defines an XMPP protocol extension for including geolocation data in XEP-0004 data forms.</abstract>
    
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
    <number>0350</number>
    <status>Deferred</status>
    <type>Standards Track</type>
    <sig>Standards</sig>
    <approver>Council</approver>
    <dependencies>
      <spec>XMPP Core</spec>
      <spec>XEP-0004</spec>
      <spec>XEP-0080</spec>
      <spec>XEP-0122</spec>
    </dependencies>
    <supersedes/>
    <supersededby/>
    <shortname>geolocation-element</shortname>
    <schemaloc>
      <url>http://www.xmpp.org/schemas/geolocation-element.xsd</url>
    </schemaloc>
    <author>
      <firstname>Michael</firstname>
      <surname>Laukner</surname>
      <email>laukner@gmail.com</email>
      <jid>laukner@jabber.org</jid>
    </author>
  <revision>
    <version>0.2</version>
    <date>2017-09-11</date>
    <initials>XEP Editor (jwi)</initials>
    <remark>Defer due to lack of activity.</remark>
  </revision>
    <revision>
      <version>0.1</version>
      <date>2014-07-03</date>
      <initials>editor (mam)</initials>
      <remark>
        <p>Initial published version approved by the XMPP Council.</p>
      </remark>
    </revision>
    <revision>
      <version>0.0.3</version>
      <date>2014-06-28</date>
      <initials>ml</initials>
      <remark>
        <p>Updated version, added 'geo:' datatypes to support 'text-single' use case.</p>
      </remark>
    </revision>
    <revision>
      <version>0.0.2</version>
      <date>2014-06-25</date>
      <initials>ml</initials>
      <remark>
        <p>Updated version, added XEP-0122 'geo:' datatypes.</p>
      </remark>
    </revision>
    <revision>
      <version>0.0.1</version>
      <date>2014-06-11</date>
      <initials>ml</initials>
      <remark>
        <p>Initial version, borrowing from XEP-0221.</p>
      </remark>
    </revision>
  </header>
  <section1 topic="Introduction" anchor="intro">
    <p>In certain protocols that make use of <span class="ref"><link url="https://xmpp.org/extensions/xep-0004.html">Data Forms (XEP-0004)</link></span> <note>XEP-0004: Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0004.html">https://xmpp.org/extensions/xep-0004.html</link>&gt;.</note>, it can be helpful to include geolocation data. One example of such a "using protocol" is <span class="ref"><link url="https://xmpp.org/extensions/xep-0346.html">Form Discovery and Publishing (XEP-0346)</link></span> <note>XEP-0346: Form Discovery and Publishing &lt;<link url="https://xmpp.org/extensions/xep-0346.html">https://xmpp.org/extensions/xep-0346.html</link>&gt;.</note>. This document defines a method for including geolocation data in a <cite>Data Form</cite> for something you manage and want to publish. This XEP leaves it open to developers how such a &lt;geoloc/&gt; form element will be rendered; possibilities might include editing Latitude and Longitude manually or through a rendered map.</p>
    <p>There may also be the need to gather location data from both humans (using a GUI format) and computer processes (using a pre-defined but flexible format). This document defines a flexible mechanism for the <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> to standardize geographical location field names in data forms, thus enabling XMPP clients to process location fields in forms while giving protocol authors a way to specify additional location data types for non-GUI processors to determine the semantic meanings of a location field.</p>
  </section1>
  <section1 topic="Requirements" anchor="requirements">
    <p>This proposal addresses the following requirements:</p>
     <ul>
       <li>Integrate geolocation data with XEP-0004.</li>
       <li>Allow a potential receiver (rather than the sender) to validate geolocation data.</li>
    </ul>
  </section1>
  <section1 topic="Integrate Geolocation Element with XEP-0004" anchor="geolocation">
    <p>The root element for geolocation data is &lt;geoloc/&gt; as defined in <span class="ref"><link url="https://xmpp.org/extensions/xep-0080.html">User Geolocation (XEP-0080)</link></span> <note>XEP-0080: User Geolocation &lt;<link url="https://xmpp.org/extensions/xep-0080.html">https://xmpp.org/extensions/xep-0080.html</link>&gt;.</note>. The information is structured by means of a &lt;geoloc/&gt; element that is qualified by the 'http://jabber.org/protocol/geoloc' namespace. The &lt;geo/&gt; element MUST be contained within a &lt;field/&gt; element qualified by the 'jabber:x:data' namespace.</p>
    <p>The following example is provided only for the purpose of illustration; consult the specifications for using protocols (e.g., XEP-0080) to see canonical examples.</p>
    <example caption="Inclusion in Data Form"><![CDATA[<x xmlns='jabber:x:data' type='form'>
  [ ... ]
   <field var='location'>
     <geoloc xmlns="http://jabber.org/protocol/geoloc">
        <text>Venice, Italy</text>
        <locality>Venice</locality>
        <country>Italy</country>
        <lat>45.44</lat>
        <lon>12.33</lon>
     </geoloc>
   </field>
   [ ... ]
</x>]]></example>
  </section1>
  <section1 topic="Allow Receiver to Valdidate Geolocation Data" anchor="validation">
    <p>All elements associated with location fields MUST be qualified by the 'http://jabber.org/protocol/geoloc' namespace. The use of namespace prefixes is RECOMMENDED for large forms, to reduce the data size. To maintain the highest level of compatibility, implementations sending the form using prefixes SHOULD use the namespace prefix "geo:", and SHOULD declare the namespace prefix mapping in the ancestor &lt;x xmlns='jabber:x:data'/&gt; element:</p>
    <p>The following example is provided only for the purpose of illustration; consult the specifications for using protocols (e.g. XEP-0080, XEP-0122) to see canonical examples.</p>
    <example caption="Validation of Geolocation Data"><![CDATA[<x xmlns='jabber:x:data'
   xmlns:geo='http://jabber.org/protocol/geoloc'
   xmlns:xdv='http://jabber.org/protocols/xdata-validate'
   type='form'>
  <title>Sample Location Form</title>
  <instructions>
    Please provide information for the following location fields...
  </instructions>
  <field type='text-single' var='name' label='Event Name'/>
  <field type='text-single' var='time' label='Event Date/Time'>
    <xdv:validate datatype='xs:dateTime'>
      <basic/>
    </xdv:validate>
  </field>
  <field type='text-single' var='latitude' label='Latitude'>
    <xdv:validate datatype='geo:lat'>
      <basic/>
    </xdv:validate>
  </field>
  <field type='text-single' var='longitude' label='Longitude'>
    <xdv:validate datatype='geo:lon'>
      <basic/>
    </xdv:validate>
  </field>
</x>]]></example>
    <section2 topic="Location Datatypes for Data Forms" anchor="location_fields">
    <p>The integration with Data Forms is accomplished via the datatypes specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0122.html">Data Forms Validation (XEP-0122)</link></span> <note>XEP-0122: Data Forms Validation &lt;<link url="https://xmpp.org/extensions/xep-0122.html">https://xmpp.org/extensions/xep-0122.html</link>&gt;.</note>. Each datatype is specific to the profile desired. The sender MUST use the 'geo:' datatypes as specified in XEP-0122. When submitting a form, a field's value(s) MUST be validated by the receiving entity based on the 'geo:' datatype identifier(s). Also, the submitter MUST provide a 'geo:' element for each location element within the data form. If a form-submitting entity receives a field type it does not understand, the 'text-single' field type from XEP-0004 MUST be assumed.</p>
    </section2>
  </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 the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
  </section1>
  <section1 topic="XMPP Registrar Considerations" anchor="registrar">
    <section2 topic="Protocol Namespaces" anchor="ns">
      <p>
        The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> already includes 'http://jabber.org/protocol/geoloc' in its registry of protocol namespaces (see &lt;<link url="https://xmpp.org/registrar/namespaces.html">https://xmpp.org/registrar/namespaces.html</link>&gt;).
      </p>
    </section2>
    <section2 topic="Location Fields and Data Form Validation Datatypes" anchor="registrar.geo.xep">
      <p>The XMPP Registrar includes 'geo:' in its registry of Data Forms Validation Datatype Prefixes.</p>
      <p>Normally, each geographic format that wishes to be considered for use with Data Forms MUST register its own datatype qualified by the "geo:" prefix. However, this document provides an initial seed, based on the currently assumed formats. The following datatypes shall be registered for use with Data Forms Validation:</p>
      <code caption="Latitude Validation Datatype Registry Submission"><![CDATA[
<datatype>
  <name>geo:lat</name>
  <desc>Datatype for publishing the latitude of a geographic location</desc>
  <doc>XEP-0080</doc>
</datatype>
]]></code>
<example caption="Validation of a XEP-0080 Latitude Field"><![CDATA[
<field type='text-single' var='latitude' label='Latitude'>
  <xdv:validate datatype='geo:lat'>
    <range min='-90'
           max='90'/>
  </xdv:validate>
  <value>45.44</value>
</field>]]></example>

      <code caption="Longitude Validation Datatype Registry Submission"><![CDATA[
<datatype>
  <name>geo:lon</name>
  <desc>Datatype for publishing the longitude of a geographic location</desc>
  <doc>XEP-0080</doc>
</datatype>
]]></code>
<example caption="Validation of XEP-0080 Longitude Field"><![CDATA[
<field type='text-single' var='longitude' label='Longitude'>
  <xdv:validate datatype='geo:lon'>
    <range min='-180'
         max='180'/>
  </xdv:validate>
  <value>12.33</value>
</field>]]></example>
    </section2>

    <section2 topic="Text Field and Data Form Validation Datatypes" anchor="registrar.geo.text">
      <p>The XMPP Registrar MAY include 'geo:' datatypes in its registry of Data Forms Validation Datatypes, which can be used with the 'text-single' field type from XEP-0004.</p>

    <code caption="DMS Data Forms Validation Datatype Registry Submission"><![CDATA[
<datatype>
  <name>geo:dms</name>
  <desc>Datatype for publishing a degrees, minutes, and seconds (DMS) location</desc>
  <doc>Degree Minutes and Seconds, 'http://en.wikipedia.org/wiki/Geographic_coordinate_system'.</doc>
</datatype>
]]></code>
<example caption="Validation of a DMS Location Field"><![CDATA[
<field type='text-single' var='dms_location'>
  <xdv:validate datatype='geo:dms'/>
    <regex>([-|\\+]?\\d{1,3}[d|D|\u00B0|\\s](\\s*\\d{1,2}['|\u2019|\\s])?(\\s*\\d{1,2}[\"|\u201d])?\\s*[N|n|S|s]?)?(\\s*|,|,\\s*)?([-|\\+]?\\d+?(\\.\\d+?)??\\s*[E|e|W|w]??)</regex>
  </xdv:validate>
  <value>52d18'24.4775"N 0d52'44.0625"W</value>
</field>]]></example>

    <code caption="MGRS Data Forms Validation Datatype Registry Submission"><![CDATA[
<datatype>
  <name>geo:mgrs</name>
  <desc>Datatype for publishing a MGRS location</desc>
  <doc>Military Grid Reference System, 'http://en.wikipedia.org/wiki/Military_grid_reference_system'.</doc>
</datatype>
]]></code>
<example caption="Validation of a MGRS Location Field"><![CDATA[
<field type='text-single' var='mgrs_location'>
  <xdv:validate datatype='geo:mgrs'/>
    <regex>\\d{1,2}[A-Za-z]\\s*[A-Za-z]{2}\\s*\\d{1,5}\\s*\\d{1,5}</regex>
  </xdv:validate>
  <value>38SMB4484</value>
</field>]]></example>

  </section2>
  </section1>
  <section1 topic="XML Schema" anchor="schema">
    <p>As this document only defines semantics for existing protocol, additional schemas are not required.</p>
  </section1>
</xep>
