GeoServer中配置shp文件作为数据源(转载)

STEP 1. Create A DataStore

STEP 1.1
Start Geoserver and then open your running Geoserver start page. If it is run locally,
the address is http://localhost:8080/geoserver<- Try clicking it if you have Geoserver already running
To get to it, open up your favorite web browser and type in that address. It will take you to the Geoserver start page.

Now we need to navigate to the DataStore config section of Geoserver.

Click on the 'Config' button. If you are not already logged in, log yourself in with the default username and password (username: admin , password: geoserver).
user_shapefile_start.gif

Next, click on the 'Data' button.
user_shapefile_start_data.gif

Then, click on the 'Stores' button.
user_shapefile_start_stores.gif

STEP 1.2
You need to tell Geoserver where the data is.

Select 'New' on the left purple-ish panel
user_shapefile_ds_new.gif

STEP 1.3
Select 'DataStore Description' as 'Shapefile'
Also set DataStore ID to be your shapefile name, it can be whatever you want, not necessarily the file name.
For our example, enter mytutorial
user_shapefile_ds_desc.gif

When you are done, hit the 'New' button.

STEP 1.4
Now we need to specify the shapefile we want to use. To locate the shapefile we need to specify where it lives relative to the data directory (data_dir/). The data directory lives right under the root location of GeoServer. For example:
C:\Java\Geoserver\data_dir
In the data directory, there is a sub directory called data/ (C:\Java\Geoserver\data_dir\data). Place your shapefile in that directory.

In the URL field, enter the location of the file. For example:

file:data/tutorial.shp

user_shapefile_ds_detail.gif
All URLs you will use are relative to the data directory (data_dir/). If you do not want to copy your full shapefile into GeoServer, there are other ways to refer to it, see the full Shapefile DataStore section of the docs.

Hit the 'Submit' button.

Now, we need to register all the changes. To do that, hit the 'Apply' button on the left, then 'Save' if you want to save it out for future use.
apply_save.gif

STEP 2. Create The FeatureType

STEP 2.1
Now, back up a spot in Geoserver Config and go to Config -> Data -> FeatureType
user_shapefile_ft_start.gif

Hit 'New'

From the drop down list, Feature Type Name, select your datastore.

Then Hit 'New'
user_shapefile_ft_new.gif

STEP 2.2
Select your DataStore: test_datastore:::tutorial
user_shapefile_ft_new_select.gif

Then hit the 'New' button.

STEP 2.3

A new screen will appear that looks a little confusing, but you can
ignore most of it. One thing you have to enter is the SRS value. If you
don't know what SRS is and you just want to see your stuff, then enter 4326.

Definitions

SRS (Spatial Reference System):
The SRS value describes what projection the data is in. It is represented by a number that uniquely identifies each projection.

user_shapefile_ft_generate.gif

Hit the 'Generate' button, this will get your bounding box and display your projection information in a faded grey color.

STEP 2.4
Now you have to add a style for the data. The style defines how the data will be drawn (color, line thickness etc..).
You can use one of the pre-cooked styles in the "Style" drop down list or create your own using the "Create New SLD" button.
If you select to use an existing style, make sure it can render your type of geometry. If you have points, use a style that can render points (for example the "point" SLD). For lines use a line style, for polygons use a polygon style. There are three default styles for you to use: point, line, polygon.

If you opt to create a new SLD with the SLD Wizard, it is pretty easy. It knows what geometries your data uses and will display the appropriate fields you need to style your data.
All you have to do in fill in the appropriate colors, either by hand or by clicking on the little multi-colored box next to the color field. This is the color picker. When you are done configuring your style, hit the Apply Style button. Then hit the Finished button.
(There is a known bug that will cause the style not to be applied if the feature type you just created hasn't been saved, this will be fixed in the next release).

STEP 2.5

Hit the 'submit' button. The window will change again and take you back to the FeatureType screen.
user_shapefile_ft_submit.gif

STEP 2.6

  • Once again, hit the 'Apply' and then 'Save' buttons.
    apply_save.gif


STEP 3. Try It Out

STEP 3.1
You can try out the WFS with this URL (change the typename from tutorial to your featureType name):
http://localhost:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.0.0&typename=tutorial

You should get back a bunch of XML (GML), and it should look confusing, but you can probably make out the attributes of your file.

STEP 3.2
You can also view the data in Google Earth (sweet!). If you have Google Earth installed, all you have to do is open up a web browser and enter this URL (changing myFeatureType to match your FeatureType name):
http://localhost:8080/geoserver/wms/kml_reflect?layers=myFeatureType

STEP 3.3

You can try out the WMS, instantly viewing your new layer with the MabBuilder based preview:
http://localhost:8080/geoserver/mapPreview.do
Just find the layer you added, and you'll get a nice zoomable map of the extent. For a more advanced view you'll actually have to dig into http://mapbuilder.sourceforge.net, or check out the Clients section for other options, both desktop and web-based]

98362.html

zhyiwww 2007-02-06 16:36 发表评论
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值