Wiki source code of Spatial Extensions
Hide last authors
2.1 | 1 | BETA VERSION | |
2 | @since 3.0 | ||
1.1 | 3 | ||
2.1 | 4 | Spatial Extensions are composed of several concepts: | |
1.1 | 5 | ||
2.1 | 6 | * a spatially enabled database, such as Oracle Spatial, MySQL, Postgis or Microsoft SQL Server 2008. | |
7 | * a specific property type to store / read geometries, such as POINT, LINE, ... | ||
8 | * hibernate extensions to query data based on spatial attributes | ||
9 | * built in services to integrate with 3rd party providers such as Google Maps or ViaMichelin for maps or geocoding | ||
10 | * widgetry to show maps and position objects on maps | ||
11 | |||
12 | = Spatial Database = | ||
13 | |||
14 | A spatial enabled database has the following capabilities: | ||
15 | |||
16 | - Store a Geometry (POINT, ...) as a column in a table using a mapping coordinate system. | ||
17 | - Query on that column using spatial functions | ||
18 | - Optionally, index those spatial data for fast retrieval. | ||
19 | |||
20 | Spatially enabled database are: | ||
21 | |||
22 | * Oracle 11g Standard and Enterprise Edition | ||
23 | * MySQL 5.1 and above (indexing not supported as of 5.5) | ||
24 | * Postgres with the GIS Extension (PostGis) | ||
25 | * Microsoft SQL Server 2008 | ||
26 | |||
27 | Other databases or version do not have spatial support. | ||
28 | |||
29 | |||
30 | = Enabling the spatial components in Requea = | ||
31 | |||
32 | By default, the spatial components are not enabled. You must specify that you want spatial functionalities in the requeadb.xml: | ||
33 | |||
34 | {{code language="xml"}} | ||
35 | <?xml version="1.0" encoding="UTF-8"?> | ||
36 | <config> | ||
37 | <DbType>oracle11g</DbType> | ||
38 | **~ <DbSpatial>true</DbSpatial>** | ||
39 | <DbDriver>oracle.jdbc.OracleDriver</DbDriver> | ||
40 | <DbURL>jdbc:oracle:thin:@rhel6ws.requea.com:1522:ORCL</DbURL> | ||
41 | <DbUser>requea</DbUser> | ||
42 | <DbPassword>xxxx</DbPassword> | ||
43 | </config> | ||
44 | {{/code}} | ||
45 | |||
46 | |||
47 | |||
48 | = Storing spatial information = | ||
49 | |||
50 | Spatial information (Geometries) are stored as special columns in the Dataabase. | ||
51 | In Requea, you should use the type "Geometry" in the Entity Property definition: | ||
52 | |||
53 | [[image:ScreenShot2011-10-13at3.50.13PM.png]] | ||
54 | |||
55 | |||
56 | = Querying on spatial using HQL = | ||
57 | |||
5.1 | 58 | The following functions can be used in HQL query (in combination with non spatial criteria): | |
2.1 | 59 | ||
5.1 | 60 | * dimension | |
61 | * geometrytype | ||
62 | * srid | ||
63 | * envelope | ||
64 | * astext | ||
65 | * asbinary | ||
66 | * isempty | ||
67 | * issimple | ||
68 | * boundary | ||
69 | * overlaps | ||
70 | * intersects | ||
71 | * contains | ||
72 | * crosses | ||
73 | * disjoint | ||
74 | * equals | ||
75 | * touches | ||
76 | * within | ||
77 | * relate | ||
78 | * distance | ||
79 | * buffer | ||
80 | * convexhull | ||
81 | * difference | ||
82 | * intersection | ||
83 | * symdifference | ||
84 | * geomunion | ||
2.1 | 85 | ||
5.1 | 86 | * extent (oracle) | |
87 | * transform (oracle) | ||
88 | |||
89 | Oracle specific functions: | ||
90 | |||
91 | * centroid | ||
92 | * concat_lines | ||
93 | * aggr_convexhull | ||
94 | * aggr_union | ||
95 | * lrs_concat | ||
96 | |||
2.1 | 97 | = Geo Services = | |
98 | |||
99 | There are 3 built in services that are available for spatial operations, in addition to storing and querying information: | ||
100 | |||
101 | * Geocoding provides a WSG84 coordinate (Latitude, Longitude) based on the postal address. | ||
102 | * Mapping provides Maps to show the position of a point, line, ... on the map. | ||
103 | * Linking provides a URL to invoke the web site of a mapping provider to show one point on a map | ||
104 | |||
105 | == GeoSpatial Providers == | ||
106 | |||
107 | - GoogleMaps: | ||
108 | |||
109 | * GeoCoding: Yes, subject to licence agreements. Should not be used on an Intranet or Extranet | ||
110 | * Mapping: Yes, subject to licence agreements. Should not be used on an Intranet or Extranet | ||
111 | * Linking: Yes | ||
112 | |||
113 | - GoogleMaps Premier: | ||
114 | |||
115 | * GeoCoding: Yes | ||
116 | * Mapping: Yes | ||
117 | * Linking: Yes | ||
118 | |||
119 | - ViaMichelin: | ||
120 | |||
121 | * GeoCoding: Yes | ||
122 | * Mapping: Yes | ||
123 | * Linking: Yes | ||
124 | |||
125 | - CloudMade: | ||
126 | |||
127 | * GeoCoding: No / Poor | ||
128 | * Mapping: Yes | ||
129 | * Linking: Yes | ||
130 | |||
131 | NOTE that Services are subject to Usage condition. Please refer to their website. | ||
132 | |||
5.1 | 133 | == Setup of GeoServices == | |
2.1 | 134 | ||
5.1 | 135 | ViaMichelin and GoogleMaps services have their own bundles. Those bundles are packages as product. | |
136 | You must add the product in your configuration. | ||
137 | |||
138 | Please note that the version of the platform should the same as the version of the GeoSpatial Extensions. | ||
139 | |||
140 | |||
141 | [[image:img39.png||alt="Product configuration / GeoSpatial"]]. | ||
142 | |||
143 | * Geocoding: | ||
144 | |||
145 | The ViaMichelin GeoCoder is a SOAP API call and requires viamichelin credentials: | ||
146 | |||
147 | [[image:img42.png]] | ||
148 | |||
149 | * GeoMapping | ||
150 | |||
151 | The ViaMichelin GeoMapping service requires the JavaScript Key (see image above). | ||
152 | |||
153 | Note that the API key MUST be setup with your website URL (localhost for a test system, ...). | ||
154 | |||
155 | |||
2.1 | 156 | == Using Geocoding == | |
157 | |||
5.1 | 158 | The Geocoding is a classical JavaScript service: | |
2.1 | 159 | ||
5.1 | 160 | {{code language="javascript"}} | |
161 | var res = Geocoder.geocodeAddress(street,null,data.rqCommune.rqNomInsee,null,"FRA"); | ||
162 | if(res != null) { | ||
163 | data.rqGeoLoc = res.Location; | ||
164 | } | ||
165 | {{/code}} | ||
166 | |||
167 | The returned object is a Location object that contains the following properties: | ||
168 | |||
169 | * City | ||
170 | * StreetNumber | ||
171 | * StreetLabel | ||
172 | * ZipCode | ||
173 | * State | ||
174 | * Country | ||
175 | * Location as a POINT (lat, long) | ||
176 | |||
177 | == Using Geomapping == | ||
178 | |||
179 | |||
180 | You must setup the Mapper you want to use in the com.requea.dynapage.geospatial.geomap system parameter: | ||
181 | |||
182 | |||
183 | [[image:img43.png||alt="GeoMapping setup"]] | ||
184 | |||
185 | |||
186 | When the mapping service is defined, Geolocated POINTS will be rendered as a map: | ||
187 | |||
188 | |||
189 | [[image:img44.png||alt="Geo Map"]] |