${mapping_GetFeatureResult_Tile}
${mapping_GetFeatureResult_Description}
private GetWFSFeatureResult ParseSuccessResult(XDocument document) { GetWFSFeatureResult featureRes = new GetWFSFeatureResult(); if (document != null && document.Document != null && document.Document.Root != null) { foreach (var item in document.Document.Root.Attributes()) { nameSpacePair.Add(item.Name.LocalName, item.Value); } //decimal="." cs="," ts=" " (-133.878943,-45.6267275) (540000,5450000) //这里只提供默认的分隔符,自定义的就不考虑了,用户如果有需求那就自己处理吧。 XElement XBounds = document.Document.Root.Element(XName.Get("boundedBy", nameSpacePair["gml"])); XElement pointvalue = XBounds != null ? XBounds.Element(XName.Get("Box", nameSpacePair["gml"])) : null; //还有unknown的情况啊 if (pointvalue != null && !string.IsNullOrEmpty(pointvalue.Value)) { string[] value = pointvalue.Value.Trim().Split(',', ' '); if (value != null && value.Length == 4) { double x1 = double.Parse(value[0], CultureInfo.InvariantCulture); double y1 = double.Parse(value[1], CultureInfo.InvariantCulture); double x2 = double.Parse(value[2], CultureInfo.InvariantCulture); double y2 = double.Parse(value[3], CultureInfo.InvariantCulture); if (x2 - x1 >= 0 || y2 - y1 >= 0) { featureRes.Bounds = new Rectangle2D(x1, y1, x2, y2); } } } else //有时候查询出来没有结果,所以就认为是成功了。 { } IEnumerable<XElement> featureMembers = document.Document.Root.Elements(XName.Get("featureMember", nameSpacePair["gml"])); foreach (var item in featureMembers) { ParseFeatureMember(featureRes, item); } } return featureRes; }
private async void ParseFeatureMember(GetWFSFeatureResult featureRes, XElement item) { if (item != null) { XElement element = item.FirstNode as XElement; string profix = string.Empty; string fullEleName = string.Empty; if (element != null) { profix = element.GetPrefixOfNamespace(element.Name.Namespace); fullEleName = string.IsNullOrEmpty(profix) ? element.Name.LocalName : profix + ":" + element.Name.LocalName; } string spatialPropName = GetSpatialPropName(fullEleName); if (!featureRes.FeaturePair.ContainsKey(fullEleName)) { featureRes.FeaturePair.Add(fullEleName, new FeatureCollection()); } if (featureRes.FeaturePair[fullEleName] != null) { foreach (Feature f in await GetFeatures(element, spatialPropName)) { featureRes.FeaturePair[fullEleName].Add(f); } } } }