Context-detection API for Android developed as a university project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FakeLocationMonitor.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2009-2010 Chris Smith
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package uk.co.md87.android.common.geo;
  23. /**
  24. * A dummy location monitor for use in emulator testing.
  25. *
  26. * @author chris
  27. */
  28. public class FakeLocationMonitor implements LocationMonitor {
  29. private int count = 0;
  30. private double[][] points = new double[][] {
  31. {51.481386d, -0.084667d}, // Place 1
  32. {51.481386d, -0.084667d},
  33. {51.481386d, -0.084667d},
  34. {51.491386d, -0.082667d},
  35. {51.501386d, -0.081667d},
  36. {51.517676d, -0.07997d}, // Place 2
  37. {51.517676d, -0.07997d},
  38. {51.517676d, -0.07997d},
  39. {51.514386d, -0.08300d},
  40. {51.511386d, -0.08500d},
  41. {51.511386d, -0.09000d},
  42. {51.511386d, -0.10000d},
  43. {51.511386d, -0.12000d},
  44. {51.511386d, -0.14000d},
  45. {51.511386d, -0.17000d},
  46. {51.498725d, -0.17950d}, // Place 3
  47. {51.498725d, -0.17950d},
  48. {51.498725d, -0.17950d},
  49. {51.481386d, -0.084667d}, // Place 1
  50. {51.481386d, -0.084667d},
  51. {51.481386d, -0.084667d},
  52. {51.491386d, -0.082667d},
  53. {51.501386d, -0.081667d},
  54. {51.517676d, -0.07997d}, // Place 2
  55. {51.517676d, -0.07997d},
  56. {51.517676d, -0.07997d},
  57. {51.514386d, -0.08300d},
  58. {51.511386d, -0.08500d},
  59. {51.511386d, -0.09000d},
  60. {51.511386d, -0.10000d},
  61. {51.511386d, -0.12000d},
  62. {51.511386d, -0.14000d},
  63. {51.511386d, -0.17000d},
  64. {51.481386d, -0.084667d}, // Place 1
  65. {51.481386d, -0.084667d},
  66. {51.481386d, -0.084667d},
  67. };
  68. public float getAccuracy() {
  69. return 0f;
  70. }
  71. public double getLat() {
  72. return points[count++ % points.length][0];
  73. }
  74. public double getLon() {
  75. return points[count % points.length][1];
  76. }
  77. }