예제 #1
0
		public static LayoutInfo ReadFrom(ArcXmlReader reader)
		{
			try
			{
				LayoutInfo layoutInfo = new LayoutInfo();

				if (reader.HasAttributes)
				{
					while (reader.MoveToNextAttribute())
					{
						string value = reader.ReadContentAsString();

						if (value.Length > 0)
						{
							switch (reader.Name)
							{
								case "pageunits": layoutInfo.PageUnits = (PageUnits)ArcXmlEnumConverter.ToEnum(typeof(PageUnits), value); break;
							}
						}
					}

					reader.MoveToElement();
				}

				if (!reader.IsEmptyElement)
				{
					reader.Read();

					while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
					{
						if (reader.NodeType == XmlNodeType.Element)
						{
							switch (reader.Name)
							{
                case "ENVELOPE": layoutInfo.Envelope = EnvelopeSerializer.ReadFrom(reader); break;
              }
						}

						reader.Read();
					}
				}

				return layoutInfo;
			}
			catch (Exception ex)
			{
				if (ex is ArcXmlException)
				{
					throw ex;
				}
				else
				{
					throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
				}
			}
		}
예제 #2
0
        public static Properties ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Properties properties = new Properties();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case Background.XmlName: properties.Background = Background.ReadFrom(reader); break;

                            case "ENVELOPE": properties.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case FeatureCoordSys.XmlName: properties.FeatureCoordSys = FeatureCoordSys.ReadFrom(reader); break;

                            case FilterCoordSys.XmlName: properties.FilterCoordSys = FilterCoordSys.ReadFrom(reader); break;

                            case ImageGeneralization.XmlName: properties.ImageGeneralization = ImageGeneralization.ReadFrom(reader); break;

                            case ImageSize.XmlName: properties.ImageSize = ImageSize.ReadFrom(reader); break;

                            case MapUnits.XmlName: properties.MapUnits = MapUnits.ReadFrom(reader); break;

                            case Output.XmlName: properties.Output = Output.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(properties);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #3
0
        public static Project ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Project project = new Project();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": project.Envelopes.Add(EnvelopeSerializer.ReadFrom(reader)); break;

                            case "MULTIPOINT":
                                IMultiPoint multiPoint = (IMultiPoint)GeometrySerializer.ReadFrom(reader);
                                IGeometry   shape      = multiPoint.Count == 1 ? (IGeometry)multiPoint[0] : (IGeometry)multiPoint;
                                project.Shapes.Add(shape);
                                break;

                            case "POLYLINE":
                            case "POLYGON":
                                project.Shapes.Add(GeometrySerializer.ReadFrom(reader));
                                break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(project);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #4
0
        public static Image ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Image image = new Image();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": image.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case Output.XmlName: image.Output = Output.ReadFrom(reader); break;

                            case Layers.XmlName: image.Layers = Layers.ReadFrom(reader); break;

                            case Scale.XmlName: image.Scale = Scale.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(image);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #5
0
        public static Features ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Features features = new Features();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": features.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case FeatureCount.XmlName: features.FeatureCount = FeatureCount.ReadFrom(reader); break;

                            case Feature.XmlName: features.Add(Feature.ReadFrom(reader)); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(features);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #6
0
        public static Layout ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Layout layout = new Layout();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": layout.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case Output.XmlName: layout.Output = Output.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(layout);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #7
0
        public static FClass ReadFrom(ArcXmlReader reader)
        {
            try
            {
                FClass fClass = new FClass();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "type": fClass.Type = (FClassType)ArcXmlEnumConverter.ToEnum(typeof(FClassType), value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": fClass.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case Field.XmlName:
                                if (fClass.Fields == null)
                                {
                                    fClass.Fields = new Fields();
                                }

                                fClass.Fields.Add(Field.ReadFrom(reader));
                                break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(fClass);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #8
0
        public static LayerInfo ReadFrom(ArcXmlReader reader)
        {
            try
            {
                LayerInfo layerInfo = new LayerInfo();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "arcmaptype": layerInfo.ArcMapType = (ArcMapType)ArcXmlEnumConverter.ToEnum(typeof(ArcMapType), value); break;

                            case "id": layerInfo.ID = value; break;

                            case "type": layerInfo.Type = (LayerType)ArcXmlEnumConverter.ToEnum(typeof(LayerType), value); break;

                            case "maxscale": layerInfo.MaxScale = value; break;

                            case "minscale": layerInfo.MinScale = value; break;

                            case "name": layerInfo.Name = value; break;

                            case "parentlayerid": layerInfo.ParentLayerID = value; break;

                            case "visible": layerInfo.Visible = Convert.ToBoolean(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": layerInfo.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case FClass.XmlName: layerInfo.FClass = FClass.ReadFrom(reader); break;

                            case GroupRenderer.XmlName: layerInfo.Renderer = GroupRenderer.ReadFrom(reader); break;

                            case RasterRenderer.XmlName: layerInfo.Renderer = RasterRenderer.ReadFrom(reader); break;

                            case ScaleDependentRenderer.XmlName: layerInfo.Renderer = ScaleDependentRenderer.ReadFrom(reader); break;

                            case SimpleLabelRenderer.XmlName: layerInfo.Renderer = SimpleLabelRenderer.ReadFrom(reader); break;

                            case SimpleRenderer.XmlName: layerInfo.Renderer = SimpleRenderer.ReadFrom(reader); break;

                            case Toc.XmlName: layerInfo.Toc = Toc.ReadFrom(reader); break;

                            case ValueMapLabelRenderer.XmlName: layerInfo.Renderer = ValueMapLabelRenderer.ReadFrom(reader); break;

                            case ValueMapRenderer.XmlName: layerInfo.Renderer = ValueMapRenderer.ReadFrom(reader); break;

                            case Extension.XmlName:
                                if (layerInfo.Extensions == null)
                                {
                                    layerInfo.Extensions = new List <Extension>();
                                }

                                layerInfo.Extensions.Add(Extension.ReadFrom(reader)); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(layerInfo);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
예제 #9
0
        public static Feature ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Feature feature = new Feature();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "featureid": feature.FeatureID = value; break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": feature.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case Fields.XmlName: feature.Fields = Fields.ReadFrom(reader); break;

                            case Field.XmlName: feature.Fields.Add(Field.ReadFrom(reader)); break;

                            case "MULTIPOINT":
                                IMultiPoint multiPoint = GeometrySerializer.ReadMultiPointFrom(reader);
                                feature.Shape = multiPoint.Count == 1 ? (IGeometry)multiPoint[0] : (IGeometry)multiPoint;
                                break;

                            case "POLYLINE": feature.Shape = GeometrySerializer.ReadPolylineFrom(reader); break;

                            case "POLYGON": feature.Shape = GeometrySerializer.ReadPolygonFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(feature);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }