如何使用GeoJson定义圆? [英] How to define a circle using GeoJson?

查看:1933
本文介绍了如何使用GeoJson定义圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Mongodb中使用几何.

I want to use geometry in Mongodb.

但根据 geojson.org

推荐答案

我遇到了完全相同的问题,解决方案是创建一个大致近似于圆形的多边形(想象一个具有32个以上边的多边形).

I had exactly the same problem, the solution is to create a polygon that roughly approximates a circle (imagine a polygon with 32+ edges).

我编写了一个模块来完成此操作.您可以像这样使用它:

I wrote a module that does this. You can use it like this:

const circleToPolygon = require('circle-to-polygon');

const coordinates = [-27.4575887, -58.99029]; //[lon, lat]
const radius = 100;                           // in meters
const numberOfEdges = 32;                     //optional that defaults to 32

let polygon = circleToPolygon(coordinates, radius, numberOfEdges);

这篇关于如何使用GeoJson定义圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆