Oracle spatial, openlayers, GeoServer development Geographic Information System Summary

Source: Internet
Author: User

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
  1. --Create a table
  2. Create table T_point
  3. (
  4. ID number,
  5. name Nvarchar2,
  6. Position Mdsys. Sdo_geometry
  7. );
  8. Create table T_line
  9. (
  10. ID number,
  11. name Nvarchar2,
  12. Position Mdsys. Sdo_geometry
  13. );
  14. Create table T_area
  15. (
  16. ID number,
  17. name Nvarchar2,
  18. Position Mdsys. Sdo_geometry
  19. );
  20. --Create spatial index
  21. INSERT INTO user_sdo_geom_metadata (Table_name,column_name, Diminfo)
  22. VALUES (
  23. ' T_point ',
  24. ' POSITION ',
  25. Mdsys. Sdo_dim_array (
  26. Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
  27. Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
  28. Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
  29. )
  30. );
  31. CREATE INDEX idx_t_point_pos on t_point (POSITION) Indextype is Mdsys.  Spatial_index;
  32. INSERT INTO user_sdo_geom_metadata (Table_name,column_name, Diminfo)
  33. VALUES (
  34. ' T_line ',
  35. ' POSITION ',
  36. Mdsys. Sdo_dim_array (
  37. Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
  38. Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
  39. Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
  40. )
  41. );
  42. CREATE INDEX idx_t_line_pos on t_line (POSITION) Indextype is Mdsys.  Spatial_index;
  43. INSERT INTO user_sdo_geom_metadata (table_name, COLUMN_NAME, Diminfo)
  44. VALUES (
  45. ' T_area ',
  46. ' POSITION ',
  47. Mdsys. Sdo_dim_array (
  48. Mdsys. Sdo_dim_element (' X ', -180,180,0.005),
  49. Mdsys. Sdo_dim_element (' Y ', -90,90,0.005),
  50. Mdsys. Sdo_dim_element (' Z ', -9000,9000,0.005)
  51. )
  52. );
  53. 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
  1. --Insertion point
  2. INSERT INTO t_point (ID, name, position)
  3. Values
  4. (1, ' Test point ',
  5. Mdsys. Sdo_geometry (3001,
  6. NULL,
  7. NULL,
  8. Mdsys.sdo_elem_info_array (1, 1, 1, 4, 1, 0),
  9. Mdsys.sdo_ordinate_array (24.886436,
  10. 102.784423,
  11. 0,
  12. 1,
  13. 0,
  14. 0
  15. )
  16. )
  17. );
  18. --Insertion Line
  19. INSERT INTO t_line (ID, name, position)
  20. Values
  21. (1, ' Test line ', Mdsys. Sdo_geometry (3002,
  22. NULL,
  23. NULL,
  24. Mdsys.sdo_elem_info_array (1, 2, 1),
  25. Mdsys.sdo_ordinate_array (0, 0, 0, 0, 90, 0, 200, 90, 0, 200, 0, 0)
  26. ));
  27. --Insert Face
  28. INSERT INTO t_area (ID, name, position)
  29. Values
  30. (1, ' Test area ', Mdsys. Sdo_geometry (3003,
  31. NULL,
  32. NULL,
  33. Mdsys.sdo_elem_info_array (1, 1003, 1),
  34. Mdsys.sdo_ordinate_array (0, 0, 0, 0, 90, 0, 200, 90, 0, 200, 0, 0, 0, 0, 0)
  35. ));

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
  1. Initialize Map
  2. var map = new Openlayers.map (' map ');
  3. var map = New Openlayers.map ({
  4. Div:"map",
  5. MAXEXTENT:[97.027587,21.166484,106.739502,29.31642],
  6. Center:New Openlayers.lonlat (101.857909,24.726875)
  7. });
  8. New Layer
  9. var ol_wms = New OpenLayers.Layer.WMS (
  10. "Openlayers WMS",
  11. "Http://10.180.80.206:9000/geoserver/wms",
  12. {layers: "sdgis:dqj"}
  13. );
  14. Add a Map control
  15. Map.addcontrol (new OpenLayers.Control.LayerSwitcher ());
  16. Map.addcontrol (new OpenLayers.Control.MousePosition ());
  17. Map.addcontrol (new OpenLayers.Control.Scale ());
  18. Layer Join Map
  19. Map.addlayers ([ol_wms]);
  20. Map.zoomtoextent ([97.027587, 21.166484, 106.739502, 27.467659], true);

Oracle spatial, openlayers, GeoServer development Geographic Information System Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.