public void parse(int eLevel, boolean show_closed, BoundingBoxE6 boundingBox) {
    // get a factory
    SAXParserFactory spf = SAXParserFactory.newInstance();
    try {

      // get a new instance of parser
      SAXParser sp = spf.newSAXParser();

      // parse the file and also register this class for call backs

      HttpClient httpClient = new DefaultHttpClient();
      HttpContext localContext = new BasicHttpContext();
      List<NameValuePair> qparams = new ArrayList<NameValuePair>();
      qparams.add(
          new BasicNameValuePair("l", "" + String.valueOf(boundingBox.getLonWestE6() / 1E6)));
      qparams.add(
          new BasicNameValuePair("b", "" + String.valueOf(boundingBox.getLatSouthE6() / 1E6)));
      qparams.add(
          new BasicNameValuePair("r", "" + String.valueOf(boundingBox.getLonEastE6() / 1E6)));
      qparams.add(
          new BasicNameValuePair("t", "" + String.valueOf(boundingBox.getLatNorthE6() / 1E6)));
      if (!show_closed) {
        qparams.add(new BasicNameValuePair("open", "1"));
      }
      URI uri;
      uri =
          URIUtils.createURI(
              "http",
              "openstreetbugs.schokokeks.org",
              -1,
              "/api/0.1/getGPX",
              URLEncodedUtils.format(qparams, "UTF-8"),
              null);
      HttpGet httpget = new HttpGet(uri);

      HttpResponse response = httpClient.execute(httpget, localContext);

      org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(OpenFixMapActivity.class);
      logger.info("Fetch " + httpget.getURI());

      sp.parse(response.getEntity().getContent(), this);

    } catch (SAXException se) {
      se.printStackTrace();
    } catch (ParserConfigurationException pce) {
      pce.printStackTrace();
    } catch (IOException ie) {
      ie.printStackTrace();
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 private String getUrlInside(BoundingBoxE6 bb, String type, int maxResults) {
   StringBuffer urlString = getCommonUrl(type, maxResults);
   urlString.append(
       "&viewbox="
           + bb.getLonWestE6() * 1E-6
           + ","
           + bb.getLatNorthE6() * 1E-6
           + ","
           + bb.getLonEastE6() * 1E-6
           + ","
           + bb.getLatSouthE6() * 1E-6);
   return urlString.toString();
 }
Esempio n. 3
0
    private ContentValues createContentValues(
        String pathname, String filename, GpxBigDeltaInterface summary) {

      BoundingBoxE6 box = summary.getBoundingBox().toBoundingBoxE6();

      ContentValues content = new ContentValues();
      content.put(GpxDbConstants.KEY_PATHNAME_OLD, pathname);
      content.put(GpxDbConstants.KEY_FILENAME, filename);
      content.put(GpxDbConstants.KEY_AVG_SPEED, summary.getSpeed());
      content.put(GpxDbConstants.KEY_MAX_SPEED, summary.getMaximumSpeed());
      content.put(GpxDbConstants.KEY_DISTANCE, summary.getDistance());
      content.put(GpxDbConstants.KEY_START_TIME, summary.getStartTime());
      content.put(GpxDbConstants.KEY_TOTAL_TIME, summary.getTimeDelta());
      content.put(GpxDbConstants.KEY_END_TIME, summary.getEndTime());
      content.put(GpxDbConstants.KEY_PAUSE, summary.getPause());
      content.put(GpxDbConstants.KEY_TYPE_ID, summary.getType());
      content.put(GpxDbConstants.KEY_EAST_BOUNDING, box.getLonEastE6());
      content.put(GpxDbConstants.KEY_WEST_BOUNDING, box.getLonWestE6());
      content.put(GpxDbConstants.KEY_NORTH_BOUNDING, box.getLatNorthE6());
      content.put(GpxDbConstants.KEY_SOUTH_BOUNDING, box.getLatSouthE6());
      return content;
    }
Esempio n. 4
0
  protected void drawOld(final Canvas canvas, final MapView mapView, final boolean shadow) {

    if (shadow) {
      return;
    }

    final int size = this.mPoints.size();
    if (size < 2) {
      // nothing to paint
      return;
    }

    final Projection pj = mapView.getProjection();

    // precompute new points to the intermediate projection.
    precomputePoints(pj);

    Point screenPoint0 = null; // points on screen
    Point screenPoint1;
    Point projectedPoint0; // points from the points list
    Point projectedPoint1;

    // clipping rectangle in the intermediate projection, to avoid performing projection.
    BoundingBoxE6 boundingBox = pj.getBoundingBox();
    Point topLeft =
        pj.toProjectedPixels(boundingBox.getLatNorthE6(), boundingBox.getLonWestE6(), null);
    Point bottomRight =
        pj.toProjectedPixels(boundingBox.getLatSouthE6(), boundingBox.getLonEastE6(), null);
    final Rect clipBounds = new Rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
    // take into account map orientation:
    if (mapView.getMapOrientation() != 0.0f)
      GeometryMath.getBoundingBoxForRotatatedRectangle(
          clipBounds, mapView.getMapOrientation(), clipBounds);

    mPath.rewind();
    projectedPoint0 = this.mPoints.get(size - 1);
    mLineBounds.set(projectedPoint0.x, projectedPoint0.y, projectedPoint0.x, projectedPoint0.y);

    for (int i = size - 2; i >= 0; i--) {
      // compute next points
      projectedPoint1 = this.mPoints.get(i);
      mLineBounds.union(projectedPoint1.x, projectedPoint1.y);

      if (!Rect.intersects(clipBounds, mLineBounds)) {
        // skip this line, move to next point
        projectedPoint0 = projectedPoint1;
        screenPoint0 = null;
        continue;
      }

      // the starting point may be not calculated, because previous segment was out of clip
      // bounds
      if (screenPoint0 == null) {
        screenPoint0 = pj.toPixelsFromProjected(projectedPoint0, this.mTempPoint1);
        mPath.moveTo(screenPoint0.x, screenPoint0.y);
      }

      screenPoint1 = pj.toPixelsFromProjected(projectedPoint1, this.mTempPoint2);

      // skip this point, too close to previous point
      if (Math.abs(screenPoint1.x - screenPoint0.x) + Math.abs(screenPoint1.y - screenPoint0.y)
          <= 1) {
        continue;
      }

      mPath.lineTo(screenPoint1.x, screenPoint1.y);

      // update starting point to next position
      projectedPoint0 = projectedPoint1;
      screenPoint0.x = screenPoint1.x;
      screenPoint0.y = screenPoint1.y;
      mLineBounds.set(projectedPoint0.x, projectedPoint0.y, projectedPoint0.x, projectedPoint0.y);
    }

    canvas.drawPath(mPath, mPaint);
  }