当前位置: 首页>>代码示例>>Java>>正文


Java LatLong类代码示例

本文整理汇总了Java中org.mapsforge.core.model.LatLong的典型用法代码示例。如果您正苦于以下问题:Java LatLong类的具体用法?Java LatLong怎么用?Java LatLong使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LatLong类属于org.mapsforge.core.model包,在下文中一共展示了LatLong类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTap

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
@Override
public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) {
	double dx1 = tapXY.x - layerXY.x;
	double dy1 = tapXY.y - layerXY.y;
	
	double rad = Math.toRadians(-angle);
	double dx = (dx1 * Math.cos(rad) - dy1 * Math.sin(rad)) / scale;
	double dy = (dx1 * Math.sin(rad) + dy1 * Math.cos(rad)) / scale;

	if (Math.abs(dx) < PIN_WIDTH/2 && Math.abs(dy + PIN_HEIGHT/2) < PIN_HEIGHT/2) {
		selected = !selected;
		requestRedraw();
		return true;
	}
	
    return false;
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:18,代码来源:Pin.java

示例2: onLocationChanged

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    LatLong newLoc = new LatLong(location.getLatitude(), location.getLongitude());
    mState.myLat = newLoc.latitude;
    mState.myLng = newLoc.longitude;
    triggerStateChange();

    String msg = String.format(Locale.getDefault(), "我的位置: (%.2f, %.2f)", mState.myLat, mState.myLng);
    Log.i(TAG, msg);

    // 所在位置顯示圖標
    mLocationMarker.setLatLong(newLoc);
    mLocationMarker.requestRedraw();

    // 移動地圖到所在位置
    getModel().mapViewPosition.setCenter(newLoc);
    getModel().mapViewPosition.setZoomLevel((byte)16);
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:19,代码来源:TaiwanMapView.java

示例3: searchUnluckyHouse

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
private void searchUnluckyHouse(String[] bbox) {
    String[] cols = {"id", "approach", "lat", "lng"};
    String   cond = "lat>=? AND lng>=? AND lat<=? AND lng<=?";
    Cursor   cur  = mUnluckyHouseDB.query("unluckyhouse", cols, cond, bbox, "", "", "");

    if (cur.getCount() > 0) {
        while (cur.moveToNext()) {
            String id      = cur.getString(0);
            String pat     = getString(R.string.pattern_unluckyhouse_subject);
            String subject = String.format(Locale.getDefault(), pat, cur.getString(1));
            double lat = cur.getDouble(2);
            double lng = cur.getDouble(3);
            mUnluckyHouses.add(new LatLong(lat, lng), subject, id);
        }
    }
    cur.close();
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:18,代码来源:MapViewFragment.java

示例4: searchUnluckyLabor

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
private void searchUnluckyLabor(String[] bbox) {
    String[] cols = {"id", "corp", "lat", "lng"};
    String   cond = "lat>=? AND lng>=? AND lat<=? AND lng<=?";
    Cursor   cur  = mUnluckyLaborDB.query("unluckylabor", cols, cond, bbox, "", "", "");

    if (cur.getCount()>0) {
        while (cur.moveToNext()) {
            String id   = cur.getString(0);
            String corp = cur.getString(cur.getColumnIndex("corp"));
            double lat  = cur.getDouble(cur.getColumnIndex("lat"));
            double lng  = cur.getDouble(cur.getColumnIndex("lng"));
            String pat  = getString(R.string.pattern_unluckylabor_subject);
            String subject = String.format(Locale.getDefault(), pat, corp);
            mUnluckyLabors.add(new LatLong(lat, lng), subject, id);
        }
    }
    cur.close();
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:19,代码来源:MapViewFragment.java

示例5: initDetailsServerOnMap

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
private void initDetailsServerOnMap() {
    if (markerList != null && markerList.size() > 0) {
        for (Marker marker : markerList) {
            layers.remove(marker);
        }
    }
    List<Server> serverList = dbHelper.getServersWithGPS();

    markerList = new ArrayList<Marker>();
    for (Server server : serverList) {
        LatLong position = new LatLong(server.getLat(), server.getLon());
        Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(ContextCompat.getDrawable(this,
                getResources().getIdentifier(ConnectionQuality.getSimplePointIcon(server.getQuality()),
                        "drawable",
                        getPackageName())));
        Marker serverMarker = new Marker(position, bitmap, 0, 0);
        markerList.add(serverMarker);
        layers.add(serverMarker);
    }
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:21,代码来源:HomeActivity.java

示例6: createPolygons

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
private void createPolygons(JSONArray coordinates) {
    Polygon polygon = new Polygon(paintFill, paintStroke,
            AndroidGraphicFactory.INSTANCE);

    List<LatLong> polygonList = polygon.getLatLongs();

    for (int j = 0; j < coordinates.length(); j++) {
        try {
            JSONArray arrLatLong = new JSONArray(coordinates.get(j).toString());
            polygonList.add(new LatLong(arrLatLong.getDouble(1), arrLatLong.getDouble(0)));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    layers.add(polygon);
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:18,代码来源:MapCreator.java

示例7: mouseDragged

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent mouseEvent) {
    super.mouseDragged(mouseEvent);
    // Save last Point
    LatLong pos = this.model.mapViewPosition.getCenter();
    int zoom = this.model.mapViewPosition.getZoomLevel();
    SimulatorMain.prefs.putInt("zoom", zoom);
    SimulatorMain.prefs.putDouble("lat", pos.getLatitude());
    SimulatorMain.prefs.putDouble("lon", pos.getLongitude());
    try {
        SimulatorMain.prefs.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }

    GPSData.setLatitude(pos.getLatitude());
    GPSData.setLongitude(pos.getLongitude());

}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:20,代码来源:GpsSimmulatorMouseEventListener.java

示例8: doInBackground

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * Queries reference database for all wifis in specified range around map centre.
 * @param args
 * 			Args is an object array containing
 * 			args[0]: session id
 * 			args[1]: min latitude as double
 * 			args[2]: max latitude as double
 * 			args[3]: min longitude as double
 *			args[4]: max longitude as double
 */
@Override
protected final ArrayList<LatLong> doInBackground(final Object... args) {         
	//Log.d(TAG, "Loading gpx points");
	ArrayList<LatLong> points = new ArrayList<LatLong>();

	DataHelper dbHelper = new DataHelper(mContext);

	ArrayList<PositionRecord> positions = dbHelper.loadPositions((Integer) args[SESSION_ID],
			(Double) args[MIN_LAT_COL], (Double) args[MAX_LAT_COL], (Double) args[MIN_LON_COL], (Double) args[MAX_LON_COL]);

	for (PositionRecord position : positions) {
		points.add(new LatLong(position.getLatitude(), position.getLongitude()));	
	}

	return points;
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:27,代码来源:GpxMapObjectsLoader.java

示例9: onLongPress

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
@Override
public void onLongPress(final LatLong tapLatLong, final Point thisXY, final Point tapXY) {
	Toast.makeText(this.getActivity(), this.getActivity().getString(R.string.saved_waypoint) + this.getActivity().getString(R.string.at) + "\n" + tapLatLong.toString(), Toast.LENGTH_LONG).show();

	if (mDataHelper == null) {
		/*
		 * Setting up database connection
		 */
		mDataHelper = new DataHelper(this.getActivity());
	}

	final PositionRecord pos = new PositionRecord(GeometryUtils.toLocation(tapLatLong), mSessionId, RadioBeacon.PROVIDER_USER_DEFINED, true);

	// so far we set end position = begin position 
	mDataHelper.storePosition(pos);
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:17,代码来源:MapViewActivity.java

示例10: activeNavigator

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * drawer polyline on map , active navigator instructions(directions) if on
 */
private void activeNavigator() {
    LatLong startPoint = Destination.getDestination().getStartPoint();
    LatLong endPoint = Destination.getDestination().getEndPoint();
    if (startPoint != null && endPoint != null) {
        // show path finding process
        navSettingsVP.setVisibility(View.INVISIBLE);

        View pathfinding = activity.findViewById(R.id.map_nav_settings_path_finding);
        pathfinding.setVisibility(View.VISIBLE);
        pathfinding.bringToFront();
        MapHandler mapHandler = MapHandler.getMapHandler();
        mapHandler.calcPath(startPoint.latitude, startPoint.longitude, endPoint.latitude, endPoint.longitude);
        if (Variable.getVariable().isDirectionsON()) {
            mapHandler.setNeedPathCal(true);
            //rest running at
        }
    }
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:22,代码来源:MapActions.java

示例11: showMyLocation

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * move map to my current location as the center of the screen
 */
protected void showMyLocation(final MapView mapView) {
    showPositionBtn.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            if (MapActivity.getmCurrentLocation() != null) {
                showPositionBtn.setImageResource(R.drawable.ic_my_location_white_24dp);
                MapHandler.getMapHandler().centerPointOnMap(
                        new LatLong(MapActivity.getmCurrentLocation().getLatitude(),
                                MapActivity.getmCurrentLocation().getLongitude()), 0);

                //                    mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(
                //                            new LatLong(MapActivity.getmCurrentLocation().getLatitude(),
                //                                    MapActivity.getmCurrentLocation().getLongitude()),
                //                            mapView.getModel().mapViewPosition.getZoomLevel()));

            } else {
                showPositionBtn.setImageResource(R.drawable.ic_location_searching_white_24dp);
                Toast.makeText(activity, "No Location Available", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:25,代码来源:MapActions.java

示例12: updateCurrentLocation

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * Updates the users location based on the location
 *
 * @param location Location
 */
private void updateCurrentLocation(Location location) {
    if (location != null) {
        mCurrentLocation = location;
    } else if (mLastLocation != null && mCurrentLocation == null) {
        mCurrentLocation = mLastLocation;
    }
    if (mCurrentLocation != null) {
        LatLong mcLatLong = new LatLong(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude());
        if (Tracking.getTracking().isTracking()) {
            MapHandler.getMapHandler().addTrackPoint(mcLatLong);
            Tracking.getTracking().addPoint(mCurrentLocation);
        }
        Layers layers = mapView.getLayerManager().getLayers();
        MapHandler.getMapHandler().removeLayer(layers, mPositionMarker);
        mPositionMarker = MapHandler.getMapHandler().createMarker(mcLatLong, R.drawable.ic_my_location_dark_24dp);
        layers.add(mPositionMarker);
        mapActions.showPositionBtn.setImageResource(R.drawable.ic_my_location_white_24dp);
    } else {
        mapActions.showPositionBtn.setImageResource(R.drawable.ic_location_searching_white_24dp);
    }
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:27,代码来源:MapActivity.java

示例13: addMarkers

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
public void addMarkers(LatLong startPoint, LatLong endPoint) {
    Layers layers = mapView.getLayerManager().getLayers();
    //        if (startPoint != null && endPoint != null) {
    //            setShortestPathRunning(true);
    //        }
    if (startPoint != null) {
        removeLayer(layers, startMarker);
        startMarker = createMarker(startPoint, R.drawable.ic_location_start_24dp);
        layers.add(startMarker);
    }
    if (endPoint != null) {
        removeLayer(layers, endMarker);
        endMarker = createMarker(endPoint, R.drawable.ic_location_end_24dp);
        layers.add(endMarker);
    }
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:17,代码来源:MapHandler.java

示例14: createPolyline

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * draws a connected series of line segments specified by a list of LatLongs.
 *
 * @param pointList
 * @param color:       the color of the polyline
 * @param strokeWidth: the stroke width of the polyline
 * @return Polyline
 */
public Polyline createPolyline(PointList pointList, int color, int strokeWidth) {
    Paint paintStroke = AndroidGraphicFactory.INSTANCE.createPaint();

    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setColor(color);
    //        paintStroke.setDashPathEffect(new float[]{25, 25});
    paintStroke.setStrokeWidth(strokeWidth);

    // TODO: new mapsforge version wants an mapsforge-paint, not an android paint.
    // This doesn't seem to support transparceny
    //paintStroke.setAlpha(128);
    Polyline line = new Polyline((Paint) paintStroke, AndroidGraphicFactory.INSTANCE);
    List<LatLong> geoPoints = line.getLatLongs();
    PointList tmp = pointList;
    for (int i = 0; i < pointList.getSize(); i++) {
        geoPoints.add(new LatLong(tmp.getLatitude(i), tmp.getLongitude(i)));
    }
    return line;
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:30,代码来源:MapHandler.java

示例15: getLatLong

import org.mapsforge.core.model.LatLong; //导入依赖的package包/类
/**
 * @param s (latitude, longitude or latitude longitude; can be degree or digital coordinates)
 * @return null if there is an error
 */
public static LatLong getLatLong(String s) {
    LatLong latlong = null;
    if (s.contains("N") || s.contains("S") || s.contains("n") || s.contains("s")) {
        return convertCoordingate(s);
    } else {
        String[] d = new String[2];
        try {
            if (s.contains(",")) {
                d = s.split(",");
            } else {
                d = s.split(" ");
            }
            return new LatLong(Double.parseDouble(d[0]), Double.parseDouble(d[1]));
        } catch (Exception e) {e.getStackTrace();}
    }

    return latlong;
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:23,代码来源:MyUtility.java


注:本文中的org.mapsforge.core.model.LatLong类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。