diff options
Diffstat (limited to 'map-server/altos-mapd/AltosMapdClient.java')
| -rw-r--r-- | map-server/altos-mapd/AltosMapdClient.java | 95 | 
1 files changed, 50 insertions, 45 deletions
| diff --git a/map-server/altos-mapd/AltosMapdClient.java b/map-server/altos-mapd/AltosMapdClient.java index 09833363..19174088 100644 --- a/map-server/altos-mapd/AltosMapdClient.java +++ b/map-server/altos-mapd/AltosMapdClient.java @@ -69,61 +69,66 @@ public class AltosMapdClient extends Thread implements AltosMapStoreListener {  		try {  			request = AltosJson.fromInputStream(socket.getInputStream()); -			double	lat = request.get_double("lat", AltosLib.MISSING); -			double	lon = request.get_double("lon", AltosLib.MISSING); -			int	zoom = request.get_int("zoom", AltosLib.MISSING); -			String	addr = request.get_string("remote_addr", null); - -			if (lat == AltosLib.MISSING || -			    lon == AltosLib.MISSING || -			    zoom == AltosLib.MISSING || -			    addr == null) -			{ +			if (request == null) {  				set_status(400); -			} else if (!AltosMapd.check_lat_lon(lat, lon)) { -				set_status(403);	/* Forbidden */ +				System.out.printf("client failed %d\n", http_status);  			} else { -				store_ready = new Semaphore(0); +				double	lat = request.get_double("lat", AltosLib.MISSING); +				double	lon = request.get_double("lon", AltosLib.MISSING); +				int	zoom = request.get_int("zoom", AltosLib.MISSING); +				String	addr = request.get_string("remote_addr", null); -				AltosMapStore	map_store = AltosMapStore.get(new AltosLatLon(lat, lon), -									      zoom, -									      AltosMapd.maptype, -									      AltosMapd.px_size, -									      AltosMapd.scale); -				int status; - -				if (map_store == null) { -					status = AltosMapTile.failed; +				if (lat == AltosLib.MISSING || +				    lon == AltosLib.MISSING || +				    zoom == AltosLib.MISSING || +				    addr == null) +				{ +					set_status(400); +				} else if (!AltosMapd.check_lat_lon(lat, lon)) { +					set_status(403);	/* Forbidden */  				} else { -					map_store.add_listener(this); -					try { -						store_ready.acquire(); -					} catch (Exception ie) { -					} +					store_ready = new Semaphore(0); -					status = map_store.status(); -				} +					AltosMapStore	map_store = AltosMapStore.get(new AltosLatLon(lat, lon), +										      zoom, +										      AltosMapd.maptype, +										      AltosMapd.px_size, +										      AltosMapd.scale); +					int status; -				if (status == AltosMapTile.fetched || status == AltosMapTile.loaded) { -					set_status(200); -					set_file(map_store.file); -				} else if (status == AltosMapTile.failed) { -					set_status(404); -				} else if (status == AltosMapTile.fetching) { -					set_status(408); -				} else if (status == AltosMapTile.bad_request) { -					set_status(400); -				} else if (status == AltosMapTile.forbidden) { -					set_status(403); -				} else { -					set_status(400); +					if (map_store == null) { +						status = AltosMapTile.failed; +					} else { +						map_store.add_listener(this); + +						try { +							store_ready.acquire(); +						} catch (Exception ie) { +						} + +						status = map_store.status(); +					} + +					if (status == AltosMapTile.fetched || status == AltosMapTile.loaded) { +						set_status(200); +						set_file(map_store.file); +					} else if (status == AltosMapTile.failed) { +						set_status(404); +					} else if (status == AltosMapTile.fetching) { +						set_status(408); +					} else if (status == AltosMapTile.bad_request) { +						set_status(400); +					} else if (status == AltosMapTile.forbidden) { +						set_status(403); +					} else { +						set_status(400); +					}  				} +				System.out.printf("%s: %.6f %.6f %d status %d\n", +						  addr, lat, lon, zoom, http_status);  			} -			System.out.printf("%s: %.6f %.6f %d status %d\n", -					  addr, lat, lon, zoom, http_status); -  		} catch (Exception e) {  			System.out.printf("client exception %s\n", e.toString());  			e.printStackTrace(System.out); | 
