Mongo geoJSON 损坏的多边形

如何解决Mongo geoJSON 损坏的多边形

我使用没有孔的 GEOJSON 多边形在 MongoDB 中进行搜索。访问光标时出现错误。错误是: OperationFailure:第二个循环不包含在第一个外部循环中 - 第二个循环必须是孔。

代码:

import pymongo
import json

def loadjson(filename):
    with open(filename) as f:
        mydict = json.load(f)
    return mydict

client = pymongo.MongoClient('mongodb://' \
                                    + 'username' \
                                    + ':' \
                                    + "password" + \
                                    '@localhost:num')

gjOr=loadjson('polygon.json')

database = client.database
collection = database["name"]
filParam = {"field": {"$geoWithin": {"$geometry": gjOr["geometry"]}}}
exParam = {"parameter": 1} 

cursorItineraries = collection.find(filParam,exParam).batch_size(2)
for i in cursorItineraries:
    print(i)

错误:

OperationFailure: Secondary loops not contained by first exterior loop - secondary loops must be holes: [ [ 4.423298831017474,45.92246510136637 ],[ 4.423272328729544,45.9224124914541 ],[ 4.423296014293201,45.92245885344253 ],[ 4.423298831017474,45.92246510136637 ] ] first loop: [ [ 45.80122758057101,4.376352681950241 ],[ 45.8044838524037,4.376220111724892 ],[ 45.80502003601278,4.384299007716068 ],[ 45.80303745929081,4.388437890276315 ],[ 45.81747689026152,4.380885175476993 ],[ 45.82029916312589,4.38306756294014 ],[ 45.82485210019716,4.37663747923372 ],[ 45.82534211272147,4.381172591846549 ],[ 45.83402693020424,4.384295932265717 ],[ 45.83750180635732,4.391204268525621 ],[ 45.83984258047744,4.387611887543129 ],[ 45.84600085935993,4.383682442715087 ],[ 45.85031045846961,4.391211993814656 ],[ 45.85985548506667,4.396744466054351 ],[ 45.8651960481546,4.395075656820409 ],[ 45.86464844812487,4.390221929905438 ],[ 45.86619589736199,4.361702458243602 ],[ 45.87693527428829,4.343076054047009 ],[ 45.88006074780913,4.340914771281566 ],[ 45.8901897554254,4.337545959836689 ],[ 45.89739332872952,4.326829637196063 ],[ 45.90391638987086,4.32382549599472 ],[ 45.905667965693,4.327990843251258 ],[ 45.91579311238129,4.346817863136088 ],[ 45.91668891008069,4.342257953265195 ],[ 45.9216251460626,4.338982596932619 ],[ 45.92997139286699,4.346628121156797 ],[ 45.93185900371628,4.337155914633498 ],[ 45.94115045303277,4.322661854063225 ],[ 45.9423274157955,4.313001397538913 ],[ 45.95343445337902,4.294525894838753 ],[ 45.95835570732176,4.301188120177739 ],[ 45.9732026997347,4.289431726797376 ],[ 45.97782302017173,4.276356808225782 ],[ 45.97999822296752,4.273060858987787 ],[ 45.98120074142516,4.259590688670001 ],[ 45.98675497867428,4.248658637365085 ],[ 45.99308572400004,4.247947359178051 ],[ 45.99614759409149,4.246662259181909 ],[ 45.99563177014321,4.251765125404147 ],[ 45.99854856923263,4.265285854935993 ],[ 45.99274541001228,4.270233183990548 ],[ 45.99239729542708,4.275045816032846 ],[ 45.99568744605374,4.289609476470726 ],[ 45.98892048061472,4.300698529315564 ],[ 45.99439301256719,4.304534538221632 ],[ 46.0051569133273,4.31261301303475 ],[ 46.00804632488756,4.310942716001039 ],[ 46.01128401825687,4.308859856852684 ],[ 46.02162453052691,4.306458712603317 ],[ 46.0215031603917,4.305677962950914 ],[ 46.02080232740203,4.301223173083229 ],[ 46.01839338755868,4.288344635543249 ],[ 46.0218025518577,4.28062738017141 ],[ 46.02393104466132,4.276598681060639 ],[ 46.03355588764234,4.270436612377799 ],[ 46.03608569278646,4.261172108339184 ],[ 46.03914954925174,4.261574439856753 ],[ 46.04921372290215,4.251694718008523 ],[ 46.05182172309517,4.254034942879366 ],[ 46.05394712145236,4.25770790411945 ],[ 46.05200674707666,4.266837389513737 ],[ 46.05371908926419,4.285713698620556 ],[ 46.06348629342862,4.297946350027559 ],[ 46.06607892681861,4.300652169094047 ],[ 46.07849083960166,4.302039193299913 ],[ 46.07922531473847,4.305599848572079 ],[ 46.08175515713837,4.311015193331216 ],[ 46.08505691781212,4.310620920782156 ],[ 46.09488700704484,4.311938135622067 ],[ 46.10036561585792,4.306608118283756 ],[ 46.11003344270973,4.30990269743367 ],[ 46.11227779249233,4.313417891784874 ],[ 46.11685288921163,4.320328061893218 ],[ 46.13001463483668,4.322725351722958 ],[ 46.13326362593953,4.330293102924566 ],[ 46.13554160597837,4.333348440257132 ],[ 46.13830957901551,4.357233936672898 ],[ 46.13849351079732,4.362195204890961 ],[ 46.1498366233474,4.377795652104825 ],[ 46.14969360157965,4.382423398963222 ],[ 46.14767758414561,4.386051143732711 ],[ 46.13709181954217,4.408851926159123 ],[ 46.13594976925808,4.417961239075054 ],[ 46.15142016044436,4.424267792344496 ],[ 46.15560425283834,4.431770589521594 ],[ 46.16791483778646,4.439193639737003 ],[ 46.16998904853596,4.435772060175736 ],[ 46.18010788550735,4.414915433192237 ],[ 46.18156481929947,4.411150008217347 ],[ 46.18227866102438,4.406966209179808 ],[ 46.18456671088968,4.403509174410789 ],[ 46.18925424643544,4.396783755671023 ],[ 46.19570191957066,4.39747939068123 ],[ 46.20316836045577,4.423571836902974 ],[ 46.20706171749928,4.422359640985007 ],[ 46.21010077361071,4.420471659265854 ],[ 46.21965844746768,4.407356367902624 ],[ 46.21982737938801,4.388683312501862 ],[ 46.22571105646608,4.386829907900418 ],[ 46.23755075963317,4.39209447339758 ],[ 46.24354546160409,4.388785758384324 ],[ 46.24619830411654,4.386173183144986 ],[ 46.24794900440396,4.38889827660288 ],[ 46.2643415894465,4.393582057210332 ],[ 46.26655827183746,4.397449686073675 ],[ 46.27187809126278,4.397064201352286 ],[ 46.27457798360896,4.396974174839016 ],[ 46.28435539290889,4.399371429518632 ],[ 46.29277972056357,4.407707294944299 ],[ 46.29609636649197,4.406422030172297 ],[ 46.29537513021594,4.411216732267508 ],[ 46.29633635905063,4.424994132856644 ],[ 46.30286120593534,4.427650449880751 ],[ 46.29631496657498,4.438330372797787 ],[ 46.29309133554136,4.440062626728649 ],[ 46.29647617285935,4.453855067913997 ],[ 46.29405157990985,4.46279605745037 ],[ 46.28443417433566,4.47602647504644 ],[ 46.28709961733546,4.484382424854218 ],[ 46.28803138168911,4.489069361733742 ],[ 46.27010728719618,4.50209226866315 ],[ 46.26716933623024,4.504596974106646 ],[ 46.2719961499778,4.542944499553459 ],[ 46.27395480446275,4.547049893978835 ],[ 46.2832619806662,4.548685286189365 ],[ 46.29129615541792,4.556044471210963 ],[ 46.29402942721709,4.55844617134213 ],[ 46.29306430926767,4.570871194910193 ],[ 46.29001185910924,4.572758405594865 ],[ 46.27707566137231,4.573323169325609 ],[ 46.27025349602457,4.58326888257721 ],[ 46.26839674289919,4.587119484978682 ],[ 46.26643179980633,4.615050419767011 ],[ 46.2654086056003,4.617672483965549 ],[ 45.80592709186426,4.865072663474678 ],[ 45.80434184846744,4.864499321786514 ],[ 45.80433950695036,4.864498347340356 ],[ 45.80545594864911,4.848595888972264 ],[ 45.76435319429793,4.801430760920382 ],[ 45.71917418711324,4.781774751613478 ],[ 45.68363470756887,4.80870542554455 ],[ 45.80122758057101,4.376352681950241 ] ],full error: {'ok': 0.0,'errmsg': 'Secondary loops not contained by first exterior loop - secondary loops must be holes: [ [ 4.423298831017474,4.376352681950241 ] ]','code': 2,'codeName': 'BadValue','operationTime': Timestamp(1611827959,1),'$clusterTime': {'clusterTime': Timestamp(1611827959,'signature': {'hash': b'\x8d\xb6\x9b7\x0b\xe7!\x11\xe6\xc1\x13\x06\xf4\xe0\xca\xfe\xcbN\x0cy','keyId': 6872375198939611144}}}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-