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).
Next, click on the 'Data' button.
Then, click on the 'Stores' button.
STEP 1.2
You need to tell Geoserver where the data is.
Select 'New' on the left purple-ish panel
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
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:
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.
STEP 2. Create The FeatureType
STEP 2.1
Now, back up a spot in Geoserver Config and go to Config -> Data -> FeatureType
Hit 'New'
From the drop down list, Feature Type Name, select your datastore.
Then Hit 'New'
STEP 2.2
Select your DataStore: test_datastore:::tutorial
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.
|
|
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.
STEP 2.6
- Once again, hit the 'Apply' and then 'Save' buttons.
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]
|----------------------------------------------------------------------------------------|
版权声明 版权所有 @zhyiwww
引用请注明来源 http://www.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2007-02-06 16:36
zhyiwww 阅读(4842)
评论(1) 编辑 收藏 所属分类:
gis