我已经成功地将地理数据导入了一个名为AdministrativeArea的类,其中包含一个WKT字段。该字段包含longitue和latitude的多边形坐标点。我已将其声明为字符串。 我想查询文档,找出我的多边形/地理区域包含在给定的边界矩形中。为此,我使用空间特征创建了一个索引。 似乎有些东西是"关闭"使用此索引或我构建它的方式:索引计数停留在0并且没有进一步发生,或者它开始构建但卡在随机数上,我收到错误消息。有人可以帮忙吗?
谢谢!
代码/错误消息:
"WKT": "POLYGON ((21.7515487670898 62.0147895812988,21.7420005798341 62.0149002075195, etc. etc.
public class AdministrativeArea_ByNameAndWKT : AbstractIndexCreationTask<AdministrativeArea>
{
public AdministrativeArea_ByNameAndWKT()
{
Map = AdministrativeAreas => from a in AdministrativeAreas
select new
{
Name = a.NAME_1,
WKT = a.WKT
};
Spatial(x => x.WKT, options => options.Geography.Default());
}
}
Failed to load routed module (viewmodels/database/status/indexing/indexStats). Details: Load timeout for modules: d3/d3
以下是我寻找区域的方法:
IList<AdministrativeArea> results = session
.Query<AdministrativeArea, AdministrativeArea_ByNameAndWKT>()
.Spatial(x => x.WKT, criteria => criteria.WithinRadius(6.0, 0.24380, 6.636))
.ToList();
...和类定义:
public class AdministrativeArea
{
public string WKT { get; set; }
public int OBJECTID { get; set; }
public float UID { get; set; }
public int ID_0 { get; set; }
public string ISO { get; set; }
public string NAME_0 { get; set; }
public int ID_1 { get; set; }
public string NAME_1 { get; set; }
public string VARNAME_1 { get; set; }
public string NL_NAME_1 { get; set; }
public string HASC_1 { get; set; }
public string CCN_1 { get; set; }
public string CCA_1 { get; set; }
public string TYPE_1 { get; set; }
public string ENGTYPE_1 { get; set; }
public string VALIDFR_1 { get; set; }
public string VALIDTO_1 { get; set; }
public string REMARKS_1 { get; set; }
public int? ID_2 { get; set; }
public string NAME_2 { get; set; }
public string VARNAME_2 { get; set; }
public string NL_NAME_2 { get; set; }
public string HASC_2 { get; set; }
public int CCN_2 { get; set; }
public string CCA_2 { get; set; }
public string TYPE_2 { get; set; }
public string ENGTYPE_2 { get; set; }
public string VALIDFR_2 { get; set; }
public string VALIDTO_2 { get; set; }
public string REMARKS_2 { get; set; }
public int ID_3 { get; set; }
public string NAME_3 { get; set; }
public string VARNAME_3 { get; set; }
public string NL_NAME_3 { get; set; }
public string HASC_3 { get; set; }
public int CCN_3 { get; set; }
public string CCA_3 { get; set; }
public string TYPE_3 { get; set; }
public string ENGTYPE_3 { get; set; }
public string VALIDFR_3 { get; set; }
public string VALIDTO_3 { get; set; }
public string REMARKS_3 { get; set; }
public int ID_4 { get; set; }
public string NAME_4 { get; set; }
public string VARNAME_4 { get; set; }
public int CCN_4 { get; set; }
public string CCA_4 { get; set; }
public string TYPE_4 { get; set; }
public string ENGTYPE_4 { get; set; }
public string VALIDFR_4 { get; set; }
public string VALIDTO_4 { get; set; }
public string REMARKS_4 { get; set; }
public int ID_5 { get; set; }
public string NAME_5 { get; set; }
public int CCN_5 { get; set; }
public string CCA_5 { get; set; }
public string TYPE_5 { get; set; }
public string ENGTYPE_5 { get; set; }
public string REGION { get; set; }
public string VARREGION { get; set; }
public float Shape_Leng { get; set; }
public float Shape_Area { get; set; }
}
...还有一个示例JSON(其中有~260.000 ......)
{
"WKT": "POLYGON ((29.666404724121 -28.5651550292969,29.6635494232178 -28.5674591064453,29.6602096557618 -28.5701694488525,29.6568603515626 -28.5728702545166,29.6519393920898 -28.5768508911132,29.6490306854248 -28.5791893005371,29.6461200714112 -28.5815391540527,29.6373901367189 -28.58856010437,29.6344795227051 -28.5909099578857,29.6345596313476 -28.5909996032715,29.6346702575684 -28.5911197662353,29.6353797912599 -28.5918998718262,29.6361103057862 -28.5927104949951,29.6368408203124 -28.5935096740723,29.6375408172609 -28.5942897796631,29.6375904083253 -28.5943508148193,29.6382408142091 -28.5950794219971,29.6389408111573 -28.595890045166,29.6396198272705 -28.5966701507568,29.6403102874756 -28.5974502563476,29.6410102844238))",
"OBJECTID": 207648,
"UID": 20764800000000000,
"ID_0": 211,
"ISO": "ZAF",
"NAME_0": "South Africa",
"ID_1": 4,
"NAME_1": "KwaZulu-Natal",
"VARNAME_1": "Natal and Zululand",
"NL_NAME_1": "",
"HASC_1": "ZA.NL",
"CCN_1": 0,
"CCA_1": "KZN",
"TYPE_1": "Provinsie",
"ENGTYPE_1": "Province",
"VALIDFR_1": "Unknown",
"VALIDTO_1": "Present",
"REMARKS_1": "",
"ID_2": 27,
"NAME_2": "Uthukela",
"VARNAME_2": "",
"NL_NAME_2": "",
"HASC_2": "ZA.NL.UL",
"CCN_2": 0,
"CCA_2": "DC23",
"TYPE_2": "District Municipality",
"ENGTYPE_2": "District Municipality",
"VALIDFR_2": 2011,
"VALIDTO_2": "Current",
"REMARKS_2": "",
"ID_3": 108,
"NAME_3": "Okhahlamba",
"VARNAME_3": "",
"NL_NAME_3": "",
"HASC_3": "",
"CCN_3": 0,
"CCA_3": "KZN235",
"TYPE_3": "Local Municipality",
"ENGTYPE_3": "Local Municipality",
"VALIDFR_3": 2011,
"VALIDTO_3": "Current",
"REMARKS_3": "",
"ID_4": 2161,
"NAME_4": 13,
"VARNAME_4": "",
"CCN_4": 52305013,
"CCA_4": "",
"TYPE_4": "Ward",
"ENGTYPE_4": "Ward",
"VALIDFR_4": 2011,
"VALIDTO_4": "Current",
"REMARKS_4": "",
"ID_5": 0,
"NAME_5": "",
"CCN_5": 0,
"CCA_5": "",
"TYPE_5": "",
"ENGTYPE_5": "",
"REGION": "",
"VARREGION": "",
"Shape_Leng": 194782209549,
"Shape_Area": 6270373326
}
顺便说一下:在每个260.000区域内有数百个,如果不是数千个纬度/经度点(由于空间原因,我在上面的例子中切断了大约90%的坐标......)。也许我的方法对这种情况不恰当?
RavenDB索引行为对此非常奇怪:它似乎得到了&#34;卡住&#34;在索引任务上(CPU介于20%和40美元之间,RAM消耗一致但缓慢上升),但没有创建新的索引条目,也没有出现错误消息。我在一台配备16GB内存和i7至3.6GHz的笔记本电脑上运行。
答案 0 :(得分:1)
问题是这个形状的长度约为5千米,宽度为600-700米,并且没有很好地对齐。 我们所拥有的默认精度模式设置为约5米,这意味着我们需要有效地绘制由许多小的5米碎片组成的形状,粗略估计它们将是大约350K。
简化形状或降低精度。
您可以在此处查看有关空间精度的文档: http://ravendb.net/docs/article-page/3.5/Csharp/indexes/indexing-spatial-data