public class MapServer extends Object
Modifier and Type | Field and Description |
---|---|
private static GraphDB |
g |
private static int |
HALT_RESPONSE
HTTP failed response.
|
private static String |
IMG_ROOT
The tile images are in the IMG_ROOT folder.
|
private static String |
OSM_DB_PATH
The OSM XML file path.
|
private static String[] |
REQUIRED_RASTER_REQUEST_PARAMS
Each raster request to the server will have the following parameters
as keys in the params map accessible by,
i.e., params.get("ullat") inside getMapRaster().
|
private static String[] |
REQUIRED_ROUTE_REQUEST_PARAMS
Each route request to the server will have the following parameters
as keys in the params map.
start_lat -> start point latitude, start_lon -> start point longitude, end_lat -> end point latitude, end_lon -> end point longitude. |
static double |
ROOT_LRLAT
The root upper left/lower right longitudes and latitudes represent the bounding box of
the root tile, as the images in the img/ folder are scraped.
|
static double |
ROOT_LRLON
The root upper left/lower right longitudes and latitudes represent the bounding box of
the root tile, as the images in the img/ folder are scraped.
|
static double |
ROOT_ULLAT
The root upper left/lower right longitudes and latitudes represent the bounding box of
the root tile, as the images in the img/ folder are scraped.
|
static double |
ROOT_ULLON
The root upper left/lower right longitudes and latitudes represent the bounding box of
the root tile, as the images in the img/ folder are scraped.
|
static Color |
ROUTE_STROKE_COLOR
Route stroke information: Cyan with half transparency.
|
static float |
ROUTE_STROKE_WIDTH_PX
Route stroke information: typically roads are not more than 5px wide.
|
static int |
TILE_SIZE
Each tile is 256x256 pixels.
|
Constructor and Description |
---|
MapServer() |
Modifier and Type | Method and Description |
---|---|
static void |
clearRoute()
Clear the current found route, if it exists.
|
static LinkedList<Long> |
findAndSetRoute(Map<String,Double> params)
Searches for the shortest route satisfying the input request parameters, sets it to be the
current route, and returns a
LinkedList of the route's node ids for testing
purposes. |
static List<Map<String,Object>> |
getLocations(String locationName)
Collect all locations that match a cleaned
locationName , and return
information about each node that matches. |
static List<String> |
getLocationsByPrefix(String prefix)
In linear time, collect all the names of OSM locations that prefix-match the query string.
|
static Map<String,Object> |
getMapRaster(Map<String,Double> params,
OutputStream os)
Handles raster API calls, queries for tiles and rasters the full image.
|
private static HashMap<String,Double> |
getRequestParams(spark.Request req,
String[] requiredParams)
Validate & return a parameter map of the required request parameters.
|
static void |
initialize()
Place any initialization statements that will be run before the server main loop here.
|
static void |
main(String[] args) |
public static final double ROOT_ULLAT
public static final double ROOT_ULLON
public static final double ROOT_LRLAT
public static final double ROOT_LRLON
public static final int TILE_SIZE
private static final int HALT_RESPONSE
public static final float ROUTE_STROKE_WIDTH_PX
public static final Color ROUTE_STROKE_COLOR
private static final String IMG_ROOT
private static final String OSM_DB_PATH
private static final String[] REQUIRED_RASTER_REQUEST_PARAMS
private static final String[] REQUIRED_ROUTE_REQUEST_PARAMS
private static GraphDB g
public static void initialize()
public static void main(String[] args)
private static HashMap<String,Double> getRequestParams(spark.Request req, String[] requiredParams)
req
- HTTP RequestrequiredParams
- TestParams to validatepublic static Map<String,Object> getMapRaster(Map<String,Double> params, OutputStream os)
The rastered photo must have the following properties:
params
- Map of the HTTP GET request's query parameters - the query bounding box and
the user viewport width and height.os
- An OutputStream that the resulting png image should be written to.REQUIRED_RASTER_REQUEST_PARAMS
public static LinkedList<Long> findAndSetRoute(Map<String,Double> params)
LinkedList
of the route's node ids for testing
purposes. params
- from the API call described in REQUIRED_ROUTE_REQUEST_PARAMSpublic static void clearRoute()
public static List<String> getLocationsByPrefix(String prefix)
prefix
- Prefix string to be searched for. Could be any case, with our without
punctuation.List
of the full names of locations whose cleaned name matches the
cleaned prefix
.public static List<Map<String,Object>> getLocations(String locationName)
locationName
, and return
information about each node that matches.locationName
- A full name of a location searched for.locationName
, and each location is a map of parameters for the Json
response as specified: