/// <summary> /// OGC WFS DescribeFeatureType /// </summary> /// <param name="context"></param> private void ProcessDescribeFeatureType(HttpResponse response, StringDictionary parameters) { if (!String.IsNullOrEmpty(parameters[WfsParameters.OutputFormat]) && String.Compare(parameters[WfsParameters.OutputFormat], Declarations.GMLSFFormat) != 0) { SetResponseToServiceException(response, WfsExceptionCode.InvalidFormat, "Invalid OUTPUTFORMAT for DescribeFeatureType Request. Only " + Declarations.GMLSFFormat + "format is supported"); return; } byte[] featureTypeBytes = null; // Check if this is a WFS or WMS request and get the appropriate layers parameter string layers = parameters[WfsParameters.TypeName]; if (String.IsNullOrEmpty(layers)) { throw new WfsFault(WfsExceptionCode.LayerNotDefined); } ViewContext context = new ViewContext(parameters); XmlSchema schema = FeatureCollection.GetFeatureSchema(context, false); using (MemoryStream memoryStream = new MemoryStream()) { schema.Write(memoryStream); featureTypeBytes = memoryStream.ToArray(); } response.Clear(); response.ContentType = "text/xml"; response.OutputStream.Write(featureTypeBytes, 0, featureTypeBytes.Length); }
public void GetFeatureSchemaTest() { ViewContext context = new ViewContext(); Layer layer = new Layer(); layer.Title = "World Administration Boundaries"; layer.Table = "world_admin"; layer.Name = "world_admin"; layer.GeometryColumn = "shape"; layer.FeatureIdColumn = "fid"; layer.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Projects\\GeospatialServices\\TestGeospatialServices\\Input\\Runtime\\TestGeospatialServicesDatabase.mdf;Integrated Security=True;User Instance=True"; context.Layers.Add(layer); XmlSchema schema = FeatureCollection.GetFeatureSchema(context, false); }