Tag: geojson

如何使用npm库提供asynchronous集成testing?

我维护一组生成有效GeoJSON所需的中间件 ,以便为其生成的服务提供支持 。 有一个npm模块,可以执行基于string或对象的linting。 由于中间件本身不在节点中,所以我希望有一个中间件的testing套件,它使用npm作为集成testing套件,确保每个端点都生成有效的GeoJSON。 我正在使用摩卡,但除此之外,我对任何产生结果的框架都是开放的。 (我已经尝试了Q,q-io,asynchronous数组和其他几个。) 这是一个我正在瞄准的同步式写法: describe('testPath()', function() { it("should be a function", function () { expect(geojsonLint.testPath).to.be.a('function') }); it("should test a path", function () { var firstPath = geojsonLint.findEndpoints()[0]; expect(geojsonLint.testPath(firstPath)).to.be.true }); }); 然后,在此基础上,testing所有path的同步版本可能如下所示: describe('testAllPaths()', function() { it("should test a path", function () { geojsonLint.findEndpoints().map(function(path) { expect(geojsonLint.testPath(path)).to.be.true } }); }); 我已经多次改变了我的testPath实现,但是最具说明性的尝试如下: testPath: function (path, […]

MongoDB / Mongoose:使用geoJSON与geoNear方法获取不正确的距离

我已经定义了我的模式 var locationSchema = new mongoose.Schema({ coords: { type: [Number], index: '2dsphere' }, }); geoJSON对象定义为 var geoOptions = { spherical: true, maxDistance: 5000, distanceMultiplier : 0.001, num: 10 } loc.geoNear(point, geoOptions, function(error, results, stats){//do stuff}); 其中loc是我的模型实例,我的观点是 var point = { type: "Point", coordinates: [lng,lat] }; 我的数据库中有两个文件,包括coords "coords" : [ 18.9164127, 72.8245292 ] "coords" : [ […]

Turf.js合并在GeoJSON中查找要素

我正在用Node.js构build一个地图应用程序。 我们有大约40,000个多边形显示在地图上,所以我试图通过在可能的情况下合并来提高性能。 Turf.js有一个合并function,看起来像票。 尽pipe如此,我还是无法完成这项工作。 这里是我试图在我的控制器中使用草皮的代码。 var mongoose = require('mongoose'); var bodyParser = require('body-parser'); var turf = require('turf'); var fs = require('fs'); exports.show = function(req, res) { res.render('map', { title: 'Map' }); }; exports.postSearch = function(req, res) { // Bunch of query stuff goes into array below, (omitted for post) mongoose.model('Claim').find({ $and:array }, function(err, polygons){ // […]

使用MapReduce来处理Cloudant中的地理空间索引结果

我在Cloudant中使用地理空间索引来检索多边形内的所有文档。 现在我想为这些文件计算一些基本的静态值(例如,一个地区的平均年龄和收入总和)。 是否有可能查询地理索引,然后将结果传递给MapReduce函数? 我怎么能实现这一点,最好在数据库内? 我可以避免查询多边形中的文档ID,然后发送执行MapReduce(我正在处理大型数据集)的检索ID? 到目前为止工作的是查询索引以及使用视图(单独)。 我的地理索引 function (doc) { if (doc.geometry && doc.geometry.coordinates) { st_index(doc.geometry); } } 我的看法 function (doc) { var beitrag = doc.properties.beitrag; var schadenaufwand = doc.schadenaufwand; if(beitrag !== null && typeof beitrag === 'number' ) { emit(doc._id, doc.properties.beitrag); } } 示例geoJson文档(原始数据看起来相似) { "_id": "01bff77f642fc4249e787d2ded011504", "_rev": "1-25a9a1a15939d5b21af3fbcc5c2d6ed1", "type": "Feature", "geometry": { "type": […]

可以使用turf.js来查找和修复不良的几何几何?

方法:目前,我正在使用turf.js进行地理处理,作为更广泛地图项目的一部分 。 我的工作stream程如下所示: 把整个县的人口普查区的地理拉 从县域拉动OSM水多边形瓷砖 recursion地拉大片和每个水瓦片成节点脚本 在脚本中, 将水瓷砖合并成单个turf.merge 在该脚本中, recursion地turf.intersect每个多边形区域与水面多边形进行turf.intersect 在脚本中,如果相交, turf.erase多边形区域中turf.erase水域 转储水擦除的文件 问题:当我的过程在步骤3中遍历每个水瓦时,它碰到一个特定瓦片并开始抛出这个错误: /Users/wboykinm/github/tribes/processing/water/node_modules/turf/node_modules/turf-intersect/index.js:45 if(poly2.type === 'Feature') geom2 = poly2.geometry; ^ TypeError: Cannot read property 'type' of null at Object.module.exports [as intersect] (/Users/wboykinm/github/tribes/processing/water/node_modules/turf/node_modules/turf-intersect/index.js:45:11) at Object.<anonymous> (/Users/wboykinm/github/tribes/processing/water/piranha.js:26:14) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) […]

MongoDB:在$ maxDistance中使用$ near操作符时不会出现间隔

当我试图从蒙戈壳find犹他州盐湖城50公里范围内的所有成员时,我得到的错误是: error: { "$err" : "point not in interval of [ -180, 180 ] :: caused by :: { 0: 0.0, 1: 50000.0 }", "code" : 16433 } 这是我正在运行的查询: db.members.find( { 'geo.point' : { $near : { $geometry : { type : "Point" , coordinates : [ 111.000 , 40.000 ] }, $maxDistance : 50000 […]

GeoJSON和Legacy坐标对在mongoDb方面有什么区别?

我想用mongoDb的$ geoNear聚合运算符来计算用户从当前位置的距离,方法如下: '$geoNear': { near: currentLocation, distanceField: 'distance', spherical: true, } 随着currentLocation是这样的: { "type" : "Point", "coordinates" : [ -122.1575745, 37.4457966 ] } 我的collections是以下types(使用mongoose): users = [{ …. location : { // GeoJSON Point or I think it is 😉 type: { type: String }, coordinates: [] } …. }] 我正在使用索引(再次mongoose的语法): userSchema.index({ location: '2dsphere' }); […]

Node.js / Javascript库来testing点是否在geojson multipolygon中

是否有一些node.js或一般的JavaScript的库,提供了一个函数来检查坐标是否在geojson multipolygon? 我试图创build一个小的HTTP API,告诉我哪个多面体(代表国家,县,城市等)包含给定的坐标。 我以为我会在内存中列出所有多边形及其边界框,然后首先检查每个多边形的边界框是否包含坐标。 如果是,那么它将检查坐标是否在多面体本身中。 我知道有一个叫做“clipper”的库被移植到了javascript ,但是它似乎并没有提供一个简单的“pointInPolygon”函数,即使库本身是非常强大的。这个库还有可能吗? 另外,我发现了另一个名为“geojson-js-utils”的库,但它似乎不支持多面体 (至less在那里没有提到) 我发现一些其他库可以检查一个点是否在一个多边形,但我不知道如何使用它们来检查一个点是否在一个多边形。 任何提示?