Skip to content

polygon (Structured Query)

isubiker edited this page Nov 11, 2011 · 1 revision

Creates a geospatial polygon for geo queries via an array of ordered points.

No edge may cover more than 180 degrees of either latitude or longitude. The polygon as a whole may not encompass both poles. These constraints are necessary to ensure an unambiguous interpretation of the polygon. There must be at least three vertices. The first vertex should be identical to the last vertex to close the polygon.

The following example creates a box centered at the equator and prime meridian that's 2 degrees wide and 2 degrees high:

{"polygon": [
    {"point": {"latitude": 1, "longitude": -1}},
    {"point": {"latitude": 1, "longitude": 1}},
    {"point": {"latitude": -1, "longitude": 1}},
    {"point": {"latitude": -1, "longitude": -1}},
    {"point": {"latitude": 1, "longitude": -1}}
]}

<polygon>
    <point>
        <latitude>1</latitude>
        <longitude>-1</longitude>
    </point>
    <point>
        <latitude>1</latitude>
        <longitude>1</longitude>
    </point>
    <point>
        <latitude>-1</latitude>
        <longitude>1</longitude>
    </point>
    <point>
        <latitude>-1</latitude>
        <longitude>-1</longitude>
    </point>
    <point>
        <latitude>1</latitude>
        <longitude>-1</longitude>
    </point>
</polygon>
Clone this wiki locally