~ubuntu-branches/ubuntu/raring/mkgmapgui/raring

« back to all changes in this revision

Viewing changes to tim/mkgmapgui/Operation.java

  • Committer: Bazaar Package Importer
  • Author(s): Mònica Ramírez Arceda
  • Date: 2011-05-15 20:46:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110515204652-zn2ggjijl3whq5bh
Tags: upstream-1.1.ds
Import upstream version 1.1.ds

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package tim.mkgmapgui;
 
2
 
 
3
import java.io.File;
 
4
 
 
5
/**
 
6
 * Class to represent an operation of mkgmap
 
7
 * including input parameters and what to do with the output
 
8
 */
 
9
public class Operation
 
10
{
 
11
        private String[] _arguments = null;
 
12
        private File _outputFile = null;
 
13
        private File _requestedFile = null;
 
14
 
 
15
        /**
 
16
         * Constructor
 
17
         * @param inArgs command line arguments to mkgmap
 
18
         * @param inOutputFile output file generated by mkgmap
 
19
         * @param inRequestedFile requested output file
 
20
         */
 
21
        public Operation(String[] inArgs, File inOutputFile, File inRequestedFile)
 
22
        {
 
23
                _arguments = inArgs;
 
24
                _outputFile = inOutputFile;
 
25
                _requestedFile = inRequestedFile;
 
26
                if (!_requestedFile.getName().toLowerCase().endsWith(".img")) {
 
27
                        _requestedFile = new File(_requestedFile.getAbsolutePath() + ".img");
 
28
                }
 
29
        }
 
30
 
 
31
        /**
 
32
         * Constructor for a convert operation
 
33
         * @param inOsmFile osm file to convert
 
34
         * @param inName name of map
 
35
         * @param inRequestedFile file requested by user
 
36
         * @return Operation object
 
37
         */
 
38
        public static Operation makeConvertOperation(File inOsmFile, String inName, File inRequestedFile)
 
39
        {
 
40
                String[] args = new String[] {"--mapname=" + inName, inOsmFile.getAbsolutePath()};
 
41
                return new Operation(args, new File(inName + ".img"), inRequestedFile);
 
42
        }
 
43
 
 
44
        /**
 
45
         * Constructor for a combine operation
 
46
         * @param inFiles array of files to combine
 
47
         * @param inRequestedFile file requested by user
 
48
         * @return Operation object
 
49
         */
 
50
        public static Operation makeCombineOperation(String[] inPaths, File inRequestedFile)
 
51
        {
 
52
                String[] args = new String[inPaths.length + 1];
 
53
                args[0] = "--gmapsupp";
 
54
                System.arraycopy(inPaths, 0, args, 1, inPaths.length);
 
55
                return new Operation(args, new File("gmapsupp.img"), inRequestedFile);
 
56
        }
 
57
 
 
58
        /**
 
59
         * @return command line arguments for mkgmap
 
60
         */
 
61
        public String[] getArgs()
 
62
        {
 
63
                return _arguments;
 
64
        }
 
65
 
 
66
        /**
 
67
         * @return output file from mkgmap
 
68
         */
 
69
        public File getOutputFile()
 
70
        {
 
71
                return _outputFile;
 
72
        }
 
73
 
 
74
        /**
 
75
         * @return requested file
 
76
         */
 
77
        public File getRequestedFile()
 
78
        {
 
79
                return _requestedFile;
 
80
        }
 
81
}