您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

连接到 WFS 服务Connect to a WFS service

Web 功能服务 (WF) 是一项 web 服务,用于查询具有标准化 API (由开放地理空间信息联盟 (OGC) 定义)的空间数据。A Web Feature Service (WFS) is a web service for querying spatial data that has a standardized API that is defined by the Open Geospatial Consortium (OGC). 使用 WfsClient 空间 IO 模块中的类,开发人员可以连接到 wf 服务并查询该服务中的数据。The WfsClient class in the spatial IO module lets developers connect to a WFS service and query data from the service.

类支持以下功能 WfsClientThe following features are supported by the WfsClient class:

  • 支持的版本: 1.0.01.1.02.0.0Supported versions: 1.0.0, 1.1.0, and 2.0.0

  • 支持的筛选器运算符:二进制比较、逻辑、数学、值和 bboxSupported filter operators: binary comparisons, logic, math, value, and bbox.

  • 仅使用发出的请求 HTTP GETRequests are made using HTTP GET only.

  • 支持的操作:Supported operations:

    OperationOperation 说明Description
    GetCapabilitiesGetCapabilities 使用有效的 WF 操作和参数生成元数据文档Generates a metadata document with valid WFS operations and parameters
    GetFeatureGetFeature 返回数据源中的选定功能Returns a selection of features from a data source
    DescribeFeatureTypeDescribeFeatureType 返回支持的功能类型Returns the supported feature types

使用 WF 客户端Using the WFS client

使用 atlas.io.ogc.WfsClient 空间 IO 模块中的类可以轻松地查询 wf 服务并将响应转换为 GeoJSON 对象。The atlas.io.ogc.WfsClient class in the spatial IO module makes it easy to query a WFS service and convert the responses into GeoJSON objects. 然后,可以将此 GeoJSON 对象用于其他映射目的。This GeoJSON object can then be used for other mapping purposes.

下面的代码查询 WF 服务,并在地图上呈现返回的功能。The following code queries a WFS service and renders the returned features on the map.


支持的筛选器Supported filters

WF 标准规范使用 OGC 筛选器。The specification for the WFS standard makes use of OGC filters. WF 客户端支持以下筛选器,假定调用的服务还支持这些筛选器。The filters below are supported by the WFS client, assuming that the service being called also supports these filters. 自定义筛选器字符串可以传递到 CustomFilter 类中。Custom filter strings can be passed into the CustomFilter class.

逻辑运算符Logical operators

  • And
  • Or
  • Not

值运算符Value operators

  • GmlObjectId
  • ResourceId

数学运算符Math operators

  • Add
  • Sub
  • Mul
  • Div

比较运算符Comparison operators

  • PropertyIsEqualTo
  • PropertyIsNotEqualTo
  • PropertyIsLessThan
  • PropertyIsGreaterThan
  • PropertyIsLessThanOrEqualTo
  • PropertyIsGreaterThanOrEqualTo
  • PropertyIsLike
  • PropertyIsNull
  • PropertyIsNil
  • PropertyIsBetween

下面的代码演示如何将不同筛选器与 WF 客户端一起使用。The following code demonstrates the use of different filters with the WFS client.


WF 服务资源管理器WFS service explorer

以下代码使用 WF 客户端来浏览 WF 服务。The following code uses the WFS client to explore WFS services. 选择服务中的属性类型层,并查看关联的图例。Select a property type layer within the service and see the associated legend.


若要访问在未启用 CORS 的终结点上托管的 WF 服务,可以将启用 CORS 的代理服务传递到 proxyService wf 客户端的选项中,如下所示。To access WFS services hosted on non-CORS enabled endpoints, a CORS enabled proxy service can be passed into the proxyService option of the WFS client as shown below.

//Create the WFS client to access the service and use the proxy service settings
client = new atlas.io.ogc.WfsClient({
    url: url,
    proxyService: window.location.origin + '/YourCorsEnabledProxyService.ashx?url='
});

后续步骤Next steps

详细了解本文中使用的类和方法:Learn more about the classes and methods used in this article:

有关可向地图添加的更多代码示例,请参阅以下文章:See the following articles for more code samples to add to your maps: