1. Welcome

## 1. Welcome

There is more help available at the Geoserver WIKI. IT IS STRONGLY RECOMMENDED YOU VISIT HERE BECAUSE USERS UPDATE THESE PAGES!

The GeoServer project is a Java implementation of the 1.0 Web Feature Server specification from the OpenGIS Consortium. GeoServer aspires to be the Apache of OpenGIS data serving and its mission is to enable greater geographic interoperability by enforcing OpenGIS standards and lowering the barriers to entry for geographic data providers.

GEOSERVER方案是来自OPENGIS CONSORTIUM1.0 WEB FEATURE 服务器型号的JAVA语言实施系统。GEOSERVER希望能发展成为OPENGIS数据服务的APACHE，其目的是通过执行OPENGIS标准让更广阔的区域能协同工作，同时减少区域数据提供者进入的障碍。

Before you can use GeoServer, you must successfully install Java, and optionally Java Servlet container such as Tomcat or Jetty. A spatially enabled database, such as the freely available PostGIS, is also recommended, but GeoServer will work with Shapefiles. This is by far the hardest part of the installation process, but the documentation to install these components is quite good. Our testing has occurred on JDK 1.4.1 or 1.4.2, Tomcat 5.0.19, Resin 2.1.13 or Jetty 4.1.27, and PostGIS 0.8.1 with GEOS on top of Postgresql 7.4. The latest stable versions of these components should work fine. This document assumes you are working with the downloaded geoserver.war file. If you wish to work with the source download please consult the developers build document

GeoServer has an active user community that you can engage by joining the GeoServer mailing list and asking questions or making suggestions. If you create a user account at this site, you may participate in forums and vote in polls as well. We also strongly encourage you to submit bugs and improvements you would like to see to our tracker, as the only way we can improve GeoServer is with your feedback. You will have to create an account to use it, but your email address will not be used except to notify you when your issue is worked on.

GEOSERVER 有一个活跃的用户集团，您可以通过加入GEOSERVERMAILING LIST这样的方式来参加这个集团，也可以询问问题或者提供建议。如果您在这个网页上建立一个用户帐号，您可以参加论坛，也可以进行投票。同时我们也非常鼓励您向我们指出程序中的错误和提高的建议，详细情况请见我们的TRACKER，因为我们能提高GEOSERVER的唯一途径就是您的反馈信息。您需要创建一个帐号以便您的使用，但是不会用到您的邮箱地址，除了通知您的ISSUE正在运行或使用中。

## 2. Installing Java

GeoServer is built against the JDK1.4. If you do not have the JDK1.4 installed on your machine, you should download it from Sun and point to the root install directory with the JAVA_HOME environment variable (set JAVA_HOME = C:\j2sdk1.4.2). Most of our testing occurred against JDK1.4.2. If your not sure if you have java, or not sure what version, type java -version from the command line. If the command doesn't work or if the version is less than 1.4 then you'll have to download, install, and set JAVA_HOME.  If you wish to use the visualization portion of GeoServer we recommend you install the Java Advanced Imaging API, which can be downloaded here.

GEOSERVER支持（against意为反对，应该是不支持，但翻译为不支持与后面句意不符合）JDK1.4。如果您的电脑上没有安装JDK1.4, 您应该从SUN处下载，并且在可变的JAVA_HOME环境下指向根目录安装(set JAVA_HOME = C:\j2sdk1.4.2)。目前我们大部分测试系统不支持JDK1.4.2。如果您不确认是否已经安装JAVA, 或者不确认哪个版本，您可以从命令栏测试JAVA版本。如果命令栏不运行或者版本低于1.4，您不得不下载安装运行JAVA_HOME。如果您希望应用GEOSERVER的可见部分，我们建议您安装JAVA ADVANCED IMAGING, (API) API可以在这里下载。

## 3. Installing a Servlet Container

If you downloaded the binary (geoserver-1.3.*-bin.zip) or windows (.exe) release of GeoServer you do not need to install a servlet container, as GeoServer now includes an embedded Jetty servlet container. But if you want to use your servlet container then the war install works just fine.

Several good open source, free servlet containers and a bevy of commercial ones exist on the market. We recommend Jetty (open source, free) or Tomcat (open source, free). Most GeoServer testing has occurred on Tomcat 5, which is remarkably simple to set up and administer.. The servlet containers should have good documentation, so we shall say nothing further here about the install. We do recommend sticking with the latest stable versions. For more information on GeoServer working with specific containers see our Servlet Container Reports, and please add additional feedback to the page (it's a wiki).

## 4. Installing a Database安装一个数据库

The GeoServer project currently supports the Oracle, ArcSDE and Shapefile data formats, but unless you already have a running Oracle or ArcSDE installation we recommend PostGIS, an excellent extension of the venerable Postgresql relational database. PostGIS and Postgresql are open source databases that are free to all users. Postgresql was developed at Berkeley several years ago and PostGIS is a recent extension developed by the clever programmers at Refractions Research.

GeoServer目前支持的数据格式有 Oracle, ArcSDE Shapefile, 如果您没有安装运行Oracle 或者 ArcSDE, 我们推荐您安装PostGIS，这个数据库和Postgresql密切相关，同时又是PostGIS的优秀拓展。 Postgresql目前对所有的用户都是免费的。Postgresql是几年前由Berkeley开发的，而PostGIS则是最近由聪明的程序员在Refractions Research里开发的。

If you'd just like to get an installation up and running quickly, and don't care so much about advanced features and speed, then we recommend the Shapefile format, with installation information here. If you have an existing Oracle spatial or ArcSDE installation, and would like to use GeoServer to serve that data as GML, then check out the install information here. Be sure to fully read this installation document before trying out Oracle, ArcSDE or Shapefile DataStores, even if you are not going to use PostGIS.

Installing Postgresql and PostGIS is the most complicated part of setting up a GeoServer site and for this reason, we will supplement the documentation to do so a little here. First, you should download the full source of Postgresql. Binaries, RPMs, and other packaged builds will generally not suffice because you will need to compile the PostGIS extension and JDBC bindings into Postgresql in order for it to correctly speak with GeoServer.

First, download Postgresql - we have had the best luck with version 7.4. You should configure and install it, per the installation instructions. It should go something like this:

./configure
gmake
gmake install

Configuring with Java is no longer required, as we supply the JDBC jar with the installation. Be sure that it is up and running, it's best to create a database and test it using psql from the command line. Then, download PostGIS. You should place PostGIS in your Postgresql 'contrib' directory, change to the postgresql root directory and follow the directions for installation there. We highly recommend installing PostGIS 0.8 with GEOS, as it will greatly speed up spatial queries. If installing GEOS be sure to read all the directions for it and PostGIS, as you have to configure your postgresql installation to make use of it.

You should, of course, check to make sure that Postgresql and PostGIS are functioning correctly before you attempt to connect with then using GeoServer. After installing PostGIS attempt to create tables with geometry columns, and insert a few features. If you are a windows user a good page on installing PostGIS is available here. You can also try out the PostGIS installer on the dcmms sourceforge project, which we've had success with as well. When starting PostGIS be sure to run it with the -i option to allow other applications (i.e. GeoServer) to connect to it.

## 5. Installing GeoServer

Move the distributed geoserver.war to the war file directory of your Java Servlet container (generally named 'webapps'). If you have an existing GeoServer installation on your machine, you should backup your old geoserver/ directory before moving the new .war file. You may run a simple test by starting your container and entering this address:

http://SERVER_ADDRESS:SERVER_PORT/geoserver/wfs/GetCapabilities

Note that SERVER_ADDRESS and SERVER_PORT should be replaced by your server's address and port (local host:8080 will suffice for the default of tomcat or resin running on your local machine). If GeoServer is running, you should see an WFS capabilities document. If you get nothing, then you should consult your server documentation to see what has gone wrong. Some modern browser may give a warning like:

This XML file does not appear to have any style information associated with it. 没有任何类型信息与这个XML文件相关联。
The document tree is shown below. 文件树展示如下。

This is not an error, it is just an indication that the document is pure XML, without a style sheet associated, which is how a WFS should respond. If a geoserver directory has not been created automatically by your server, then your server is probably not behaving as it should.

## 6. Configuring GeoServer    设置 GEOSERVER

After logging in and changing the password the next step is to click on the configure link. This is the central place to configure GeoServer. You should work through each of the four categories, first setting your contact information and global values in Server, and then the WMS and WFS specific descriptions and contents. Contents will allow you to enable or disable each Service and WFS will also let you specify the transaction level - that is if users should be able to access the transaction operations.

Be sure to always hit the submit button, and to then test your changes in GeoServer hit 'Apply' on the right. The changes you put in will take effect immediately. If you like the changes then hit 'Save' and they will be stored to disk permanently. If you do not like the changes you can roll back to the last saved ones by hitting 'Load'.

If you want to avoid the web admin tool then directly editing the files shall work just as well. Your work flow will just be a bit different, you will work from the source tree and rebuild the war after you have changed the options. If you choose to use the web administration interface you can skip the next section, but read up on the options that follow, as they are in the administration tool as well.

This section assumes at least passing familiarity with XML files. However, if you simply follow the test file example exactly, you should be able to create a working configuration file. The services.xml file resides at geoserver/WEB-INF. You should edit this file, and changes will be picked up when you run <i>ant war</i>. This sets the global configuration options for your server as well as the service elements of the WMS and WFS services. An example services.xml is shown here:

<?xml version="1.0" encoding="UTF-8" ?>
<serverConfiguration>
  <global>
    <loggingLevel>FINE</loggingLevel>
    <verbose value="true">
  </global>
  <services>
    <service type="WFS" enabled="true">
      <name>GeoServer</name>
      <title>The TOPP Basemap Server</title>
      <abstract>This is a test server. It contains some basemap data from New York City.</abstract>
      <keywords><keyword>New York</keyword><keyword>transportation</keyword></keywords>
      <onlineResource>http://beta.vfny.org/geoserver</onlineResource>
      <maintainer>Vision for New York</maintainer>
      <gmlPrefixing value="true"/>
      <serviceLevel value="2"/>
    </service
  </services>
  <namespace default="true" uri="http://www.openplans.org/topp" prefix="topp"/>
  <namespace uri="http://www.opengis.net/cite/data" prefix="cdf"/>
</serverConfiguration>

You should modify the values between the tags only. All values are defined below:

 Option Name Description Logging Level How much ou put should go to the logs, one of: SEVERE, WARNING, INFO, CONFIG, FINER, FINEST URL The base url where geoserver will be available. If just testing on a local machine localhost should be fine. This is used in the capabilities document, which reports to clients the entry points for accessing features. verbose true if the xml returned should have human readable formatting name This is the name of your server and is arbitrary. title This is the title of the server and is arbitrary abstract This is a brief description of what your server does and is arbitrary. keywords A series of comma seperated keywords, describing the data and purpose of the server. onlineResource A unique url where information for this server resides. Even if you have no real online source it is important to put something here, for default namespace surfaces. It is fine to use the same url as the URL element. maintainer The name of the maintainer for this server. gmlPrefixing true when GML prefixing is required. serviceLevel The service level, 1 is basic, 2 is transactional.

For more configuration options, check the Advanced section.

## 7. Adding Data to GeoServer

To add new data to GeoServer go to Config -> Data. You should first define the GML name space that your features should occur in. This distinguishes your features from others on the Internet. This is not necessary if you are only working with the WMS. Defining a namespace as the 'default' allows you to request featureTypes without prepending the namespace prefix, but is not used for much else.

Next you need to create a Data Store. This is the GeoServer terminology for the source of data. It can be a database or a file, and can contain one or more Feature Types (Layers in WMS terms). In a database each table is a FeatureType. To define a new DataStore click on the 'Stores' button, select the type from the list and input the appropriate parameters. Note that you must pick one namespace for each DataStore. If you really want different featureTypes in the same DataStore to be in different name spaces you can get around this by defining two DataStores with the same parameters and different names and name spaces.

After creating the DataStore you may upload SLD files to serve as the Styles for GeoServer's WMS. For more on SLD see the specification. GeoServer is working to become a true SLD-WMS, but for now the SLD files must be uploaded and defined using the web administration interface. If the WMS is not needed then no additional styles are needed.

Finally you should create the appropriate FeatureTypes. Hitting the 'New' button will generate a list of all the featureTypes in all the DataStores, in the format DataStoreID::FeatureTypeName. Pick the featureType to create, and then edit the meta information. If deploying GeoServer it is important to fill out this information accurately, as it appears in the capabilities document, which gives clients about the data available. The 'generate' button currently only works if the data itself is stored in Lat Long (EPSG:4326 - which you should set for the SRS if your data is in Lat Long). Soon we will support transformation from the Spatial Reference System specified into Lat Long.

After hitting submit you should be able to hit 'Apply', and then the GetCapabilities request given earlier should include your newly added FeatureType. If you are just working with the web interface, you can skip to the next section (the file information will soon be ported to the developers documentation), though some of the tables may prove helpful.

If working with files, data to geoserver is now centralized in the catalog.xml file, located in geoserver/WEB-INF. This file can be thought of as the central place for data in GeoServer. It contains the connection parameters to various DataStores, as well as style and namespace information. In older versions of GeoServer each featureType's info.xml file contained connection parameters, but this lead to a lot of duplication as many featureTypes are often contained in a single database. So now each featureType just references a DataStore defined in the catalog.xml file. The following sample catalog.xml file is for a PostGIS DataStore, as it is the most solid one that GeoServer supports. Shapefile, Oracle and ArcSDE DataStores are also available in various degrees of maturity; click on the hyper links for more information.

 <?xml version="1.0" encoding="UTF-8" ?>
<catalog>
  <!-- defines the datastores, more than one is possible -->
  <datastores>
    <datastore id="local.postgis" enabled="true" namespace="topp">
      <connectionParams>
        <parameter name="host" value="localhost"/>
        <parameter name="port" value="5432"/>
        <parameter name="database" value="testdb"/>
        <parameter name="user" value="testuser"/>
        <parameter name="passwd" value="pass"/>
        <parameter name="dbtype" value="postgis"/>
      </connectionParams>
    </datastore>
  </datastores>

  <!--defines the namespaces, should have at least a default -->
  <namespaces>
    <namespace default="true" uri="http://www.openplans.org/topp" prefix="topp"/>
    <namespace uri="http://www.opengis.net/cite/data" prefix="cdf"/>
  </namespaces>
 </catalog>

This file defines a DataStore, that featureTypes will reference using its local.postgis id. The namespace attribute references the prefix of the topp namespace defined below. The enabled attribute is used to 'turn off' the DataStore, featureTypes referencing it will not be accessible to users. The connection Params for PostGIS should be as follows:

 Option Name Description dbtype Must be 'PostGIS' for a PostGIS DataStore. 必须是POSTGIS数据储存库的POSTGIS host Must match the PostGIS postmaster daemon URI exactly, port excluded. Can be a number or name – local host or 127.0.0.1 if PostGIS is on the same machine as geoserver, if not it can reference the ip address or host name. 必须与POSTGIS POSTMASTER DAEMON URI准确相配。可以是一个数字或者名字－如果POSTGIS和GEOSERVER 在同一个机器上，用当地主机或者127.0.0.1；如果不是，可以参考IP地址或者主机名字。 port Must match the PostGIS postmaster daemon port exactly (generally 5432). 必须与POSTGIS POSTMASTER DAEMON PORT准确相配。（一般5432） database Must match the PostGIS database name exactly. 必须与POSTGIS数据库名字准确相配。 user Must match the PostGIS database user exactly. 必须与POSTGIS数据库用户准确相配。 passwd Must match the PostGIS database user password exactly. 必须与POSTGIS数据库用户密码准确相配。

The namespace element should have a uri attribute, which just needs to be unique, it does not have to actually reference anything. Each prefix should be unique as well, as it is used internally by geoserver. The default value indicates which namespace will be used if a user asks for a typeName without specifying its namespace. It should generally be sufficient to just define one namespace, as the default, and to use it for all DataStores. If two featureTypes need to be in different namespaces but share the same DataStore then the easy solution is to just define two DataStores with the same connectionParams but different ids and namespaces.

Once catalog.xml is set up then individual featureTypes contained in the DataStores need to be configured. Each featureType gets its own directory in conf/featureTypes. The general convention is to name each directory has the same name as the featureType contained in it, but it does not matter. If two featureTypes have the same name then the namespace prefix should be appended (as two with different names must be in different namespaces). So if we have a featureType named rail, it should have a directory geoserver/conf/featureTypes/rail. In this directory there is one required file, info.xml, which contains a reference to the DataStore and meta information about the featureType. The meta information is only used in the returned Capabilities document, name and DataStore are the only values that affect the running of GeoServer. It looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<featureType DataStore="local.postgis">
    <name>rail</name>
    <title>NYC Rail Centerlines</title>
    <abstract>This is a simple rail coverage from the New York City basemap.</abstract>
    <keywords>rail, railroad, World Trade Center, New York City</keywords>
    <SRS>32118</SRS>
    <latLonBoundingBox minx="-74.27000" miny="40.50000" maxx="-73.80000" maxy="40.94000" />
    <styles default="normal"/>
</featureType>
 Option Name Description DataStore Must reference a DataStore that contains the featureType of name. 必须参照包含冷行特征名字的数据储蓄库。 name The name of the featureType. Must be in the referenced DataStore. For example in PostGIS it must refer to a table in the database of local.postgis. 类型特征的名字。必须在参照的数据储蓄库中。比如在POSTGIS中，必须涉及在当地POSTGIS的数据库中的一个桌面。 abstract A brief description of what the featureType represents. 关于类型特征的简单描述。 keywords Words to search that represent the featureType, reported in 描述类型特征的调查，报告 styles The default style for this feature type. 类型特征的默认格式。 SRS The EPSG code of the spatial reference system of this featureType. Other SRS's are not yet supported. 类型特征的空间参考系统的EPSG编码。不支持其他SRS系统。 latLonBoundingBox The bounding box in LatLon coordinates. LATLON中的捆绑盒。

There is also an optional file called schema.xml. In past versions this was required, it is a fragment of the GML schema of the featureType, returned by Describe FeatureType. As of 1.1.0 the schema.xml file is only needed if a more precise schema is needed. If the file is not present then GeoServer will automatically generate the schema for DescribeFeatureType responses - this should be sufficient for most users.

## 8. Obtaining Test Data

The easiest way to get some PostGIS data to work with is to acquire shapefiles and use the shp2pgsql utility provided by PostGIS. It should be in your pgsql installation directory, under the bin subdirectory. As for acquiring shapefiles, the US census provides a lot of their data free of cost in the shape format, available here. The GeoServer also includes support for using shapefiles directly, information about this option is available in the advanced section. Using the shapefiles directly sacrifices a lot of speed and flexibility, so converting them to PostGIS is the recommended way, but the option is available for easier set up.

## 9. Testing GeoServer――测试GEOSERVER

Testing GeoServer can be done with any standard web browser. The easiest way is to use URL encoded Key Value pairs. If GeoServer is running on the same machine as the web browser, say on a tomcat instance running on port 8080, then the Capabilities document can be tested by just typing in the location:

http://localhost:8080/geoserver/wfs?request=GetCapabilities, for example, or http://localhost:8080/geoserver/wfs?request=GetFeature&typename=topp:rail.

The WFS specification has more information on KVP encoding. It is good for basic requests, but it falls short with more complex filters and transactions. For that we recommend using XML encoding.

WFS规格拥有关于KVP解密的更多信息。对基本的要求来说这是好的，但是对更多的复杂的筛选和传输来说还是有所欠缺的。建于此我们推荐使用XML解密。

The latest release of GeoServer also includes a great testing utility for XML post requests. It is available at http://SERVER_ADDRESS:SERVER_PORT/geoserver/wfs/TestWfsPost. There are also a number of samples in the Demo section of the web administration tool. To use of the TestWfsPost servlet just make sure that the request is going to the right location (it defaults to GetFeature), and write the XML request just as the WFS specification does it.

XML POST请求来说，GEOSERVER的最新版本也包含了一个高级的测试系统。详情请见http://SERVER_ADDRESS:SERVER_PORT/geoserver/wfs/TestWfsPost. 在网页管理工具的DEMO部分也有很多例子。使用TESTWFSPOST SERVLET, 只要确认请求被发往准确的位置（默认为GETFEATURE），写下XML请求如同WFS规格一样。

The web administration tool also now includes a 'Demo' section, which has a number of sample requests. To issue one of the sample request use the pull down request box, select one and hit the 'Change' button. Unfortunately we haven't yet figured out javascript within jsps and struts, or we would have it change automatically. After hitting change then hit 'Submit', and GeoServer will return the request. You may modify the requests to work with your server. And you may even put your own requests in the geoserver/data/demo directory. These requests make a great reference for how to make WFS and WMS requests. And please let us know if you feel any important ones are missing, and we can easily add them for the next release.

For those who do not wish to use the Demo web interface, included is a set of links for the default dataset distributed with GeoServer.

## 10. Visualizing your Data

GeoServer includes an integrated Web Map Service (WMS). For more information about setting it up see WMS section. But using the web administration interface should be pretty self explanatory, just make sure that you have Java Advanced Imaging (JAI) installed, it can be downloaded here and the Image I/O extension here. The trickiest part is figuring out the correct GetMap request to issue to the WMS. A sample request is as follows:

GEOSERVER包含一套完整的环球地图服务（WMS）。更多安装信息，请查看WMS部分。但是使用环球管理平台必须带有详细的自我说明，以此确保您已经安装JAI系统，JAI系统可以在这里下载，IMAGE I/O的延伸请见这里。其中最难的部分就是汇总出与WMS相符合的正确的GETMAP请求。详细实例如下：

 http://localhost:8080/geoserver/wms?request=GetMap&layers=topp:bc_roads&bbox=489153,5433000,529000,5460816
&width=400&height=200&srs=EPSG:27354&styles=normal&Format=image/png

To adapt it to your data the two parameters to change are 'layers' and 'bbox'. The layers param should be changed to the FeatureType that you successfully added to GeoServer. Do a GetCapabilities request:

 http://localhost:8080/geoserver/wms?request=GetCapabilities

Your feature Type should show up as one of the layers there. The name there should be the one used to use in the layers param of the GetMap request. If the Capabilities document does not contain it then try adding it again. If it does the next thing to do is to obtain the bounding box for the feature. The easiest way to do this is to issue a GetFeature request to the wfs using your featureType, for example:

 http://localhost:8080/geoserver/wfs/GetFeature?typename=topp:my_data

The response is a FeatureCollection, which will include a bounded By element as follows:

 <gml:boundedBy>
   <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#27354">
    <gml:coordinates decimal="." cs="," ts=" ">
        -73.933217,40.78587 -73.768722,40.914404
    </gml:coordinates>
   </gml:Box>
</gml:boundedBy>

These values will be the boundingBox of all data in the featureType. If you have a very large table then you may want to not use the full bounding box, but this should give a good guideline of where the features are actually contained. The coordinates values can be used almost directly in the bbox param - you just need to make sure to change the middle space to a comma. Currently the srs param is ignored, GeoServer simply returns data as it is stored. Future versions wil do coordinate transformation based on the srs parameter. You can also change the other params to adjust the format, height and width of the image returned, as well as the style, if you have properly added the SLD files. So the final request for my_data will look like this:

 http://localhost:8080/geoserver/wms?request=GetMap&layers=topp:my_data&bbox=-73.933217,40.78587,-73.768722,40.914404
&width=400&height=200&srs=EPSG:27354&styles=normal&Format=image/png

posted on 2005-11-11 18:32 刘民 阅读(...) 评论(...) 编辑 收藏