Share via


Polygon XML File Format

Polygon XML File Format

As an alternate to using one of the polygon creation tools, you can manually create your own polygon data files. However, due to the geometry requirements for polygons, manually creating a polygon file is not recommended. If you manually create XML files for your polygons, the files must contain specific information.

Polygon File Format Requirements

A valid polygon XML file must contain the following:

  1. An embedded XSD schema with two namespaces:

  2. A dataroot element, which contains:

    • One or more CustomerPolygonEntity elements

    • A generated attribute, which is set to a dateTime value.

  3. The CustomerPolygonEntity element must contain the following elements:

    • EntityID

    • Latitude. If you do not provide this value, MapPoint Web Service calculates the Latitude value and adds the value during the upload process.

    • Longitude. If you do not provide this value, MapPoint Web Service calculates the Longitude value and adds the value during the upload process.

    • EntityGeometry, which defines a poly namespace by referencing https://s.mappoint.net/polygon-40/.

  4. The EntityGeometry element must contain a Polygon element.

  5. The Polygon element contains:

    • One ExteriorRing element

    • Zero or more InteriorRing elements

      The value for an ExteriorRing or InteriorRing element is a list of latitude,longitude pairs separated by semicolons (with no semicolon at the end of the list): latitude1,longitude1;latitude2,longitude2

The following rules apply to the polygons you define in the ExteriorRing or InteriorRing element:

  1. Each vertex is defined by a pair of latitude,longitude values.

  2. No two latitude,longitude pairs can be the same within a polygon.

    • You do not need to "close" the polygon by specifying the final vertex of a polygon, as this will be a duplicate of the first vertex.

    • Internal polygons cannot overlap or intersect external polygons.

  3. Each ring you define must contain at least 3 vertices.

Sample Polygon File

The following XML shows a complete, valid polygon XML file with all required elements:

          <?xml version="1.0" encoding="UTF-8"?>
          <root xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:od="urn:schemas-microsoft-com:officedata">
          <xsd:schema>
          <xsd:element name="dataroot">
          <xsd:complexType>
          <xsd:sequence>
          <xsd:element ref="CustomerPolygonEntity" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="generated" type="xsd:dateTime"/>
          </xsd:complexType>
          </xsd:element>
          <xsd:element name="CustomerPolygonEntity">
          <xsd:complexType>
          <xsd:sequence>
          <xsd:element name="EntityID" minOccurs="0" od:jetType="integer" od:sqlSType="smallint" type="xsd:short"/>
          <xsd:element name="Latitude" minOccurs="0" od:jetType="double" od:sqlSType="float" type="xsd:double"/>
          <xsd:element name="Longitude" minOccurs="0" od:jetType="double" od:sqlSType="float" type="xsd:double"/>
          <xsd:any namespace="##other" />
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>
          </xsd:schema>

          <dataroot xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" generated="2004-05-21T17:11:40">
          <CustomerPolygonEntity>
          <EntityID>1</EntityID>
          <Latitude>42.00</Latitude>
          <Longitude>-100.00</Longitude>
          <poly:EntityGeometry xmlns:poly="https://s.mappoint.net/polygon-40/">
          <Polygon>
          <ExteriorRing>40,-98;40,-102;44,-102;44,-98</ExteriorRing>
          <InteriorRing>41,-101;43,-100;41,-99</InteriorRing>
          </Polygon>
          </poly:EntityGeometry>
          </CustomerPolygonEntity>
          </dataroot>
          </root>