~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to general/g.proj/create.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <errno.h>
 
2
#include <string.h>
 
3
 
 
4
#include <grass/gis.h>
 
5
#include <grass/glocale.h>
 
6
 
 
7
#include "local_proto.h"
 
8
 
 
9
void create_location(char *location)
 
10
{
 
11
    int ret;
 
12
 
 
13
    ret = G_make_location(location, &cellhd, projinfo, projunits);
 
14
    if (ret == 0)
 
15
        G_message(_("Location <%s> created"), location);
 
16
    else if (ret == -1)
 
17
        G_fatal_error(_("Unable to create location <%s>: %s"),
 
18
                      location, strerror(errno));
 
19
    else if (ret == -2)
 
20
        G_fatal_error(_("Unable to create projection files: %s"),
 
21
                    strerror(errno));
 
22
    else
 
23
        /* Shouldn't happen */
 
24
      G_fatal_error(_("Unable to create location <%s>"), location);
 
25
 
 
26
    G_message(_("You can switch to the new location by\n`%s=%s`"),
 
27
              "g.mapset mapset=PERMANENT location", location);
 
28
}
 
29
 
 
30
void modify_projinfo()
 
31
{
 
32
    const char *mapset = G_mapset();
 
33
    struct Cell_head old_cellhd;
 
34
    
 
35
    if (strcmp(mapset, "PERMANENT") != 0)
 
36
        G_fatal_error(_("You must select the PERMANENT mapset before updating the "
 
37
                        "current location's projection (current mapset is <%s>)"),
 
38
                      mapset);
 
39
    
 
40
    /* Read projection information from current location first */
 
41
    G_get_default_window(&old_cellhd);
 
42
    
 
43
    char path[GPATH_MAX];
 
44
        
 
45
    /* Write out the PROJ_INFO, and PROJ_UNITS if available. */
 
46
    if (projinfo != NULL) {
 
47
        G_file_name(path, "", "PROJ_INFO", "PERMANENT");
 
48
        G_write_key_value_file(path, projinfo);
 
49
    }
 
50
    
 
51
    if (projunits != NULL) {
 
52
        G_file_name(path, "", "PROJ_UNITS", "PERMANENT");
 
53
        G_write_key_value_file(path, projunits);
 
54
    }
 
55
    
 
56
    if ((old_cellhd.zone != cellhd.zone) ||
 
57
        (old_cellhd.proj != cellhd.proj)) {
 
58
        /* Recreate the default, and current window files if projection
 
59
         * number or zone have changed */
 
60
        G_put_element_window(&cellhd, "", "DEFAULT_WIND");
 
61
        G_put_element_window(&cellhd, "", "WIND");
 
62
        G_message(_("Default region was updated to the new projection, but if you have "
 
63
                    "multiple mapsets `g.region -d` should be run in each to update the "
 
64
                    "region from the default"));
 
65
    }
 
66
    G_important_message(_("Projection information updated"));
 
67
}