Exemplo n.º 1
0
  /**
   * Method used to draw a line on map.
   *
   * @param advancedStyle
   * @param currentZoomLevel the current zoom level of the map view
   */
  public void drawLines(AdvancedStyle advancedStyle, byte currentZoomLevel) {
    Paint stroke = StyleManager.getStrokePaint4Style(advancedStyle);
    Paint textStroke = StyleManager.getTextStrokePaint4Style(advancedStyle);
    ShapeWriter wr = new ShapeWriter(pointTransformer);
    wr.setRemoveDuplicatePoints(true);
    wr.setDecimation(style4Table.decimationFactor);
    if (stroke == null && textStroke == null) {
      // Can't draw
      return;
    }

    while (geometryIterator.hasNext()) {
      Geometry geom = geometryIterator.next();
      DrawableShape shape = wr.toShape(geom);
      if (stroke != null) {
        shape.draw(canvas, stroke);
      }

      // draw labels if zoom level fits and data is available
      if (currentZoomLevel >= advancedStyle.label_minZoom
          && textStroke != null
          && shape instanceof PathShape
          && geom.getUserData() != null) {

        Object userData = geom.getUserData();

        canvas.drawTextOnPath(
            userData.toString(),
            ((PathShape) shape).getPath(),
            LABEL_H_OFFSET,
            LABEL_V_OFFSET,
            textStroke);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * method used to draw a polygon on map
   *
   * @param advancedStyle
   */
  public void drawPolygons(AdvancedStyle advancedStyle) {
    Paint stroke = StyleManager.getStrokePaint4Style(advancedStyle);
    Paint fill = StyleManager.getFillPaint4Style(advancedStyle);

    if (stroke == null && fill == null) {
      // Can't draw
      return;
    }

    ShapeWriter wr = new ShapeWriter(pointTransformer);
    wr.setRemoveDuplicatePoints(true);
    wr.setDecimation(style4Table.decimationFactor);
    while (geometryIterator.hasNext()) {

      Geometry geom = geometryIterator.next();
      if (geom != null) {
        DrawableShape shape = wr.toShape(geom);
        if (fill != null) {
          shape.fill(canvas, fill);
        }
        if (stroke != null) {
          shape.draw(canvas, stroke);
        }
      }
    }
  }
  @Override
  protected AdvancedStyle getStyle() {
    if (style != null) {
      return style;
    }
    Bundle extras = getIntent().getExtras();
    String tableName = extras.getString(SpatialiteLibraryConstants.PREFS_KEY_TEXT);
    try {
      spatialTable = SpatialDataSourceManager.getInstance().getVectorTableByName(tableName);
    } catch (Exception e) {
      Log.e("STYLE", "unable to retrive table" + tableName);
    }

    style = StyleManager.getInstance().getStyle(spatialTable.getName());

    return style;
  }
Exemplo n.º 4
0
  /**
   * Initializes the database
   *
   * @return true if the initialization was successful
   */
  private boolean initDb() {
    // init styleManager
    StyleManager.getInstance().init(this, MAP_DIR);
    // init Db
    SpatialDataSourceManager dbManager = SpatialDataSourceManager.getInstance();

    try {
      // Only if not already loaded some tables
      if (dbManager.getSpatialVectorTables(false).size() <= 0) {
        dbManager.init(MAP_DIR);
      }
    } catch (Exception e) {

      return false;
    }
    return true;
  }