/[drupal]/contributions/modules/geonames/geonames_config.inc
ViewVC logotype

Contents of /contributions/modules/geonames/geonames_config.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat May 10 17:53:59 2008 UTC (18 months, 2 weeks ago) by serosero
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
File MIME type: text/x-php
Initial Drupal 6 release
1 <?php
2 // $Id
3
4 /**
5 * GeoNames Configuration
6 *
7 * @param $a, $b see function
8 *
9 * @return see bottom of function...
10 */
11
12 function geonames_config($a = NULL, $b = NULL) {
13
14 $config['search'] = array(
15 'service_name' => 'search',
16 'service_full_name' => 'GeoNames Fulltext Search',
17 'description' => t('Search provides names and information for geographical locations, it is probably the most comprehensive search available from GeoNames and has numereous possible parameter combinations. Note that this service allows some parameters to be arrays: country, featureclass and featurecode.'),
18 'service_path' => 'search',
19 'credit_cost' => 1,
20 'result_cache_prefix' => 'seares:',
21 'data_cache_prefix' => 'seadat:',
22 'allowed_parameters' => array(
23 // our style // geonames style
24 'query' => 'q',
25 'name' => 'name',
26 'name_equals' => 'name_equals',
27 'maxrows' => 'maxRows',
28 'startrow' => 'startRow',
29 'country' => 'country',
30 'admincode1' => 'adminCode1',
31 'admincode2' => 'adminCode2',
32 'admincode3' => 'adminCode3',
33 'featureclass' => 'featureClass',
34 'featurecode' => 'featureCode',
35 'lang' => 'lang',
36 'style' => 'style',
37 ),
38 'array_parameters' => array( // Parameters that are allowed to be arrays (or just string)
39 'country',
40 'featurecode',
41 'featureclass',
42 ),
43 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
44 'query',
45 'name',
46 'name_equals'
47 ),
48 'required_parameters_type' => 'single',
49 'query_defaults' => array(
50 'type' => 'xml',
51 'maxrows' => 15,
52 'featureclass' => 'p',
53 'startrow' => 0
54 ),
55 'pager' => TRUE,
56 'detect_style' => TRUE,
57 );
58 $config['postalcodecountryinfo'] = array(
59 'service_name' => 'postalcodecountryinfo',
60 'service_full_name' => 'Postal Code Country Info',
61 'description' => 'Find countries for which postal code geocoding is available.',
62 'service_path' => 'postalCodeCountryInfo',
63 'credit_cost' => 1,
64 'result_cache_prefix' => 'pccires:',
65 'data_cache_prefix' => 'pccidat:',
66 'allowed_parameters' => array(
67 'country',
68 ),
69 'columns' => array(
70 'countrycode',
71 'countryname',
72 'numpostalcodes',
73 'minpostalcode',
74 'maxpostalcode',
75 ),
76 );
77 $config['children'] = array(
78 'service_name' => 'children',
79 'service_full_name' => 'Place Hierarchy: Children',
80 'description' => t('Find the children of a given geonameId.'),
81 'service_path' => 'children',
82 'credit_cost' => 1,
83 'result_cache_prefix' => 'hcres:',
84 'data_cache_prefix' => 'hcdat:',
85 'allowed_parameters' => array(
86 // our style // geonames style
87 'geonameid' => 'geonameId',
88 'style' => 'style',
89 'lang' => 'lang',
90 ),
91 'required_parameters' => array(
92 'geonameid',
93 ),
94 'required_parameters_type' => 'single',
95 'detect_style' => TRUE,
96 );
97 $config['countrycode'] = array(
98 'service_name' => 'countrycode',
99 'service_full_name' => 'Country Code (reverse geocoding)',
100 'description' => t('Find Country Code from latitude and longitude'),
101 'service_path' => 'countrycode',
102 'credit_cost' => 1,
103 'result_cache_prefix' => 'ccres:',
104 'data_cache_prefix' => 'ccdat:',
105 'allowed_parameters' => array(
106 //our style geonames style
107 'lat' => 'lat',
108 'lng' => 'lng',
109 'lang' => 'lang',
110 'type' => 'type',
111 ),
112 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
113 'lat',
114 'lng'
115 ),
116 'required_parameters_type' => 'all',
117 'query_defaults' => array(
118 'type' => 'xml'
119 ),
120 'columns' => array('countrycode', 'countryname'),
121 );
122 $config['countryinfo'] = array(
123 'service_name' => 'countryinfo',
124 'service_full_name' => 'Country Info (Bounding Box, Capital, Area in square km, Population)',
125 'description' => 'Find countries for which postal code geocoding is available.',
126 'service_path' => 'countryInfo',
127 'credit_cost' => 1,
128 'result_cache_prefix' => 'couires:',
129 'data_cache_prefix' => 'couidat:',
130 'allowed_parameters' => array(
131 //our style geonames style
132 'country' => 'country',
133 'lang' => 'lang',
134 ),
135 'columns' => array(
136 'countrycode',
137 'countryname',
138 'isonumeric',
139 'isoalpha3',
140 'fipscode',
141 'continent',
142 'capital',
143 'areainsqkm',
144 'population',
145 'currencycode',
146 'languages',
147 'geonameid',
148 'bboxwest',
149 'bboxnorth',
150 'bboxsouth',
151 'bboxeast',
152 ),
153 );
154 $config['countrysubdivision'] = array(
155 'service_name' => 'countrysubdivision',
156 'service_full_name' => 'Country Subdivision (reverse geocoding)',
157 'description' => t('Find Country Code from latitude and longitude'),
158 'service_path' => 'countrySubdivision',
159 'credit_cost' => 1,
160 'result_cache_prefix' => 'csres:',
161 'data_cache_prefix' => 'csdat:',
162 'allowed_parameters' => array(
163 //our style geonames style
164 'lat' => 'lat',
165 'lng' => 'lng',
166 'lang' => 'lang',
167 ),
168 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
169 'lat',
170 'lng'
171 ),
172 'required_parameters_type' => 'all',
173 'columns' => array('countrycode', 'countryname', 'admincode1', 'adminname1'),
174 );
175 $config['gtopo30'] = array(
176 'service_name' => 'gtopo30',
177 'service_full_name' => 'Elevation - GTOPO30',
178 'description' => t('GTOPO30 is a global digital elevation model (DEM) with a horizontal grid spacing of 30 arc seconds (approximately 1 kilometer). GTOPO30 was derived from several raster and vector sources of topographic information.'),
179 'service_path' => 'gtopo30',
180 'credit_cost' => 0,
181 'result_cache_prefix' => 'gtpres:',
182 'data_cache_prefix' => 'gtpdat:',
183 'allowed_parameters' => array(
184 //our style geonames style
185 'lat' => 'lat',
186 'lng' => 'lng',
187 'type' => 'type',
188 ),
189 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
190 'lat',
191 'lng'
192 ),
193 'required_parameters_type' => 'all',
194 'query_defaults' => array(
195 'type' => 'xml'
196 ),
197 );
198 $config['hierarchy'] = array(
199 'service_name' => 'hierarchy',
200 'service_full_name' => 'Place Hierarchy: Hierarchy',
201 'description' => t('Find all Geonames higher up in the hierarchy of a place name.'),
202 'service_path' => 'hierarchy',
203 'credit_cost' => 1,
204 'result_cache_prefix' => 'hires:',
205 'data_cache_prefix' => 'hidat:',
206 'allowed_parameters' => array(
207 // our style // geonames style
208 'geonameid' => 'geonameId',
209 'style' => 'style',
210 'lang' => 'lang',
211 ),
212 'required_parameters' => array(
213 'geonameid',
214 ),
215 'required_parameters_type' => 'single',
216 'detect_style' => TRUE,
217 );
218 $config['nearbyplace'] = array(
219 'service_name' => 'nearbyplace',
220 'service_full_name' => 'Find nearby Place Name (reverse geocoding)',
221 'description' => t('Find nearby place name (reverse geocoding)'),
222 'service_path' => 'findNearbyPlaceName',
223 'credit_cost' => 4,
224 'result_cache_prefix' => 'neares:',
225 'data_cache_prefix' => 'neadat:',
226 'allowed_parameters' => array(
227 //our style geonames style
228 'lat' => 'lat',
229 'lng' => 'lng',
230 'radius' => 'radius',
231 'maxrows' => 'maxRows',
232 'style' => 'style', // Default = MEDIUM
233 ),
234 'query_defaults' => array(
235 'radius' => 20
236 ),
237 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
238 'lat',
239 'lng'
240 ),
241 'required_parameters_type' => 'all',
242 );
243 $config['nearbypostalcodes'] = array(
244 'service_name' => 'nearbypostalcodes',
245 'service_full_name' => 'Find nearby Postal Codes (reverse geocoding)',
246 'description' => 'Find nearby Postal Codes (reverse geocoding)',
247 'service_path' => 'findNearbyPostalCodes',
248 'credit_cost' => 2,
249 'result_cache_prefix' => 'nbpres:',
250 'data_cache_prefix' => 'nbpdat:',
251 'allowed_parameters' => array(
252 //our style geonames style
253 'lat' => 'lat',
254 'lng' => 'lng',
255 'radius' => 'radius',
256 'postalcode' => 'postalcode',
257 'maxrows' => 'maxRows', // Geonames default = 5
258 'country' => 'country', // Geonames default = ALL
259 'style' => 'style',
260 ),
261 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
262 array('lat', 'lng'),
263 array('postalcode', 'country')
264 ),
265 'required_parameters_type' => 'all',
266 'query_defaults' => array(
267 'maxrows' => 15,
268 'radius' => 10,
269 'style' => 'medium',
270 ),
271 'columns' => array(
272 'postalcode',
273 'name',
274 'countrycode',
275 'lat',
276 'lng',
277 'distance',
278 'admincode1',
279 'admincode2',
280 'admincode3',
281 'adminname1',
282 'adminname2',
283 'adminname3',
284 ),
285 );
286 $config['nearbywikipedia'] = array(
287 'service_name' => 'nearbywikipedia',
288 'service_full_name' => 'Find nearby Wikipedia Entries (reverse geocoding)',
289 'description' => 'Find nearby Wikipedia Entries (reverse geocoding)',
290 'service_path' => 'findNearbyWikipedia',
291 'credit_cost' => 2,
292 'result_cache_prefix' => 'wikres:',
293 'data_cache_prefix' => 'wikdat:',
294 'allowed_parameters' => array(
295 //our style geonames style
296 'lat' => 'lat',
297 'lng' => 'lng',
298 'radius' => 'radius',
299 'postalcode' => 'postalcode',
300 'lang' => 'lang', // Geonames default = en
301 'maxrows' => 'maxRows', // Geonames default = 5
302 'country' => 'country', // Geonames default = ALL
303 ),
304 'pager' => false,
305 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
306 array('lat', 'lng'),
307 array('postalcode', 'country')
308 ),
309 'required_parameters_type' => 'all',
310 'query_defaults' => array(
311 'maxrows' => 15,
312 'radius' => 10
313 ),
314 'columns' => array(
315 'summary' => 'summary',
316 'feature' => 'feature',
317 'population' => 'population',
318 'elevation' => 'elevation',
319 'lat' => 'lat',
320 'lng' => 'lng',
321 'wikipediaurl' => 'wikipediaUrl',
322 'thumbnailimg' => 'thumbnailImg',
323 'lang' => 'lang',
324 'distance' => 'distance',
325 ),
326 );
327 $config['neighbours'] = array(
328 'service_name' => 'neighbours',
329 'service_full_name' => 'Place Hierarchy: Neighbours',
330 'description' => t('Returns the neighbours for a given geonameId.'),
331 'service_path' => 'neighbours',
332 'credit_cost' => 1,
333 'result_cache_prefix' => 'hnres:',
334 'data_cache_prefix' => 'hndat:',
335 'allowed_parameters' => array(
336 // our style // geonames style
337 'geonameid' => 'geonameId',
338 'style' => 'style',
339 'lang' => 'lang',
340 ),
341 'required_parameters' => array(
342 'geonameid',
343 ),
344 'required_parameters_type' => 'single',
345 'detect_style' => TRUE,
346 );
347 $config['postalcodesearch'] = array(
348 'service_name' => 'postalcodesearch',
349 'service_full_name' => 'Postal Code Search',
350 'description' => t('Postalcode search provides placenames/postalcodes for locations.'),
351 'service_path' => 'postalCodeSearch',
352 'credit_cost' => 1,
353 'result_cache_prefix' => 'pcsres:',
354 'data_cache_prefix' => 'pcsdat:',
355 'allowed_parameters' => array(
356 // our style // geonames style
357 'postalcode' => 'postalcode',
358 'placename' => 'placename',
359 'maxrows' => 'maxRows',
360 'style' => 'style',
361 'country' => 'country', // if not set -- all countries
362 ),
363 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
364 'postalcode',
365 'placename',
366 ),
367 'required_parameters_type' => 'single',
368 'query_defaults' => array(
369 'maxrows' => 10,
370 'style' => 'medium',
371 ),
372 'columns' => array(
373 'postalcode',
374 'name',
375 'countrycode',
376 'lat',
377 'lng',
378 'admincode1',
379 'adminname1',
380 'admincode2',
381 'adminname2',
382 'admincode3',
383 'adminname3'
384 ),
385 );
386 $config['siblings'] = array(
387 'service_name' => 'siblings',
388 'service_full_name' => 'Place Hierarchy: Siblings',
389 'description' => t('Returns the siblings for a given geonameId.'),
390 'service_path' => 'siblings',
391 'credit_cost' => 1,
392 'result_cache_prefix' => 'hsres:',
393 'data_cache_prefix' => 'hsdat:',
394 'allowed_parameters' => array(
395 // our style // geonames style
396 'geonameid' => 'geonameId',
397 'style' => 'style',
398 'lang' => 'lang',
399 ),
400 'required_parameters' => array(
401 'geonameid',
402 ),
403 'required_parameters_type' => 'single',
404 'detect_style' => TRUE,
405 );
406 $config['srtm3'] = array(
407 'service_name' => 'srtm3',
408 'service_full_name' => 'Elevation - SRTM3',
409 'description' => t('Shuttle Radar Topography Mission (SRTM) elevation data. The dataset covers land areas between 60 degrees north and 56 degrees south. This web service is using SRTM3 data with data points located every 3-arc-second (approximately 90 meters) on a latitude/longitude grid. Result: a single number giving the elevation in meters according to srtm3, ocean areas have been masked as "no data" and have been assigned a value of -32768'),
410 'service_path' => 'srtm3',
411 'credit_cost' => 1,
412 'result_cache_prefix' => 'strmres:',
413 'data_cache_prefix' => 'strmdat:',
414 'allowed_parameters' => array(
415 //our style geonames style
416 'lat' => 'lat',
417 'lng' => 'lng',
418 'type' => 'type',
419 ),
420 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
421 'lat',
422 'lng'
423 ),
424 'required_parameters_type' => 'all',
425 'query_defaults' => array(
426 'type' => 'xml'
427 ),
428 );
429 $config['timezone'] = array(
430 'service_name' => 'timezone',
431 'service_full_name' => 'Timezone',
432 'description' => t('Find the timezone for a given lat/lng with gmt offset (1. January) and dst offset (1. July)'),
433 'service_path' => 'timezone',
434 'credit_cost' => 1,
435 'result_cache_prefix' => 'tzres:',
436 'data_cache_prefix' => 'tzdat:',
437 'allowed_parameters' => array(
438 //our style geonames style
439 'lat' => 'lat',
440 'lng' => 'lng',
441 ),
442 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
443 'lat',
444 'lng'
445 ),
446 'required_parameters_type' => 'all',
447 'query_defaults' => array(
448 'type' => 'xml'
449 ),
450 'columns' => array('countrycode','countryname','lat','lng','timezoneid','dstoffset','gmtoffset'),
451 );
452 $config['wikipediabbox'] = array(
453 'service_name' => 'wikipediabbox',
454 'service_full_name' => 'Wikipedia Articles from Bounding Box',
455 'description' => 'Search Wikipedia entries within the Bounding Box',
456 'service_path' => 'wikipediaBoundingBox',
457 'credit_cost' => 1,
458 'result_cache_prefix' => 'wikbres:',
459 'data_cache_prefix' => 'wikbdat:',
460 'allowed_parameters' => array(
461 //our style geonames style
462 'north' => 'north',
463 'south' => 'south',
464 'east' => 'east',
465 'west' => 'west',
466 'lang' => 'lang',
467 'maxrows' => 'maxRows',
468 ),
469 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
470 'north',
471 'south',
472 'east',
473 'west',
474 ),
475 'required_parameters_type' => 'all',
476 'query_defaults' => array(
477 'maxrows' => 15,
478 ),
479 'columns' => array(
480 'lang',
481 'title',
482 'summary',
483 'feature',
484 'population',
485 'elevation',
486 'lat',
487 'lng',
488 'wikipediaurl',
489 'thumbnailimg',
490 ),
491 );
492 $config['wikipediasearch'] = array(
493 'service_name' => 'wikipediasearch',
494 'service_full_name' => 'Wikipedia Fulltext Search',
495 'description' => 'Search Wikipedia entries in Fulltext',
496 'service_path' => 'wikipediaSearch',
497 'credit_cost' => 1,
498 'result_cache_prefix' => 'wiksres:',
499 'data_cache_prefix' => 'wiksdat:',
500 'allowed_parameters' => array(
501 //our style geonames style
502 'query' => 'q',
503 'title' => 'title',
504 'lang' => 'lang', // Geonames default = en
505 'maxrows' => 'maxRows', // Geonames default = 5
506 ),
507 'required_parameters' => array( // If you have set query_defaults you should not include the parameter here
508 array('query'),
509 array('title'),
510 ),
511 'required_parameters_type' => 'all',
512 'query_defaults' => array(
513 'maxrows' => 15,
514 ),
515 'columns' => array(
516 'lang',
517 'title',
518 'summary',
519 'feature',
520 'population',
521 'elevation',
522 'lat',
523 'lng',
524 'wikipediaurl',
525 'thumbnailimg',
526 ),
527 );
528
529 $services = array_keys($config);
530
531 switch ($a) {
532 case 'services':
533 // Return configured services or return full configuration
534 return $services;
535
536 case 'all values':
537 $key = $b;
538 foreach ($config as $c) {
539 $values[] = $c[$key];
540 }
541 return $values;
542 } // end switch
543
544 // get a single variable from a service
545 $service = $a;
546 if (in_array($service, $services)) {
547 $service = $a;
548 $variable = $b;
549 return $config[$service][$variable];
550 }
551
552 // if nothing else works, just return the full config ;)
553 return $config;
554 }

  ViewVC Help
Powered by ViewVC 1.1.2