private void CreateFeatureDefinition(string description, string name, KMLStyle kmlStyle, XElement placemark) { FeatureDescriptor fd = null; // Determine what kind of feature is present in the placemark XElement geomElement = GetFeatureType(placemark); if (geomElement != null && geomElement.Name != null) { switch (geomElement.Name.LocalName) { case "Point": fd = ExtractPoint(kmlStyle, geomElement); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } break; case "LineString": fd = ExtractPolyLine(kmlStyle, geomElement); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } break; case "LinearRing": fd = ExtractLinearRing(kmlStyle, geomElement); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } break; case "MultiGeometry": // Use recursion to walk the hierarchy of embedded definitions IEnumerable<XNode> x = geomElement.Nodes(); foreach (XNode n in x) { string s = n.ToString(); if (s.Contains("Point")) { XElement e = (XElement)n; fd = ExtractPoint(kmlStyle, e); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } } if (s.Contains("LineString")) { XElement e = (XElement)n; fd = ExtractPolyLine(kmlStyle, e); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } } if (s.Contains("Polygon")) { XElement e = (XElement)n; fd = ExtractPolygon(kmlStyle, e); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } } if (s.Contains("LinearRing")) { XElement e = (XElement)n; fd = ExtractLinearRing(kmlStyle, e); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } } } break; //CreateFeatureDefinition(description, name, kmlStyle, geomElement); //break; case "Polygon": fd = ExtractPolygon(kmlStyle, geomElement); if (fd != null) { if (!String.IsNullOrEmpty(description)) fd.Attributes.Add("description", description); if (!String.IsNullOrEmpty(name)) fd.Attributes.Add("name", name); featureDefs.AddFeature(fd); } break; } // If a feature definition was created, then assign attributes and add to collection //if (fd != null) //{ // if (!String.IsNullOrEmpty(description)) // fd.Attributes.Add("description", description); // if (!String.IsNullOrEmpty(name)) // fd.Attributes.Add("name", name); // featureDefs.AddFeature(fd); //} } }
useCasesForKml ++;
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.