Setting geometric and geographical data

The section Geometric and geographical data lists the elements that are used for defining geometric properties of geographical objects. Each element corresponds to a geometric shape and a geo object that is used for displaying this shape on the map.

The geometric shape is bound to a locality by setting the coordinates of corresponding points. For a geometric point, its coordinates are set; for a polyline, the coordinates of its points; for a polygon, the coordinates of the points of the closed polylines that make up its exterior and interior edges.

The coordinates of points and polyline points are set using the gml:pos and gml:posList elements. To specify coordinates that define the viewport or a polygon outline, the gml:lowerCorner and gml:upperCorner elements are used.

To set the coordinates of a point, its longitude and latitude are listed in order and separated by a space. For example, <gml:pos>55.0298 82.9197</gml:pos>. This is how coordinates are set for points that are described using the gml:pos, gml:lowerCorner and gml:upperCorner elements. When setting coordinates for a sequence of points using the gml:posList element, pairs of point coordinates are separated by a space in the same way. For example, <gml:posList>55.0298 82.9197 55.0496 82.9694</gml:posList>.

Polyline and closed polyline

To set the points of a polyline, either two or more gml:pos elements or the gml:posList element can be used.

<ymaps:GeoObject>
    <gml:name>Polyline</gml:name>
    <gml:description>The coordinates for points on a polyline can be defined using two or more gml:pos elements</gml:description>
    <gml:LineString>
        <gml:pos>32.199411 58.601185</gml:pos>
        <gml:pos>32.189411 58.595185</gml:pos>
    </gml:LineString>
</ymaps:GeoObject>

Example:

YMapsML file: http://api.yandex.com.tr/maps/ymapsml/examples/xml/linestring.xml.

HTML page: http://api.yandex.com.tr/maps/ymapsml/examples/linestring.html.

<ymaps:GeoObject>
    <gml:name>Closed polyline</gml:name>
    <gml:description>The coordinates for points on a polyline can also be defined using the gml:posList element</gml:description>
    <gml:LinearRing>
        <gml:posList>37.178027 55.486953 38.040535 55.486953 38.040535 56.018499 37.178027 56.018499</gml:posList>
    </gml:LinearRing>
</ymaps:GeoObject>

Example:

YMapsML file: http://api.yandex.com.tr/maps/ymapsml/examples/xml/linearring.xml.

HTML page: http://api.yandex.com.tr/maps/ymapsml/examples/linearring.html.

Polygon

The exterior boundary of a polygon consists of a closed polyline, which is described using the gml:LinearRing element.

<ymaps:GeoObject>
    <gml:name>Polygon</gml:name>
    <gml:description>The exterior boundary of a polygon consists of a closed polyline</gml:description>
    <gml:Polygon>
        <gml:exterior>
            <gml:LinearRing>
                <gml:posList>37.178027 55.486953 38.040535 55.486953 38.040535 56.018499 37.178027 56.018499</gml:posList>
            </gml:LinearRing>
        </gml:exterior>
    </gml:Polygon>
</ymaps:GeoObject>

In this example, the gml:LinearRing element is located inside the gml:exterior container. This reflects the fact that a polygon can have not only an exterior edge, but an interior edge as well (a "hole" inside the polygon). In addition, the number of interior holes is unlimited.

The interior boundary of a polygon is also set using a closed polyline. The gml:LinearRing element is wrapped in the gml:interior container. In the current version of the Yandex.Maps API, the contents of the gml:interior element are not interpreted. A feature for processing interior edges of polygons is planned for one of the upcoming versions of the API.

Example:

YMapsML file: http://api.yandex.com.tr/maps/ymapsml/examples/xml/polygon.xml.

HTML page: http://api.yandex.com.tr/maps/ymapsml/examples/polygon.html.

Viewport and polygon outline

The viewport and polygon outline of a geographical object or collection are described using the gml:boundedBy element. These areas are defined by setting the point coordinates of the lower left and upper right corners.

To set point coordinates for the lower left corner, the gml:lowerCorner element is used, and for the upper right corner, the gml:upperCorner element is used.

<ymaps:GeoObject>
    <gml:name>Polyline</gml:name>
    <gml:description>A polygon outline can be set for a geographical object or collection</gml:description>
    <gml:boundedBy>
        <gml:Envelope>
            <gml:lowerCorner>45 60</gml:lowerCorner>
            <gml:upperCorner>30 50</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
    <gml:LineString>
        <gml:pos>32.199411 58.601185</gml:pos>
        <gml:pos>32.189411 58.595185</gml:pos>
    </gml:LineString>
</ymaps:GeoObject>

An example of setting the viewport on a map is provided in the section Map parameters.