1 : /******************************************************************************
2 : * $Id: ogr_opt.cpp 22332 2011-05-08 15:32:37Z rouault $
3 : *
4 : * Project: OpenGIS Simple Features
5 : * Purpose: Functions for getting list of projection types, and their parms.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2000, Frank Warmerdam
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #include "ogr_srs_api.h"
31 : #include "cpl_string.h"
32 :
33 : CPL_CVSID("$Id: ogr_opt.cpp 22332 2011-05-08 15:32:37Z rouault $");
34 :
35 : static const char *papszParameterDefinitions[] = {
36 : SRS_PP_CENTRAL_MERIDIAN, "Central Meridian", "Long", "0.0",
37 : SRS_PP_SCALE_FACTOR, "Scale Factor", "Ratio", "1.0",
38 : SRS_PP_STANDARD_PARALLEL_1, "Standard Parallel 1", "Lat", "0.0",
39 : SRS_PP_STANDARD_PARALLEL_2, "Standard Parallel 2", "Lat", "0.0",
40 : SRS_PP_LONGITUDE_OF_CENTER, "Longitude of Center", "Long", "0.0",
41 : SRS_PP_LATITUDE_OF_CENTER, "Latitude of Center", "Lat", "0.0",
42 : SRS_PP_LONGITUDE_OF_ORIGIN, "Longitude of Origin", "Long", "0.0",
43 : SRS_PP_LATITUDE_OF_ORIGIN, "Latitude of Origin", "Lat", "0.0",
44 : SRS_PP_FALSE_EASTING, "False Easting", "m", "0.0",
45 : SRS_PP_FALSE_NORTHING, "False Northing", "m", "0.0",
46 : SRS_PP_AZIMUTH, "Azimuth", "Angle", "0.0",
47 : SRS_PP_LONGITUDE_OF_POINT_1,"Longitude of Point 1", "Long", "0.0",
48 : SRS_PP_LATITUDE_OF_POINT_1, "Latitude of Point 1", "Lat", "0.0",
49 : SRS_PP_LONGITUDE_OF_POINT_2,"Longitude of Point 2", "Long", "0.0",
50 : SRS_PP_LATITUDE_OF_POINT_2, "Latitude of Point 2", "Lat", "0.0",
51 : SRS_PP_LONGITUDE_OF_POINT_3,"Longitude of Point 3", "Long", "0.0",
52 : SRS_PP_LATITUDE_OF_POINT_3, "Latitude of Point 3", "Lat", "0.0",
53 : SRS_PP_RECTIFIED_GRID_ANGLE,"Rectified Grid Angle", "Angle", "0.0",
54 : SRS_PP_SATELLITE_HEIGHT, "Satellite Height", "m", "35785831.0",
55 : NULL
56 : };
57 :
58 : static const char *papszProjectionDefinitions[] = {
59 :
60 : "*",
61 : SRS_PT_TRANSVERSE_MERCATOR,
62 : "Transverse Mercator",
63 : SRS_PP_LATITUDE_OF_ORIGIN,
64 : SRS_PP_CENTRAL_MERIDIAN,
65 : SRS_PP_SCALE_FACTOR,
66 : SRS_PP_FALSE_EASTING,
67 : SRS_PP_FALSE_NORTHING,
68 :
69 : "*",
70 : SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED,
71 : "Transverse Mercator (South Oriented)",
72 : SRS_PP_LATITUDE_OF_ORIGIN,
73 : SRS_PP_CENTRAL_MERIDIAN,
74 : SRS_PP_SCALE_FACTOR,
75 : SRS_PP_FALSE_EASTING,
76 : SRS_PP_FALSE_NORTHING,
77 :
78 : "*",
79 : SRS_PT_TUNISIA_MINING_GRID,
80 : "Tunisia Mining Grid",
81 : SRS_PP_LATITUDE_OF_ORIGIN,
82 : SRS_PP_CENTRAL_MERIDIAN,
83 : SRS_PP_FALSE_EASTING,
84 : SRS_PP_FALSE_NORTHING,
85 :
86 : "*",
87 : SRS_PT_ALBERS_CONIC_EQUAL_AREA,
88 : "Albers Conic Equal Area",
89 : SRS_PP_STANDARD_PARALLEL_1,
90 : SRS_PP_STANDARD_PARALLEL_2,
91 : SRS_PP_LATITUDE_OF_CENTER,
92 : SRS_PP_LONGITUDE_OF_CENTER,
93 : SRS_PP_FALSE_EASTING,
94 : SRS_PP_FALSE_NORTHING,
95 :
96 : "*",
97 : SRS_PT_AZIMUTHAL_EQUIDISTANT,
98 : "Azimuthal Equidistant",
99 : SRS_PP_LATITUDE_OF_CENTER,
100 : SRS_PP_LONGITUDE_OF_CENTER,
101 : SRS_PP_FALSE_EASTING,
102 : SRS_PP_FALSE_NORTHING,
103 :
104 : "*",
105 : SRS_PT_CYLINDRICAL_EQUAL_AREA,
106 : "Cylindrical Equal Area",
107 : SRS_PP_STANDARD_PARALLEL_1,
108 : SRS_PP_CENTRAL_MERIDIAN,
109 : SRS_PP_FALSE_EASTING,
110 : SRS_PP_FALSE_NORTHING,
111 :
112 : "*",
113 : SRS_PT_CASSINI_SOLDNER,
114 : "Cassini/Soldner",
115 : SRS_PP_LATITUDE_OF_ORIGIN,
116 : SRS_PP_CENTRAL_MERIDIAN,
117 : SRS_PP_FALSE_EASTING,
118 : SRS_PP_FALSE_NORTHING,
119 :
120 : "*",
121 : SRS_PT_EQUIDISTANT_CONIC,
122 : "Equidistant Conic",
123 : SRS_PP_STANDARD_PARALLEL_1,
124 : SRS_PP_STANDARD_PARALLEL_2,
125 : SRS_PP_LATITUDE_OF_CENTER,
126 : SRS_PP_LONGITUDE_OF_CENTER,
127 : SRS_PP_FALSE_EASTING,
128 : SRS_PP_FALSE_NORTHING,
129 :
130 : "*",
131 : SRS_PT_BONNE,
132 : "Bonne",
133 : SRS_PP_STANDARD_PARALLEL_1,
134 : SRS_PP_CENTRAL_MERIDIAN,
135 : SRS_PP_FALSE_EASTING,
136 : SRS_PP_FALSE_NORTHING,
137 :
138 : "*",
139 : SRS_PT_ECKERT_I,
140 : "Eckert I",
141 : SRS_PP_CENTRAL_MERIDIAN,
142 : SRS_PP_FALSE_EASTING,
143 : SRS_PP_FALSE_NORTHING,
144 :
145 : "*",
146 : SRS_PT_ECKERT_II,
147 : "Eckert II",
148 : SRS_PP_CENTRAL_MERIDIAN,
149 : SRS_PP_FALSE_EASTING,
150 : SRS_PP_FALSE_NORTHING,
151 :
152 : "*",
153 : SRS_PT_ECKERT_III,
154 : "Eckert III",
155 : SRS_PP_CENTRAL_MERIDIAN,
156 : SRS_PP_FALSE_EASTING,
157 : SRS_PP_FALSE_NORTHING,
158 :
159 : "*",
160 : SRS_PT_ECKERT_IV,
161 : "Eckert IV",
162 : SRS_PP_CENTRAL_MERIDIAN,
163 : SRS_PP_FALSE_EASTING,
164 : SRS_PP_FALSE_NORTHING,
165 :
166 : "*",
167 : SRS_PT_ECKERT_V,
168 : "Eckert V",
169 : SRS_PP_CENTRAL_MERIDIAN,
170 : SRS_PP_FALSE_EASTING,
171 : SRS_PP_FALSE_NORTHING,
172 :
173 : "*",
174 : SRS_PT_ECKERT_VI,
175 : "Eckert VI",
176 : SRS_PP_CENTRAL_MERIDIAN,
177 : SRS_PP_FALSE_EASTING,
178 : SRS_PP_FALSE_NORTHING,
179 :
180 : "*",
181 : SRS_PT_EQUIRECTANGULAR,
182 : "Equirectangular",
183 : SRS_PP_LATITUDE_OF_ORIGIN,
184 : SRS_PP_CENTRAL_MERIDIAN,
185 : SRS_PP_STANDARD_PARALLEL_1,
186 : SRS_PP_FALSE_EASTING,
187 : SRS_PP_FALSE_NORTHING,
188 :
189 : "*",
190 : SRS_PT_GAUSSSCHREIBERTMERCATOR,
191 : "Gauss-Schreiber Transverse Mercator",
192 : SRS_PP_LATITUDE_OF_ORIGIN,
193 : SRS_PP_CENTRAL_MERIDIAN,
194 : SRS_PP_SCALE_FACTOR,
195 : SRS_PP_FALSE_EASTING,
196 : SRS_PP_FALSE_NORTHING,
197 :
198 : "*",
199 : SRS_PT_GALL_STEREOGRAPHIC,
200 : "Gall Stereographic",
201 : SRS_PP_CENTRAL_MERIDIAN,
202 : SRS_PP_FALSE_EASTING,
203 : SRS_PP_FALSE_NORTHING,
204 :
205 : "*",
206 : SRS_PT_GOODE_HOMOLOSINE,
207 : "Goode Homolosine",
208 : SRS_PP_CENTRAL_MERIDIAN,
209 : SRS_PP_FALSE_EASTING,
210 : SRS_PP_FALSE_NORTHING,
211 :
212 : "*",
213 : SRS_PT_IGH,
214 : "Interrupted Goode Homolosine",
215 :
216 : "*",
217 : SRS_PT_GEOSTATIONARY_SATELLITE,
218 : "Geostationary Satellite",
219 : SRS_PP_CENTRAL_MERIDIAN,
220 : SRS_PP_SATELLITE_HEIGHT,
221 : SRS_PP_FALSE_EASTING,
222 : SRS_PP_FALSE_NORTHING,
223 :
224 : "*",
225 : SRS_PT_GNOMONIC,
226 : "Gnomonic",
227 : SRS_PP_LATITUDE_OF_ORIGIN,
228 : SRS_PP_CENTRAL_MERIDIAN,
229 : SRS_PP_FALSE_EASTING,
230 : SRS_PP_FALSE_NORTHING,
231 :
232 : "*",
233 : SRS_PT_HOTINE_OBLIQUE_MERCATOR,
234 : "Hotine Oblique Mercator",
235 : SRS_PP_LATITUDE_OF_CENTER,
236 : SRS_PP_LONGITUDE_OF_CENTER,
237 : SRS_PP_AZIMUTH,
238 : SRS_PP_RECTIFIED_GRID_ANGLE,
239 : SRS_PP_SCALE_FACTOR,
240 : SRS_PP_FALSE_EASTING,
241 : SRS_PP_FALSE_NORTHING,
242 :
243 : "*",
244 : SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN,
245 : "Hotine Oblique Mercator Two Point Natural Origin",
246 : SRS_PP_LATITUDE_OF_CENTER,
247 : SRS_PP_LATITUDE_OF_POINT_1,
248 : SRS_PP_LONGITUDE_OF_POINT_1,
249 : SRS_PP_LATITUDE_OF_POINT_2,
250 : SRS_PP_LONGITUDE_OF_POINT_2,
251 : SRS_PP_SCALE_FACTOR,
252 : SRS_PP_FALSE_EASTING,
253 : SRS_PP_FALSE_NORTHING,
254 :
255 : "*",
256 : SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA,
257 : "Lambert Azimuthal Equal Area",
258 : SRS_PP_LATITUDE_OF_CENTER,
259 : SRS_PP_LONGITUDE_OF_CENTER,
260 : SRS_PP_FALSE_EASTING,
261 : SRS_PP_FALSE_NORTHING,
262 :
263 : "*",
264 : SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP,
265 : "Lambert Conformal Conic (2SP)",
266 : SRS_PP_STANDARD_PARALLEL_1,
267 : SRS_PP_STANDARD_PARALLEL_2,
268 : SRS_PP_LATITUDE_OF_ORIGIN,
269 : SRS_PP_CENTRAL_MERIDIAN,
270 : SRS_PP_FALSE_EASTING,
271 : SRS_PP_FALSE_NORTHING,
272 :
273 : "*",
274 : SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP,
275 : "Lambert Conformal Conic (1SP)",
276 : SRS_PP_LATITUDE_OF_ORIGIN,
277 : SRS_PP_CENTRAL_MERIDIAN,
278 : SRS_PP_SCALE_FACTOR,
279 : SRS_PP_FALSE_EASTING,
280 : SRS_PP_FALSE_NORTHING,
281 :
282 : "*",
283 : SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM,
284 : "Lambert Conformal Conic (2SP - Belgium)",
285 : SRS_PP_STANDARD_PARALLEL_1,
286 : SRS_PP_STANDARD_PARALLEL_2,
287 : SRS_PP_LATITUDE_OF_ORIGIN,
288 : SRS_PP_CENTRAL_MERIDIAN,
289 : SRS_PP_FALSE_EASTING,
290 : SRS_PP_FALSE_NORTHING,
291 :
292 : "*",
293 : SRS_PT_MILLER_CYLINDRICAL,
294 : "Miller Cylindrical",
295 : SRS_PP_LATITUDE_OF_CENTER,
296 : SRS_PP_LONGITUDE_OF_CENTER,
297 : SRS_PP_FALSE_EASTING,
298 : SRS_PP_FALSE_NORTHING,
299 :
300 : "*",
301 : SRS_PT_MERCATOR_1SP,
302 : "Mercator (1SP)",
303 : SRS_PP_LATITUDE_OF_ORIGIN,
304 : SRS_PP_CENTRAL_MERIDIAN,
305 : SRS_PP_SCALE_FACTOR,
306 : SRS_PP_FALSE_EASTING,
307 : SRS_PP_FALSE_NORTHING,
308 :
309 : "*",
310 : SRS_PT_MERCATOR_2SP,
311 : "Mercator (2SP)",
312 : SRS_PP_STANDARD_PARALLEL_1,
313 : SRS_PP_LATITUDE_OF_ORIGIN,
314 : SRS_PP_CENTRAL_MERIDIAN,
315 : SRS_PP_FALSE_EASTING,
316 : SRS_PP_FALSE_NORTHING,
317 :
318 : "*",
319 : SRS_PT_MOLLWEIDE,
320 : "Mollweide",
321 : SRS_PP_CENTRAL_MERIDIAN,
322 : SRS_PP_FALSE_EASTING,
323 : SRS_PP_FALSE_NORTHING,
324 :
325 : "*",
326 : SRS_PT_NEW_ZEALAND_MAP_GRID,
327 : "New Zealand Map Grid",
328 : SRS_PP_LATITUDE_OF_ORIGIN,
329 : SRS_PP_CENTRAL_MERIDIAN,
330 : SRS_PP_FALSE_EASTING,
331 : SRS_PP_FALSE_NORTHING,
332 :
333 : "*",
334 : SRS_PT_OBLIQUE_STEREOGRAPHIC,
335 : "Oblique Stereographic",
336 : SRS_PP_LATITUDE_OF_ORIGIN,
337 : SRS_PP_CENTRAL_MERIDIAN,
338 : SRS_PP_SCALE_FACTOR,
339 : SRS_PP_FALSE_EASTING,
340 : SRS_PP_FALSE_NORTHING,
341 :
342 : "*",
343 : SRS_PT_ORTHOGRAPHIC,
344 : "Orthographic",
345 : SRS_PP_LATITUDE_OF_ORIGIN,
346 : SRS_PP_CENTRAL_MERIDIAN,
347 : SRS_PP_FALSE_EASTING,
348 : SRS_PP_FALSE_NORTHING,
349 :
350 : "*",
351 : SRS_PT_POLYCONIC,
352 : "Polyconic",
353 : SRS_PP_LATITUDE_OF_ORIGIN,
354 : SRS_PP_CENTRAL_MERIDIAN,
355 : SRS_PP_FALSE_EASTING,
356 : SRS_PP_FALSE_NORTHING,
357 :
358 : "*",
359 : SRS_PT_POLAR_STEREOGRAPHIC,
360 : "Polar Stereographic",
361 : SRS_PP_LATITUDE_OF_ORIGIN,
362 : SRS_PP_CENTRAL_MERIDIAN,
363 : SRS_PP_SCALE_FACTOR,
364 : SRS_PP_FALSE_EASTING,
365 : SRS_PP_FALSE_NORTHING,
366 :
367 : "*",
368 : SRS_PT_ROBINSON,
369 : "Robinson",
370 : SRS_PP_LONGITUDE_OF_CENTER,
371 : SRS_PP_FALSE_EASTING,
372 : SRS_PP_FALSE_NORTHING,
373 :
374 : "*",
375 : SRS_PT_SINUSOIDAL,
376 : "Sinusoidal",
377 : SRS_PP_LONGITUDE_OF_CENTER,
378 : SRS_PP_FALSE_EASTING,
379 : SRS_PP_FALSE_NORTHING,
380 :
381 : "*"
382 : SRS_PT_STEREOGRAPHIC,
383 : "Stereographic",
384 : SRS_PP_LATITUDE_OF_ORIGIN,
385 : SRS_PP_CENTRAL_MERIDIAN,
386 : SRS_PP_SCALE_FACTOR,
387 : SRS_PP_FALSE_EASTING,
388 : SRS_PP_FALSE_NORTHING,
389 :
390 : "*"
391 : SRS_PT_TWO_POINT_EQUIDISTANT,
392 : "Two Point Equidistant",
393 : SRS_PP_LATITUDE_OF_1ST_POINT,
394 : SRS_PP_LONGITUDE_OF_1ST_POINT,
395 : SRS_PP_LATITUDE_OF_2ND_POINT,
396 : SRS_PP_LONGITUDE_OF_2ND_POINT,
397 : SRS_PP_FALSE_EASTING,
398 : SRS_PP_FALSE_NORTHING,
399 :
400 : "*",
401 : SRS_PT_VANDERGRINTEN,
402 : "Van Der Grinten",
403 : SRS_PP_CENTRAL_MERIDIAN,
404 : SRS_PP_FALSE_EASTING,
405 : SRS_PP_FALSE_NORTHING,
406 :
407 : "*"
408 : SRS_PT_KROVAK,
409 : "Krovak",
410 : SRS_PP_LATITUDE_OF_CENTER,
411 : SRS_PP_LONGITUDE_OF_CENTER,
412 : SRS_PP_AZIMUTH,
413 : SRS_PP_PSEUDO_STD_PARALLEL_1,
414 : SRS_PP_SCALE_FACTOR,
415 : SRS_PP_FALSE_EASTING,
416 : SRS_PP_FALSE_NORTHING,
417 :
418 : "*",
419 : SRS_PT_IMW_POLYCONIC,
420 : "International Map of the World Polyconic",
421 : SRS_PP_LATITUDE_OF_1ST_POINT,
422 : SRS_PP_LATITUDE_OF_2ND_POINT,
423 : SRS_PP_CENTRAL_MERIDIAN,
424 : SRS_PP_FALSE_EASTING,
425 : SRS_PP_FALSE_NORTHING,
426 :
427 : "*",
428 : SRS_PT_WAGNER_I,
429 : "Wagner I (Kavraisky VI)",
430 : SRS_PP_FALSE_EASTING,
431 : SRS_PP_FALSE_NORTHING,
432 :
433 : "*",
434 : SRS_PT_WAGNER_II,
435 : "Wagner II",
436 : SRS_PP_FALSE_EASTING,
437 : SRS_PP_FALSE_NORTHING,
438 :
439 : "*",
440 : SRS_PT_WAGNER_III,
441 : "Wagner III",
442 : SRS_PP_LATITUDE_OF_ORIGIN,
443 : SRS_PP_FALSE_EASTING,
444 : SRS_PP_FALSE_NORTHING,
445 :
446 : "*",
447 : SRS_PT_WAGNER_IV,
448 : "Wagner IV",
449 : SRS_PP_FALSE_EASTING,
450 : SRS_PP_FALSE_NORTHING,
451 :
452 : "*",
453 : SRS_PT_WAGNER_V,
454 : "Wagner V",
455 : SRS_PP_FALSE_EASTING,
456 : SRS_PP_FALSE_NORTHING,
457 :
458 : "*",
459 : SRS_PT_WAGNER_VI,
460 : "Wagner VI",
461 : SRS_PP_FALSE_EASTING,
462 : SRS_PP_FALSE_NORTHING,
463 :
464 : "*",
465 : SRS_PT_WAGNER_VII,
466 : "Wagner VII",
467 : SRS_PP_FALSE_EASTING,
468 : SRS_PP_FALSE_NORTHING,
469 :
470 : NULL
471 : };
472 :
473 :
474 :
475 :
476 : /************************************************************************/
477 : /* OPTGetProjectionMethods() */
478 : /************************************************************************/
479 :
480 : /**
481 : * Fetch list of possible projection methods.
482 : *
483 : * @return Returns NULL terminated list of projection methods. This should
484 : * be freed with CSLDestroy() when no longer needed.
485 : */
486 :
487 1 : char **OPTGetProjectionMethods()
488 :
489 : {
490 : int i;
491 1 : char **papszList = NULL;
492 :
493 356 : for( i = 1; papszProjectionDefinitions[i] != NULL; i++ )
494 : {
495 355 : if( EQUAL(papszProjectionDefinitions[i-1],"*") )
496 48 : papszList = CSLAddString(papszList,papszProjectionDefinitions[i]);
497 : }
498 :
499 1 : return papszList;
500 : }
501 :
502 : /************************************************************************/
503 : /* OPTGetParameterList() */
504 : /************************************************************************/
505 :
506 : /**
507 : * Fetch the parameters for a given projection method.
508 : *
509 : * @param pszProjectionMethod internal name of projection methods to fetch
510 : * the parameters for, such as "Transverse_Mercator"
511 : * (SRS_PT_TRANSVERSE_MERCATOR).
512 : *
513 : * @param ppszUserName pointer in which to return a user visible name for
514 : * the projection name. The returned string should not be modified or
515 : * freed by the caller. Legal to pass in NULL if user name not required.
516 : *
517 : * @return returns a NULL terminated list of internal parameter names that
518 : * should be freed by the caller when no longer needed. Returns NULL if
519 : * projection method is unknown.
520 : */
521 :
522 48 : char **OPTGetParameterList( const char *pszProjectionMethod,
523 : char ** ppszUserName )
524 :
525 : {
526 48 : char **papszList = NULL;
527 : int i;
528 :
529 8353 : for( i = 1; papszProjectionDefinitions[i] != NULL; i++ )
530 : {
531 8353 : if( papszProjectionDefinitions[i-1][0] == '*'
532 : && EQUAL(papszProjectionDefinitions[i],pszProjectionMethod) )
533 : {
534 48 : i++;
535 :
536 48 : if( ppszUserName != NULL )
537 48 : *ppszUserName = (char *)papszProjectionDefinitions[i];
538 :
539 48 : i++;
540 519 : while( papszProjectionDefinitions[i] != NULL
541 235 : && papszProjectionDefinitions[i][0] != '*' )
542 : {
543 : papszList = CSLAddString( papszList,
544 188 : papszProjectionDefinitions[i] );
545 188 : i++;
546 : }
547 48 : if( papszList == NULL) /* IGH has no parameter, so return an empty list instead of NULL */
548 1 : papszList = (char**) CPLCalloc(1, sizeof(char*));
549 48 : return papszList;
550 : }
551 : }
552 :
553 0 : return NULL;
554 : }
555 :
556 : /************************************************************************/
557 : /* OPTGetParameterInfo() */
558 : /************************************************************************/
559 :
560 : /**
561 : * Fetch information about a single parameter of a projection method.
562 : *
563 : * @param pszProjectionMethod name of projection method for which the parameter
564 : * applies. Not currently used, but in the future this could affect defaults.
565 : * This is the internal projection method name, such as "Tranverse_Mercator".
566 : *
567 : * @param pszParameterName name of the parameter to fetch information about.
568 : * This is the internal name such as "central_meridian"
569 : * (SRS_PP_CENTRAL_MERIDIAN).
570 : *
571 : * @param ppszUserName location at which to return the user visible name for
572 : * the parameter. This pointer may be NULL to skip the user name. The
573 : * returned name should not be modified or freed.
574 : *
575 : * @param ppszType location at which to return the parameter type for
576 : * the parameter. This pointer may be NULL to skip. The returned type
577 : * should not be modified or freed. The type values are described above.
578 : *
579 : * @param pdfDefaultValue location at which to put the default value for
580 : * this parameter. The pointer may be NULL.
581 : *
582 : * @return TRUE if parameter found, or FALSE otherwise.
583 : */
584 :
585 188 : int OPTGetParameterInfo( const char * pszProjectionMethod,
586 : const char * pszParameterName,
587 : char ** ppszUserName,
588 : char ** ppszType,
589 : double *pdfDefaultValue )
590 :
591 : {
592 : int i;
593 :
594 : (void) pszProjectionMethod;
595 :
596 1350 : for( i = 0; papszParameterDefinitions[i] != NULL; i += 4 )
597 : {
598 1348 : if( EQUAL(papszParameterDefinitions[i],pszParameterName) )
599 : {
600 186 : if( ppszUserName != NULL )
601 186 : *ppszUserName = (char *)papszParameterDefinitions[i+1];
602 186 : if( ppszType != NULL )
603 186 : *ppszType = (char *)papszParameterDefinitions[i+2];
604 186 : if( pdfDefaultValue != NULL )
605 186 : *pdfDefaultValue = atof(papszParameterDefinitions[i+3]);
606 :
607 186 : return TRUE;
608 : }
609 : }
610 :
611 2 : return FALSE;
612 : }
613 :
|