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


Java Geo类代码示例

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


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

示例1: sort

import com.androzic.util.Geo; //导入依赖的package包/类
public void sort(final int type)
{
	Collections.sort(application.getWaypoints(), new Comparator<Waypoint>() {
		@Override
		public int compare(Waypoint o1, Waypoint o2)
		{
			if (type == 1)
			{
				// TODO cache distances
				double dist1 = Geo.distance(loc[0], loc[1], o1.latitude, o1.longitude);
				double dist2 = Geo.distance(loc[0], loc[1], o2.latitude, o2.longitude);
				return (Double.compare(dist1, dist2));
			}
			else
			{
				return (o1.name.compareToIgnoreCase(o2.name));
			}
		}
	});
	notifyDataSetChanged();
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:22,代码来源:WaypointList.java

示例2: navigateTo

import com.androzic.util.Geo; //导入依赖的package包/类
private void navigateTo(final Route route, final int direction)
{
	clearNavigation();
	connect();
	startForeground(NOTIFICATION_ID, getNotification());

	vmgav = new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

	navRoute = route;
	navDirection = direction;
	navCurrentRoutePoint = navDirection == 1 ? 1 : navRoute.length()-2;

	navWaypoint = navRoute.getWaypoint(navCurrentRoutePoint);
	prevWaypoint = navRoute.getWaypoint(navCurrentRoutePoint - navDirection);
	navProximity = navWaypoint.proximity > 0 ? navWaypoint.proximity : routeProximity;
	navRouteDistance = -1;
	navCourse = Geo.bearing(prevWaypoint.latitude, prevWaypoint.longitude, navWaypoint.latitude, navWaypoint.longitude);
	updateNavigationState(STATE_STARTED);
	if (lastKnownLocation != null)
		calculateNavigationStatus(lastKnownLocation, 0, 0);
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:22,代码来源:NavigationService.java

示例3: navRouteWaypointETE

import com.androzic.util.Geo; //导入依赖的package包/类
public int navRouteWaypointETE(int index)
{
	if (index == 0)
		return 0;
	int ete = Integer.MAX_VALUE;
	if (avvmg > 0)
	{
		int i = navDirection == DIRECTION_FORWARD ? index : navRoute.length() - index - 1;
		int j = i - navDirection;
		MapObject w1 = navRoute.getWaypoint(i);
		MapObject w2 = navRoute.getWaypoint(j);
		double distance = Geo.distance(w1.latitude, w1.longitude, w2.latitude, w2.longitude);
		ete = (int) Math.round(distance / avvmg / 60);
	}
	return ete;
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:17,代码来源:NavigationService.java

示例4: addPoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void addPoint(boolean continous, double lat, double lon, double elev, double speed, double bearing, double accuracy, long time)
{
	if (lastTrackPoint != null)
	{
		distance += Geo.distance(lastTrackPoint.latitude, lastTrackPoint.longitude, lat, lon);
	}
	lastTrackPoint = new TrackPoint(continous, lat, lon, elev, speed, bearing, accuracy, time);
	boolean needNewSegment = false;
	synchronized (lastSegment)
	{
		needNewSegment = !continous || lastSegment.trackpoints.size() > SEGMENT_CAPACITY;
	}
	if (needNewSegment)
	{
		synchronized (this)
		{
			lastSegment = new TrackSegment();
			lastSegment.independent = !continous;
			segments.add(lastSegment);
		}
	}
	synchronized (lastSegment)
	{
		if (maxPoints > 0 && lastSegment.trackpoints.size() > maxPoints)
		{
			// TODO add correct cleaning if preferences changed
			TrackPoint fp = lastSegment.trackpoints.get(0);
			TrackPoint sp = lastSegment.trackpoints.get(1);
			distance -= Geo.distance(fp.latitude, fp.longitude, sp.latitude, sp.longitude);
			lastSegment.trackpoints.remove(0);
		}
		lastSegment.trackpoints.add(lastTrackPoint);
	}
	lastSegment.bounds.extend(lastTrackPoint.latitude, lastTrackPoint.longitude);
}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:36,代码来源:Track.java

示例5: addWaypoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void addWaypoint(Waypoint waypoint)
{
	if (lastWaypoint != null)
	{
		distance += Geo.distance(lastWaypoint.latitude, lastWaypoint.longitude, waypoint.latitude, waypoint.longitude);
	}
	lastWaypoint = waypoint;
	waypoints.add(lastWaypoint);		
}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:10,代码来源:Route.java

示例6: insertWaypoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void insertWaypoint(Waypoint waypoint)
{
	if (waypoints.size() < 2)
	{
		addWaypoint(waypoint);
		return;
	}
	int after = waypoints.size() - 1;
	double xtk = Double.MAX_VALUE;
	synchronized (waypoints)
	{
		for (int i = 0; i < waypoints.size()-1; i++)
		{
			double distance = Geo.distance(waypoint.latitude, waypoint.longitude, waypoints.get(i+1).latitude, waypoints.get(i+1).longitude);
			double bearing1 = Geo.bearing(waypoint.latitude, waypoint.longitude, waypoints.get(i+1).latitude, waypoints.get(i+1).longitude);
			double dtk1 = Geo.bearing(waypoints.get(i).latitude, waypoints.get(i).longitude, waypoints.get(i+1).latitude, waypoints.get(i+1).longitude);
			double cxtk1 = Math.abs(Geo.xtk(distance, dtk1, bearing1));
			double bearing2 = Geo.bearing(waypoint.latitude, waypoint.longitude, waypoints.get(i).latitude, waypoints.get(i).longitude);
			double dtk2 = Geo.bearing(waypoints.get(i+1).latitude, waypoints.get(i+1).longitude, waypoints.get(i).latitude, waypoints.get(i).longitude);
			double cxtk2 = Math.abs(Geo.xtk(distance, dtk2, bearing2));
			
			if (cxtk2 != Double.POSITIVE_INFINITY && cxtk1 < xtk)
			{
				xtk = cxtk1;
				after = i;
			}
		}
	}
	waypoints.add(after+1, waypoint);
	lastWaypoint = waypoints.get(waypoints.size()-1);
	distance = distanceBetween(0, waypoints.size()-1);
}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:33,代码来源:Route.java

示例7: distanceBetween

import com.androzic.util.Geo; //导入依赖的package包/类
public double distanceBetween(int first, int last)
{
	double dist = 0.0;
	synchronized (waypoints)
	{
		for (int i = first; i < last; i++)
		{
			dist += Geo.distance(waypoints.get(i).latitude, waypoints.get(i).longitude, waypoints.get(i+1).latitude, waypoints.get(i+1).longitude);
		}
	}
	return dist;
}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:13,代码来源:Route.java

示例8: course

import com.androzic.util.Geo; //导入依赖的package包/类
public double course(int prev, int next)
{
	synchronized (waypoints)
	{
		return Geo.bearing(waypoints.get(prev).latitude, waypoints.get(prev).longitude, waypoints.get(next).latitude, waypoints.get(next).longitude);
	}
}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:8,代码来源:Route.java

示例9: setRouteWaypoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void setRouteWaypoint(int waypoint)
{
	navCurrentRoutePoint = waypoint;
	navWaypoint = navRoute.getWaypoint(navCurrentRoutePoint);
	int prev = navCurrentRoutePoint - navDirection;
	if (prev >= 0 && prev < navRoute.length())
		prevWaypoint = navRoute.getWaypoint(prev);
	else
		prevWaypoint = null;
	navProximity = navWaypoint.proximity > 0 ? navWaypoint.proximity : routeProximity;
	navRouteDistance = -1;
	navCourse = prevWaypoint == null ? 0.0 : Geo.bearing(prevWaypoint.latitude, prevWaypoint.longitude, navWaypoint.latitude, navWaypoint.longitude);
	updateNavigationState(STATE_NEXTWPT);
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:15,代码来源:NavigationService.java

示例10: nextRouteWaypoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void nextRouteWaypoint() throws IndexOutOfBoundsException
{
	navCurrentRoutePoint += navDirection;
	navWaypoint = navRoute.getWaypoint(navCurrentRoutePoint);
	prevWaypoint = navRoute.getWaypoint(navCurrentRoutePoint - navDirection);
	navProximity = navWaypoint.proximity > 0 ? navWaypoint.proximity : routeProximity;
	navRouteDistance = -1;
	navCourse = Geo.bearing(prevWaypoint.latitude, prevWaypoint.longitude, navWaypoint.latitude, navWaypoint.longitude);
	updateNavigationState(STATE_NEXTWPT);
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:11,代码来源:NavigationService.java

示例11: prevRouteWaypoint

import com.androzic.util.Geo; //导入依赖的package包/类
public void prevRouteWaypoint() throws IndexOutOfBoundsException
{
	navCurrentRoutePoint -= navDirection;
	navWaypoint = navRoute.getWaypoint(navCurrentRoutePoint);
	int prev = navCurrentRoutePoint - navDirection;
	if (prev >= 0 && prev < navRoute.length())
		prevWaypoint = navRoute.getWaypoint(prev);
	else
		prevWaypoint = null;
	navProximity = navWaypoint.proximity > 0 ? navWaypoint.proximity : routeProximity;
	navRouteDistance = -1;
	navCourse = prevWaypoint == null ? 0.0 : Geo.bearing(prevWaypoint.latitude, prevWaypoint.longitude, navWaypoint.latitude, navWaypoint.longitude);
	updateNavigationState(STATE_NEXTWPT);
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:15,代码来源:NavigationService.java

示例12: setAccuracy

import com.androzic.util.Geo; //导入依赖的package包/类
public void setAccuracy(float accuracy)
{
	if (accuracy > 0 && this.accuracy != accuracy)
	{
		this.accuracy = accuracy;
		double[] loc = application.getLocation();
		double[] prx = Geo.projection(loc[0], loc[1], accuracy/2, 90);
		int[] cxy = application.getXYbyLatLon(loc[0], loc[1]);
		int[] pxy = application.getXYbyLatLon(prx[0], prx[1]);
		radius = (int) Math.hypot((pxy[0]-cxy[0]), (pxy[1]-cxy[1]));
	}
	enabled = accuracy > 0;
   }
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:14,代码来源:AccuracyOverlay.java

示例13: onPrepareBuffer

import com.androzic.util.Geo; //导入依赖的package包/类
@Override
public void onPrepareBuffer(final Viewport viewport, final Canvas c)
{
	if (ancor == null)
		return;
	
	final double[] loc = viewport.mapCenter;
	final int[] cxy = viewport.mapCenterXY;

       int sx = ancorXY[0] - cxy[0] + viewport.width / 2;
       int sy = ancorXY[1] - cxy[1] + viewport.height / 2;
       
       if (ancorXY[0] != cxy[0] || ancorXY[1] != cxy[1])
       {
        if (sx >= 0 && sy >= 0 && sx <= viewport.width && sy <= viewport.height)
        {
        	c.drawLine(0, 0, ancorXY[0]-cxy[0], ancorXY[1]-cxy[1], linePaint);
        	c.drawCircle(ancorXY[0]-cxy[0], ancorXY[1]-cxy[1], linePaint.getStrokeWidth(), circlePaint);
        }
        else
        {
        	double bearing = Geo.bearing(loc[0], loc[1], ancor[0], ancor[1]);
        	c.save();
        	c.rotate((float) bearing, 0, 0);
        	c.drawLine(0, 0, 0, - viewport.height / 2 - viewport.width / 2, linePaint);
        	c.restore();
        }
       }
}
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:30,代码来源:DistanceOverlay.java

示例14: onClick

import com.androzic.util.Geo; //导入依赖的package包/类
public void onClick(View v)
    {
    	try
    	{
    		Androzic application = Androzic.getApplication();
    		Waypoint waypoint = new Waypoint();
    		View view = getView();
    		waypoint.name = ((TextView) view.findViewById(R.id.name_text)).getText().toString();
    		double distance = Integer.parseInt(((TextView) view.findViewById(R.id.distance_text)).getText().toString());
    		double bearing = Double.parseDouble(((TextView) view.findViewById(R.id.bearing_text)).getText().toString());
    		int src = ((Spinner) view.findViewById(R.id.source_spinner)).getSelectedItemPosition();
    		int df = ((Spinner) view.findViewById(R.id.distance_spinner)).getSelectedItemPosition();
    		int bf = ((Spinner) view.findViewById(R.id.bearing_spinner)).getSelectedItemPosition();
    		double[] loc;
    		if (src > 0)
    		{
    			 loc = new double[2];
    			 loc[0] = waypoints.get(src-1).latitude;
    			 loc[1] = waypoints.get(src-1).longitude;
    		}
    		else
    		{
				loc = application.getLocation();
    		}

    		if (df == 0)
    		{
    			distance = distance / StringFormatter.distanceFactor * 1000;
    		}
    		else
    		{
    			distance = distance / StringFormatter.distanceShortFactor;
    		}
      bearing = bearing * StringFormatter.angleFactor;
    		if (bf == 1)
    		{
    			GeomagneticField mag = new GeomagneticField((float) loc[0], (float) loc[1], 0.0f, System.currentTimeMillis());
    			bearing += mag.getDeclination();
       if (bearing > 360d)
        bearing -= 360d;
    		}
    		double[] prj = Geo.projection(loc[0], loc[1], distance, bearing);
    		waypoint.latitude = prj[0];
    		waypoint.longitude = prj[1];
    		waypoint.date = Calendar.getInstance().getTime();
    		application.addWaypoint(waypoint);

    		getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, null);
dismiss();
    	}
    	catch (Exception e)
    	{
			Toast.makeText(getActivity(), "Invalid input", Toast.LENGTH_LONG).show();
			e.printStackTrace();
    	}
    }
 
开发者ID:andreynovikov,项目名称:Androzic,代码行数:57,代码来源:WaypointProject.java

示例15: bindView

import com.androzic.util.Geo; //导入依赖的package包/类
@Override
public void bindView(View view, Context context, Cursor cursor)
{
	Log.w(TAG, ">>>> bindView");
	
	Tracker tracker = dataAccess.getFullInfoTracker(cursor);
	TextView t = (TextView) view.findViewById(R.id.name);
	t.setText(tracker.name);
	Application application = Application.getApplication();
	Bitmap b = application.getMarker(tracker.marker);
	if (b != null)
	{
		Drawable drawable = new BitmapDrawable(getResources(), b);
		drawable.setBounds(0, 0, b.getWidth(), b.getHeight());
		t.setCompoundDrawables(drawable, null, null, null);
		t.setCompoundDrawablePadding(b.getWidth() / 3);
	}
	else
	{
		t.setCompoundDrawables(null, null, null, null);
	}
	t = (TextView) view.findViewById(R.id.sender);
	t.setText(tracker.sender);
	t = (TextView) view.findViewById(R.id.imei);
	t.setText(tracker.imei);
	String coordinates = StringFormatter.coordinates(coordinatesFormat, " ", tracker.latitude, tracker.longitude);
	t = (TextView) view.findViewById(R.id.coordinates);
	t.setText(coordinates);
	String speed = String.valueOf(Math.round(tracker.speed * speedFactor)) + " " + speedAbbr;
	t = (TextView) view.findViewById(R.id.speed);
	t.setText(speed);
	String distance = "";
	synchronized (currentLocation)
	{
		if (!"fake".equals(currentLocation.getProvider()))
		{
			double dist = Geo.distance(tracker.latitude, tracker.longitude, currentLocation.getLatitude(), currentLocation.getLongitude());
			double bearing = Geo.bearing(currentLocation.getLatitude(), currentLocation.getLongitude(), tracker.latitude, tracker.longitude);
			distance = StringFormatter.distanceH(dist) + " " + StringFormatter.bearingSimpleH(bearing);
		}
	}
	t = (TextView) view.findViewById(R.id.distance);
	t.setText(distance);
	String battery = "";
	if (tracker.battery == Integer.MAX_VALUE)
		battery = getString(R.string.full);
	if (tracker.battery == Integer.MIN_VALUE)
		battery = getString(R.string.low);
	if (tracker.battery >= 0 && tracker.battery <= 100)
		battery = String.valueOf(tracker.battery) + "%";
	t = (TextView) view.findViewById(R.id.battery);
	if (! "".equals(battery))
		t.setText(String.format("%s: %s", getString(R.string.battery), battery));
	else
		t.setText("");
	String signal = "";
	if (tracker.signal == Integer.MAX_VALUE)
		signal = getString(R.string.full);
	if (tracker.signal == Integer.MIN_VALUE)
		signal = getString(R.string.low);
	if (tracker.signal >= 0 && tracker.signal <= 100)
		signal = String.valueOf(tracker.signal) + "%";
	t = (TextView) view.findViewById(R.id.signal);
	if (! "".equals(signal))
		t.setText(String.format("%s: %s", getString(R.string.signal), signal));
	else
		t.setText("");
	Calendar calendar = Calendar.getInstance();
	calendar.setTimeInMillis(tracker.time);
	Date date = calendar.getTime();
	String modified = DateFormat.getDateFormat(TrackerList.this).format(date) + " " + DateFormat.getTimeFormat(TrackerList.this).format(date);
	t = (TextView) view.findViewById(R.id.modified);
	t.setText(modified);
}
 
开发者ID:andreynovikov,项目名称:androzic-plugin-tracker,代码行数:75,代码来源:TrackerList.java


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