thanks to open source, the use of openlayers+geoserver GIS development is very simple, fully can apply to develop MIS system experience, I summarized here as three steps:
1. Data preparation
2. Data release
3. Data presentation
I will follow this idea to introduce, first of all, the data release:
First, the data release
GIS data sources are various, have vector data, have raster data, have text database, have relational database, because I usually use Oracle spatial database and postgis,oracle more, so I use Oracle as an example to illustrate, other comprehend by analogy, At least most of the things I've met are like this.
Using Oracle to manage spatial data can be completely considered a relational database, which is why I can apply the experience of MIS system, Oracle spatial database adds a spatial object mdsys.sdo_geometry to store spatial data, like varchar, int these types are the same, but this type is an object.
It is important to note that this spatial object needs to create a spatial index to be published correctly, and to create a spatial index is now defined in the metadata table, and below I will sample how to create a spatial database table for the underlying point-line polygon in the spatial graph:
SQL code
- --Create a table
- Create table T_point
- (
- ID number,
- name Nvarchar2,
- Position Mdsys. Sdo_geometry
- );
- Create table T_line
- (
- ID number,
- name Nvarchar2,
- Position Mdsys. Sdo_geometry
- );
- Create table T_area
- (
- ID number,
- name Nvarchar2,
- Position Mdsys. Sdo_geometry
- );
- --Create spatial index
- INSERT INTO user_sdo_geom_metadata (Table_name,column_name, Diminfo)
- VALUES (
- ' T_point ',
- ' POSITION ',
- Mdsys. Sdo_dim_array (
- Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
- Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
- Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
- )
- );
- CREATE INDEX idx_t_point_pos on t_point (POSITION) Indextype is Mdsys. Spatial_index;
- INSERT INTO user_sdo_geom_metadata (Table_name,column_name, Diminfo)
- VALUES (
- ' T_line ',
- ' POSITION ',
- Mdsys. Sdo_dim_array (
- Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
- Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
- Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
- )
- );
- CREATE INDEX idx_t_line_pos on t_line (POSITION) Indextype is Mdsys. Spatial_index;
- INSERT INTO user_sdo_geom_metadata (table_name, COLUMN_NAME, Diminfo)
- VALUES (
- ' T_area ',
- ' POSITION ',
- Mdsys. Sdo_dim_array (
- Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
- Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
- Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
- )
- );
- CREATE INDEX idx_t_area_pos on t_area (POSITION) Indextype is Mdsys. Spatial_index;
Now you can see that the spatial table is created, and we can operate like a normal relational database, using an insert example to illustrate:
SQL code
- --Insertion point
- INSERT INTO t_point (ID, name, position)
- Values
- (1, ' Test point ',
- Mdsys. Sdo_geometry (3001,
- NULL,
- NULL,
- Mdsys.sdo_elem_info_array (1, 1, 1, 4, 1, 0),
- Mdsys.sdo_ordinate_array (24.886436,
- 102.784423,
- 0,
- 1,
- 0,
- 0
- )
- )
- );
- --Insertion Line
- INSERT INTO t_line (ID, name, position)
- Values
- (1, ' Test line ', Mdsys. Sdo_geometry (3002,
- NULL,
- NULL,
- Mdsys.sdo_elem_info_array (1, 2, 1),
- Mdsys.sdo_ordinate_array (0, 0, 0, 0, 90, 0, 200, 90, 0, 200, 0, 0)
- ));
- --Insert Face
- INSERT INTO t_area (ID, name, position)
- Values
- (1, ' Test area ', Mdsys. Sdo_geometry (3003,
- NULL,
- NULL,
- Mdsys.sdo_elem_info_array (1, 1003, 1),
- Mdsys.sdo_ordinate_array (0, 0, 0, 0, 90, 0, 200, 90, 0, 200, 0, 0, 0, 0, 0)
- ));
The above code constructs a spatial object, the description of which can refer to the relevant documentation, which is not explained in detail here. Ready data can be released after the data, data release is one of the less technical content of the manual work, you can refer to a series of articles here: http://www.cnblogs.com/beniao/archive/2011/01/08/1930822.html
After the data is published, the data can be presented, and the data display can be applied to the MIS control concept, as follows:
1. Create a Map control
2. Create a layer
3. Add layers to the map
4. Add other controls to the map
The following code shows the details:
JS Code
- Initialize Map
- var map = new Openlayers.map (' map ');
- var map = New Openlayers.map ({
- Div:"map",
- MAXEXTENT:[97.027587,21.166484,106.739502,29.31642],
- Center:New Openlayers.lonlat (101.857909,24.726875)
- });
- New Layer
- var ol_wms = New OpenLayers.Layer.WMS (
- "Openlayers WMS",
- "Http://10.180.80.206:9000/geoserver/wms",
- {layers: "sdgis:dqj"}
- );
- Add a Map control
- Map.addcontrol (new OpenLayers.Control.LayerSwitcher ());
- Map.addcontrol (new OpenLayers.Control.MousePosition ());
- Map.addcontrol (new OpenLayers.Control.Scale ());
- Layer Join Map
- Map.addlayers ([ol_wms]);
- Map.zoomtoextent ([97.027587, 21.166484, 106.739502, 27.467659], true);
Oracle spatial, openlayers, GeoServer development Geographic Information System Summary