Android Open Source - PalmaBici Bike Lane






From Project

Back to project page PalmaBici.

License

The source code is released under:

GNU General Public License

If you think the Android project PalmaBici listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2012 Sergio Garcia Villalonga (yayalose@gmail.com)
 */* w  w w  . j  a  v a  2 s .  c o m*/
 * This file is part of PalmaBici.
 *
 *    PalmaBici is free software: you can redistribute it and/or modify
 *    it under the terms of the Affero GNU General Public License version 3
 *    as published by the Free Software Foundation.
 *
 *    PalmaBici is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *    Affero GNU General Public License for more details
 *    (https://www.gnu.org/licenses/agpl-3.0.html).
 *    
 */

package com.poguico.palmabici.util;

import java.util.ArrayList;

import com.poguico.palmabici.R;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.PathOverlay;
import org.xmlpull.v1.XmlPullParser;

import android.app.Activity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.util.DisplayMetrics;

public class BikeLane {
  //private static ArrayList<ArrayList<GeoPoint>> paths = null;
  private static ArrayList<PathOverlay> osmPaths = null;
  
  private static void init (Activity activity, MapView mapView) {
    PathOverlay pathOverlay;
    osmPaths = new ArrayList<PathOverlay>();
    Resources res = activity.getResources();
    XmlResourceParser xpp = res.getXml(R.xml.carril_bici_palma);
    
    DisplayMetrics dpi = activity.getResources().getDisplayMetrics();
    float pathWidth = dpi.density*4;
    
    try {
        xpp.next();
            int eventType = xpp.getEventType();
            

            while (eventType != XmlPullParser.END_DOCUMENT) {
              if(eventType == XmlPullParser.START_TAG &&
                  xpp.getName().equals("coordinates")) {
                eventType = xpp.next();

                if(eventType == XmlPullParser.TEXT) {
                  String text = xpp.getText();

                  pathOverlay = new PathOverlay(0xffa0a0ff,
                                            pathWidth,
                                            mapView.getResourceProxy());
                  for (String coordinate : text.split("\n")) {
                    String[] coordElements = coordinate.split(",");

                      pathOverlay.addPoint(
                        new GeoPoint(Double.valueOf(coordElements[1]),
                                 Double.valueOf(coordElements[0])));
                  }
                  
                  osmPaths.add(pathOverlay);
                }
              } else {
                eventType = xpp.next();
              }
            }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  
  public static ArrayList<PathOverlay> getOSMPaths(Activity activity, MapView mapView) {
    if (osmPaths == null) {
      init(activity, mapView);
    }
    
    return osmPaths;
  }
}




Java Source Code List

com.poguico.palmabici.DatabaseManager.java
com.poguico.palmabici.MainActivity.java
com.poguico.palmabici.PreferencesActivity.java
com.poguico.palmabici.ShareActivity.java
com.poguico.palmabici.SynchronizableElement.java
com.poguico.palmabici.WelcomeActivity.java
com.poguico.palmabici.map.OpenStreetMapConstants.java
com.poguico.palmabici.map.ResourceProxyImpl.java
com.poguico.palmabici.map.StationMapFragment.java
com.poguico.palmabici.network.synchronizer.NetworkStationAlarm.java
com.poguico.palmabici.network.synchronizer.NetworkSyncCallback.java
com.poguico.palmabici.network.synchronizer.NetworkSynchronizerTask.java
com.poguico.palmabici.network.synchronizer.NetworkSynchronizer.java
com.poguico.palmabici.notification.NotificationManager.java
com.poguico.palmabici.parsers.Parser.java
com.poguico.palmabici.synchronizers.LocationSynchronizer.java
com.poguico.palmabici.util.BikeLane.java
com.poguico.palmabici.util.Formatter.java
com.poguico.palmabici.util.NetworkInformation.java
com.poguico.palmabici.util.Station.java
com.poguico.palmabici.widgets.CreditsDialog.java
com.poguico.palmabici.widgets.NewFeaturesDialog.java
com.poguico.palmabici.widgets.SidebarMenu.java
com.poguico.palmabici.widgets.StationInfoWidget.java