Commit fa0b0a167406e4fe0f7290c21af5633b9c534b8d
1 parent
975828a0
Ajout clss servlet pour récup bytes et coord d'une map
Showing
2 changed files
with
82 additions
and
0 deletions
Show diff stats
project/server_servlet/src/main/java/MapByteServlet.java
0 → 100644
1 | +import repository.Map; | ||
2 | +import service.MapService; | ||
3 | + | ||
4 | +import javax.servlet.ServletException; | ||
5 | +import javax.servlet.http.HttpServlet; | ||
6 | +import javax.servlet.http.HttpServletRequest; | ||
7 | +import javax.servlet.http.HttpServletResponse; | ||
8 | +import java.io.IOException; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by Guillaume on 29/05/2017. | ||
12 | + */ | ||
13 | +public class MapByteServlet extends HttpServlet { | ||
14 | + @Override | ||
15 | + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
16 | + throws ServletException, IOException { | ||
17 | + | ||
18 | + MapService mapService = new MapService(); | ||
19 | + int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); | ||
20 | + Map map = mapService.getMap(mapId); | ||
21 | + | ||
22 | + servletResponse.setContentType("image/png"); | ||
23 | + servletResponse.getWriter().print(map.getContent()); | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
28 | + throws ServletException, IOException { | ||
29 | + service(servletRequest, servletResponse); | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
34 | + throws ServletException, IOException { | ||
35 | + service(servletRequest, servletResponse); | ||
36 | + } | ||
37 | +} | ||
0 | \ No newline at end of file | 38 | \ No newline at end of file |
project/server_servlet/src/main/java/MapScaleServlet.java
0 → 100644
1 | +import repository.Location; | ||
2 | +import repository.Map; | ||
3 | +import service.MapService; | ||
4 | +import service.PositioningService; | ||
5 | + | ||
6 | +import javax.servlet.ServletException; | ||
7 | +import javax.servlet.http.HttpServlet; | ||
8 | +import javax.servlet.http.HttpServletRequest; | ||
9 | +import javax.servlet.http.HttpServletResponse; | ||
10 | +import java.io.IOException; | ||
11 | +import java.net.DatagramPacket; | ||
12 | +import java.net.DatagramSocket; | ||
13 | +import java.net.InetAddress; | ||
14 | + | ||
15 | +import static java.lang.Thread.sleep; | ||
16 | + | ||
17 | +/** | ||
18 | + * Created by Guillaume on 29/05/2017. | ||
19 | + */ | ||
20 | +public class MapScaleServlet extends HttpServlet { | ||
21 | + @Override | ||
22 | + public void service (final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
23 | + throws ServletException, IOException { | ||
24 | + | ||
25 | + MapService mapService = new MapService(); | ||
26 | + int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); | ||
27 | + Map map = mapService.getMap(mapId); | ||
28 | + | ||
29 | + servletResponse.setContentType("text/plain"); | ||
30 | + servletResponse.getWriter().print(String.format("{x1:%f;y1:%f;x2:%f;y2:%f}", map.getX_topLeft() | ||
31 | + , map.getY_topLeft(), map.getX_bottomRight(), map.getY_bottomRight())); | ||
32 | + } | ||
33 | + | ||
34 | + @Override | ||
35 | + public void doGet(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
36 | + throws ServletException, IOException { | ||
37 | + service(servletRequest, servletResponse); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void doPost(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) | ||
42 | + throws ServletException, IOException { | ||
43 | + service(servletRequest, servletResponse); | ||
44 | + } | ||
45 | +} |