采用开源软件搭建WebGIS系统(8)遇到困难,决定试一试WFS

简介:
今天会用TextSymbolizer来显示文字。

数据源geo_first_class_city_point 结构如下:

gid:  int
area:  double
perimeter:  double
res1_4m_:  long 
res1_4m_id:  long 
gbcode:  int 
name:  string 
adcode93:  int
adcode99:  int
adclass:  int 
pinyin:  string 
the_geom:  pointProperty 
 
该层所采用的sld文件:
     < FeatureTypeStyle >
      
< FeatureTypeName > feature </ FeatureTypeName >
      
< Rule >
        
< TextSymbolizer >
            
< Geometry >
                
< ogc:PropertyName > the_geom </ ogc:PropertyName >
            
</ Geometry >
            
< Label >
                
< ogc:PropertyName > name </ ogc:PropertyName >
            
</ Label >
            
< Font >
                
< CssParameter  name ="font-family" > 宋体 </ CssParameter >
                
< CssParameter  name ="font-style" > italic </ CssParameter >
                
< CssParameter  name ="font-Size" >
                    
< literal > 10 </ literal >
                
</ CssParameter >
            
</ Font >
            
< LabelPlacement >
                
< PointPlacement >
                    
< AnchorPoint >
                        
< AnchorPointX > 0 </ AnchorPointX >
                        
< AnchorPointY > 0 </ AnchorPointY >
                    
</ AnchorPoint >
                
</ PointPlacement >
            
</ LabelPlacement >
            
< Fill >
                
< CssParameter  name ="fill" > #000000 </ CssParameter >
            
</ Fill >
            
< Halo />
        
</ TextSymbolizer >
        
< PointSymbolizer >
        
< Geometry >
            
< ogc:PropertyName > the_geom </ ogc:PropertyName >
        
</ Geometry >
            
< graphic >
                
< size > 6 </ size >
                
< mark >
                    
< wellknownname > circle </ wellknownname >
                    
< Fill >
                        
< CssParameter  name ="fill" > #FF0000 </ CssParameter >
                        
< CssParameter  name ="fill-opacity" > 0.8 </ CssParameter >
                    
</ Fill >
                
</ mark >
            
</ graphic >
        
</ PointSymbolizer >
    
</ Rule >
    
</ FeatureTypeStyle >


这里就不一项项解释上面各项含意了。不清楚的话请看OGC SLD规范。

得到图:



现在文字出来了,就是不好看。要弄好看点,可能需要进行坐标变换。看了看geoserver文档,当前geoserver对坐标变换支持不够。那怎么办呢?干脆通过WFS把数据调到客户端,到时候想怎么办就怎么办,想怎么显示就怎么显示,还可以加上超链接。


WFS调用格式举例如下:

http://localhost/geoserver/wfs/GetFeature?typeName=geo_first_class_city_point&BBOX=97.11500000000001,27.5225,119.11500000000001,44.5225

typeName就是你的数据层的名字,BBOX是查询范围。返回结果:

 

  <? xml version="1.0" encoding="UTF-8"  ?>  
< wfs:FeatureCollection  xmlns:wfs ="http://www.opengis.net/wfs"  xmlns:topp ="http://www.openplans.org/topp"  xmlns:gml ="http://www.opengis.net/gml"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation ="http://www.openplans.org/topp http://localhost:80/geoserver/wfs/DescribeFeatureType?typeName=topp:geo_first_class_city_point http://www.opengis.net/wfs http://localhost:80/geoserver/data/capabilities/wfs/1.0.0/WFS-basic.xsd" >
< gml:boundedBy >
< gml:Box  srsName ="http://www.opengis.net/gml/srs/epsg.xml#4326" >
  
< gml:coordinates  decimal ="."  cs =","  ts ="" > 101.7874527,28.20082474 118.77278137,40.82094193 </ gml:coordinates >  
  
</ gml:Box >
  
</ gml:boundedBy >
< gml:featureMember >
< topp:geo_first_class_city_point  fid ="geo_first_class_city_point.83613" >
  
< topp:gid > 0 </ topp:gid >  
  
< topp:area > 0.0 </ topp:area >  
  
< topp:perimeter > 0.0 </ topp:perimeter >  
  
< topp:res1_4m_ > 1 </ topp:res1_4m_ >  
  
< topp:res1_4m_id > 61 </ topp:res1_4m_id >  
  
< topp:gbcode > 31010 </ topp:gbcode >  
  
< topp:name > 北京 </ topp:name >  
  
< topp:adcode93 > 110100 </ topp:adcode93 >  
  
< topp:adcode99 > 110100 </ topp:adcode99 >  
  
< topp:adclass > 1 </ topp:adclass >  
  
< topp:pinyin > Beijing </ topp:pinyin >  
< topp:the_geom >
< gml:Point  srsName ="http://www.opengis.net/gml/srs/epsg.xml#4326" >
  
< gml:coordinates  decimal ="."  cs =","  ts ="" > 116.3809433,39.9236145 </ gml:coordinates >  
  
</ gml:Point >
  
</ topp:the_geom >
  
</ topp:geo_first_class_city_point >
  
</ gml:featureMember >
< gml:featureMember >
    ……
  
</ gml:featureMember >
  
</ wfs:FeatureCollection >

这样我可以在客户端解析wfs返回的数据,想怎么显示怎么显示。

实际上Geoserver+Geotools已经实现了大部分webgis的功能,只要理解了OGC规范,不难开发出复杂的应用。

本文转自xiaotie博客园博客,原文链接http://www.cnblogs.com/xiaotie/archive/2005/08/19/218509.html如需转载请自行联系原作者


xiaotie 集异璧实验室(GEBLAB)

相关文章
|
12月前
|
Web App开发 SQL 前端开发
前端页面加载性能指标之LCP
本文介绍了 Largest Contentful Paint (LCP),一种衡量网页加载性能的指标,专注于视口内最大图片或文本块的完全渲染时间,旨在提升用户对主要内容加载速度的感知。文章还探讨了LCP的测量方法和优化策略,如图像优化、懒加载等,以帮助改善网页性能。
1133 5
KyLinV10 安装realtek-r8125 2.5G网卡驱动。
KyLinV10 安装realtek-r8125 2.5G网卡驱动。
|
存储 C语言
寒假C语言刷题——day01
寒假C语言刷题——day01
|
测试技术
【CCCC】L2-022 重排链表 (25分),链表遍历
【CCCC】L2-022 重排链表 (25分),链表遍历
254 0
|
2天前
|
弹性计算 运维 搜索推荐
三翼鸟携手阿里云ECS g9i:智慧家庭场景的效能革命与未来生活新范式
三翼鸟是海尔智家旗下全球首个智慧家庭场景品牌,致力于提供覆盖衣、食、住、娱的一站式全场景解决方案。截至2025年,服务近1亿家庭,连接设备超5000万台。面对高并发、低延迟与稳定性挑战,全面升级为阿里云ECS g9i实例,实现连接能力提升40%、故障率下降90%、响应速度提升至120ms以内,成本降低20%,推动智慧家庭体验全面跃迁。
|
3天前
|
数据采集 人工智能 自然语言处理
3分钟采集134篇AI文章!深度解析如何通过云无影AgentBay实现25倍并发 + LlamaIndex智能推荐
结合阿里云无影 AgentBay 云端并发采集与 LlamaIndex 智能分析,3分钟高效抓取134篇 AI Agent 文章,实现 AI 推荐、智能问答与知识沉淀,打造从数据获取到价值提炼的完整闭环。
351 91
|
10天前
|
人工智能 自然语言处理 前端开发
Qoder全栈开发实战指南:开启AI驱动的下一代编程范式
Qoder是阿里巴巴于2025年发布的AI编程平台,首创“智能代理式编程”,支持自然语言驱动的全栈开发。通过仓库级理解、多智能体协同与云端沙箱执行,实现从需求到上线的端到端自动化,大幅提升研发效率,重塑程序员角色,引领AI原生开发新范式。
850 156
|
3天前
|
数据采集 缓存 数据可视化
Android 无侵入式数据采集:从手动埋点到字节码插桩的演进之路
本文深入探讨Android无侵入式埋点技术,通过AOP与字节码插桩(如ASM)实现数据采集自动化,彻底解耦业务代码与埋点逻辑。涵盖页面浏览、点击事件自动追踪及注解驱动的半自动化方案,提升数据质量与研发效率,助力团队迈向高效、稳定的智能化埋点体系。(238字)
257 156