RavenDB 空间索引未建立
RavenDB spatial index not building
我已成功将地理数据导入到我称为 AdministrativeArea 的 class 中,其中包含一个 WKT 字段。该字段包含经度和纬度的多边形坐标点。我已将其声明为字符串。
我想查询文档以找出我的哪些 polygons/geographic 区域包含在给定的边界矩形内。为此,我使用空间特征创建了一个索引。
这个索引或我正在构建它的方式似乎 "off" :索引计数停留在 0 并且没有进一步发生,或者它开始构建但停留在随机数上,我得到一条错误信息。有人可以帮忙吗?
谢谢!
code/error 消息:
"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();
...和 class 定义:
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 个区域中,每个区域都有数百个甚至数千个 lat/lng 点(出于 space 原因,我在上面的示例中切断了大约 90% 的坐标...)。也许我的方法不适合这种情况?
RavenDB 的索引行为对此非常奇怪:它似乎在索引任务上得到 "stuck"(CPU 在 20% 到 40$ 之间,并且 RAM 消耗持续但缓慢地上升),但没有创建新的索引条目,也没有出现错误消息。我 运行 这台笔记本电脑配备 16GB 内存和 ~3.6GHz 的 i7。
这就是你的身材
问题是这个形状长约 5 公里,宽约 600 - 700 米,并且没有很好地对齐。
我们默认的精度模式设置为大约 5 米,这意味着我们需要有效地绘制一个由许多 5 米小块组成的形状,粗略估计大约有 350K 个。
要么简化形状,要么降低精度。
你可以在这里看到关于空间精度的文档:
http://ravendb.net/docs/article-page/3.5/Csharp/indexes/indexing-spatial-data
我已成功将地理数据导入到我称为 AdministrativeArea 的 class 中,其中包含一个 WKT 字段。该字段包含经度和纬度的多边形坐标点。我已将其声明为字符串。 我想查询文档以找出我的哪些 polygons/geographic 区域包含在给定的边界矩形内。为此,我使用空间特征创建了一个索引。 这个索引或我正在构建它的方式似乎 "off" :索引计数停留在 0 并且没有进一步发生,或者它开始构建但停留在随机数上,我得到一条错误信息。有人可以帮忙吗?
谢谢!
code/error 消息:
"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();
...和 class 定义:
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 个区域中,每个区域都有数百个甚至数千个 lat/lng 点(出于 space 原因,我在上面的示例中切断了大约 90% 的坐标...)。也许我的方法不适合这种情况?
RavenDB 的索引行为对此非常奇怪:它似乎在索引任务上得到 "stuck"(CPU 在 20% 到 40$ 之间,并且 RAM 消耗持续但缓慢地上升),但没有创建新的索引条目,也没有出现错误消息。我 运行 这台笔记本电脑配备 16GB 内存和 ~3.6GHz 的 i7。
这就是你的身材
问题是这个形状长约 5 公里,宽约 600 - 700 米,并且没有很好地对齐。 我们默认的精度模式设置为大约 5 米,这意味着我们需要有效地绘制一个由许多 5 米小块组成的形状,粗略估计大约有 350K 个。
要么简化形状,要么降低精度。
你可以在这里看到关于空间精度的文档: http://ravendb.net/docs/article-page/3.5/Csharp/indexes/indexing-spatial-data