Search in sources :

Example 11 with GeoPoint

use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.

the class NaviEngine method getNewInstruction.

private NaviInstruction getNewInstruction() {
    nearestP.arrPos = 0;
    nearestP.distance = Double.MAX_VALUE;
    uiJob = UiJob.UpdateInstruction;
    if (instructions.size() > 0) {
        Instruction in = instructions.get(0);
        long fullTime = countFullTime(in.getTime());
        GeoPoint curPos = new GeoPoint(in.getPoints().getLat(0), in.getPoints().getLon(0));
        double partDistance = countPartDistance(curPos, in, 0);
        if (partDistance == 0) {
            partDistanceScaler = 1;
        } else {
            partDistanceScaler = in.getDistance() / partDistance;
        }
        Instruction nextIn = null;
        if (instructions.size() > 1) {
            nextIn = instructions.get(1);
        }
        NaviInstruction nIn = new NaviInstruction(in, nextIn, fullTime);
        if (speakDistanceCheck(in.getDistance()) && nearestP.isDirectionOk()) {
            naviVoice.speak(nIn.getVoiceText());
            naviVoiceSpoken = true;
        } else {
            naviVoiceSpoken = false;
        }
        return nIn;
    }
    uiJob = UiJob.Finished;
    return null;
}
Also used : GeoPoint(org.oscim.core.GeoPoint) Instruction(com.graphhopper.util.Instruction)

Example 12 with GeoPoint

use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.

the class NaviEngine method findClosestStreet.

private GeoPoint findClosestStreet(GeoPoint fromPos) {
    QueryResult pos = MapHandler.getMapHandler().getHopper().getLocationIndex().findClosest(fromPos.getLatitude(), fromPos.getLongitude(), EdgeFilter.ALL_EDGES);
    int n = pos.getClosestEdge().getBaseNode();
    NodeAccess nodeAccess = MapHandler.getMapHandler().getHopper().getGraphHopperStorage().getNodeAccess();
    GeoPoint gp = new GeoPoint(nodeAccess.getLat(n), nodeAccess.getLon(n));
    return gp;
}
Also used : GeoPoint(org.oscim.core.GeoPoint) QueryResult(com.graphhopper.storage.index.QueryResult) NodeAccess(com.graphhopper.storage.NodeAccess) GeoPoint(org.oscim.core.GeoPoint)

Example 13 with GeoPoint

use of org.oscim.core.GeoPoint in project graphhopper by graphhopper.

the class MainActivity method loadMap.

void loadMap(File areaFolder) {
    logUser("loading map");
    // Map events receiver
    mapView.map().layers().add(new MapEventsReceiver(mapView.map()));
    // Map file source
    MapFileTileSource tileSource = new MapFileTileSource();
    tileSource.setMapFile(new File(areaFolder, currentArea + ".map").getAbsolutePath());
    VectorTileLayer l = mapView.map().setBaseMap(tileSource);
    mapView.map().setTheme(VtmThemes.DEFAULT);
    mapView.map().layers().add(new BuildingLayer(mapView.map(), l));
    mapView.map().layers().add(new LabelLayer(mapView.map(), l));
    // Markers layer
    itemizedLayer = new ItemizedLayer<>(mapView.map(), (MarkerSymbol) null);
    mapView.map().layers().add(itemizedLayer);
    // Map position
    GeoPoint mapCenter = tileSource.getMapInfo().boundingBox.getCenterPoint();
    mapView.map().setMapPosition(mapCenter.getLatitude(), mapCenter.getLongitude(), 1 << 15);
    setContentView(mapView);
    loadGraphStorage();
}
Also used : LabelLayer(org.oscim.layers.tile.vector.labeling.LabelLayer) GeoPoint(org.oscim.core.GeoPoint) MarkerSymbol(org.oscim.layers.marker.MarkerSymbol) VectorTileLayer(org.oscim.layers.tile.vector.VectorTileLayer) BuildingLayer(org.oscim.layers.tile.buildings.BuildingLayer) File(java.io.File) MapFileTileSource(org.oscim.tiling.source.mapfile.MapFileTileSource)

Example 14 with GeoPoint

use of org.oscim.core.GeoPoint in project graphhopper by graphhopper.

the class MainActivity method createPathLayer.

private PathLayer createPathLayer(PathWrapper response) {
    Style style = Style.builder().fixed(true).generalization(Style.GENERALIZATION_SMALL).strokeColor(0x9900cc33).strokeWidth(4 * getResources().getDisplayMetrics().density).build();
    PathLayer pathLayer = new PathLayer(mapView.map(), style);
    List<GeoPoint> geoPoints = new ArrayList<>();
    PointList pointList = response.getPoints();
    for (int i = 0; i < pointList.getSize(); i++) geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i)));
    pathLayer.setPoints(geoPoints);
    return pathLayer;
}
Also used : PathLayer(org.oscim.layers.vector.PathLayer) GeoPoint(org.oscim.core.GeoPoint) PointList(com.graphhopper.util.PointList) ArrayList(java.util.ArrayList) Style(org.oscim.layers.vector.geometries.Style) GeoPoint(org.oscim.core.GeoPoint)

Example 15 with GeoPoint

use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.

the class GeocodeActivity method createAddAddrClickListener.

private OnClickListener createAddAddrClickListener(Spinner sp, final EditText addr1, final EditText addr2, final EditText addr3, final EditText addr4) {
    final GeoPoint loc;
    if (sp.getSelectedItem().toString().equals(SEL_FROM)) {
        loc = locations[0];
    } else if (sp.getSelectedItem().toString().equals(SEL_TO)) {
        loc = locations[1];
    } else {
        loc = locations[2];
    }
    OnClickListener l = new OnClickListener() {

        @Override
        public void onClick(View v) {
            new AsyncTask<Void, Void, Void>() {

                @Override
                protected Void doInBackground(Void... params) {
                    Address addr = new Address(Locale.getDefault());
                    addr.setAddressLine(0, addr1.getText().toString());
                    addr.setAddressLine(1, addr2.getText().toString());
                    addr.setAddressLine(2, addr3.getText().toString());
                    addr.setAddressLine(3, addr4.getText().toString());
                    addr.setLatitude(loc.getLatitude());
                    addr.setLongitude(loc.getLongitude());
                    AddressLoc.addToProp(favourites, addr);
                    String mapDir = Variable.getVariable().getMapsFolder().getParent();
                    String propFile = new File(mapDir, FAV_PROP_FILE).getPath();
                    try (FileOutputStream fos = new FileOutputStream(propFile)) {
                        favourites.store(fos, "List of favourites");
                    } catch (IOException e) {
                        logUser("Unable to store favourites");
                    }
                    return null;
                }
            }.execute();
            GeocodeActivity.this.finish();
        }
    };
    return l;
}
Also used : GeoPoint(org.oscim.core.GeoPoint) Address(android.location.Address) FileOutputStream(java.io.FileOutputStream) OnClickListener(android.view.View.OnClickListener) IOException(java.io.IOException) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) File(java.io.File)

Aggregations

GeoPoint (org.oscim.core.GeoPoint)25 File (java.io.File)5 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 AdapterView (android.widget.AdapterView)4 Location (android.location.Location)3 ViewGroup (android.view.ViewGroup)3 TextView (android.widget.TextView)3 Instruction (com.graphhopper.util.Instruction)3 ArrayList (java.util.ArrayList)3 MapView (org.oscim.android.MapView)3 MarkerSymbol (org.oscim.layers.marker.MarkerSymbol)3 Address (android.location.Address)2 MotionEvent (android.view.MotionEvent)2 IOException (java.io.IOException)2 BuildingLayer (org.oscim.layers.tile.buildings.BuildingLayer)2 VectorTileLayer (org.oscim.layers.tile.vector.VectorTileLayer)2 LabelLayer (org.oscim.layers.tile.vector.labeling.LabelLayer)2 MapFileTileSource (org.oscim.tiling.source.mapfile.MapFileTileSource)2 Intent (android.content.Intent)1