GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Close
  • FAQ
  • Docs
  • API
  • Community
  • Blog
  • Accessing ReQL
  • r
  • connect
  • close
  • reconnect
  • use
  • run
  • changes

This view

  • Original page
  • New address

GeezerVison is showing rethinkdb.com — ReQL command reference - RethinkDB


▲ Back to top

Command syntax

r.polygon([lon1, lat1], [lon2, lat2], [lon3, lat3], ...) → polygon

r.polygon(point1, point2, point3, ...) → polygon

Description

Construct a geometry object of type Polygon. The Polygon can be specified in one of two ways:

  • Three or more two-item arrays, specifying latitude and longitude numbers of the polygon’s vertices;
  • Three or more Point objects specifying the polygon’s vertices.

Longitude (−180 to 180) and latitude (−90 to 90) of vertices are plotted on a perfect sphere. See Geospatial support for more information on ReQL’s coordinate system.

If the last point does not specify the same coordinates as the first point, polygon will close the polygon by connecting them. You cannot directly construct a polygon with holes in it using polygon, but you can use polygonSub to use a second polygon within the interior of the first to define a hole.

Example: Define a polygon.

r.table('geo').insert({
    id: 101,
    rectangle: r.polygon(
        [-122.423246,37.779388],
        [-122.423246,37.329898],
        [-121.886420,37.329898],
        [-121.886420,37.779388]
    )
}).run(conn, callback);

Example: Define a polygon using an array of vertices.

You can use the args command to pass an array of Point objects (or latitude-longitude pairs) to polygon.

var vertices = [
    [-122.423246,37.779388],
    [-122.423246,37.329898],
    [-121.886420,37.329898],
    [-121.886420,37.779388]
];
r.table('geo').insert({
    id: 102,
    rectangle: r.polygon(r.args(vertices))
}).run(conn, callback);

Related commands

  • point
  • line
  • circle

Get more help

Couldn't find what you were looking for?

  • Ask a question on Stack Overflow
  • Chat with us and our community on Slack
  • Talk to the team on IRC on #[email protected] — via Webchat
  • Ping @rethinkdb on Twitter
  • Post an issue on the documentation issue tracker on GitHub

Contribute: edit this page or open an issue

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.