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;
 }
 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;
 }
  @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);
    }
  }
  /**
   * 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;
  }
 public static final boolean isOnCircle(GeoPoint obj, GeoPoint center, float radius) {
   return isOnCircle(
       obj.getLatitudeE6(),
       obj.getLongitudeE6(),
       center.getLatitudeE6(),
       center.getLongitudeE6(),
       radius * 8.3);
 }
  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);
  }
Exemple #7
0
  public static void zoomMapFromMaxLatLong(MapController mc, LatLongLimit limits) {

    GeoPoint max = new GeoPoint((int) limits.maxLatitude, (int) limits.maxLongitude);
    GeoPoint min = new GeoPoint((int) limits.minLatitude, (int) limits.minLongitude);

    int maxLatMicro = max.getLatitudeE6();
    int maxLonMicro = max.getLongitudeE6();
    int minLatMicro = min.getLatitudeE6();
    int minLonMicro = min.getLongitudeE6();

    mc.zoomToSpan(maxLatMicro - minLatMicro, maxLonMicro - minLonMicro);
  }
Exemple #8
0
  public static GeoPoint getCenter(LatLongLimit limits) {
    GeoPoint max = new GeoPoint((int) limits.minLatitude, (int) limits.maxLongitude);
    GeoPoint min = new GeoPoint((int) limits.minLatitude, (int) limits.minLongitude);

    int maxLatMicro = max.getLatitudeE6();
    int maxLonMicro = max.getLongitudeE6();
    int minLatMicro = min.getLatitudeE6();
    int minLonMicro = min.getLongitudeE6();

    GeoPoint center =
        new GeoPoint((maxLatMicro + minLatMicro) / 2, (maxLonMicro + minLonMicro) / 2);

    return center;
  }
 @Override
 public void onResume() {
   super.onResume();
   myLocaltionOverlay.enableMyLocation();
   locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
   registerReceiver(mProxymityBroadcast, new IntentFilter("pdm.test.mappe"));
   Intent intentTermini = new Intent("pdm.test.mappe");
   intentTermini.putExtra("overlay", 1);
   Intent intentPiazzadellarepublica = new Intent("pdm.test.mappe");
   intentPiazzadellarepublica.putExtra("overlay", 2);
   Intent intentColosseo = new Intent("pdm.test.mappe");
   intentColosseo.putExtra("overlay", 3);
   Intent intentCasaromoloeremo = new Intent("pdm.test.mappe");
   intentCasaromoloeremo.putExtra("overlay", 4);
   mPendingTermini =
       PendingIntent.getBroadcast(this, 1, intentTermini, PendingIntent.FLAG_CANCEL_CURRENT);
   mPendingPiazzadellarepubblica =
       PendingIntent.getBroadcast(
           this, 2, intentPiazzadellarepublica, PendingIntent.FLAG_CANCEL_CURRENT);
   mPendingColosseo =
       PendingIntent.getBroadcast(this, 3, intentColosseo, PendingIntent.FLAG_CANCEL_CURRENT);
   mPendingCasaromoloeremo =
       PendingIntent.getBroadcast(
           this, 4, intentCasaromoloeremo, PendingIntent.FLAG_CANCEL_CURRENT);
   locationManager.addProximityAlert(
       termini.getLatitudeE6() * 0.000001,
       termini.getLongitudeE6() * 0.000001,
       400,
       -1,
       mPendingTermini);
   locationManager.addProximityAlert(
       piazzadellarepubblica.getLatitudeE6() * 0.000001,
       piazzadellarepubblica.getLongitudeE6() * 0.000001,
       300,
       -1,
       mPendingPiazzadellarepubblica);
   locationManager.addProximityAlert(
       colosseo.getLatitudeE6() * 0.000001,
       colosseo.getLongitudeE6() * 0.000001,
       500,
       -1,
       mPendingColosseo);
   locationManager.addProximityAlert(
       casaromoloeremo.getLatitudeE6() * 0.000001,
       casaromoloeremo.getLongitudeE6() * 0.000001,
       350,
       -1,
       mPendingCasaromoloeremo);
 }
  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;
  }
  /**
   * 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;
  }
 /**
  * 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();
 }
 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;
 }
    /**
     * 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;
    }
  /**
   * 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();
    }
  }
  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();
    }
  }
 /**
  * Is a given GeoPoint in the current projection of the map.
  *
  * @param eval
  * @return
  */
 protected boolean isGeoPointOnScreen(GeoPoint geopoint) {
   boolean onscreen = geopoint != null;
   if (geopoint != null && mGeoTopLeft != null && mGeoBottumRight != null) {
     onscreen = onscreen && mGeoTopLeft.getLatitudeE6() > geopoint.getLatitudeE6();
     onscreen = onscreen && mGeoBottumRight.getLatitudeE6() < geopoint.getLatitudeE6();
     if (mGeoTopLeft.getLongitudeE6() < mGeoBottumRight.getLongitudeE6()) {
       onscreen = onscreen && mGeoTopLeft.getLongitudeE6() < geopoint.getLongitudeE6();
       onscreen = onscreen && mGeoBottumRight.getLongitudeE6() > geopoint.getLongitudeE6();
     } else {
       onscreen =
           onscreen
               && (mGeoTopLeft.getLongitudeE6() < geopoint.getLongitudeE6()
                   || mGeoBottumRight.getLongitudeE6() > geopoint.getLongitudeE6());
     }
   }
   return onscreen;
 }
  /** 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();
    }
  }
Exemple #19
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;
 }
 @Override
 public void locationChanged(GeoPoint p) {
   ((TextView) findViewById(R.id.CoordText))
       .setText(
           (p == null
               ? "No location found."
               : "( " + p.getLatitudeE6() + ", " + p.getLongitudeE6() + " )"));
 }
  public float metersToPixels(float meters, GeoPoint geoPoint) {
    double latitude = ((double) geoPoint.getLatitudeE6()) / 1000000.0;

    double radians = latitude * Math.PI / 180.;

    double mercatorDistance = meters / (2. * Math.PI * Math.cos(radians) * EARTH_RADIUS_METERS);

    return (float) (mercatorDistance * Math.pow(2, mZoom) * DOUBLE_IMAGE_TILE_SIZE);
  }
  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 ArrayList<GeoPoint> getPointsFromGoogle(GeoPoint fromPoint, GeoPoint toPoint) {
    ArrayList<GeoPoint> ret = new ArrayList<GeoPoint>();
    String strUrl =
        "http://maps.googleapis.com/maps/api/directions/json?origin="
            + fromPoint.getLatitudeE6() / 1E6
            + ","
            + fromPoint.getLongitudeE6() / 1E6
            + "&destination="
            + toPoint.getLatitudeE6() / 1E6
            + ","
            + toPoint.getLongitudeE6() / 1E6
            + "&sensor=false";

    JSONObject json = null;
    try {
      // swapnil.c
      String encoded = "";
      URL url = new URL(strUrl);
      encoded = (new HandleURL().doInBackground(url)); // swapnil.c		
      JSONTokener jt = new JSONTokener(encoded);
      json = new JSONObject(jt);

      JSONArray routesArr = (JSONArray) json.get("routes");
      JSONObject j1 = (JSONObject) routesArr.get(0);

      // get travel time
      JSONArray legsArr = (JSONArray) j1.get("legs");
      JSONObject j3 = (JSONObject) legsArr.get(0);
      googtime = ((JSONObject) j3.get("duration")).get("text").toString();

      // route polyline decoding
      String polyline = ((JSONObject) j1.get("overview_polyline")).get("points").toString();
      ArrayList<GeoPoint> poly = new ArrayList<GeoPoint>();
      poly = (ArrayList<GeoPoint>) Polyline.decodePolyline(polyline);

      ret = poly;
      return ret;
    } catch (Exception e) {
      // String exp = e.getMessage();
      Log.d("gcatch", e.getMessage());
    }
    return ret;
  }
  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);
  }
Exemple #25
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);
 }
Exemple #26
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);
  }
Exemple #27
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);
 }
Exemple #29
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);
  }
Exemple #30
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();
    }
  }