在雷达上测量坐标 [英] Scale coordinates on radar

查看:119
本文介绍了在雷达上测量坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为android开发一款雷达。 (以下教程: http://www.androidph.com/ 2009/02 / app-10-beer-radar.html



我将我所在位置附近5KM范围内的所有用户从服务器之后,我在我的自定义视图中绘制像这样:

pre $ float $(float)(userLocation.getLongitude()+ getWidth( )/ 2 - currentLong);
float yU =(float)(getHeight()/ 2 - userLocation.getLatitude()+ currentLat);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);

现在我的问题是,我需要缩放绘制在雷达上的点/坐标,因为距离5KM以内的所有用户都将被绘制为仅距离中心2-3像素。我将如何做到这一点?

解决方案

这是一种方法。您只需将scale变量的值设置为所需的值;

  float scale = 3.0f ; //设置为任意数字来改变绘图比例

float xU =(float)(getWidth()/ 2 +(userLocation.getLongitude() - currentLong)* scale);
float yU =(float)(getHeight()/ 2 - (userLocation.getLatitude() - currentLat)* scale);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);


I'm currently developing an radar for android. (Following this tutorial: http://www.androidph.com/2009/02/app-10-beer-radar.html )

I'm getting all users within a range of 5KM around my current location from the server after that I draw in my customview like this:

float xU = (float)(userLocation.getLongitude() + getWidth() / 2 - currentLong);
float yU = (float)(getHeight() / 2 - userLocation.getLatitude() + currentLat);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);

Now my problem is, that I need to scale the the points / coordinates I draw on the radar, because all users within a distance below 5KM will be drawn like only 2-3 Pixel away from the center. How would I manage to do that?

解决方案

This is one way to do it. All you need to do is to set the value of the "scale" variable to the required value;

float scale = 3.0f; //set this to any number to change the drawing scale

float xU = (float)(getWidth() / 2 + (userLocation.getLongitude() - currentLong) * scale);
float yU = (float)(getHeight() / 2 - (userLocation.getLatitude() - currentLat) * scale);
canvas.drawBitmap(bmpUser,xU,yU,radarPaint);

这篇关于在雷达上测量坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆