Mongodb 地圈和干草堆索引拒绝有效的线字符串
Mongodb geosphere and haystack indexes rejecting valid line strings
我试图在三个地理索引中的每一个插入以下geojsonlint数据。 唯一接受数据的是 2d 索引。
干草堆索引产生以下错误:
insertDocument :: caused by :: 16776 geo field is not a number
{
"v" : 1,
"key" : {
"geometry.coordinates" : "geoHaystack",
"properties.asset_type" : 1
},
"name" : "geometry.coordinates_geoHaystack_properties.asset_type_1",
"ns" : "smallcell.poles",
"bucketSize" : 1
}
2dsphere 生成以下错误:
insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?
{
"v" : 1,
"key" : {
"geometry.coordinates" : "2dsphere"
},
"name" : "geometry.coordinates_2dsphere",
"ns" : "smallcell.poles",
"2dsphereIndexVersion" : 2
}
有人有什么想法吗?
{
type : "Feature",
geometry : {
type : "LineString",
coordinates : [[-118.6058, 34.17195], [-118.60589, 34.17195], [-118.606057, 34.171953], [-118.606096, 34.171954], [-118.60647, 34.17196], [-118.60702, 34.17196], [-118.60713, 34.17196], [-118.6076, 34.17195], [-118.6077, 34.17195], [-118.60779, 34.171949], [-118.6088, 34.17194], [-118.609203, 34.17194], [-118.60932, 34.17194], [-118.60964, 34.17195], [-118.6102, 34.17198], [-118.6104, 34.172], [-118.610704, 34.172031], [-118.61089, 34.17205], [-118.61115, 34.17207], [-118.61135, 34.17207], [-118.61175, 34.17204], [-118.61215, 34.17199], [-118.61265, 34.17196], [-118.61366, 34.17196], [-118.61455, 34.17196], [-118.61678, 34.17196], [-118.61819, 34.17197], [-118.61896, 34.17196], [-118.61971, 34.17195], [-118.620452, 34.17195], [-118.62115, 34.17195], [-118.62153, 34.17195], [-118.62287, 34.17196], [-118.62333, 34.17197], [-118.6238, 34.17197], [-118.62543, 34.17196], [-118.62731, 34.17194], [-118.628244, 34.17194], [-118.62957, 34.17194], [-118.63206, 34.17192]]
},
properties : {
id : 0.0,
asset_type : "FBR",
carrier : "AT&T",
type : "ON_ROAD",
cbsa : "31100",
lata : "730",
zip : null,
state : null
}
}
您的索引位于错误的字段中。索引字段应该是geometry
,而不是geometry.coordinates
。
示例代码:
var lineString = {
type : "Feature",
geometry : {
type : "LineString",
coordinates : [[-118.6058, 34.17195], [-118.60589, 34.17195], [-118.606057, 34.171953], [-118.606096, 34.171954], [-118.60647, 34.17196], [-118.60702, 34.17196], [-118.60713, 34.17196], [-118.6076, 34.17195], [-118.6077, 34.17195], [-118.60779, 34.171949], [-118.6088, 34.17194], [-118.609203, 34.17194], [-118.60932, 34.17194], [-118.60964, 34.17195], [-118.6102, 34.17198], [-118.6104, 34.172], [-118.610704, 34.172031], [-118.61089, 34.17205], [-118.61115, 34.17207], [-118.61135, 34.17207], [-118.61175, 34.17204], [-118.61215, 34.17199], [-118.61265, 34.17196], [-118.61366, 34.17196], [-118.61455, 34.17196], [-118.61678, 34.17196], [-118.61819, 34.17197], [-118.61896, 34.17196], [-118.61971, 34.17195], [-118.620452, 34.17195], [-118.62115, 34.17195], [-118.62153, 34.17195], [-118.62287, 34.17196], [-118.62333, 34.17197], [-118.6238, 34.17197], [-118.62543, 34.17196], [-118.62731, 34.17194], [-118.628244, 34.17194], [-118.62957, 34.17194], [-118.63206, 34.17192]]
},
properties : {
id : 0.0,
asset_type : "FBR",
carrier : "AT&T",
type : "ON_ROAD",
cbsa : "31100",
lata : "730",
zip : null,
state : null
}
};
db.testLS.remove({});
db.testLS.ensureIndex( { geometry : "2dsphere" } );
db.testLS.insert( lineString );
// example query using a point
db.testLS.find( { geometry : {
$near : {
$geometry : {
type : "Point",
coordinates : [ 110, 30 ]
}
}
} } );
// returns the lineString object.
相关文章:
- 有哪些有效的方法可以消除一组 100 万个字符串>重复数据?
- 当映射包含字符串向量作为值时,从值中获取键的有效方法
- 如何正确解析子字符串,以便它们对我的新手计算器有效?
- C++程序在将 int 与 cin 一起使用时有效,但不能使用字符串
- 如何检查字符串格式在读取C++文本文件时是否有效?
- 创建字符串数组的有效方法
- 访问包含P的有效索引时返回空格的C++字符串
- 如何有效地将一个大std::字符串的一部分转换为float
- C++Int有效地字符串
- 是否有更有效的方法来生成日期的REGEX字符串
- 是什么使这个以'+'开头的字符串添加成为有效的语句?
- 为C++字符串中的特殊符号 (") 赋予文字含义的有效C++方法
- 拆分字符串输入并查找字符是否有效
- 设计返回有效字符串的方法或函数
- 使用 pair<int、int> 或字符串作为 map<> 键,哪个更有效?
- 字符串只包含有效的字符?
- 如何更有效地计算n个字符串之间的不匹配分数?
- 当字符串中只有一个"GOOD"字符串可用时,从没有空格的字符串中提取第一个单词的最佳和有效方法?
- 使用UTF8Proc的C 字符串到UTF8有效字符串
- 保证有效字符串作为函数参数