OpenLayers调用ArcGIS Server发布的WFS服务

原创: 蔡建良 2013-08-20

一. 开发环境

1) Openlayers2.13+arcgis server9.3

2) WFS地图空间参考EPSG: 4326也可以是EPSG:102113

3) Openlayers底图空间参考EPSG: 900913

二. 发布地图服务

1) 采用ArcMap制作mxd地图文档。

2) 采用ArcCatalog发布地图服务,将wfs打勾。

部分操作截图如下:

3) 测试WFS服务:

http://lx-server/arcgis/services/Yangdi/MapServer/WFSServer?request=GetCapabilities&service=WFS

三. 采用OpenLayers.Layer.Vector调用。该方法为POST方式。

WFS1.1.0支持服务端重投影:

new OpenLayers.Layer.Vector("一类样地",{

strategies: [new OpenLayers.Strategy.BBOX()],

protocol: new OpenLayers.Protocol.WFS({

version: "1.1.0",

srsName: "EPSG:102113",

url: "http://lx-server/arcgis/services/Yangdi/MapServer/WFSServer",

featureNS: "",

featureType: "plotpoint_Liaoning_Intersect",

maxFeatures: "10",

geometryName: "Shape"

}),

projection: new OpenLayers.Projection("EPSG:102113"),

visibility: false

})

WFS1.0.0不支持服务端重投影,这边是客户端重投影:

new OpenLayers.Layer.Vector("一类样地",{

strategies: [new OpenLayers.Strategy.BBOX()],

protocol: new OpenLayers.Protocol.WFS({

version: "1.0.0",

srsName: "EPSG:4326",

url: "http://lx-server/arcgis/services/Yangdi/MapServer/WFSServer",

featureNS: "",

featureType: "plotpoint_Liaoning_Intersect",

maxFeatures: "10",

geometryName: "Shape"

}),

projection: new OpenLayers.Projection("EPSG:4326"),

visibility: false

})

四. 采用OpenLayers.Layer.WFS调用。该方法为GET方式。

注意:使用该方法必须引入deprecated.js 文件。

new OpenLayers.Layer.WFS(

"一类样地",

"http://lx-server/arcgis/services/Yangdi/MapServer/WFSServer?",

{

request: 'GetFeature',

typename: "plotpoint_Liaoning_Intersect",

maxfeatures: 10,

extractAttributes: false,

version: "1.1.0",

srsName: "EPSG:102113"

},

{

projection: new OpenLayers.Projection("EPSG:900913"),

isBaseLayer: false,

extractAttributes: false,

visibility: false

}

)

五. OpenLayers调用WFS服务跨域问题解决

1) 在IIS中部署Openlayers开发的网站。

2) 安装python。并让IIS支持python脚本。部分操作截图:

3) 将openlayes自带的proxy.cgi扩展名改为proxy.py,并做如下修改。

(1) 打开proxy.py文件,将开头第一行内容

#!/usr/bin/env python (这是linux的路径)

改为windows路径:

#!C:/Python25/python.exe –u

(2) 在allowedHosts数组中添加要访问的跨域网址lx-server。

allowedHosts = ['www.openlayers.org', 'openlayers.org',

'labs.metacarta.com', 'world.freemap.in',

'prototype.openmnnd.org', 'geo.openplans.org',

'sigma.openplans.org', 'demo.opengeo.org',

'www.openstreetmap.org', 'sample.azavea.com',

'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080',

'vmap0.tiles.osgeo.org', 'www.openrouteservice.org',

'maps.wien.gv.at','lx-server’]

4) 在网页脚本中加入如下代码:

OpenLayers.ProxyHost = "proxy.py?url=";

六.测试

在浏览器上运行网页:http://localhost/ yangdi/index.html

效果如下:

Wfs服务返回数据格式为:

<wfs:FeatureCollection xmlns:anhuiplot="http://jane/arcgis/services/anhuiplot/MapServer/WFSServer" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jane/arcgis/services/anhuiplot/MapServer/WFSServer http://localhost/arcgis/services/anhuiplot/MapServer/WFSServer?request=DescribeFeatureType%26version=1.1.0%26typename=anhuiproj http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">

<gml:boundedBy>...</gml:boundedBy>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

<gml:featureMember>...</gml:featureMember>

</wfs:FeatureCollection>

---其中featureMember-----------------

<gml:featureMember>

<anhuiplot:anhuiproj gml:id="F3__10">

<anhuiplot:OBJECTID>10</anhuiplot:OBJECTID>

<anhuiplot:Shape>

<gml:Point>

<gml:pos>13058352.4935765 3694896.1439479</gml:pos>

</gml:Point>

</anhuiplot:Shape>

<anhuiplot:PLOT_NO>6975</anhuiplot:PLOT_NO>

</anhuiplot:anhuiproj>

</gml:featureMember>

经测试返回10个要素,数据大小为45K。这是由于字段太多造成。可将wfs服务的数据源不需要的字段删除,留下关键字段。最后留下3个字段,返回数据的大小变为4K。

OpenLayers调用ArcGIS Server发布的WFS服务的更多相关文章

  1. OpenLayers调用arcgis server发布的地图服务

    有两种方式可以调用arcgis server发布的地图服务,一种是rest,一种是wms.  地图的投影为900913,arcgis server为10.0版本,地图服务的空间参考为3857.   与 ...

  2. ArcGIS API for JavaScript(2)-ArcGIS Server发布要素图层服务

    1.前言 上一篇该系列的文章我们主要讲了一下基础Web地图搭建,这篇我们主要讲一下ArcGIS Server发布服务,并且如何调用服务.将自己的数据加载到Web地图当中来,实现Web端浏览数据. 2. ...

  3. C#中winform下利用ArcEngine调用ArcGIS Server发布的服务 AE9.3

    主要使用了AE中的IAGSServerOject接口及IMapServer接口.Private void GetServerTest_Click(object sender, EventArgs e) ...

  4. C#中winform下利用ArcEngine调用ArcGIS Server发布的服务 AE 10

    开发环境:vs2010 + AE 10 测试 public Form1() { ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engi ...

  5. Arcgis api for javascript学习笔记 - 不改变默认端口(6080)情况下,外网访问Arcgis Server 发布的接口

    Arcgis Server发布的地图服务地址默认端口号是6080,假设本机上只对80端口做了外网映射,在IIS中部署了一个网站绑定了80端口,那么网站中某个页面通过arcgis api for js ...

  6. arcgis engine 调用arcgis server服务

    首先需要添加两个引用: using ESRI.ArcGIS.GISClient;using ESRI.ArcGIS.DataSourcesRaster; /// <summary> /// ...

  7. 不同网段无法加载ArcGIS Server发布服务解决方法

    问题描述: ArcGIS Server 10发布的服务, (1)在相同网段的Desktop9.3和Engine 9.3程序下可以正常显示, (2)在不同网段Desktop9.3和Engine 9.3程 ...

  8. ArcGis server发布地图服务

    ArcGIS server发布服务: 首先修改地图文档属性中的关联默认数据库 最后使用分享将地图服务发布到server上,是地图服务可以使用: 注意一定要勾选 Feature Access选项 fea ...

  9. ArcMap 发布 ArcGIS Server OGC(WMSServer,MapServer)服务

    完整的从ArcMap部署地图到ArcGIS Server 中作为地图服务的过程. 1. 添加图层数据-- 不能添加地图 baseMap 2. 安装ArcGIS Server ,记住登录Manager ...

随机推荐

  1. mp3 音频 音乐 tag ID3 ID3V1 ID3V2 标签 读取信息 获得图片 jpeg bmp 图片转换等

    mp3 音频 音乐 tag ID3 ID3V1 ID3V2 标签 读取信息 获得图片 jpeg bmp 图片转换(上) MP3文件格式(二)---ID3v2 图:ID3V1标签结构 图:ID3V2标签 ...

  2. mysql C api

    1.初始化一个链接结构. 2.创建一个链接. 3.执行查询. 4.关闭链接. MYSQL* conn; 首先,声明一个conn指针指向一个MYSQL结构体,这个结构体就是一个数据库连接句柄. conn ...

  3. WEB前端介绍

    1.WEB前端是神马 Web前端开发是从网页制作演变而来的,名称上有很明显的时代特征.在互联网的演化进程中,网页制作是Web1.0时代的产物,那时网站的主要内容都是静态的,用户使用网站的行为也以浏览为 ...

  4. Deeplearning原文作者Hinton代码注解

    [z]Deeplearning原文作者Hinton代码注解 跑Hinton最初代码时看到这篇注释文章,很少细心,待研究... 原文地址:>http://www.cnblogs.com/BeDPS ...

  5. php set_include_path

    string set_include_path ( string $new_include_path ) 为当前脚本设置 include_path 运行时的配置选项. Example #2 添加到in ...

  6. js中indexOF和lastIndexOf

    indexOFindexOf() 方法返回某个指定的字符串值在字符串中首次出现的位置(从左向右).没有匹配的则返回-1,否则返回首次出现位置的字符串的下标值. var src="images ...

  7. 习惯&感恩

    A不喜欢吃鸡蛋,都给了B吃,刚开始B很感谢,久而久之便习惯了.习惯了,便理所当然了. 后来有一天,A将鸡蛋给了C,B就不爽了.她忘记了这个鸡蛋本来就是A的,A想给谁都可以. 为此,她们大吵一架,从此绝 ...

  8. 命令 crontab

    crontab命令选项基本只有对用户操作的选项: -u 指定一个用户 -l 列出某个用户的任务计划 -r 删除某个用户的任务 -e 编辑某个用户的任务 所以,要查看所有用户的,只能根据/etc/pas ...

  9. poj -3614 Sunscreen(贪心 + 优先队列)

    http://poj.org/problem?id=3614 有c头奶牛在沙滩上晒太阳,每头奶牛能忍受的阳光强度有一个最大值(max_spf) 和最小值(min_spf),奶牛有L种防晒霜,每种可以固 ...

  10. 《OD学hadoop》第二周0702

    大数据离线计算hadoop2.x 三周(6天) markdown文本剪辑器 罗振宇--跨年演讲,时间的朋友 http://tech.163.com/16/0101/11/BC87H8DF000915B ...