~ubuntu-branches/ubuntu/warty/xplanet/warty

« back to all changes in this revision

Viewing changes to libprojection/getProjection.cc

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040824071400-2dr4qnjbjmm8z3ia
Tags: 1.0.6-1ubuntu1
Build-depend: libtiff4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
    Xplanet 0.94 - render an image of a planet into an X window
3
 
    Copyright (C) 2002 Hari Nair <hari@alumni.caltech.edu>
4
 
 
5
 
    This program is free software; you can redistribute it and/or modify
6
 
    it under the terms of the GNU General Public License as published by
7
 
    the Free Software Foundation; either version 2 of the License, or
8
 
    (at your option) any later version.
9
 
 
10
 
    This program is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
    GNU General Public License for more details.
14
 
 
15
 
    You should have received a copy of the GNU General Public License
16
 
    along with this program; if not, write to the Free Software
17
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
****************************************************************************/
19
 
 
20
 
#include <cctype>
21
 
#include <iostream>
22
 
#include <cstring>
23
 
using namespace std;
24
 
 
25
 
#include "keywords.h"
26
 
 
27
 
#include "ProjectionBase.h"
28
 
#include "ProjectionAncient.h"
29
 
#include "ProjectionAzimuthal.h"
30
 
#include "ProjectionHemisphere.h"
31
 
#include "ProjectionMollweide.h"
32
 
#include "ProjectionMercator.h"
33
 
#include "ProjectionOrthographic.h"
34
 
#include "ProjectionPeters.h"
35
 
#include "ProjectionRectangular.h"
36
 
 
37
 
int 
38
 
getProjectionType(char *proj_string)
39
 
{
40
 
    int projection;
41
 
 
42
 
    char *lowercase = proj_string;
43
 
    char *ptr = proj_string;
44
 
    while (*ptr != '\0') *ptr++ = tolower(*proj_string++);
45
 
    if (strncmp(lowercase, "ancient", 2) == 0)
46
 
        projection = ANCIENT;
47
 
    else if (strncmp(lowercase, "azimuthal", 2) == 0)
48
 
        projection = AZIMUTHAL;
49
 
    else if (strncmp(lowercase, "hemisphere", 1) == 0)
50
 
        projection = HEMISPHERE;
51
 
    else if (strncmp(lowercase, "mercator", 2) == 0)
52
 
        projection = MERCATOR;
53
 
    else if (strncmp(lowercase, "mollweide", 2) == 0)
54
 
        projection = MOLLWEIDE;
55
 
    else if (strncmp(lowercase, "orthographic", 1) == 0)
56
 
        projection = ORTHOGRAPHIC;
57
 
    else if (strncmp(lowercase, "peters", 1) == 0)
58
 
        projection = PETERS;
59
 
    else if (strncmp(lowercase, "rectangular", 1) == 0)
60
 
        projection = RECTANGULAR;
61
 
    else 
62
 
    {
63
 
        cerr << "Unknown projection, using rectangular\n";
64
 
        projection = RECTANGULAR;
65
 
    }
66
 
    return(projection);
67
 
}
68
 
 
69
 
ProjectionBase *
70
 
getProjection(const int projection, const int width, const int height)
71
 
{
72
 
    ProjectionBase *thisProjection = NULL;
73
 
    switch (projection)
74
 
    {
75
 
    case ANCIENT:
76
 
        thisProjection = new ProjectionAncient(width, height);
77
 
        break;
78
 
    case AZIMUTHAL:
79
 
        thisProjection = new ProjectionAzimuthal(width, height);
80
 
        break;
81
 
    case HEMISPHERE:
82
 
        thisProjection = new ProjectionHemisphere(width, height);
83
 
        break;
84
 
    case MERCATOR:
85
 
        thisProjection = new ProjectionMercator(width, height);
86
 
        break;
87
 
    case MOLLWEIDE:
88
 
        thisProjection = new ProjectionMollweide(width, height);
89
 
        break;
90
 
    case ORTHOGRAPHIC:
91
 
        thisProjection = new ProjectionOrthographic(width, height);
92
 
        break;
93
 
    case PETERS:
94
 
        thisProjection = new ProjectionPeters(width, height);
95
 
        break;
96
 
    default:
97
 
        break;
98
 
    }
99
 
    return(thisProjection);
100
 
}