internal static void AddLayerInfo(EsriLayerInfo info, XmlReader propReader) { while (propReader.Read()) { if (propReader.NodeType == XmlNodeType.Element) { switch (propReader.Name) { case "FCLASS": info.IsQueryable = true; EsriField.ProcessFields(info, propReader); // AddFeatureInfo(info, propReader); break; case "ENVELOPE": info._baseExtent = EsriEnvelope.ProcessEnvelopeNode(propReader); break; case "EXTENSION": // type = Geocode, StoredQuery, or Extract if (propReader.MoveToAttribute("type")) { switch (propReader.Value) { case "Geocode": if (propReader.MoveToElement()) { if (propReader.MoveToAttribute("name")) { string x = propReader.Value; } } break; case "StoredQuery": break; case "Extract": break; } } break; default: string t = propReader.Name; break; } } else if (propReader.NodeType == XmlNodeType.EndElement) { if (propReader.Name == "LAYERINFO" || propReader.Name == "LAYER") break; } } }
internal static EsriLayerInfo AddLayerInfo(XmlReader responseReader, bool isServiceInfo) { EsriLayerInfo newLayer = new EsriLayerInfo(); while (responseReader.MoveToNextAttribute()) { switch (responseReader.Name) { case "name": newLayer._name = responseReader.Value; break; case "maxscale": newLayer._maxscale = double.Parse(responseReader.Value); break; case "minscale": newLayer._minscale = double.Parse(responseReader.Value); break; case "visible": bool vis; if (bool.TryParse(responseReader.Value, out vis)) { newLayer._isVisible = vis; } else newLayer._isVisible = responseReader.Value == "@true"; break; case "type": newLayer._type = responseReader.Value; break; case "id": newLayer._id = responseReader.Value; break; case "featurecount": newLayer.FeatureCount = int.Parse(responseReader.Value); break; } } if (isServiceInfo) AddLayerInfo(newLayer, responseReader); return newLayer; }
//public static EsriLayerInfo Create(LAYERINFO layerInfo) //{ // EsriLayerInfo info = new EsriLayerInfo(); // if (layerInfo.visibleSpecified) info._isVisible = layerInfo.visible == LAYERINFOVisible.@true; // info._id = layerInfo.id; // try // { // if (!string.IsNullOrEmpty(layerInfo.minscale)) // { // info._minscale = double.Parse(layerInfo.minscale); // } // } // catch { } // try // { // if (!string.IsNullOrEmpty(layerInfo.maxscale)) // { // info._maxscale = double.Parse(layerInfo.maxscale); // } // } // catch { } // info._name = layerInfo.name; // info._type = layerInfo.type.ToString(); // if (layerInfo.Items != null) // { // for (int i = 0; i < layerInfo.Items.Length; i++) // { // if (layerInfo.Items[i] is ENVELOPE) // { // info._baseExtent = EsriEnvelope.Create(layerInfo.Items[i] as ENVELOPE); // } // else if (layerInfo.Items[i] is FCLASS) // { // info.IsQueryable = true; // ProcessItems(layerInfo.Items[i] as FCLASS, info); // } // } // } // return info; //} //private static void ProcessItems(FCLASS fCLASS, EsriLayerInfo info) //{ // foreach (object obj in fCLASS.Items) // { // if (obj is ENVELOPE) // { // info._baseExtent = EsriEnvelope.Create(obj as ENVELOPE); // } // else if (obj is FIELD) // { // info._Fields.Add(EsriField.ProcessFieldNode(obj as FIELD)); // } // } //} //{"id":0,"name":"Davidson_County","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null} internal static GISLayerInfo Create(JSONObject obj) { EsriLayerInfo info = new EsriLayerInfo(); for (int idx = 0; idx < obj.Count; idx++) { switch (obj[idx]) { case "id": info._id = obj.getString("id"); break; case "name": info._name = obj.getString("name"); break; case "": info._isVisible = obj.getBool("defaultVisibility"); break; } } return info; }
internal static void AddFeatureInfo(EsriLayerInfo info, XmlReader propReader) { while (propReader.Read()) { if (propReader.NodeType == XmlNodeType.Element) { switch (propReader.Name) { case "FIELD": EsriField.ProcessFields(info, propReader); break; default: string t = propReader.Name; break; } } else if (propReader.NodeType == XmlNodeType.EndElement) { if (propReader.Name == "PROPERTIES") break; } } }
internal static void ProcessFields(EsriLayerInfo info, XmlReader responseReader) { while (responseReader.Read()) { if (responseReader.NodeType == XmlNodeType.EndElement && responseReader.Name == "FCLASS") break; if (responseReader.NodeType == XmlNodeType.Element) { if (responseReader.Name == "ENVELOPE") { info._baseExtent = EsriEnvelope.ProcessEnvelopeNode(responseReader); } else { info.Fields.Add(EsriField.ProcessField(responseReader)); } } } }