Package huskymaps

Class MapServer


  • public class MapServer
    extends Object
    Run the huskymaps server.
    See Also:
    MapGraph
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static Set<String> ALLOWED_HIGHWAY_TYPES
      Only allow for non-service roads.
      private static int MAX_MATCHES
      Maximum number of autocomplete search results.
      private static String OSM_DB_PATH
      The OpenStreetMap XML file path.
      private static String PLACES_PATH
      The place-importance TSV data file path from OpenStreetMap.
      private static int PORT
      Default port for serving the application locally.
      private static double SEATTLE_ROOT_LATDPP
      The latitudinal distance per pixel when the map is centered on Seattle.
      private static double SEATTLE_ROOT_LONDPP
      The longitudinal distance per pixel when the map is centered on Seattle.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapServer()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(String[] args)  
      private static org.locationtech.spatial4j.shape.Point pointLonLat​(org.locationtech.spatial4j.context.SpatialContext context, String... lonLat)
      Returns a new Point from parsing the given longitude and latitude strings.
      private static int port()
      Returns the port for communicating with the server.
      private static URL url​(org.locationtech.spatial4j.shape.Point center, int zoom, int width, int height, List<org.locationtech.spatial4j.shape.Point> locations)
      Return the API URL for retrieving the map image.
      private static BufferedImage withPolyline​(BufferedImage image, int[] xPoints, int[] yPoints)
      Returns a new image identical to the given image except for an additional polyline defined by the points.
    • Field Detail

      • PORT

        private static final int PORT
        Default port for serving the application locally.
        See Also:
        Constant Field Values
      • OSM_DB_PATH

        private static final String OSM_DB_PATH
        The OpenStreetMap XML file path. Downloaded from BBBike using custom region selection.
        See Also:
        Constant Field Values
      • PLACES_PATH

        private static final String PLACES_PATH
        The place-importance TSV data file path from OpenStreetMap.
        See Also:
        Constant Field Values
      • ALLOWED_HIGHWAY_TYPES

        private static final Set<String> ALLOWED_HIGHWAY_TYPES
        Only allow for non-service roads. This prevents going on pedestrian streets.
      • MAX_MATCHES

        private static final int MAX_MATCHES
        Maximum number of autocomplete search results.
        See Also:
        Constant Field Values
      • SEATTLE_ROOT_LONDPP

        private static final double SEATTLE_ROOT_LONDPP
        The longitudinal distance per pixel when the map is centered on Seattle.
        See Also:
        Constant Field Values
      • SEATTLE_ROOT_LATDPP

        private static final double SEATTLE_ROOT_LATDPP
        The latitudinal distance per pixel when the map is centered on Seattle.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MapServer

        public MapServer()
    • Method Detail

      • port

        private static int port()
        Returns the port for communicating with the server.
        Returns:
        the port for communicating with the server.
      • pointLonLat

        private static org.locationtech.spatial4j.shape.Point pointLonLat​(org.locationtech.spatial4j.context.SpatialContext context,
                                                                          String... lonLat)
        Returns a new Point from parsing the given longitude and latitude strings.
        Parameters:
        context - the spatial context.
        lonLat - the strings representing the longitude and latitude.
        Returns:
        a new Point from parsing the given longitude and latitude strings.
      • url

        private static URL url​(org.locationtech.spatial4j.shape.Point center,
                               int zoom,
                               int width,
                               int height,
                               List<org.locationtech.spatial4j.shape.Point> locations)
                        throws MalformedURLException
        Return the API URL for retrieving the map image.
        Parameters:
        center - the center of the map image.
        width - the width of the window.
        height - the height of the window.
        locations - the list of locations (or null).
        Returns:
        the URL for retrieving the map image.
        Throws:
        MalformedURLException - if the URL is invalid.
      • withPolyline

        private static BufferedImage withPolyline​(BufferedImage image,
                                                  int[] xPoints,
                                                  int[] yPoints)
        Returns a new image identical to the given image except for an additional polyline defined by the points.
        Parameters:
        image - the input image.
        xPoints - the x-coordinates for the points on the polyline.
        yPoints - the y-coordinates for the points on the polyline.
        Returns:
        a new image identical to the given image except for an additional polyline defined by the points.