GeoServer学习手记(四):Servlet及HTTP派发过程之一
转载 粟卫民http://www.gisdev.cn/ http://blog.csdn.net/suen/ 日期:2009-10-29
本来是打算一个工程一个工程来分析介绍,可是在学习的过程中,发现这样的效果并不好,连自己有时候都被一些代码搞得晕头转向,所以转换了思路。先学习和介绍一些关于GeoServer的通用的原理,然后再针对每一个工程进行分析。由于接收输入为任何系统的第一步,因此首先从Servlet及HTTP派发过程开始。GeoServer的HTTP派发也有一个发展变化的过程。
1.6版之前的HTTP派发过程
在GeoServer的1.6版本之前的版本中,还没有使用OWS Dispatching System(http://geoserver.org/display/GEOS/GSIP+7+-+OWS+Dispatching+System ),因此只存在一次派发,即在web.xml中配置需要派发的servlet类。
WfsDispatcher
org.vfny.geoserver.wfs.servlets.WfsDispatcher
具体可参考:How a Get Feature Requests Works,(http://geoserver.org/display/GEOSDOC/1+How+a+GetFeature+Request+Works,为了方便起见,转载到下面)
How a Get Feature Requests Works
This page will describe how a getFeature() request works in Geoserver. It will also show you how to set up Eclipse and use the debugger to run through a getFeature() request yourself.
There are three bodies to a getFeature() request: DataSet
Request
Try it in Eclipse
You can walk through this tutorial using the debugger by following these steps:
Make sure your Eclipse is set up to run the debugger. If not, refer to this page
Put a break point in the method 'doGet()' in WfsDispatcher
Run Geoserver in Debug mode: Run -> Debug... -> select your debug task -> hit 'Debug'
Open up your favorite web browser and click this link
Response
DataSet
A dataset is the data that will be read by the getFeature() request. It is what makes up our maps.
Here is an example of a PostGIS database (or a shapefile) with the following data in it:
tiger_ny=# select state_name,state_abbr,persons::int4,families::int4,houshold::int4,male::int4, female::int4, geometrytype(the_geom) as the_geom from states_postgis; state_name | state_abbr | persons | families | houshold | male | female | the_geom---------------+------------+----------+----------+----------+---------+---------+-------------- Iowa | IA | 2776755 | 740819 | 1064325 | 1344802 | 1431953 | MULTIPOLYGON ... Massachusetts | MA | 6016425 | 1514746 | 2247110 | 2888745 | 3127680 | MULTIPOLYGON ... Nebraska | NE | 1578385 | 415427 | 602363 | 769439 | 808946 | MULTIPOLYGON ... New York | NY | 18235907 | 4548344 | 6746555 | 8739138 | 9496769 | MULTIPOLYGON ... Pennsylvania | PA | 11881643 | 3155989 | 4495966 | 5694265 | 6187378 | MULTIPOLYGON ... Connecticut | CT | 3287116 | 864493 | 1230479 | 1592873 | 1694243 | MULTIPOLYGON ... Rhode Island | RI | 1003464 | 258886 | 377977 | 481496 | 521968 | MULTIPOLYGON ... New Jersey | NJ | 7484736 | 1962314 | 2687478 | 3622220 | 3862516 | MULTIPOLYGON ... Indiana | IN | 5544159 | 1480351 | 2065355 | 2688281 | 2855878 | MULTIPOLYGON ... Nevada | NV | 1201833 | 307400 | 466297 | 611880 | 589953 | MULTIPOLYGON ......
In Reality
Geoserver ships with a USA states shapefile that has all the above data in it. It also contains more columns than the above, but I've simplified it for easier reading. You can put the Geoserver "states" shapefile in PostGIS, using the shp2pgsql program that comes with PostGIS, and use a PostGIS datastore instead.
NOTE: This discussion is pretty much the same for any datastore (ie. with oracle, shapefiles, DB2, SDE, etc...).
In the above example of the data, a Feature is one of the rows. For example
Iowa | IA | 2776755 | 740819 | 1064325 | 1344802 | 1431953 | MULTIPOLYGON ...is a Feature.
A getFeature request will be targetted at the data and will bring back Features in the form of GML.
(未完待续)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/suen/archive/2009/11/02/4759332.aspx