简体   繁体   中英

RethinkDB - Polygon Doesn't Accept an Array of Vertices?

I'm really loving that RethinkDB has Geospatial out of the box.

My only issue I'm having is with adding Polygons.

The docs ( https://www.rethinkdb.com/api/javascript/polygon/ ) says I can only insert my points as arguments. This is completely unrealistic and unusable because I don't know how many vertices my user will decide on their polygon. It would be great if I could throw it an array of vertices but I get the error:

Unhandled rejection ReqlDriverError: r.polygon takes at least 3 arguments, 1 provided.

The only thing I can think of doing is making 16 separate functions that take in the specified amount of vertices in an array.

Any ideas what I can do? Thank you!

You can use r.args to splice an array into a variadic function. So r.polygon(r.args(ARRAY_OF_POINTS)) should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM