/**
  * Previous path GeoPoint was off screen and the next one will be to or the first on screen when
  * the path reaches the projection.
  *
  * @return
  */
 private boolean moveOffscreenWaypoint(int flexStepsize) {
   while (mWaypointsCursor.move(flexStepsize)) {
     if (mWaypointsCursor.isLast()) {
       return true;
     }
     GeoPoint evalPoint = extractGeoPoint();
     // Do no include log wrong 0.0 lat 0.0 long, skip to next value in while-loop
     if (evalPoint.getLatitudeE6() == 0 || evalPoint.getLongitudeE6() == 0) {
       continue;
     }
     //         Log.d( TAG, String.format( "Evaluate point number %d ",
     // mWaypointsCursor.getPosition() ) );
     if (possibleScreenPass(mPrevGeoPoint, evalPoint)) {
       mPrevGeoPoint = evalPoint;
       if (flexStepsize == 1) // Just stumbled over a border
       {
         return true;
       } else {
         mWaypointsCursor.move(-1 * flexStepsize); // Take 1 step back
         return moveOffscreenWaypoint(flexStepsize / 2); // Continue at halve accelerated speed
       }
     } else {
       moveToGeoPoint(evalPoint);
       mPrevGeoPoint = evalPoint;
     }
   }
   return mWaypointsCursor.moveToLast();
 }
    /**
     * React to tap events on Map by showing an appropriate detail activity
     *
     * @see com.google.android.maps.ItemizedOverlay#onTap(com.google.android.maps.GeoPoint,
     *     com.google.android.maps.MapView)
     */
    @Override
    public boolean onTap(GeoPoint p, MapView mvMap1) {
      long lat = p.getLatitudeE6();
      long lon = p.getLongitudeE6();

      long rowid = -1;
      JobsCursor c = db.getJobs(JobsCursor.SortBy.title);
      for (int i = 0; i < c.getCount(); i++) {
        if (Math.abs(c.getColLatitude() - lat) < 1000
            && Math.abs(c.getColLongitude() - lon) < 1000) {
          rowid = c.getColJobsId();
          break;
        } else {
          c.moveToNext();
        }
      }

      if (0 > rowid) {
        return false;
      }

      Bundle b = new Bundle();
      b.putLong("_id", rowid);
      Intent i = new Intent(MicroJobs.this, MicroJobsDetail.class);
      i.putExtras(b);
      startActivity(i);

      return true;
    }
Esempio n. 3
0
 private boolean isOnScreen(GeoPoint eval) {
   boolean under = this.mTopLeft.getLatitudeE6() > eval.getLatitudeE6();
   boolean above = this.mBottumRight.getLatitudeE6() < eval.getLatitudeE6();
   boolean right = this.mTopLeft.getLongitudeE6() < eval.getLongitudeE6();
   boolean left = this.mBottumRight.getLongitudeE6() > eval.getLongitudeE6();
   return under && above && right && left;
 }
Esempio n. 4
0
  private String translatePointToAddress(GeoPoint point) {
    String defaultString = "No address found.";
    Geocoder geoCoder = new Geocoder(getContext(), Locale.getDefault());

    // Attempt to get address(es)
    List<Address> addresses;
    try {
      addresses =
          geoCoder.getFromLocation(point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6, 1);
    } catch (IOException exception) {
      // Return default if an error occurred
      exception.printStackTrace();
      return defaultString;
    }

    // Return default if nothing found
    if (addresses.size() <= 0) {
      return defaultString;
    }

    // Construct address string
    String addressString = "";
    for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++) {
      addressString += addresses.get(0).getAddressLine(i) + "\n";
    }

    return addressString;
  }
Esempio n. 5
0
  /**
   * using the users lat/lon saves car location to lat/lon files and passes that geopoint info to
   * setCar also writes address to notes
   *
   * @author ricky barrette 3-31-2010
   * @author WWPowers 3-31-2010
   */
  private void markCar() {
    // removed old parking timer
    // ParkingTimerDialog.stopTimer(this);

    GeoPoint user = mMap.getUserLocation();

    /*
     * if the user location is not null then save car lat and lon to files
     * pass geopoint info to set car, which will setup and show the car
     * overlay get address info and add it to the notes file
     *
     * else inform user that they dont have a gps signal
     */
    if (user != null) {
      mSettings
          .edit()
          .putInt(Settings.LAT, user.getLatitudeE6())
          .putInt(Settings.LON, user.getLongitudeE6())
          .commit();

      setCar(user);

      mListener.onCarMarked(user);

    } else {
      Toast.makeText(getActivity(), R.string.no_gps_signal, Toast.LENGTH_LONG).show();
    }
  }
Esempio n. 6
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    super.draw(canvas, mapView, shadow);

    Projection projection = mapView.getProjection();

    int latSpan = mapView.getLatitudeSpan();
    int lngSpan = mapView.getLongitudeSpan();
    GeoPoint mapCenter = mapView.getMapCenter();
    int mapLeftGeo = mapCenter.getLongitudeE6() - (lngSpan / 2);
    int mapRightGeo = mapCenter.getLongitudeE6() + (lngSpan / 2);

    int mapTopGeo = mapCenter.getLatitudeE6() - (latSpan / 2);
    int mapBottomGeo = mapCenter.getLatitudeE6() + (latSpan / 2);

    GeoPoint geoPoint = this.getSampleLocation();

    if ((geoPoint.getLatitudeE6() > mapTopGeo && geoPoint.getLatitudeE6() < mapBottomGeo)
        && (geoPoint.getLongitudeE6() > mapLeftGeo && geoPoint.getLongitudeE6() < mapRightGeo)) {
      Point myPoint = new Point();
      projection.toPixels(geoPoint, myPoint);
      Bitmap marker =
          BitmapFactory.decodeResource(mapView.getContext().getResources(), R.drawable.markerblue);
      canvas.drawBitmap(marker, myPoint.x - 15, myPoint.y - 30, null);
    }
  }
  private void setZoomLevel() {
    Object[] keys = map.keySet().toArray();
    OverlayItem item;
    if (keys.length > 1) {
      int minLatitude = Integer.MAX_VALUE;
      int maxLatitude = Integer.MIN_VALUE;
      int minLongitude = Integer.MAX_VALUE;
      int maxLongitude = Integer.MIN_VALUE;

      for (Object key : keys) {
        item = map.get((String) key);
        GeoPoint p = item.getPoint();
        int lati = p.getLatitudeE6();
        int lon = p.getLongitudeE6();

        maxLatitude = Math.max(lati, maxLatitude);
        minLatitude = Math.min(lati, minLatitude);
        maxLongitude = Math.max(lon, maxLongitude);
        minLongitude = Math.min(lon, minLongitude);
      }
      mapController.zoomToSpan(
          Math.abs(maxLatitude - minLatitude), Math.abs(maxLongitude - minLongitude));
      mapController.animateTo(
          new GeoPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2));

    } else {
      String key = (String) keys[0];
      item = map.get(key);
      mapController.animateTo(item.getPoint());
      while (mapController.zoomIn()) {}

      mapController.zoomOut();
    }
  }
Esempio n. 8
0
 public double calculationByDistance(GeoPoint gpOrigem, GeoPoint gpDestino) {
   int Radius = 6371; // radius of earth in Km
   double c = 0f;
   if (gpOrigem != null && gpDestino != null) {
     double lat1 = gpOrigem.getLatitudeE6() / 1E6;
     double lat2 = gpDestino.getLatitudeE6() / 1E6;
     double lon1 = gpOrigem.getLongitudeE6() / 1E6;
     double lon2 = gpDestino.getLongitudeE6() / 1E6;
     double dLat = Math.toRadians(lat2 - lat1);
     double dLon = Math.toRadians(lon2 - lon1);
     double a =
         Math.sin(dLat / 2) * Math.sin(dLat / 2)
             + Math.cos(Math.toRadians(lat1))
                 * Math.cos(Math.toRadians(lat2))
                 * Math.sin(dLon / 2)
                 * Math.sin(dLon / 2);
     c = 2 * Math.asin(Math.sqrt(a));
     double valueResult = Radius * c;
     double km = valueResult / 1;
     DecimalFormat newFormat = new DecimalFormat("####");
     Integer kmInDec = Integer.valueOf(newFormat.format(km));
     double meter = valueResult % 1000;
     double meterInDec = Integer.valueOf(newFormat.format(meter));
     Log.i("Radius Value", "" + valueResult + "   KM  " + kmInDec + " Meter   " + meterInDec);
   }
   return Radius * c;
 }
  /**
   * Method that generates POIs with red markers and random geoposition
   *
   * @param context
   * @return array list of POIs
   */
  public ArrayList<ExamplePoiModel> getRedArray(Context context) {

    Random randomObject = new Random();
    ArrayList<ExamplePoiModel> poisArray = new ArrayList<ExamplePoiModel>();
    ExamplePoiModel poiObject;

    for (int i = 0; i < NUM_POIS / 2; i++) {

      int latE6 = (int) ((randomObject.nextFloat() * GEO_MAX * 2) - GEO_MAX);
      int lonE6 = (int) ((randomObject.nextFloat() * GEO_MAX * 2) - GEO_MAX);
      GeoPoint randomGeoPoint = new GeoPoint(latE6, lonE6);

      Drawable customMarker = context.getResources().getDrawable(R.drawable.poi_red);
      customMarker.setBounds(
          0, 0, customMarker.getIntrinsicWidth(), customMarker.getIntrinsicHeight());

      poiObject = new ExamplePoiModel();
      poiObject.setGeoPoint(randomGeoPoint);
      poiObject.setMarkerDrawable(customMarker);
      poiObject.setTitle("Red #" + i);
      poiObject.setSnippet(
          "Position: "
              + randomGeoPoint.getLatitudeE6() / 1E6
              + ", "
              + randomGeoPoint.getLongitudeE6() / 1E6);

      poisArray.add(poiObject);
    }
    return poisArray;
  }
Esempio n. 10
0
 public static final boolean isOnCircle(GeoPoint obj, GeoPoint center, float radius) {
   return isOnCircle(
       obj.getLatitudeE6(),
       obj.getLongitudeE6(),
       center.getLatitudeE6(),
       center.getLongitudeE6(),
       radius * 8.3);
 }
Esempio n. 11
0
 @Override
 public void locationChanged(GeoPoint p) {
   ((TextView) findViewById(R.id.CoordText))
       .setText(
           (p == null
               ? "No location found."
               : "( " + p.getLatitudeE6() + ", " + p.getLongitudeE6() + " )"));
 }
  public Point getPoint(GeoPoint geoPoint) {
    double x = MITMapView.computeGoogleX(geoPoint.getLongitudeE6(), mZoom);
    double y = MITMapView.computeGoogleY(geoPoint.getLatitudeE6(), mZoom);

    int pixelX = (int) Math.round((x - mLeftCol) * MITMapView.IMAGE_TILE_SIZE) - mLeftOffset;
    int pixelY = (int) Math.round((y - mTopRow) * MITMapView.IMAGE_TILE_SIZE) - mTopOffset;

    return new Point(pixelX, pixelY);
  }
  public MapCanvasDrawer(int width, int height, GeoPoint geoPoint, int zoom) {
    initCanvasBitmap(width, height);

    mZoom = zoom;

    double centerY = MITMapView.computeGoogleY(geoPoint.getLatitudeE6(), mZoom);
    double centerX = MITMapView.computeGoogleX(geoPoint.getLongitudeE6(), mZoom);

    initTileCoordinates(centerX, centerY, width, height);
  }
Esempio n. 14
0
  public static final float getSpotAngle(Context _context, GeoPoint p, Location _me) {
    Location location = new Location("LOCATION_SERVICE");

    try {
      location.setLatitude(p.getLatitudeE6());
      location.setLongitude(p.getLatitudeE6());
    } catch (Exception e) {
    }
    return _me.bearingTo(location);
  }
Esempio n. 15
0
 public void writeToParcel(Parcel parcel, int flags) {
   parcel.writeLong(mId);
   mBitmap.writeToParcel(parcel, 0);
   parcel.writeInt(mLocation.getLatitudeE6());
   parcel.writeInt(mLocation.getLongitudeE6());
   parcel.writeString(mTitle);
   parcel.writeString(mOwner);
   parcel.writeString(mThumbUrl);
   parcel.writeString(mOwnerUrl);
   parcel.writeString(mPhotoUrl);
 }
Esempio n. 16
0
  public GeoPoint min() {
    int minLat = Integer.MAX_VALUE;
    int minLon = Integer.MAX_VALUE;

    for (GeoPoint item : points) {
      int lat = item.getLatitudeE6();
      int lon = item.getLongitudeE6();
      minLat = Math.min(lat, minLat);
      minLon = Math.min(lon, minLon);
    }
    return new GeoPoint(minLat, minLon);
  }
 @Override
 public void onChange(
     MapView view, GeoPoint newCenter, GeoPoint oldCenter, int newZoom, int oldZoom) {
   // Check values
   if ((!newCenter.equals(oldCenter)) && (newZoom != oldZoom)) {
     mHandler.post(mOnMapZoomPan);
   } else if (!newCenter.equals(oldCenter)) {
     mHandler.post(mOnMapPan);
   } else if (newZoom != oldZoom) {
     mHandler.post(mOnMapZoom);
   }
 }
Esempio n. 18
0
  @Override
  protected boolean onTap(int i) {

    GeoPoint gpoint = myOverlays.get(i).getPoint();
    double lat = gpoint.getLatitudeE6() / 1e6;
    double lon = gpoint.getLongitudeE6() / 1e6;
    String toast = "Title: " + myOverlays.get(i).getTitle();
    toast += "\nText: " + myOverlays.get(i).getSnippet();
    toast += "\nSymbol coordinates: Lat = " + lat + " Lon = " + lon + " (microdegrees)";
    Toast.makeText(context, toast, Toast.LENGTH_LONG).show();
    showDialog();
    return (true);
  }
Esempio n. 19
0
  public GeoPoint max() {
    int maxLat = Integer.MIN_VALUE;
    int maxLon = Integer.MIN_VALUE;

    for (GeoPoint item : points) {
      int lat = item.getLatitudeE6();
      int lon = item.getLongitudeE6();
      maxLat = Math.max(lat, maxLat);
      maxLon = Math.max(lon, maxLon);
    }

    return new GeoPoint(maxLat, maxLon);
  }
 public double distanceBetween(GeoPoint start, Location end) {
   double sLat = start.getLatitudeE6() / 1E6;
   double sLong = start.getLongitudeE6() / 1E6;
   // double eLat = end.getLatitudeE6() / 1E6;
   // double eLong = end.getLongitudeE6() / 1E6;
   Location l1 = new Location("Loc8");
   l1.setLatitude(sLat);
   l1.setLongitude(sLong);
   // Location l2 = new Location("Loc8");
   // l2.setLatitude(eLat);
   // l2.setLongitude(eLong);
   return l1.distanceTo(end);
 }
Esempio n. 21
0
  public void testParsePlacemarkPoint() {
    String xmlBody =
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\r\n"
            + ""
            + "					<Placemark>\r\n"
            + "					<name>PunktReception</name>\r\n"
            + "					<LookAt>\r\n"
            + "						<longitude>15.00000033315315</longitude>\r\n"
            + "						<latitude>61.99999830712358</latitude>\r\n"
            + "						<altitude>0</altitude>\r\n"
            + "						<heading>2.941567373323467e-007</heading>\r\n"
            + "						<tilt>0</tilt>\r\n"
            + "						<range>11003036.41038311</range>\r\n"
            + "						<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>\r\n"
            + "					</LookAt>\r\n"
            + "					<styleUrl>#m_ylw-pushpin</styleUrl>\r\n"
            + "					<Point>\r\n"
            + "						<coordinates>15.00000033315315,61.99999830712357,0</coordinates>\r\n"
            + "					</Point>\r\n"
            + "				</Placemark>\r\n"
            + "";
    KMLparser kmlParser = new KMLparser(true);

    try {
      parser.setInput(new StringReader(xmlBody));
      int eventType = parser.getEventType();
      while (eventType != XmlPullParser.START_TAG) {
        eventType = parser.next();
      }
      assertTrue("kml".equalsIgnoreCase(parser.getName()));
      eventType = parser.next();
      while (eventType != XmlPullParser.START_TAG) {
        eventType = parser.next();
      }
      assertTrue("getName() = " + parser.getName(), "Placemark".equalsIgnoreCase(parser.getName()));
      eventType = parser.next();
      Placemark pm = kmlParser.parsePlacemark(parser);
      assertNotNull(pm);
      assertTrue("PunktReception".equals(pm.getName()));
      Iterator<GeoPoint> e = pm.getCoords();
      assertTrue(e.hasNext());
      GeoPoint c = e.next();
      assertNotNull(c);
      assertTrue(Math.abs(c.getLatitudeE6() - 62 * 1E6) < 1E5);
      assertTrue((c.getLongitudeE6() - 15 * 1E6) < 1E5);
      assertFalse(e.hasNext());

    } catch (Exception e) {
      fail();
    }
  }
  /** Getting Latitude and Longitude on Touch event * */
  @Override
  public boolean onTouchEvent(MotionEvent event, MapView mapView) {

    if (event.getAction() == 1) {
      GeoPoint geopoint =
          mapView.getProjection().fromPixels((int) event.getX(), (int) event.getY());
      // latitude
      double lat = geopoint.getLatitudeE6() / 1E6;
      // longitude
      double lon = geopoint.getLongitudeE6() / 1E6;
      Toast.makeText(context, "Lat: " + lat + ", Lon: " + lon, Toast.LENGTH_SHORT).show();
    }
    return false;
  }
  @Override
  public boolean onTap(GeoPoint p, MapView mapView) {
    Dialog dialogInstance =
        new MapAlertDialog(
            mContext,
            GeoPointUtils.getDegrees(p.getLatitudeE6()),
            GeoPointUtils.getDegrees(p.getLongitudeE6()));

    dialogInstance.show();
    dialogInstance.setCancelable(true);
    dialogInstance.setCanceledOnTouchOutside(true);

    return true;
  }
  /**
   * Calculates in which segment opposited to the projecting a geo point resides
   *
   * @param p1
   * @return
   */
  private int toSegment(GeoPoint p1) {
    //      Log.d( TAG, String.format( "Comparing %s to points TL %s and BR %s", p1, mTopLeft,
    // mBottumRight ));
    int nr;
    if (p1.getLongitudeE6() < mGeoTopLeft.getLongitudeE6()) // left
    {
      nr = 1;
    } else if (p1.getLongitudeE6() > mGeoBottumRight.getLongitudeE6()) // right
    {
      nr = 3;
    } else
    // middle
    {
      nr = 2;
    }

    if (p1.getLatitudeE6() > mGeoTopLeft.getLatitudeE6()) // top
    {
      nr = nr + 0;
    } else if (p1.getLatitudeE6() < mGeoBottumRight.getLatitudeE6()) // bottom
    {
      nr = nr + 6;
    } else
    // middle
    {
      nr = nr + 3;
    }
    return nr;
  }
  @Override
  public boolean onTouchEvent(MotionEvent e, MapView mapView) {
    if (e.getAction() == MotionEvent.ACTION_DOWN) {
      switch (mode) {
        case SEARCH_NEARBY_CURRENT_LOCATION:
          if (products == null || products.size() == 0) {
            return false;
          }

          GeoPoint touchPoint = mapView.getProjection().fromPixels((int) e.getX(), (int) e.getY());
          double minDistance = Double.MAX_VALUE;
          int index = 0;
          int touchIndex = 0;
          for (ProductInfo productInfo : products) {
            double distance =
                Math.sqrt(
                    Math.pow(touchPoint.getLatitudeE6() - productInfo.lat * 1E6, 2)
                        + Math.pow(touchPoint.getLongitudeE6() - productInfo.lng * 1E6, 2));
            if (distance < minDistance) {
              minDistance = distance;
              touchIndex = index;
            }

            index++;
          }

          Intent intent = new Intent(context, ViewProductActivity.class);
          intent.putExtra(Global.PRODUCT_INFO, products.get(touchIndex));
          context.startActivity(intent);

          return true;

        case SEARCH_NEARBY_LOCATION:
          radius = NO_RADIUS;
          center =
              mapView
                  .getProjection()
                  .fromPixels(
                      (int) e.getX() - OVERLAY_WIDTH / 2, (int) e.getY() - OVERLAY_WIDTH / 2);
          mapView.invalidate();
          break;

        default:
          break;
      }
    }

    return false;
  }
Esempio n. 26
0
  /** Returns the building associated with the GeoPoint */
  public static Building getBuilding(GeoPoint point, Context context) {
    Building build = null;

    SQLiteDatabase db = new FINDatabase(context).getReadableDatabase();
    Cursor cursor =
        db.query(
            "buildings",
            null,
            "latitude = '"
                + point.getLatitudeE6()
                + "' AND longitude = '"
                + point.getLongitudeE6()
                + "' AND deleted = 0",
            null,
            null,
            null,
            null);

    if (cursor.getCount() > 0) {
      cursor.moveToFirst();

      int bid = cursor.getInt(cursor.getColumnIndex("bid"));
      String name = cursor.getString(cursor.getColumnIndex("name"));

      cursor =
          db.query(
              "floors", null, "bid = " + bid + " AND deleted = 0", null, null, null, "fnum DESC");
      cursor.moveToFirst();

      int count = cursor.getCount();

      int[] fids = new int[count];
      String[] names = new String[count];
      for (int i = 0; i < count; i++) {
        fids[i] = cursor.getInt(cursor.getColumnIndex("fid"));
        names[i] = cursor.getString(cursor.getColumnIndex("name"));

        cursor.moveToNext();
      }

      build = new Building(bid, name, fids, names);
    }

    cursor.close();
    db.close();

    return build;
  }
  public static int updatePoint(
      ContentResolver provider,
      Uri contentUri,
      long id,
      String latKeyE6,
      String longKeyE6,
      GeoPoint point) {

    Uri uri = ContentUris.withAppendedId(contentUri, id);

    ContentValues values = new ContentValues();

    values.put(latKeyE6, point.getLatitudeE6());
    values.put(longKeyE6, point.getLongitudeE6());
    return provider.update(uri, values, null, null);
  }
Esempio n. 28
0
 public static final double gp2m(GeoPoint StartP, GeoPoint EndP) {
   double lat1 = StartP.getLatitudeE6() / 1E6;
   double lat2 = EndP.getLatitudeE6() / 1E6;
   double lon1 = StartP.getLongitudeE6() / 1E6;
   double lon2 = EndP.getLongitudeE6() / 1E6;
   double dLat = Math.toRadians(lat2 - lat1);
   double dLon = Math.toRadians(lon2 - lon1);
   double a =
       Math.sin(dLat / 2) * Math.sin(dLat / 2)
           + Math.cos(Math.toRadians(lat1))
               * Math.cos(Math.toRadians(lat2))
               * Math.sin(dLon / 2)
               * Math.sin(dLon / 2);
   double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
   return 6378140 * c;
 }
  /** Either the Path or the Dots are calculated based on he current track coloring method */
  private synchronized void calculateTrackAsync() {
    GeoPoint oldTopLeft = mGeoTopLeft;
    GeoPoint oldBottumRight = mGeoBottumRight;
    mGeoTopLeft = mProjection.fromPixels(0, 0);
    mGeoBottumRight = mProjection.fromPixels(mWidth, mHeight);

    if (mRequeryFlag
        || oldTopLeft == null
        || oldBottumRight == null
        || mGeoTopLeft.getLatitudeE6() / 100 != oldTopLeft.getLatitudeE6() / 100
        || mGeoTopLeft.getLongitudeE6() / 100 != oldTopLeft.getLongitudeE6() / 100
        || mGeoBottumRight.getLatitudeE6() / 100 != oldBottumRight.getLatitudeE6() / 100
        || mGeoBottumRight.getLongitudeE6() / 100 != oldBottumRight.getLongitudeE6() / 100) {
      calculateStepSize();

      mScreenPoint.x = -1;
      mScreenPoint.y = -1;
      this.mPrevDrawnScreenPoint.x = -1;
      this.mPrevDrawnScreenPoint.y = -1;

      switch (mTrackColoringMethod) {
        case (DRAW_CALCULATED):
        case (DRAW_MEASURED):
        case (DRAW_RED):
        case (DRAW_GREEN):
          calculatePath();
          synchronized (mPath) // Switch the fresh path with the old Path object
          {
            Path oldPath = mPath;
            mPath = mPathCalculation;
            mPathCalculation = oldPath;
          }
          break;
        case (DRAW_DOTS):
          calculateDots();
          synchronized (mDotPath) // Switch the fresh path with the old Path object
          {
            Vector<DotVO> oldDotPath = mDotPath;
            mDotPath = mDotPathCalculation;
            mDotPathCalculation = oldDotPath;
          }
          break;
      }
      mLoggerMap.onDateOverlayChanged();
    }
  }
Esempio n. 30
0
 private Route directions(final GeoPoint start, final GeoPoint dest) {
   Parser parser;
   String jsonURL = "http://maps.google.com/maps/api/directions/json?";
   final StringBuffer sBuf = new StringBuffer(jsonURL);
   sBuf.append("origin=");
   sBuf.append(start.getLatitudeE6() / 1E6);
   sBuf.append(',');
   sBuf.append(start.getLongitudeE6() / 1E6);
   sBuf.append("&destination=");
   sBuf.append(dest.getLatitudeE6() / 1E6);
   sBuf.append(',');
   sBuf.append(dest.getLongitudeE6() / 1E6);
   sBuf.append("&sensor=true&mode=driving");
   parser = new GoogleParser(sBuf.toString());
   Route r = parser.parse();
   return r;
 }