altos-mapd: Add --max-zoom to limit tile loading. Set default to 15.
authorKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 22:28:32 +0000 (16:28 -0600)
committerKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 22:32:17 +0000 (15:32 -0700)
This ensures that we won't end up serving huge numbers of high
resolution images.

Signed-off-by: Keith Packard <keithp@keithp.com>
map-server/altos-mapd/AltosMapd.java
map-server/altos-mapd/altos-mapd-default
map-server/altos-mapd/altos-mapd.service

index 1be1655d5eddfd88c0c98cfb76907d4b0cb31989..29528541beaf08a3fcfe3bfc3eddeedaf5ee2e22 100644 (file)
@@ -32,6 +32,8 @@ public class AltosMapd implements AltosLaunchSiteListener {
 
        public final static int scale = 1;
 
 
        public final static int scale = 1;
 
+       public static int max_zoom = 17;
+
        public static double valid_radius = 17000;      /* 17km */
 
        public String map_dir = null;
        public static double valid_radius = 17000;      /* 17km */
 
        public String map_dir = null;
@@ -40,7 +42,8 @@ public class AltosMapd implements AltosLaunchSiteListener {
 
        public void usage() {
                System.out.printf("usage: altos-mapd [--mapdir <map-directory] [--launch-sites <launch-sites-file>]\n" +
 
        public void usage() {
                System.out.printf("usage: altos-mapd [--mapdir <map-directory] [--launch-sites <launch-sites-file>]\n" +
-                                 "                  [--radius <valid-radius-m> [--port <port>] [--key <key-file>]\n");
+                                 "                  [--radius <valid-radius-m> [--port <port>] [--key <key-file>]\n" +
+                                 "                  [--max-zoom <max-zoom-level>\n");
                System.exit(1);
        }
 
                System.exit(1);
        }
 
@@ -69,6 +72,10 @@ public class AltosMapd implements AltosLaunchSiteListener {
        }
 
        public static boolean check_lat_lon(double lat, double lon, int zoom) {
        }
 
        public static boolean check_lat_lon(double lat, double lon, int zoom) {
+
+               if (zoom > max_zoom)
+                       return false;
+
                AltosMapTransform       transform = new AltosMapTransform(px_size, px_size, zoom, new AltosLatLon(lat, lon));
 
                AltosLatLon             upper_left = transform.screen_lat_lon(new AltosPointInt(0, 0));
                AltosMapTransform       transform = new AltosMapTransform(px_size, px_size, zoom, new AltosLatLon(lat, lon));
 
                AltosLatLon             upper_left = transform.screen_lat_lon(new AltosPointInt(0, 0));
@@ -156,6 +163,13 @@ public class AltosMapd implements AltosLaunchSiteListener {
                        } else if (args[i].equals("--key") && i < args.length-1) {
                                key_file = args[i+1];
                                skip = 2;
                        } else if (args[i].equals("--key") && i < args.length-1) {
                                key_file = args[i+1];
                                skip = 2;
+                       } else if (args[i].equals("--max-zoom") && i < args.length-1) {
+                               try {
+                                       max_zoom = AltosParse.parse_int(args[i+1]);
+                               } catch (ParseException pe) {
+                                       usage();
+                               }
+                               skip = 2;
                        } else {
                                usage();
                        }
                        } else {
                                usage();
                        }
index 40d283a20da501fbb0dfad26a9b42426c14f5f1d..1611f0b66de1a1469b807eabf5764f18dc3e6dad 100644 (file)
@@ -1,3 +1,4 @@
 MAPKEY=/home/altos-mapd/google-maps-api-key
 MAPDIR=/home/altos-mapd/maps
 LAUNCHSITES=/var/www/html/launch-sites.txt
 MAPKEY=/home/altos-mapd/google-maps-api-key
 MAPDIR=/home/altos-mapd/maps
 LAUNCHSITES=/var/www/html/launch-sites.txt
+MAXZOOM=17
index d6f01da1e4de96da804ee1f952531e6eded8706d..ba263c2ac67a0c6b038df444360e75b55bb89b39 100644 (file)
@@ -8,7 +8,7 @@ Type=simple
 User=altos-mapd
 Restart=always
 EnvironmentFile=/etc/default/altos-mapd-default
 User=altos-mapd
 Restart=always
 EnvironmentFile=/etc/default/altos-mapd-default
-ExecStart=/usr/bin/altos-mapd --key $MAPKEY --mapdir $MAPDIR --launch-sites $LAUNCHSITES
+ExecStart=/usr/bin/altos-mapd --key $MAPKEY --mapdir $MAPDIR --launch-sites $LAUNCHSITES --max-zoom $MAXZOOM
 
 [Install]
 WantedBy=multi-user.target
 
 [Install]
 WantedBy=multi-user.target