altos-mapd: Use command line to pass map directory in
[fw/altos] / map-server / altos-mapd / AltosMapd.java
1 /*
2  * Copyright © 2018 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 package altosmapd;
16
17 import java.net.*;
18 import java.io.*;
19
20 import org.altusmetrum.altoslib_13.*;
21
22 public class AltosMapd {
23
24         public final static int port = 16717;
25
26         public final static int maptype = AltosMap.maptype_hybrid;
27
28         public final static int px_size = 512;
29
30         public final static int scale = 1;
31
32         public static void main(final String[] args) {
33
34                 AltosMapdServer server = new AltosMapdServer(port);
35
36                 AltosPreferences.init(new AltosMapdPreferences());
37
38                 if (args.length < 1) {
39                         System.out.printf("usage: altos-mapd <map-directory>\n");
40                         System.exit(1);
41                 }
42
43                 AltosPreferences.mapdir = new File(args[0]);
44
45                 for (;;) {
46                         Socket client = server.accept();
47                         if (client == null) {
48                                 System.out.printf("accept failed\n");
49                                 continue;
50                         }
51                         System.out.printf("got client\n");
52                         new AltosMapdClient(client);
53                 }
54         }
55 }